aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-x86-64
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2022-01-14 13:48:36 -0800
committerH.J. Lu <hjl.tools@gmail.com>2022-01-26 05:27:56 -0800
commitc804c6f98d342c3d46f73d7a7ec6229d5ab1c9f3 (patch)
treed3070e014b3a5057b8c9305121f18ce56a4c9558 /ld/testsuite/ld-x86-64
parent8357282156771d782be3e3c3d44cc5ad7e1f89d7 (diff)
downloadgdb-c804c6f98d342c3d46f73d7a7ec6229d5ab1c9f3.zip
gdb-c804c6f98d342c3d46f73d7a7ec6229d5ab1c9f3.tar.gz
gdb-c804c6f98d342c3d46f73d7a7ec6229d5ab1c9f3.tar.bz2
ld: Rewrite lang_size_relro_segment_1
1. Compute the desired PT_GNU_RELRO segment base and find the maximum section alignment of sections starting from the PT_GNU_RELRO segment. 2. Find the first preceding load section. 3. Don't add the 1-page gap between the first preceding load section and the relro segment if the maximum page size >= the maximum section alignment. Align the PT_GNU_RELRO segment first. Subtract the maximum page size if therer is still a 1-page gap. PR ld/28743 PR ld/28819 * ldlang.c (lang_size_relro_segment_1): Rewrite. * testsuite/ld-x86-64/pr28743-1.d: New file. * testsuite/ld-x86-64/pr28743-1.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr28743-1.
Diffstat (limited to 'ld/testsuite/ld-x86-64')
-rw-r--r--ld/testsuite/ld-x86-64/pr28743-1.d50
-rw-r--r--ld/testsuite/ld-x86-64/pr28743-1.s16
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp1
3 files changed, 67 insertions, 0 deletions
diff --git a/ld/testsuite/ld-x86-64/pr28743-1.d b/ld/testsuite/ld-x86-64/pr28743-1.d
new file mode 100644
index 0000000..4a20f8e
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr28743-1.d
@@ -0,0 +1,50 @@
+#as: --64
+#ld: -melf_x86_64 -shared -z relro -z now --hash-style=sysv -z max-page-size=0x1000 -z noseparate-code $NO_DT_RELR_LDFLAGS
+#readelf: -S -l --wide
+#target: x86_64-*-linux*
+
+There are 17 section headers, starting at offset 0x101228:
+
+Section Headers:
+ \[Nr\] Name Type Address Off Size ES Flg Lk Inf Al
+ \[ 0\] NULL 0000000000000000 000000 000000 00 0 0 0
+ \[ 1\] .hash HASH 0000000000000120 000120 000018 04 A 2 0 8
+ \[ 2\] .dynsym DYNSYM 0000000000000138 000138 000048 18 A 3 1 8
+ \[ 3\] .dynstr STRTAB 0000000000000180 000180 00000a 00 A 0 0 1
+ \[ 4\] .rela.dyn RELA 0000000000000190 000190 000018 18 A 2 0 8
+ \[ 5\] .plt PROGBITS 00000000000001b0 0001b0 000010 10 AX 0 0 16
+ \[ 6\] .plt.got PROGBITS 00000000000001c0 0001c0 000008 08 AX 0 0 8
+ \[ 7\] .text PROGBITS 00000000000001c8 0001c8 00000c 00 AX 0 0 1
+ \[ 8\] .eh_frame PROGBITS 00000000000001d8 0001d8 00006c 00 A 0 0 8
+ \[ 9\] .init_array INIT_ARRAY 00000000000ffff8 0ffff8 000004 08 WA 0 0 8
+ \[10\] .fini_array FINI_ARRAY 0000000000100000 100000 000100 08 WA 0 0 1048576
+ \[11\] .dynamic DYNAMIC 0000000000100100 100100 000150 10 WA 3 0 8
+ \[12\] .got PROGBITS 0000000000100250 100250 000020 08 WA 0 0 8
+ \[13\] .data PROGBITS 0000000000101000 101000 000100 00 WA 0 0 1
+ \[14\] .symtab SYMTAB 0000000000000000 101100 000078 18 15 3 8
+ \[15\] .strtab STRTAB 0000000000000000 101178 000029 00 0 0 1
+ \[16\] .shstrtab STRTAB 0000000000000000 1011a1 000080 00 0 0 1
+Key to Flags:
+ W \(write\), A \(alloc\), X \(execute\), M \(merge\), S \(strings\), I \(info\),
+ L \(link order\), O \(extra OS processing required\), G \(group\), T \(TLS\),
+ C \(compressed\), x \(unknown\), o \(OS specific\), E \(exclude\),
+ D \(mbind\), l \(large\), p \(processor specific\)
+
+Elf file type is DYN \(Shared object file\)
+Entry point 0x0
+There are 4 program headers, starting at offset 64
+
+Program Headers:
+ Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
+ LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000244 0x000244 R E 0x1000
+ LOAD 0x0ffff8 0x00000000000ffff8 0x00000000000ffff8 0x001108 0x001108 RW 0x100000
+ DYNAMIC 0x100100 0x0000000000100100 0x0000000000100100 0x000150 0x000150 RW 0x8
+ GNU_RELRO 0x0ffff8 0x00000000000ffff8 0x00000000000ffff8 0x001008 0x001008 R 0x1
+
+ Section to Segment mapping:
+ Segment Sections...
+ 00 .hash .dynsym .dynstr .rela.dyn .plt .plt.got .text .eh_frame
+ 01 .init_array .fini_array .dynamic .got .data
+ 02 .dynamic
+ 03 .init_array .fini_array .dynamic .got
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr28743-1.s b/ld/testsuite/ld-x86-64/pr28743-1.s
new file mode 100644
index 0000000..2e9a150
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr28743-1.s
@@ -0,0 +1,16 @@
+ .text
+ .globl foo
+ .type foo, @function
+foo:
+ .cfi_startproc
+ call func@plt
+ movq func@GOTPCREL(%rip), %rax
+ .cfi_endproc
+ .section .init_array,"aw",@init_array
+ .p2align 3
+ .zero 0x4
+ .section .fini_array,"aw",@fini_array
+ .p2align 20
+ .zero 0x100
+ .data
+ .zero 0x100
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 3bfc5e6..5ef66a2 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -511,6 +511,7 @@ run_dump_test "dt-relr-1a"
run_dump_test "dt-relr-1a-x32"
run_dump_test "dt-relr-1b"
run_dump_test "dt-relr-1b-x32"
+run_dump_test "pr28743-1"
if ![istarget "x86_64-*-linux*"] {
return