Skip to content

Commit 744a469

Browse files
authored
[BOLT,test] Add --image-base to tests that use --section-start
When using -no-pie without a SECTIONS command, the linker uses the target's default image base. If -Ttext= or --section-start specifies an output section address below this base, the result is likely unintended. LLD will give a diagnostic (#140187) and may change the behavior in the future. It's good to set an explicit image base to avoid relying on its current behavior. BOLT doesn't seem to care whether a PT_PHDR segment is present. Pull Request: #140570
1 parent 80f0ffb commit 744a469

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

bolt/test/AArch64/check-init-not-moved.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# address. Test checks that _init is not moved.
66

77
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
8-
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static -Wl,--section-start=.data=0x1000 -Wl,--section-start=.init=0x1004
8+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static -Wl,--image-base=0,-Tdata=0x1000,--section-start=.init=0x1004
99
# RUN: llvm-bolt %t.exe -o %t.bolt
1010
# RUN: llvm-nm %t.exe | FileCheck --check-prefix=CHECK-ORIGINAL %s
1111
# RUN: llvm-nm %t.bolt | FileCheck --check-prefix=CHECK-BOLTED %s

bolt/test/AArch64/pad-before-funcs.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
11-
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -Wl,--section-start=.text=0x4000
11+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -Wl,--image-base=0x3000,--section-start=.text=0x4000
1212
# RUN: llvm-bolt %t.exe -o %t.bolt.0 --pad-funcs-before=_start:0
1313
# RUN: llvm-bolt %t.exe -o %t.bolt.4 --pad-funcs-before=_start:4
1414
# RUN: llvm-bolt %t.exe -o %t.bolt.8 --pad-funcs-before=_start:8

bolt/test/RISCV/reloc-jt.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// NOTE: assign section addresses explicitly to make the symbol difference
22
/// calculation below less fragile.
3-
// RUN: %clang %cflags -Wl,--section-start=.text=0x1000,--section-start=.data=0x2000 -o %t %s
3+
// RUN: %clang %cflags -Wl,--image-base=0,--section-start=.text=0x1000,--section-start=.data=0x2000 -o %t %s
44
// RUN: llvm-bolt -o %t.bolt %t
55
// RUN: llvm-readelf -x .data %t.bolt | FileCheck %s
66

bolt/test/X86/double-rel-scan.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# REQUIRES: system-linux
77

88
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
9-
# RUN: ld.lld %t.o -o %t.exe -q --Ttext=0x80000
9+
# RUN: ld.lld %t.o -o %t.exe -q --image-base=0x80000 --Ttext=0x80000
1010
# RUN: llvm-bolt %t.exe --relocs -o %t.bolt --funcs=foo
1111
# RUN: llvm-objdump -d --print-imm-hex %t.exe \
1212
# RUN: | FileCheck %s

bolt/test/X86/double-rel.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# REQUIRES: system-linux
66

77
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
8-
# RUN: ld.lld %t.o -o %t.exe -q --Tdata=0x80000
8+
# RUN: ld.lld %t.o -o %t.exe -q --image-base=0x70000 --Tdata=0x80000
99
# RUN: llvm-bolt %t.exe --relocs -o %t.null --print-only=_start --print-disasm \
1010
# RUN: | FileCheck %s --check-prefix=CHECK-BOLT
1111
# RUN: llvm-objdump -d --print-imm-hex %t.exe \

0 commit comments

Comments
 (0)