i#3161: Add pure-static-client-DR-app support#7177
Merged
derekbruening merged 10 commits intomasterfrom Jan 10, 2025
Merged
Conversation
Adds support for statically linking a client and DR into a pure-static application. The code support for this involves expecting to not find symbols via dlsym and to instead directly invoke dr_client_main(). A weak copy of dr_client_main() is added to avoid problems with static DR used in standalone mode. Since even static client libraries today pull in the shared DR library, getting CMake to build a pure static binary with a client occupies the bulk of the changes here: + A new cmake routine configure_DynamoRIO_static_client() is added which links with dynamorio_static instead of dynamorio. + Static libz libraries are identified in an admittedly hacky manner. + A new client library variant "_drstatic" is added (alongside today's base shared library and "_static" variant) for all the ext/ libraries. This is identical to "_static" except it uses configure_DynamoRIO_static_client(). A drmemtrace_drstatic variant is also added, which also links with static libz. A new test tool.drcacheoff.purestatic is added which verifies that a static client and DR linked into a pure-static binary all work together. Fixes #3161
…eak sym attempt on Windows
…Ubuntu22 test list; remove libc6-dev packages
…EAK_MAIN is defined, which is only true for a new drmemtrace_weakmain target. This is require to avoid collisions with the new weak dr_client_main in dynamrio_static. The drmemtrace_drstatic does not define DRMEMTRACE_WEAK_MAIN so the new test is updated to not expect those output lines.
…ine dr_client_main; rm assert from weak main b/c non-client uses run it
…in external build
Contributor
|
Perhaps you meant to request review and not assign the PR to me? |
Contributor
Author
Oops, yes. Fixed. |
abhinav92003
approved these changes
Jan 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for statically linking a client and DR into a pure-static application.
The code support for this involves expecting to not find symbols via dlsym and to instead directly invoke dr_client_main(). A weak copy of dr_client_main() is added to avoid problems with static DR used in standalone mode.
Since even static client libraries today pull in the shared DR library, getting CMake to build a pure static binary with a client occupies the bulk of the changes here:
A new cmake routine configure_DynamoRIO_static_client() is added which links with dynamorio_static instead of dynamorio.
Static libz libraries are identified in an admittedly hacky manner.
A new client library variant "_drstatic" is added (alongside today's base shared library and "_static" variant) for all the ext/ libraries. This is identical to "_static" except it uses configure_DynamoRIO_static_client(). A drmemtrace_drstatic variant is also added, which also links with static libz.
The drmemtrace weak dr_client_main no longer works with the new dynamorio_static weak symbol so it is instead made strong and removed completely when DRMEMTRACE_NO_MAIN is defined; a drmemtrace_nomain variant is created with this set.
A new test tool.drcacheoff.purestatic is added which verifies that a static client and DR linked into a pure-static binary all work together. It is difficult to get it to link on Ubuntu20, when cross-compiling, and in other setups due to the need for a static libpthread and other requirements, so the test is limited to Ubuntu22 64-bit where it is added to the test list there and confirmed to be built and run:
Fixes #3161