forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BOLT] Support map other function entry address (llvm#101466)
Allow BOLT to map the old address to a new binary address if the old address is the entry of the function.
- Loading branch information
1 parent
a0bd782
commit 7d1f00d
Showing
2 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
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,32 @@ | ||
// This test examines whether BOLT can correctly process when | ||
// dynamic relocation points to other entry points of the | ||
// function. | ||
|
||
# RUN: %clang %cflags -fPIC -pie %s -o %t.exe -nostdlib -Wl,-q | ||
# RUN: llvm-bolt %t.exe -o %t.bolt > %t.out.txt | ||
# RUN: readelf -r %t.bolt >> %t.out.txt | ||
# RUN: llvm-objdump --disassemble-symbols=chain %t.bolt >> %t.out.txt | ||
# RUN: FileCheck %s --input-file=%t.out.txt | ||
|
||
## Check if the new address in `chain` is correctly updated by BOLT | ||
# CHECK: Relocation section '.rela.dyn' at offset 0x{{.*}} contains 1 entry: | ||
# CHECK: {{.*}} R_X86_64_RELATIVE [[#%x,ADDR:]] | ||
# CHECK: [[#ADDR]]: c3 retq | ||
.text | ||
.type chain, @function | ||
chain: | ||
movq $1, %rax | ||
Label: | ||
ret | ||
.size chain, .-chain | ||
|
||
.type _start, @function | ||
.global _start | ||
_start: | ||
jmpq *.Lfoo(%rip) | ||
ret | ||
.size _start, .-_start | ||
|
||
.data | ||
.Lfoo: | ||
.quad Label |