aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-10-03 14:11:43 -0700
committerH.J. Lu <hjl.tools@gmail.com>2018-10-03 14:11:53 -0700
commitfb9bbfd7f2d39a1d4850fcf0f63ef1f077f55e4b (patch)
treedfec84c7d8359a052808f5799d30d4b8266f10ad /ld
parent34c0fc000f5202dc8f5feeb35d682913ee508230 (diff)
downloadgdb-fb9bbfd7f2d39a1d4850fcf0f63ef1f077f55e4b.zip
gdb-fb9bbfd7f2d39a1d4850fcf0f63ef1f077f55e4b.tar.gz
gdb-fb9bbfd7f2d39a1d4850fcf0f63ef1f077f55e4b.tar.bz2
ELF: Add testcases for PR ld/23658
Add testcases to verify that all SHT_NOTE sections with the same section alignment are placed in a single PT_NOTE segment. PR ld/23658 * testsuite/ld-elf/pr23658-1.d: New file. * testsuite/ld-elf/pr23658-1a.s: Likewise. * testsuite/ld-elf/pr23658-1b.s: Likewise. * testsuite/ld-elf/pr23658-1c.s: Likewise. * testsuite/ld-elf/pr23658-1d.s: Likewise. * testsuite/ld-elf/pr23658-2.rd: Likewise. * testsuite/ld-elf/pr23658-3.d: Likewise. * testsuite/ld-elf/pr23658-3.s: Likewise. * testsuite/ld-elf/pr23658-3.t: Likewise. * testsuite/ld-elf/shared.exp: Run PR ld/23658 tests.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog14
-rw-r--r--ld/testsuite/ld-elf/pr23658-1.d16
-rw-r--r--ld/testsuite/ld-elf/pr23658-1a.s21
-rw-r--r--ld/testsuite/ld-elf/pr23658-1b.s16
-rw-r--r--ld/testsuite/ld-elf/pr23658-1c.s16
-rw-r--r--ld/testsuite/ld-elf/pr23658-1d.s16
-rw-r--r--ld/testsuite/ld-elf/pr23658-2.rd6
-rw-r--r--ld/testsuite/ld-elf/pr23658-3.d8
-rw-r--r--ld/testsuite/ld-elf/pr23658-3.s4
-rw-r--r--ld/testsuite/ld-elf/pr23658-3.t14
-rw-r--r--ld/testsuite/ld-elf/shared.exp21
11 files changed, 152 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index f17a8f2..091d9f2 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,6 +1,20 @@
2018-10-03 H.J. Lu <hongjiu.lu@intel.com>
PR ld/23658
+ * testsuite/ld-elf/pr23658-1.d: New file.
+ * testsuite/ld-elf/pr23658-1a.s: Likewise.
+ * testsuite/ld-elf/pr23658-1b.s: Likewise.
+ * testsuite/ld-elf/pr23658-1c.s: Likewise.
+ * testsuite/ld-elf/pr23658-1d.s: Likewise.
+ * testsuite/ld-elf/pr23658-2.rd: Likewise.
+ * testsuite/ld-elf/pr23658-3.d: Likewise.
+ * testsuite/ld-elf/pr23658-3.s: Likewise.
+ * testsuite/ld-elf/pr23658-3.t: Likewise.
+ * testsuite/ld-elf/shared.exp: Run PR ld/23658 tests.
+
+2018-10-03 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/23658
* ldlang.c (lang_insert_orphan): Group and sort output note
sections by section alignments.
diff --git a/ld/testsuite/ld-elf/pr23658-1.d b/ld/testsuite/ld-elf/pr23658-1.d
new file mode 100644
index 0000000..252fb87
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-1.d
@@ -0,0 +1,16 @@
+#source: pr23658-1a.s
+#source: pr23658-1b.s
+#source: pr23658-1c.s
+#source: pr23658-1d.s
+#source: start.s
+#ld: --build-id
+#readelf: -l --wide
+# Since generic linker targets don't place SHT_NOTE sections as orphan,
+# SHT_NOTE sections aren't grouped nor sorted.
+#xfail: cr16-* crx-* d30v-* dlx-* fr30-* frv-* iq2000-*
+#xfail: m68hc12-* mn10200-* moxie-* mt-* msp430-* pj-*
+
+#...
+ +[0-9]+ +\.note\.4 \.note\.1 +
+ +[0-9]+ +\.note.gnu.build-id \.note\.2 .note\.3 +
+#pass
diff --git a/ld/testsuite/ld-elf/pr23658-1a.s b/ld/testsuite/ld-elf/pr23658-1a.s
new file mode 100644
index 0000000..bc34f86
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-1a.s
@@ -0,0 +1,21 @@
+ .text
+ .global foo
+foo:
+ .dc.a 0
+
+ .section ".note.4", "a"
+ .p2align 3
+ .long .L1 - .L0 /* name length. */
+ .long .L3 - .L1 /* data length. */
+ .long 123456 /* note type. */
+.L0:
+ .asciz "GNU" /* vendor name. */
+.L1:
+ .p2align 3
+ .long 0 /* pr_type. */
+ .long .L5 - .L4 /* pr_datasz. */
+.L4:
+ .zero 0x10
+.L5:
+ .p2align 3
+.L3:
diff --git a/ld/testsuite/ld-elf/pr23658-1b.s b/ld/testsuite/ld-elf/pr23658-1b.s
new file mode 100644
index 0000000..3b44b42
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-1b.s
@@ -0,0 +1,16 @@
+ .section ".note.2", "a"
+ .p2align 2
+ .long .L1 - .L0 /* name length. */
+ .long .L3 - .L1 /* data length. */
+ .long 12345 /* note type. */
+.L0:
+ .asciz "GNU" /* vendor name. */
+.L1:
+ .p2align 2
+ .long 0 /* pr_type. */
+ .long .L5 - .L4 /* pr_datasz. */
+.L4:
+ .zero 0x10
+.L5:
+ .p2align 2
+.L3:
diff --git a/ld/testsuite/ld-elf/pr23658-1c.s b/ld/testsuite/ld-elf/pr23658-1c.s
new file mode 100644
index 0000000..fb218ce
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-1c.s
@@ -0,0 +1,16 @@
+ .section ".note.1", "a"
+ .p2align 3
+ .long .L1 - .L0 /* name length. */
+ .long .L3 - .L1 /* data length. */
+ .long 12345 /* note type. */
+.L0:
+ .asciz "GNU" /* vendor name. */
+.L1:
+ .p2align 3
+ .long 0 /* pr_type. */
+ .long .L5 - .L4 /* pr_datasz. */
+.L4:
+ .zero 0x10
+.L5:
+ .p2align 3
+.L3:
diff --git a/ld/testsuite/ld-elf/pr23658-1d.s b/ld/testsuite/ld-elf/pr23658-1d.s
new file mode 100644
index 0000000..93fe502
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-1d.s
@@ -0,0 +1,16 @@
+ .section ".note.3", "a"
+ .p2align 2
+ .long .L1 - .L0 /* name length. */
+ .long .L3 - .L1 /* data length. */
+ .long 12345 /* note type. */
+.L0:
+ .asciz "GNU" /* vendor name. */
+.L1:
+ .p2align 2
+ .long 0 /* pr_type. */
+ .long .L5 - .L4 /* pr_datasz. */
+.L4:
+ .zero 0x10
+.L5:
+ .p2align 2
+.L3:
diff --git a/ld/testsuite/ld-elf/pr23658-2.rd b/ld/testsuite/ld-elf/pr23658-2.rd
new file mode 100644
index 0000000..9f89c4b
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-2.rd
@@ -0,0 +1,6 @@
+#...
+ +[0-9]+ +\.interp \.note.4 \.note.1 \.note.2 \.note.3.*
+#...
+ +[0-9]+ +\.note\.4 \.note\.1 +
+ +[0-9]+ +\.note\.2 .note\.3 +
+#pass
diff --git a/ld/testsuite/ld-elf/pr23658-3.d b/ld/testsuite/ld-elf/pr23658-3.d
new file mode 100644
index 0000000..2f018aa
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-3.d
@@ -0,0 +1,8 @@
+#as: -mx86-used-note=yes
+#ld: -T pr23658-3.t -z noseparate-code
+#nm: -B
+#target: i?86-*-* x86_64-*-*
+
+#...
+0+4000 D __FOO
+#...
diff --git a/ld/testsuite/ld-elf/pr23658-3.s b/ld/testsuite/ld-elf/pr23658-3.s
new file mode 100644
index 0000000..1d05efd
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-3.s
@@ -0,0 +1,4 @@
+ .data
+ .global baz
+baz:
+ .word 0
diff --git a/ld/testsuite/ld-elf/pr23658-3.t b/ld/testsuite/ld-elf/pr23658-3.t
new file mode 100644
index 0000000..ffc3467
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-3.t
@@ -0,0 +1,14 @@
+SECTIONS
+{
+ .data 0x1000 :
+ {
+ *(.data)
+ QUAD (__FOO);
+ }
+
+ .foo 0x4000 :
+ {
+ PROVIDE (__FOO = .);
+ *(.foo)
+ }
+}
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index cdb171d..c894d21 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -49,6 +49,12 @@ if [istarget "sparc*-*-*"] {
append AFLAGS_PIC " -K PIC"
}
+# GAS options to disable program property note.
+set AFLAGS_NOTE ""
+if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
+ append AFLAGS_NOTE "-mx86-used-note=no"
+}
+
# This target requires a non-default emulation for successful shared
# library/executable builds.
set LFLAGS ""
@@ -1474,3 +1480,18 @@ if { [istarget "i?86-*-*"]
] \
]
}
+
+run_ld_link_tests [list \
+ [list "Build pr23658.so" \
+ "-shared" "" "$AFLAGS_PIC" \
+ {pr23658-1a.s} {} "pr23658.so"] \
+ [list \
+ "Build pr23658-2" \
+ "--dynamic-linker tmpdir/pr23658.so --no-as-needed tmpdir/pr23658.so" \
+ "" \
+ $AFLAGS_NOTE \
+ { pr23658-1a.s pr23658-1b.s pr23658-1c.s pr23658-1d.s start.s } \
+ {{readelf {-lW} pr23658-2.rd}} \
+ "pr23658-2" \
+ ] \
+]