aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog19
-rw-r--r--ld/ldlang.c4
-rw-r--r--ld/testsuite/ld-elf/pr26256-1.s20
-rw-r--r--ld/testsuite/ld-elf/pr26256-1.t13
-rw-r--r--ld/testsuite/ld-elf/pr26256-1a.d7
-rw-r--r--ld/testsuite/ld-elf/pr26256-1b.d7
-rw-r--r--ld/testsuite/ld-elf/pr26256-2.s32
-rw-r--r--ld/testsuite/ld-elf/pr26256-2.t9
-rw-r--r--ld/testsuite/ld-elf/pr26256-2a.d20
-rw-r--r--ld/testsuite/ld-elf/pr26256-2b-alt.d21
-rw-r--r--ld/testsuite/ld-elf/pr26256-2b.d22
-rw-r--r--ld/testsuite/ld-elf/pr26256-3.s27
-rw-r--r--ld/testsuite/ld-elf/pr26256-3a.d11
-rw-r--r--ld/testsuite/ld-elf/pr26256-3a.t17
-rw-r--r--ld/testsuite/ld-elf/pr26256-3b.d12
-rw-r--r--ld/testsuite/ld-elf/pr26256-3b.t16
16 files changed, 256 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 8d45491..1fe689a 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,22 @@
+2021-01-04 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/26256
+ * ldlang.c (gc_section_callback): Set pattern.
+ * testsuite/ld-elf/pr26256-1.s: New file.
+ * testsuite/ld-elf/pr26256-1.t: Likewise.
+ * testsuite/ld-elf/pr26256-1a.d: Likewise.
+ * testsuite/ld-elf/pr26256-1b.d: Likewise.
+ * testsuite/ld-elf/pr26256-2.s: Likewise.
+ * testsuite/ld-elf/pr26256-2.t: Likewise.
+ * testsuite/ld-elf/pr26256-2a.d: Likewise.
+ * testsuite/ld-elf/pr26256-2b-alt.d: Likewise.
+ * testsuite/ld-elf/pr26256-2b.d: Likewise.
+ * testsuite/ld-elf/pr26256-3.s: Likewise.
+ * testsuite/ld-elf/pr26256-3a.d: Likewise.
+ * testsuite/ld-elf/pr26256-3a.t: Likewise.
+ * testsuite/ld-elf/pr26256-3b.d: Likewise.
+ * testsuite/ld-elf/pr26256-3b.t: Likewise.
+
2021-01-04 Alan Modra <amodra@gmail.com>
PR 26822
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 32450fb..8cbeda6 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -7488,7 +7488,7 @@ lang_reset_memory_regions (void)
static void
gc_section_callback (lang_wild_statement_type *ptr,
- struct wildcard_list *sec ATTRIBUTE_UNUSED,
+ struct wildcard_list *sec,
asection *section,
struct flag_info *sflag_info ATTRIBUTE_UNUSED,
lang_input_statement_type *file ATTRIBUTE_UNUSED,
@@ -7498,6 +7498,8 @@ gc_section_callback (lang_wild_statement_type *ptr,
should be as well. */
if (ptr->keep_sections)
section->flags |= SEC_KEEP;
+ if (sec)
+ section->pattern = sec->spec.name;
}
/* Iterate over sections marking them against GC. */
diff --git a/ld/testsuite/ld-elf/pr26256-1.s b/ld/testsuite/ld-elf/pr26256-1.s
new file mode 100644
index 0000000..7351f76
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-1.s
@@ -0,0 +1,20 @@
+ .section .text.bar,"ax",%progbits
+ .globl bar
+ .type bar, %function
+bar:
+ .section __patchable_function_entries,"awo",%progbits,bar
+ .dc.a .LPFE1
+ .section .text.bar,"ax",%progbits
+.LPFE1:
+ .byte 0
+ .section .text._start,"ax",%progbits
+ .globl _start
+ .type _start, %function
+_start:
+ .section __patchable_function_entries,"awo",%progbits,_start
+ .dc.a .LPFE2
+ .section .text._start,"ax",%progbits
+.LPFE2:
+ .byte 0
+ .section .init.data,"aw",%progbits
+ .byte 0
diff --git a/ld/testsuite/ld-elf/pr26256-1.t b/ld/testsuite/ld-elf/pr26256-1.t
new file mode 100644
index 0000000..f93fff9
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-1.t
@@ -0,0 +1,13 @@
+SECTIONS
+{
+ .text : { *(.text*) }
+ .init.data :
+ {
+ *(.init.data);
+ *(__patchable_function_entries);
+ }
+ /DISCARD/ :
+ {
+ *(.reginfo) *(.MIPS.abiflags) *(.MIPS.options) *(.trampolines)
+ }
+}
diff --git a/ld/testsuite/ld-elf/pr26256-1a.d b/ld/testsuite/ld-elf/pr26256-1a.d
new file mode 100644
index 0000000..025ace0
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-1a.d
@@ -0,0 +1,7 @@
+#source: pr26256-1.s
+#ld: -e _start -T pr26256-1.t
+#nm: -n
+
+#...
+[0-9a-f]+ T _start
+#pass
diff --git a/ld/testsuite/ld-elf/pr26256-1b.d b/ld/testsuite/ld-elf/pr26256-1b.d
new file mode 100644
index 0000000..760c6d8
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-1b.d
@@ -0,0 +1,7 @@
+#source: pr26256-1.s
+#ld: -e _start
+#nm: -n
+
+#...
+[0-9a-f]+ T _start
+#pass
diff --git a/ld/testsuite/ld-elf/pr26256-2.s b/ld/testsuite/ld-elf/pr26256-2.s
new file mode 100644
index 0000000..70e3693
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-2.s
@@ -0,0 +1,32 @@
+ .section .text,"ax",%progbits,unique,0
+ .globl text0
+text0:
+ .nop
+ .section .text,"ax",%progbits,unique,1
+ .globl text1
+text1:
+ .nop
+ .section .linkorder,"ao",%progbits,0,unique,0
+ .globl linkorder2
+linkorder2:
+ .byte 0
+ .section .linkorder,"ao",%progbits,text0
+ .globl linkorder0
+linkorder0:
+ .byte 1
+ .section .linkorder,"ao",%progbits,text1
+ .globl linkorder1
+linkorder1:
+ .byte 2
+ .section .linkorder,"a",%progbits
+ .globl linkorder3
+linkorder3:
+ .byte 3
+ .section .linkorder,"ao",%progbits,0,unique,3
+ .globl linkorder4
+linkorder4:
+ .byte 4
+ .text
+ .global _start
+_start:
+ .nop
diff --git a/ld/testsuite/ld-elf/pr26256-2.t b/ld/testsuite/ld-elf/pr26256-2.t
new file mode 100644
index 0000000..0c5e5bc
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-2.t
@@ -0,0 +1,9 @@
+SECTIONS
+{
+ .linkorder : { *(.linkorder.*) }
+ .text : { *(.text) }
+ /DISCARD/ :
+ {
+ *(.reginfo) *(.MIPS.abiflags) *(.MIPS.options) *(.trampolines)
+ }
+}
diff --git a/ld/testsuite/ld-elf/pr26256-2a.d b/ld/testsuite/ld-elf/pr26256-2a.d
new file mode 100644
index 0000000..03804d8
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-2a.d
@@ -0,0 +1,20 @@
+#source: pr26256-2.s
+#ld: -e _start -T pr26256-2.t
+#nm: -n
+#xfail: [is_generic]
+
+#...
+[0-9a-f]+ R linkorder2
+#...
+[0-9a-f]+ R linkorder3
+#...
+[0-9a-f]+ R linkorder4
+#...
+[0-9a-f]+ R linkorder0
+#...
+[0-9a-f]+ R linkorder1
+#...
+[0-9a-f]+ T text0
+#...
+[0-9a-f]+ T text1
+#pass
diff --git a/ld/testsuite/ld-elf/pr26256-2b-alt.d b/ld/testsuite/ld-elf/pr26256-2b-alt.d
new file mode 100644
index 0000000..f2f03a0
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-2b-alt.d
@@ -0,0 +1,21 @@
+#source: pr26256-2.s
+#ld: -e _start
+#nm: -n
+#target: fr30-*-* iq2000-*-* ip2k-*-* xstormy16-*-*
+# These targets place .linkorder sections before .text sections.
+
+#...
+[0-9a-f]+ R linkorder2
+#...
+[0-9a-f]+ R linkorder3
+#...
+[0-9a-f]+ R linkorder4
+#...
+[0-9a-f]+ R linkorder0
+#...
+[0-9a-f]+ R linkorder1
+#...
+[0-9a-f]+ T text0
+#...
+[0-9a-f]+ T text1
+#pass
diff --git a/ld/testsuite/ld-elf/pr26256-2b.d b/ld/testsuite/ld-elf/pr26256-2b.d
new file mode 100644
index 0000000..60c3bff
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-2b.d
@@ -0,0 +1,22 @@
+#source: pr26256-2.s
+#ld: -e _start
+#nm: -n
+#xfail: [is_generic]
+#notarget: fr30-*-* iq2000-*-* ip2k-*-* xstormy16-*-*
+# These targets place .linkorder sections before .text sections.
+
+#...
+[0-9a-f]+ T text0
+#...
+[0-9a-f]+ T text1
+#...
+[0-9a-f]+ R linkorder2
+#...
+[0-9a-f]+ R linkorder3
+#...
+[0-9a-f]+ R linkorder4
+#...
+[0-9a-f]+ R linkorder0
+#...
+[0-9a-f]+ R linkorder1
+#pass
diff --git a/ld/testsuite/ld-elf/pr26256-3.s b/ld/testsuite/ld-elf/pr26256-3.s
new file mode 100644
index 0000000..baad9dc
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-3.s
@@ -0,0 +1,27 @@
+ .text
+ .global _start
+_start:
+ .long 0x33333333
+ .long 0x33333333
+ .long 0x33333333
+ .long 0x33333333
+
+ .section .rosection,"a"
+ .byte 9
+
+ .section .text.bar,"a",%progbits
+ .long 0x22222222
+ .long 0x22222222
+ .long 0x22222222
+ .long 0x22222222
+ .section .text.foo,"a",%progbits
+ .long 0x11111111
+ .long 0x11111111
+ .long 0x11111111
+ .long 0x11111111
+ .section .rodata.foo,"ao",%progbits,.text.foo
+ .byte 1
+ .section .rodata.bar,"a",%progbits
+ .byte 2
+ .section .rodata.bar,"ao",%progbits,.text.bar
+ .byte 3
diff --git a/ld/testsuite/ld-elf/pr26256-3a.d b/ld/testsuite/ld-elf/pr26256-3a.d
new file mode 100644
index 0000000..4546f0a
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-3a.d
@@ -0,0 +1,11 @@
+#source: pr26256-3.s
+#ld: -e _start -T pr26256-3a.t
+#readelf: -x .rodata -x .text
+
+Hex dump of section \'.rodata\':
+ 0x[a-f0-9]+ +00010203 +040907 +.+
+
+Hex dump of section \'.text\':
+ 0x[a-f0-9]+ +22222222 +22222222 +22222222 +.+
+ 0x[a-f0-9]+ +11111111 +11111111 +11111111 +.+
+ 0x[a-f0-9]+ +33333333 +33333333 +33333333 +.+
diff --git a/ld/testsuite/ld-elf/pr26256-3a.t b/ld/testsuite/ld-elf/pr26256-3a.t
new file mode 100644
index 0000000..12f6fd1
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-3a.t
@@ -0,0 +1,17 @@
+SECTIONS
+{
+ .rodata :
+ {
+ BYTE(0)
+ *(.rodata.foo)
+ *(.rodata.bar)
+ BYTE(4)
+ *(.rosection)
+ BYTE(7)
+ }
+ .text : {*(.text.bar) *(.text.foo)}
+ /DISCARD/ :
+ {
+ *(.reginfo) *(.MIPS.abiflags) *(.MIPS.options) *(.trampolines)
+ }
+}
diff --git a/ld/testsuite/ld-elf/pr26256-3b.d b/ld/testsuite/ld-elf/pr26256-3b.d
new file mode 100644
index 0000000..7d6dff2
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-3b.d
@@ -0,0 +1,12 @@
+#source: pr26256-3.s
+#ld: -e _start -T pr26256-3b.t
+#readelf: -x .rodata -x .text
+#xfail: [is_generic]
+
+Hex dump of section \'.rodata\':
+ 0x[a-f0-9]+ +00020301 +040907 +.+
+
+Hex dump of section \'.text\':
+ 0x[a-f0-9]+ +22222222 +22222222 +22222222 +.+
+ 0x[a-f0-9]+ +11111111 +11111111 +11111111 +.+
+ 0x[a-f0-9]+ +33333333 +33333333 +33333333 +.+
diff --git a/ld/testsuite/ld-elf/pr26256-3b.t b/ld/testsuite/ld-elf/pr26256-3b.t
new file mode 100644
index 0000000..952c8d2
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr26256-3b.t
@@ -0,0 +1,16 @@
+SECTIONS
+{
+ .rodata :
+ {
+ BYTE(0)
+ *(.rodata*)
+ BYTE(4)
+ *(.rosection)
+ BYTE(7)
+ }
+ .text : {*(.text.bar) *(.text.foo)}
+ /DISCARD/ :
+ {
+ *(.reginfo) *(.MIPS.abiflags) *(.MIPS.options) *(.trampolines)
+ }
+}