[PATCH] D131309: [ELF] Add ability to get a symbol by name from the hash table section

Joseph Huber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 5 19:38:20 PDT 2022


jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, jdoerfert, MaskRay, alexander-shaposhnikov, tra.
Herald added a subscriber: StephenFan.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The `SHT_HASH` sections in an ELF are used to look up a symbol in the
symbol table using a symbol's name. This is done by obtaining the
`SHT_HASH` section and using its `sh_link` attribute to access the
associated symbol table, from which we can access the string table
containing the associated name. We can then search for the symbol using
the hash of the name and the buckets and chains in the hash table
itself. This patch adds support for doing this inside LLVM so we can
look up a symbol value in a dynamic object using just the name. The specific
use-case for this is for offloading where we wish to identify the values of
runtime symbols without needing to fully load the shared library.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131309

Files:
  llvm/include/llvm/Object/ELF.h
  llvm/unittests/Object/ELFObjectFileTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131309.450464.patch
Type: text/x-patch
Size: 6083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220806/becbc194/attachment.bin>


More information about the llvm-commits mailing list