summaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2022-01-05 16:01:08 -0800
committerH.J. Lu <hjl.tools@gmail.com>2022-01-12 06:04:52 -0800
commit4d9e2e53b9f93b0ae33ba948ae3d2825b3424441 (patch)
treec54f87d1e130339406ccfa3036412b82c963e3d6 /ld
parent5af6f000d88622107e7382d337af2884fd211da2 (diff)
ld: Add simple DT_RELR tests
* testsuite/ld-elf/dt-relr-1.s: New file. * testsuite/ld-elf/dt-relr-1a.d: Likewise. * testsuite/ld-elf/dt-relr-1b.d: Likewise. * testsuite/ld-elf/dt-relr-1c.d: Likewise. * testsuite/ld-elf/dt-relr-2.s: Likewise. * testsuite/ld-elf/dt-relr-2a.d: Likewise. * testsuite/ld-elf/dt-relr-2b.d: Likewise. * testsuite/ld-elf/dt-relr-2c.d: Likewise. * testsuite/ld-elf/dt-relr-2d.d: Likewise. * testsuite/ld-elf/dt-relr-2e.d: Likewise. * testsuite/ld-elf/dt-relr-2f.d: Likewise. * testsuite/ld-elf/dt-relr-2g.d: Likewise. * testsuite/ld-elf/dt-relr-2h.d: Likewise. * testsuite/ld-elf/dt-relr-3.s: Likewise. * testsuite/ld-elf/dt-relr-3a.d: Likewise. * testsuite/ld-elf/dt-relr-3b.d: Likewise. * testsuite/ld-i386/dt-relr-1.s: Likewise. * testsuite/ld-i386/dt-relr-1a.d: Likewise. * testsuite/ld-i386/dt-relr-1b.d: Likewise. * testsuite/ld-x86-64/dt-relr-1a-x32.d: Likewise. * testsuite/ld-x86-64/dt-relr-1a.d: Likewise. * testsuite/ld-x86-64/dt-relr-1b-x32.d: Likewise. * testsuite/ld-x86-64/dt-relr-1b.d: Likewise. * testsuite/ld-x86-64/dt-relr-1.s: Likewise. * testsuite/ld-i386/i386.exp: Run dt-relr-1a and dt-relr-1b. * testsuite/ld-x86-64/x86-64.exp: Run dt-relr-1a, dt-relr-1a-x32 dt-relr-1b and dt-relr-1b-x32.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ld-elf/dt-relr-1.s13
-rw-r--r--ld/testsuite/ld-elf/dt-relr-1a.d10
-rw-r--r--ld/testsuite/ld-elf/dt-relr-1b.d9
-rw-r--r--ld/testsuite/ld-elf/dt-relr-1c.d9
-rw-r--r--ld/testsuite/ld-elf/dt-relr-2.s20
-rw-r--r--ld/testsuite/ld-elf/dt-relr-2a.d10
-rw-r--r--ld/testsuite/ld-elf/dt-relr-2b.d17
-rw-r--r--ld/testsuite/ld-elf/dt-relr-2c.d17
-rw-r--r--ld/testsuite/ld-elf/dt-relr-2d.d17
-rw-r--r--ld/testsuite/ld-elf/dt-relr-2e.d17
-rw-r--r--ld/testsuite/ld-elf/dt-relr-2f.d8
-rw-r--r--ld/testsuite/ld-elf/dt-relr-2g.d9
-rw-r--r--ld/testsuite/ld-elf/dt-relr-2h.d9
-rw-r--r--ld/testsuite/ld-elf/dt-relr-3.s12
-rw-r--r--ld/testsuite/ld-elf/dt-relr-3a.d9
-rw-r--r--ld/testsuite/ld-elf/dt-relr-3b.d9
-rw-r--r--ld/testsuite/ld-i386/dt-relr-1.s14
-rw-r--r--ld/testsuite/ld-i386/dt-relr-1a.d27
-rw-r--r--ld/testsuite/ld-i386/dt-relr-1b.d30
-rw-r--r--ld/testsuite/ld-i386/i386.exp2
-rw-r--r--ld/testsuite/ld-x86-64/dt-relr-1.s14
-rw-r--r--ld/testsuite/ld-x86-64/dt-relr-1a-x32.d27
-rw-r--r--ld/testsuite/ld-x86-64/dt-relr-1a.d27
-rw-r--r--ld/testsuite/ld-x86-64/dt-relr-1b-x32.d30
-rw-r--r--ld/testsuite/ld-x86-64/dt-relr-1b.d30
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp4
26 files changed, 400 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elf/dt-relr-1.s b/ld/testsuite/ld-elf/dt-relr-1.s
new file mode 100644
index 0000000000..1eb3458816
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-1.s
@@ -0,0 +1,13 @@
+ .text
+ .p2align 3
+ .globl _start
+_start:
+ .byte 0
+
+ .data
+ .p2align 3
+ .globl data
+data:
+ .byte 0
+ // Offset is not a multiple of 2. Don't use DT_RELR.
+ .dc.a __ehdr_start + 10
diff --git a/ld/testsuite/ld-elf/dt-relr-1a.d b/ld/testsuite/ld-elf/dt-relr-1a.d
new file mode 100644
index 0000000000..55c93cefb5
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-1a.d
@@ -0,0 +1,10 @@
+#source: dt-relr-1.s
+#ld: -e _start $DT_RELR_LDFLAGS
+#readelf: -rW -d
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#...
+There is no dynamic section in this file.
+#...
+There are no relocations in this file.
+#pass
diff --git a/ld/testsuite/ld-elf/dt-relr-1b.d b/ld/testsuite/ld-elf/dt-relr-1b.d
new file mode 100644
index 0000000000..2b78f75d37
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-1b.d
@@ -0,0 +1,9 @@
+#source: dt-relr-1.s
+#ld: -e _start -pie $DT_RELR_LDFLAGS
+#readelf: -rW -d
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#failif
+#...
+Relocation section '\.relr\.dyn' at offset .*
+#pass
diff --git a/ld/testsuite/ld-elf/dt-relr-1c.d b/ld/testsuite/ld-elf/dt-relr-1c.d
new file mode 100644
index 0000000000..14f6cda683
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-1c.d
@@ -0,0 +1,9 @@
+#source: dt-relr-1.s
+#ld: -shared $DT_RELR_LDFLAGS
+#readelf: -rW -d
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#failif
+#...
+Relocation section '\.relr\.dyn' at offset .*
+#pass
diff --git a/ld/testsuite/ld-elf/dt-relr-2.s b/ld/testsuite/ld-elf/dt-relr-2.s
new file mode 100644
index 0000000000..bd1f3dfa16
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-2.s
@@ -0,0 +1,20 @@
+ .text
+ .p2align 3
+ .globl _start
+_start:
+ .byte 0
+
+ .data
+ .p2align 3
+ .globl data
+data:
+
+ .dc.a .data
+ .dc.a 0
+ .dc.a data + 2
+ .dc.a __ehdr_start + 4
+ .dc.a __ehdr_start + 9
+
+ .byte 0
+ // Offset is not a multiple of 2. Don't use DT_RELR.
+ .dc.a __ehdr_start + 10
diff --git a/ld/testsuite/ld-elf/dt-relr-2a.d b/ld/testsuite/ld-elf/dt-relr-2a.d
new file mode 100644
index 0000000000..31ef9e8e80
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-2a.d
@@ -0,0 +1,10 @@
+#source: dt-relr-2.s
+#ld: -e _start $DT_RELR_LDFLAGS
+#readelf: -rW -d
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#...
+There is no dynamic section in this file.
+#...
+There are no relocations in this file.
+#pass
diff --git a/ld/testsuite/ld-elf/dt-relr-2b.d b/ld/testsuite/ld-elf/dt-relr-2b.d
new file mode 100644
index 0000000000..7c401732a5
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-2b.d
@@ -0,0 +1,17 @@
+#source: dt-relr-2.s
+#ld: -e _start -pie $DT_RELR_LDFLAGS
+#readelf: -rW -d
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#...
+ 0x[0-9a-f]+ \(RELR\) +0x[0-9a-f]+
+ 0x[0-9a-f]+ \(RELRSZ\) +(8|16) \(bytes\)
+ 0x[0-9a-f]+ \(RELRENT\) +(4|8) \(bytes\)
+#...
+Relocation section '\.rel(a|)\.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
+#...
+[0-9a-f]+ +[0-9a-f]+ +R_.*_RELATIVE .*
+#...
+Relocation section '\.relr\.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ 4 offsets
+#pass
diff --git a/ld/testsuite/ld-elf/dt-relr-2c.d b/ld/testsuite/ld-elf/dt-relr-2c.d
new file mode 100644
index 0000000000..63877b2f90
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-2c.d
@@ -0,0 +1,17 @@
+#source: dt-relr-2.s
+#ld: -shared $DT_RELR_LDFLAGS
+#readelf: -rW -d
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#...
+ 0x[0-9a-f]+ \(RELR\) +0x[0-9a-f]+
+ 0x[0-9a-f]+ \(RELRSZ\) +(8|16) \(bytes\)
+ 0x[0-9a-f]+ \(RELRENT\) +(4|8) \(bytes\)
+#...
+Relocation section '\.rel(a|)\.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+#...
+[0-9a-f]+ +[0-9a-f]+ +R_.*_RELATIVE .*
+#...
+Relocation section '\.relr\.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ 3 offsets
+#pass
diff --git a/ld/testsuite/ld-elf/dt-relr-2d.d b/ld/testsuite/ld-elf/dt-relr-2d.d
new file mode 100644
index 0000000000..e11528f395
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-2d.d
@@ -0,0 +1,17 @@
+#source: dt-relr-2.s
+#ld: -e _start -pie $DT_RELR_LDFLAGS --no-relax
+#readelf: -rW -d
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#...
+ 0x[0-9a-f]+ \(RELR\) +0x[0-9a-f]+
+ 0x[0-9a-f]+ \(RELRSZ\) +(8|16) \(bytes\)
+ 0x[0-9a-f]+ \(RELRENT\) +(4|8) \(bytes\)
+#...
+Relocation section '\.rel(a|)\.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
+#...
+[0-9a-f]+ +[0-9a-f]+ +R_.*_RELATIVE .*
+#...
+Relocation section '\.relr\.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ 4 offsets
+#pass
diff --git a/ld/testsuite/ld-elf/dt-relr-2e.d b/ld/testsuite/ld-elf/dt-relr-2e.d
new file mode 100644
index 0000000000..9cd268f9e7
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-2e.d
@@ -0,0 +1,17 @@
+#source: dt-relr-2.s
+#ld: -e _start -pie $DT_RELR_LDFLAGS -z nocombreloc
+#readelf: -rW -d
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#...
+ 0x[0-9a-f]+ \(RELR\) +0x[0-9a-f]+
+ 0x[0-9a-f]+ \(RELRSZ\) +(8|16) \(bytes\)
+ 0x[0-9a-f]+ \(RELRENT\) +(4|8) \(bytes\)
+#...
+Relocation section '\.rel(a|)\.data' at offset 0x[0-9a-f]+ contains 1 entry:
+#...
+[0-9a-f]+ +[0-9a-f]+ +R_.*_RELATIVE .*
+#...
+Relocation section '\.relr\.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ 4 offsets
+#pass
diff --git a/ld/testsuite/ld-elf/dt-relr-2f.d b/ld/testsuite/ld-elf/dt-relr-2f.d
new file mode 100644
index 0000000000..4ad592f71f
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-2f.d
@@ -0,0 +1,8 @@
+#source: dt-relr-2.s
+#ld: -r $DT_RELR_LDFLAGS
+#readelf: -rW
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#...
+Relocation section '\.rel(a|)\.data' at offset 0x[0-9a-f]+ contains 5 entries:
+#pass
diff --git a/ld/testsuite/ld-elf/dt-relr-2g.d b/ld/testsuite/ld-elf/dt-relr-2g.d
new file mode 100644
index 0000000000..78e370068a
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-2g.d
@@ -0,0 +1,9 @@
+#source: dt-relr-2.s
+#ld: -e _start -pie $NO_DT_RELR_LDFLAGS
+#readelf: -rW -d
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#failif
+#...
+Relocation section '\.relr\.dyn' at offset .*
+#pass
diff --git a/ld/testsuite/ld-elf/dt-relr-2h.d b/ld/testsuite/ld-elf/dt-relr-2h.d
new file mode 100644
index 0000000000..312373fb17
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-2h.d
@@ -0,0 +1,9 @@
+#source: dt-relr-2.s
+#ld: -e _start -shared $NO_DT_RELR_LDFLAGS
+#readelf: -rW -d
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#failif
+#...
+Relocation section '\.relr\.dyn' at offset .*
+#pass
diff --git a/ld/testsuite/ld-elf/dt-relr-3.s b/ld/testsuite/ld-elf/dt-relr-3.s
new file mode 100644
index 0000000000..d020132466
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-3.s
@@ -0,0 +1,12 @@
+ .text
+ .p2align 3
+ .globl _start
+_start:
+ .byte 0
+
+ // Section alignment is not a multiple of 2. Don't use DT_RELR.
+ .data
+ .p2align 0
+ .globl data
+data:
+ .dc.a data
diff --git a/ld/testsuite/ld-elf/dt-relr-3a.d b/ld/testsuite/ld-elf/dt-relr-3a.d
new file mode 100644
index 0000000000..5a8a014803
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-3a.d
@@ -0,0 +1,9 @@
+#source: dt-relr-3.s
+#ld: -e _start -pie $DT_RELR_LDFLAGS
+#readelf: -rW -d
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#failif
+#...
+Relocation section '\.relr\.dyn' at offset .*
+#pass
diff --git a/ld/testsuite/ld-elf/dt-relr-3b.d b/ld/testsuite/ld-elf/dt-relr-3b.d
new file mode 100644
index 0000000000..6c38e6968d
--- /dev/null
+++ b/ld/testsuite/ld-elf/dt-relr-3b.d
@@ -0,0 +1,9 @@
+#source: dt-relr-3.s
+#ld: -shared $DT_RELR_LDFLAGS
+#readelf: -rW -d
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+#failif
+#...
+Relocation section '\.relr\.dyn' at offset .*
+#pass
diff --git a/ld/testsuite/ld-i386/dt-relr-1.s b/ld/testsuite/ld-i386/dt-relr-1.s
new file mode 100644
index 0000000000..034939299b
--- /dev/null
+++ b/ld/testsuite/ld-i386/dt-relr-1.s
@@ -0,0 +1,14 @@
+ .text
+foo:
+ call func1@PLT
+ pushl __ehdr_start@GOT(%ebx)
+
+ .section .bar,"aw",@progbits
+ .p2align 2
+ .dc.a data1
+ .dc.a __ehdr_start
+
+ .section .foo,"aw",@progbits
+ .p2align 2
+ .dc.a data1
+ .dc.a __ehdr_start
diff --git a/ld/testsuite/ld-i386/dt-relr-1a.d b/ld/testsuite/ld-i386/dt-relr-1a.d
new file mode 100644
index 0000000000..cbb8ab6158
--- /dev/null
+++ b/ld/testsuite/ld-i386/dt-relr-1a.d
@@ -0,0 +1,27 @@
+#source: dt-relr-1.s
+#as: --32
+#ld: -shared -melf_i386 $DT_RELR_LDFLAGS
+#readelf: -r -s --wide
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 2 entries:
+ +Offset +Info +Type +Sym. Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +data1
+[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +data1
+
+Relocation section '\.rel\.plt' at offset 0x[0-9a-f]+ contains 1 entry:
+ +Offset +Info +Type +Sym. Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_JUMP_SLOT +0+ +func1
+
+Relocation section '.relr.dyn' at offset 0x[a-f0-9]+ contains 2 entries:
+ +3 offsets
+[a-f0-9]+
+[a-f0-9]+
+[a-f0-9]+
+
+#...
+Symbol table '.symtab' contains [0-9]+ entries:
+ Num: Value Size Type Bind Vis Ndx Name
+#...
+ +[a-f0-9]+: 00000000 0 NOTYPE LOCAL DEFAULT 1 __ehdr_start
+#pass
diff --git a/ld/testsuite/ld-i386/dt-relr-1b.d b/ld/testsuite/ld-i386/dt-relr-1b.d
new file mode 100644
index 0000000000..3dd988158c
--- /dev/null
+++ b/ld/testsuite/ld-i386/dt-relr-1b.d
@@ -0,0 +1,30 @@
+#source: dt-relr-1.s
+#as: --32
+#ld: -shared -melf_i386 $DT_RELR_LDFLAGS -z nocombreloc
+#readelf: -r -s --wide
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+Relocation section '\.rel\.bar' at offset [0x0-9a-f]+ contains 1 entry:
+ +Offset +Info +Type +Sym. Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +data1
+
+Relocation section '\.rel\.foo' at offset [0x0-9a-f]+ contains 1 entry:
+ +Offset +Info +Type +Sym. Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +data1
+
+Relocation section '\.rel\.plt' at offset 0x[0-9a-f]+ contains 1 entry:
+ +Offset +Info +Type +Sym. Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_JUMP_SLOT +0+ +func1
+
+Relocation section '.relr.dyn' at offset 0x[a-f0-9]+ contains 2 entries:
+ +3 offsets
+[a-f0-9]+
+[a-f0-9]+
+[a-f0-9]+
+
+#...
+Symbol table '.symtab' contains [0-9]+ entries:
+ Num: Value Size Type Bind Vis Ndx Name
+#...
+ +[a-f0-9]+: 00000000 0 NOTYPE LOCAL DEFAULT 1 __ehdr_start
+#pass
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index c2d8d8268c..fe36b0fb53 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -507,6 +507,8 @@ run_dump_test "pr27491-1c"
run_dump_test "pr27491-2"
run_dump_test "pr27491-3"
run_dump_test "pr27491-4"
+run_dump_test "dt-relr-1a"
+run_dump_test "dt-relr-1b"
if { !([istarget "i?86-*-linux*"]
|| [istarget "i?86-*-gnu*"]
diff --git a/ld/testsuite/ld-x86-64/dt-relr-1.s b/ld/testsuite/ld-x86-64/dt-relr-1.s
new file mode 100644
index 0000000000..0483a9c625
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/dt-relr-1.s
@@ -0,0 +1,14 @@
+ .text
+foo:
+ call func1@PLT
+ add __ehdr_start@GOTPCREL(%rip), %rax
+
+ .section .bar,"aw",@progbits
+ .p2align 3
+ .dc.a data1
+ .dc.a __ehdr_start
+
+ .section .foo,"aw",@progbits
+ .p2align 3
+ .dc.a data1
+ .dc.a __ehdr_start
diff --git a/ld/testsuite/ld-x86-64/dt-relr-1a-x32.d b/ld/testsuite/ld-x86-64/dt-relr-1a-x32.d
new file mode 100644
index 0000000000..3b603cd4b0
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/dt-relr-1a-x32.d
@@ -0,0 +1,27 @@
+#source: dt-relr-1.s
+#as: --x32
+#ld: -shared -melf32_x86_64 $DT_RELR_LDFLAGS
+#readelf: -r -s --wide
+#target: x86_64-*-linux*
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ +Offset +Info +Type +Sym. Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_32 +0+ +data1 \+ 0
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_32 +0+ +data1 \+ 0
+
+Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entry:
+ +Offset +Info +Type +Sym. Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func1 \+ 0
+
+Relocation section '.relr.dyn' at offset 0x[a-f0-9]+ contains 2 entries:
+ +3 offsets
+[a-f0-9]+
+[a-f0-9]+
+[a-f0-9]+
+
+#...
+Symbol table '.symtab' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__ehdr_start
+#pass
diff --git a/ld/testsuite/ld-x86-64/dt-relr-1a.d b/ld/testsuite/ld-x86-64/dt-relr-1a.d
new file mode 100644
index 0000000000..abf2352a92
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/dt-relr-1a.d
@@ -0,0 +1,27 @@
+#source: dt-relr-1.s
+#as: --64
+#ld: -shared -melf_x86_64 $DT_RELR_LDFLAGS
+#readelf: -r -s --wide
+#target: x86_64-*-linux*
+
+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_64 +0+ +data1 \+ 0
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_64 +0+ +data1 \+ 0
+
+Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entry:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func1 \+ 0
+
+Relocation section '.relr.dyn' at offset 0x[a-f0-9]+ contains 2 entries:
+ +3 offsets
+[a-f0-9]+
+[a-f0-9]+
+[a-f0-9]+
+
+#...
+Symbol table '.symtab' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__ehdr_start
+#pass
diff --git a/ld/testsuite/ld-x86-64/dt-relr-1b-x32.d b/ld/testsuite/ld-x86-64/dt-relr-1b-x32.d
new file mode 100644
index 0000000000..05c376c5d4
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/dt-relr-1b-x32.d
@@ -0,0 +1,30 @@
+#source: dt-relr-1.s
+#as: --x32
+#ld: -shared -melf32_x86_64 $DT_RELR_LDFLAGS -z nocombreloc
+#readelf: -r -s --wide
+#target: x86_64-*-linux*
+
+Relocation section '.rela.bar' at offset 0x[0-9a-f]+ contains 1 entry:
+ +Offset +Info +Type +Sym. Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_32 +0+ +data1 \+ 0
+
+Relocation section '.rela.foo' at offset 0x[0-9a-f]+ contains 1 entry:
+ +Offset +Info +Type +Sym. Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_32 +0+ +data1 \+ 0
+
+Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entry:
+ +Offset +Info +Type +Sym. Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func1 \+ 0
+
+Relocation section '.relr.dyn' at offset 0x[a-f0-9]+ contains 2 entries:
+ +3 offsets
+[a-f0-9]+
+[a-f0-9]+
+[a-f0-9]+
+
+#...
+Symbol table '.symtab' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__ehdr_start
+#pass
diff --git a/ld/testsuite/ld-x86-64/dt-relr-1b.d b/ld/testsuite/ld-x86-64/dt-relr-1b.d
new file mode 100644
index 0000000000..703b68f6fa
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/dt-relr-1b.d
@@ -0,0 +1,30 @@
+#source: dt-relr-1.s
+#as: --64
+#ld: -shared -melf_x86_64 $DT_RELR_LDFLAGS -z nocombreloc
+#readelf: -r -s --wide
+#target: x86_64-*-linux*
+
+Relocation section '.rela.bar' at offset 0x[0-9a-f]+ contains 1 entry:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_64 +0+ +data1 \+ 0
+
+Relocation section '.rela.foo' at offset 0x[0-9a-f]+ contains 1 entry:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_64 +0+ +data1 \+ 0
+
+Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entry:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func1 \+ 0
+
+Relocation section '.relr.dyn' at offset 0x[a-f0-9]+ contains 2 entries:
+ +3 offsets
+[a-f0-9]+
+[a-f0-9]+
+[a-f0-9]+
+
+#...
+Symbol table '.symtab' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__ehdr_start
+#pass
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index b404812805..3bfc5e6e46 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -507,6 +507,10 @@ run_dump_test "pr27491-1c"
run_dump_test "pr27491-2"
run_dump_test "pr27491-3"
run_dump_test "pr27491-4"
+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"
if ![istarget "x86_64-*-linux*"] {
return