Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coff archives: handle newline-separated long names #117

Merged
merged 2 commits into from
Apr 15, 2023
Merged

Coff archives: handle newline-separated long names #117

merged 2 commits into from
Apr 15, 2023

Conversation

nojb
Copy link
Collaborator

@nojb nojb commented Apr 15, 2023

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
Copy link
Collaborator Author

nojb commented Apr 15, 2023

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