diff options
author | Lang Hames <lhames@gmail.com> | 2023-04-17 01:22:52 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2023-04-17 01:45:01 +0000 |
commit | e4b6e686b70529db2c6424bd4094545836fdcd99 (patch) | |
tree | d39eb3e2a0a223b94d4e0a4c1b284cd0ba64d840 /llvm/tools/llvm-jitlink | |
parent | b63b77a1e087cd85ce770c3b6e32ffcef5ffaa49 (diff) | |
download | llvm-e4b6e686b70529db2c6424bd4094545836fdcd99.zip llvm-e4b6e686b70529db2c6424bd4094545836fdcd99.tar.gz llvm-e4b6e686b70529db2c6424bd4094545836fdcd99.tar.bz2 |
[JITLink][ELF][x86-64] Add support for R_X86_64_GOTPC32 relocation.
Adds support for the R_X86_64_GOTPC32 relocation, which is a 32-bit delta to
the global offset table.
Since the delta to the GOT doesn't actually require any GOT entries to exist
this commit adds an extra fallback path to the getOrCreateGOTSymbol function:
If the symbol is in the extenal symbols list but no entry exists then the
symbol is turned into an absolute symbol pointing to an arbitrary address in
the current graph's allocation (accessing this address via the symbol would be
illegal, but any access should have triggered creation of a GOT entry which
would prevent this fallback path from being taken in the first place).
This commit also updates the llvm-jitlink tool to scrape the addresses of the
absolute symbols in the graph so that the testcase can see the now-absolute
_GLOBAL_OFFSET_TABLE_ symbol.
Diffstat (limited to 'llvm/tools/llvm-jitlink')
-rw-r--r-- | llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp index 2b798f9..5200dbc 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp @@ -151,6 +151,11 @@ Error registerELFGraphInfo(Session &S, LinkGraph &G) { } } + // Add symbol info for absolute symbols. + for (auto *Sym : G.absolute_symbols()) + S.SymbolInfos[Sym->getName()] = {Sym->getSize(), + Sym->getAddress().getValue()}; + auto SecAddr = FirstSym->getAddress(); auto SecSize = (LastSym->getBlock().getAddress() + LastSym->getBlock().getSize()) - |