Skip to content

Coff archives: handle newline-separated long names - #117

Merged
nojb merged 2 commits into
ocaml:masterfrom
nojb:longnames_newline
Apr 15, 2023
Merged

nojb merged 2 commits into
ocaml:masterfrom
nojb:longnames_newline

Conversation

@nojb

@nojb nojb commented Apr 15, 2023

Copy link
Copy Markdown
Collaborator

Static archives (.a) generated by GNU toolchains use newline (\n) as separator in the "long names" header, instead of \000 (used in MS' toolchain). This header is used whenever object names take more than 16 bytes. The absence of \000's triggered a quadratic behaviour when reading object names.

To fix this, we postprocess the "long name" string table to replace \n (and/or the optional trailing /) by \000. Similar logic is present in binutils:

https://github.com/bminor/binutils-gdb/blob/672008e6dcacddd76a5551aec9a30cd31c102d72/bfd/archive.c#L1323-L1324

(ARFMAG[1] is \n above.)

Fixes #101

@nojb

nojb commented Apr 15, 2023

Copy link
Copy Markdown
Collaborator Author

In the absence of @dra27 who is out sick, I am merging this bugfix that is rather low-risk.

@nojb
nojb merged commit ccff5ff into ocaml:master Apr 15, 2023
@nojb
nojb deleted the longnames_newline branch April 15, 2023 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implementing a less memory intensive read function

1 participant