ocaml / flexdll

a dlopen-like API for Windows
Other
100 stars 30 forks source link

Coff archives: handle newline-separated long names #117

Closed nojb closed 1 year ago

nojb commented 1 year ago

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 commented 1 year ago

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