aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-elf
diff options
context:
space:
mode:
authorHakan Candar <hakancandar@protonmail.com>2024-10-28 11:01:59 +0000
committerAlan Modra <amodra@gmail.com>2024-10-29 19:38:39 +1030
commitf4e363cae297ec3e24dec0d95f3d422879f498a3 (patch)
tree4ab387403489f6d95a894ce56d6f221637ebb7b4 /ld/testsuite/ld-elf
parent80ac47851105702689004e07952ab6a4c04062b0 (diff)
downloadgdb-f4e363cae297ec3e24dec0d95f3d422879f498a3.zip
gdb-f4e363cae297ec3e24dec0d95f3d422879f498a3.tar.gz
gdb-f4e363cae297ec3e24dec0d95f3d422879f498a3.tar.bz2
ld/ELF: Add --image-base command line option to the ELF linker
LLD has dropped the option -Ttext-segment for specifying image base addresses, instead forcing the use of the --image-base option for both ELF and PE targets. As it stands, GNU LD and LLVM LLD are incompatible, having two different options for the same functionality. This patch enables the use of --image-base on ELF targets, advancing consistency and compatibility. See: https://reviews.llvm.org/D70468 https://maskray.me/blog/2020-11-15-explain-gnu-linker-options#address-related https://sourceware.org/bugzilla/show_bug.cgi?id=25207 Moreover, a new test has been added to ensure -z separate-code behaviour when used with -Ttext-segment stays the same. When this combination is used, -Ttext-segment sets the address of the first segment (R), not the text segment (RX), and like with -z noseparate-code, no segments lesser than the specified address are created. If this behaviour was to change, the first (R) segment of the ELF file would begin in a lesser address than the specified text (RX) segment, breaking traditional use of this option for specifying image base address.
Diffstat (limited to 'ld/testsuite/ld-elf')
-rw-r--r--ld/testsuite/ld-elf/pr25207.d11
-rw-r--r--ld/testsuite/ld-elf/pr25207.s13
2 files changed, 24 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elf/pr25207.d b/ld/testsuite/ld-elf/pr25207.d
new file mode 100644
index 0000000..edec777
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25207.d
@@ -0,0 +1,11 @@
+#source: pr25207.s
+#ld: -z separate-code -Ttext-segment=0x120000 -z max-page-size=0x10000
+#readelf: -l --wide
+#target: *-*-linux* *-*-gnu* arm*-*-uclinuxfdpiceabi
+# changing -Ttext-segment behaviour will break --image-base (pr25207)
+# -Ttext-segment=<ADDR> should set the first segment address,
+# not necessarily the first executable segment.
+
+#...
+ LOAD +0x0+ 0x0*120000 0x0*120000 0x[0-9a-f]+ 0x[0-9a-f]+ R .*
+#pass
diff --git a/ld/testsuite/ld-elf/pr25207.s b/ld/testsuite/ld-elf/pr25207.s
new file mode 100644
index 0000000..6cfdfd0
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25207.s
@@ -0,0 +1,13 @@
+ .section .text, "ax"
+ .globl main
+ .globl start
+ .globl _start
+ .globl __start
+main:
+start:
+_start:
+__start:
+ .byte 0
+
+ .section .rodata
+ .byte 0