[Libomptarget] Add utility functions for loading an ELF symbol by name
authorJoseph Huber <jhuber6@vols.utk.edu>
Sat, 3 Sep 2022 16:38:26 +0000 (11:38 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Wed, 7 Sep 2022 17:38:50 +0000 (12:38 -0500)
commit894531f59beb03c17a6e11e5b9c9995182b8d727
tree3f8ac9cb3509d90fe8cd70d44c3690564bf199f8
parent8105f555af3617b273740a64d2ad50fdf595d7a1
[Libomptarget] Add utility functions for loading an ELF symbol by name

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 utility functions that allow us to look up a symbol in
an ELF file by name. It will first attempt to look through the hash
tables, and then search the section tables manually if failed. This
allows us to pull out constants necessary for setting up offloading
without first loading the object.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D131309
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
openmp/libomptarget/plugins/common/elf_common/CMakeLists.txt
openmp/libomptarget/plugins/common/elf_common/ELFSymbols.cpp [new file with mode: 0644]
openmp/libomptarget/plugins/common/elf_common/ELFSymbols.h [new file with mode: 0644]