Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JITLink] Demote symbol scope to local during external-to-absolute co…
…nversion. When an external symbol is converted to an absolute it should be demoted to local scope so that the symbol does not become a new definition within this LinkGraph.
- Loading branch information
Showing
2 changed files
with
32 additions
and
2 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
26 changes: 26 additions & 0 deletions
26
llvm/test/ExecutionEngine/JITLink/X86/ELF_external_to_absolute_conversion.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,26 @@ | ||
# RUN: llvm-mc -triple=x86_64-unknown-linux-gnu -filetype=obj -o %t %s | ||
# RUN: llvm-jitlink -phony-externals -noexec %t | ||
# | ||
# Check that symbol scope is demoted to local when external symbols are | ||
# converted to absolutes. This is demotion is necessary to avoid "unexpected | ||
# definition" errors. | ||
# | ||
# The reference to _GLOBAL_OFFSET_TABLE_ will trigger creation of an external | ||
# _GLOBAL_OFFSET_TABLE_ symbol, and the GOTOFF relocation will force creation | ||
# of a GOT symbol without actually introducing any GOT entries. Together these | ||
# should cause the external _GLOBAL_OFFSET_TABLE_ symbol to be converted to an | ||
# absolute symbol with address zero. If the scope is not demoted correctly this | ||
# will trigger an "unexpected definition" error. | ||
|
||
.text | ||
.file "ELF_external_to_absolute_conversion.s" | ||
.globl main | ||
.p2align 4, 0x90 | ||
.type main,@function | ||
main: | ||
.L0$pb: | ||
leaq .L0$pb(%rip), %rax | ||
movabsq $_GLOBAL_OFFSET_TABLE_-.L0$pb, %rcx | ||
movabsq $_foo@GOTOFF, %rax | ||
xorq %rax, %rax | ||
retq |