-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
18 changes: 18 additions & 0 deletions
18
llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_GOTPC32.s
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# RUN: llvm-mc -triple=x86_64-unknown-linux -position-independent \ | ||
# RUN: -filetype=obj -o %t.o %s | ||
# RUN: llvm-jitlink -noexec -check=%s %t.o | ||
|
||
# jitlink-check: decode_operand(main, 4) = _GLOBAL_OFFSET_TABLE_ - next_pc(main) | ||
|
||
.text | ||
.section .text.main,"ax",@progbits | ||
.globl main | ||
.p2align 4, 0x90 | ||
.type main,@function | ||
main: | ||
leal _GLOBAL_OFFSET_TABLE_(%rip), %ebx | ||
xorl %eax, %eax | ||
retq | ||
.Lfunc_end0: | ||
.size main, .Lfunc_end0-main | ||
|
This file contains 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