Bitcode extraction from ar files
Opened this issue · 1 comments
An archive file (e.g. static library) requires special handling. Currently build-bom can be used to extract from an archive file (via objcopy) but the result is only the bitcode for the last member of the archive. It's not clear if objcopy is only extracting this last member, or if it's extracting each member in turn and overwriting the output file each time. Regardless, build-bom should be updated to specifically support extraction from archive files.
Clarification: objdump will extract the section from all members of an ar
file, one after another, each overwriting the output section file leaving the final contents of the section file as provided by the final member of the archive (that has the requested section).
To properly handle static libraries, it may be necessary to extract each member first and run objdump
on each one, or alternatively extract and link them all together and run objdump
on the linked result.
However, it can also be observed that when an executable is linked with the static library, only those members of the static library that are needed are included in the final executable (and they are then available via the bitcode from that executable). Therefore, extracting bitcode from the static library itself may yield code that is not actually present in the final solution, and one can take the position that the bitcode really should be extracted from the final executable and not the static library.
If the latter perspective is taken, it may still be useful to detect when the bitcode extraction is being run on a static library and warn the user about the behavior that will exhibit.