Find the symbols via DT_GNU_HASH instead of DT_HASH.#36
Merged
clalancette merged 2 commits intoros2from May 28, 2024
Merged
Conversation
This avoids a warning when building with modern CMake. Signed-off-by: Chris Lalancette <clalancette@gmail.com>
Since glibc 2.36 (released in August 2022), builds of libc.so.6 are built with the default value of --hash-style on all platforms. The immediate effect of this is that linker no longer generates a DT_HASH section, which is what Mimick uses to detect vital functions like vfprintf and abort. It turns out that Ubuntu and Debian specifically override this behavior on amd64 and i386, since there are some proprietary applications on those platforms that depend on this. However, this override is *not* applied on aarch64, so there is no DT_HASH. This explains the discrepancy we see when running CI on amd64 (where Mimick tests succeed) and aarch64 (where Mimick tests fail). It also turns out that DT_HASH is "deprecated", and has been for about 15 years. Thus, all of our platforms (going back to RHEL-8) support this construct. Thus, this commit implements getting symbols from DT_GNU_HASH instead of from DT_HASH. Note that it also changes it so that we *prefer* to get the data from DT_GNU_HASH, as someday DT_HASH may go away entirely. I should note that I borrowed heavily from https://flapenguin.me/elf-dt-gnu-hash and https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dl-lookup.c;h=3d2369dbf2b7ca219eaf80a820e2a8e1329fbf50;hb=HEAD#l350 to implement this, though I made a bunch of changes to fix warnings and better integrate into the Mimick source code. Signed-off-by: Chris Lalancette <clalancette@gmail.com>
wjwwood
approved these changes
May 28, 2024
Author
|
CI for this is in ros2/mimick_vendor#37 (comment) , so going ahead and merging. |
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.
Since glibc 2.36 (released in August 2022), builds of libc.so.6
are built with the default value of --hash-style on all platforms.
The immediate effect of this is that linker no longer generates
a DT_HASH section, which is what Mimick uses to detect vital
functions like vfprintf and abort.
It turns out that Ubuntu and Debian specifically override this
behavior on amd64 and i386, since there are some proprietary
applications on those platforms that depend on this. However,
this override is not applied on aarch64, so there is no DT_HASH.
This explains the discrepancy we see when running CI on amd64
(where Mimick tests succeed) and aarch64 (where Mimick tests fail).
It also turns out that DT_HASH is "deprecated", and has been for
about 15 years. Thus, all of our platforms (going back to RHEL-8)
support this construct.
Thus, this commit implements getting symbols from DT_GNU_HASH instead
of from DT_HASH. Note that it also changes it so that we prefer
to get the data from DT_GNU_HASH, as someday DT_HASH may go away
entirely.
I should note that I borrowed heavily from
https://flapenguin.me/elf-dt-gnu-hash and
https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dl-lookup.c;h=3d2369dbf2b7ca219eaf80a820e2a8e1329fbf50;hb=HEAD#l350
to implement this, though I made a bunch of changes to fix
warnings and better integrate into the Mimick source code.