This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Add ability to get a symbol by name from the GNU_HASH table section
AbandonedPublic

Authored by jhuber6 on Aug 26 2022, 8:41 AM.

Details

Summary

The SHT_GNU_HASH section contains information used to identify symbols
using only their name. Previous support was added for the sys-V hash
table section. This patch expands this support to apply to the GNU hash
table as well. So now this function works with both hash table methods.
Implementation derived from description at
https://flapenguin.me/elf-dt-gnu-hash.

Depends on D132696

Diff Detail

Event Timeline

jhuber6 created this revision.Aug 26 2022, 8:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 26 2022, 8:41 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
jhuber6 requested review of this revision.Aug 26 2022, 8:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 26 2022, 8:41 AM
jhuber6 updated this revision to Diff 455927.Aug 26 2022, 8:43 AM

This implements the GNU support that @MaskRay wanted. I would heavily prefer supporting both as is done in this patch.

I was going to start reviewing this, and made a couple of initial nitpick comments (there will be more if I come back to this), but if the patch series gets abandoned due to @MaskRay's opposition, there's little point in me wasting the time on the review, so I'll hold off for a while.

llvm/include/llvm/Object/ELF.h
536

From a pure readability perspective, it might be worth breaking the two "modes" of this function (SHT_GNU_HASH vs SHT_HASH) into helper functions. This function is otherwise getting quite long and half of it is irrelevant to any given usage.

llvm/unittests/Object/ELFObjectFileTest.cpp
945–946

Nit: This should be fixed in the prerequisite patch.

jhuber6 abandoned this revision.Sep 5 2022, 9:10 AM

Abandoning this patch as its functionality has been moved into D131309. This loses us the test coverage, but it passed the suite here so we can conclude it was correctly implemented.