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

Bitcode extraction from ar files #42

Open
kquick opened this issue Aug 9, 2022 · 1 comment
Open

Bitcode extraction from ar files #42

kquick opened this issue Aug 9, 2022 · 1 comment

Comments

@kquick
Copy link
Contributor

kquick commented Aug 9, 2022

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.

@kquick
Copy link
Contributor Author

kquick commented Mar 12, 2024

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.

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

No branches or pull requests

1 participant