aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-02-06 18:04:58 -0800
committerH.J. Lu <hjl.tools@gmail.com>2020-02-06 18:05:10 -0800
commitb7d072167715829eed0622616f6ae0182900de3e (patch)
tree5015f461be45da594a9a8b5e80356e083033224e /ld
parent3c83b08abfff01d45ce78cabd29e83923b270c3b (diff)
downloadgdb-b7d072167715829eed0622616f6ae0182900de3e.zip
gdb-b7d072167715829eed0622616f6ae0182900de3e.tar.gz
gdb-b7d072167715829eed0622616f6ae0182900de3e.tar.bz2
ELF: Support the section flag 'o' in .section directive
As shown in https://sourceware.org/bugzilla/show_bug.cgi?id=25490 --gc-sections will silently remove __patchable_function_entries section and generate corrupt result. This patch adds the section flag 'o' to .section directive: .section __patchable_function_entries,"awo",@progbits,foo .section __patchable_function_entries,"awoG",@progbits,foo,foo,comdat .section __patchable_function_entries,"awo",@progbits,bar,unique,4 .section __patchable_function_entries,"awoG",@progbits,foo,foo,comdat,unique,1 which specifies the symbol name which the section references. Assmebler will set its elf_linked_to_section to a local section where the symbol is defined. Linker is updated to call mark_hook if gc_mark of any of its linked-to sections is set after all sections, except for backend specific ones, have been garbage collected. bfd/ PR gas/25381 * bfd-in2.h: Regenerated. * elflink.c (_bfd_elf_gc_mark_extra_sections): Call mark_hook on section if gc_mark of any of its linked-to sections is set and don't set gc_mark again. * section.c (asection): Add linked_to_symbol_name to map_head union. gas/ PR gas/25381 * config/obj-elf.c (get_section): Also check linked_to_symbol_name. (obj_elf_change_section): Also set map_head.linked_to_symbol_name. (obj_elf_parse_section_letters): Handle the 'o' flag. (build_group_lists): Renamed to ... (build_additional_section_info): This. Set elf_linked_to_section from map_head.linked_to_symbol_name. (elf_adjust_symtab): Updated. * config/obj-elf.h (elf_section_match): Add linked_to_symbol_name. * doc/as.texi: Document the 'o' flag. * testsuite/gas/elf/elf.exp: Run PR gas/25381 tests. * testsuite/gas/elf/section18.d: New file. * testsuite/gas/elf/section18.s: Likewise. * testsuite/gas/elf/section19.d: Likewise. * testsuite/gas/elf/section19.s: Likewise. * testsuite/gas/elf/section20.d: Likewise. * testsuite/gas/elf/section20.s: Likewise. * testsuite/gas/elf/section21.d: Likewise. * testsuite/gas/elf/section21.l: Likewise. * testsuite/gas/elf/section21.s: Likewise. ld/ PR ld/24526 PR ld/25021 PR ld/25490 * testsuite/ld-elf/elf.exp: Run PR ld/25490 tests. * testsuite/ld-elf/pr24526.d: New file. * testsuite/ld-elf/pr24526.s: Likewise. * testsuite/ld-elf/pr25021.d: Likewise. * testsuite/ld-elf/pr25021.s: Likewise. * testsuite/ld-elf/pr25490-2-16.rd: Likewise. * testsuite/ld-elf/pr25490-2-32.rd: Likewise. * testsuite/ld-elf/pr25490-2-64.rd: Likewise. * testsuite/ld-elf/pr25490-2.s: Likewise. * testsuite/ld-elf/pr25490-3-16.rd: Likewise. * testsuite/ld-elf/pr25490-3-32.rd: Likewise. * testsuite/ld-elf/pr25490-3-64.rd: Likewise. * testsuite/ld-elf/pr25490-3.s: Likewise. * testsuite/ld-elf/pr25490-4-16.rd: Likewise. * testsuite/ld-elf/pr25490-4-32.rd: Likewise. * testsuite/ld-elf/pr25490-4-64.rd: Likewise. * testsuite/ld-elf/pr25490-4.s: Likewise. * testsuite/ld-elf/pr25490-5-16.rd: Likewise. * testsuite/ld-elf/pr25490-5-32.rd: Likewise. * testsuite/ld-elf/pr25490-5-64.rd: Likewise. * testsuite/ld-elf/pr25490-5.s: Likewise. * testsuite/ld-elf/pr25490-6-16.rd: Likewise. * testsuite/ld-elf/pr25490-6-32.rd: Likewise. * testsuite/ld-elf/pr25490-6-64.rd: Likewise. * testsuite/ld-elf/pr25490-6.s: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog33
-rw-r--r--ld/testsuite/ld-elf/elf.exp63
-rw-r--r--ld/testsuite/ld-elf/pr24526.d9
-rw-r--r--ld/testsuite/ld-elf/pr24526.s13
-rw-r--r--ld/testsuite/ld-elf/pr25021.d7
-rw-r--r--ld/testsuite/ld-elf/pr25021.s22
-rw-r--r--ld/testsuite/ld-elf/pr25490-2-16.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-2-32.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-2-64.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-2.s9
-rw-r--r--ld/testsuite/ld-elf/pr25490-3-16.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-3-32.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-3-64.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-3.s18
-rw-r--r--ld/testsuite/ld-elf/pr25490-4-16.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-4-32.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-4-64.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-4.s20
-rw-r--r--ld/testsuite/ld-elf/pr25490-5-16.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-5-32.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-5-64.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-5.s17
-rw-r--r--ld/testsuite/ld-elf/pr25490-6-16.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-6-32.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-6-64.rd7
-rw-r--r--ld/testsuite/ld-elf/pr25490-6.s30
26 files changed, 345 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 66a5049..b5c8326 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,4 +1,35 @@
-2020-02-07 H.J. Lu <hongjiu.lu@intel.com>
+2020-02-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/24526
+ PR ld/25021
+ PR ld/25490
+ * testsuite/ld-elf/elf.exp: Run PR ld/25490 tests.
+ * testsuite/ld-elf/pr24526.d: New file.
+ * testsuite/ld-elf/pr24526.s: Likewise.
+ * testsuite/ld-elf/pr25021.d: Likewise.
+ * testsuite/ld-elf/pr25021.s: Likewise.
+ * testsuite/ld-elf/pr25490-2-16.rd: Likewise.
+ * testsuite/ld-elf/pr25490-2-32.rd: Likewise.
+ * testsuite/ld-elf/pr25490-2-64.rd: Likewise.
+ * testsuite/ld-elf/pr25490-2.s: Likewise.
+ * testsuite/ld-elf/pr25490-3-16.rd: Likewise.
+ * testsuite/ld-elf/pr25490-3-32.rd: Likewise.
+ * testsuite/ld-elf/pr25490-3-64.rd: Likewise.
+ * testsuite/ld-elf/pr25490-3.s: Likewise.
+ * testsuite/ld-elf/pr25490-4-16.rd: Likewise.
+ * testsuite/ld-elf/pr25490-4-32.rd: Likewise.
+ * testsuite/ld-elf/pr25490-4-64.rd: Likewise.
+ * testsuite/ld-elf/pr25490-4.s: Likewise.
+ * testsuite/ld-elf/pr25490-5-16.rd: Likewise.
+ * testsuite/ld-elf/pr25490-5-32.rd: Likewise.
+ * testsuite/ld-elf/pr25490-5-64.rd: Likewise.
+ * testsuite/ld-elf/pr25490-5.s: Likewise.
+ * testsuite/ld-elf/pr25490-6-16.rd: Likewise.
+ * testsuite/ld-elf/pr25490-6-32.rd: Likewise.
+ * testsuite/ld-elf/pr25490-6-64.rd: Likewise.
+ * testsuite/ld-elf/pr25490-6.s: Likewise.
+
+2020-02-06 H.J. Lu <hongjiu.lu@intel.com>
* testsuite/lib/ld-lib.exp (check_gc_sections_available): Mark
z80 as not supported.
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index 989fb50..7b8e8f6 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -76,9 +76,32 @@ run_ld_link_tests [list \
if [is_elf64 tmpdir/symbol3w.a] {
set ASFLAGS "$ASFLAGS --defsym ALIGN=3"
set pr23900_1_exp "pr23900-1-64.rd"
+ set pr25490_2_exp "pr25490-2-64.rd"
+ set pr25490_3_exp "pr25490-3-64.rd"
+ set pr25490_4_exp "pr25490-4-64.rd"
+ set pr25490_5_exp "pr25490-5-64.rd"
+ set pr25490_6_exp "pr25490-6-64.rd"
} else {
set ASFLAGS "$ASFLAGS --defsym ALIGN=2"
set pr23900_1_exp "pr23900-1-32.rd"
+ if { [istarget avr-*-*]
+ || [istarget h8300-*-*]
+ || [istarget ip2k-*-*]
+ || [istarget m68hc11-*]
+ || [istarget "xc16x-*"]
+ || [istarget "z80-*-*"] } {
+ set pr25490_2_exp "pr25490-2-16.rd"
+ set pr25490_3_exp "pr25490-3-16.rd"
+ set pr25490_4_exp "pr25490-4-16.rd"
+ set pr25490_5_exp "pr25490-5-16.rd"
+ set pr25490_6_exp "pr25490-6-16.rd"
+ } else {
+ set pr25490_2_exp "pr25490-2-32.rd"
+ set pr25490_3_exp "pr25490-3-32.rd"
+ set pr25490_4_exp "pr25490-4-32.rd"
+ set pr25490_5_exp "pr25490-5-32.rd"
+ set pr25490_6_exp "pr25490-6-32.rd"
+ }
}
@@ -172,6 +195,46 @@ if { [istarget *-*-*linux*]
]
}
+if [check_gc_sections_available] {
+ run_ld_link_tests [list \
+ [list "__patchable_function_entries section 2" \
+ "--gc-sections -e _start" \
+ "" \
+ "" \
+ {pr25490-2.s} \
+ [list [list "readelf" {-SW} $pr25490_2_exp]] \
+ "pr25490-2.exe"] \
+ [list "__patchable_function_entries section 3" \
+ "--gc-sections -e _start" \
+ "" \
+ "" \
+ {pr25490-3.s} \
+ [list [list "readelf" {-SW} $pr25490_3_exp]] \
+ "pr25490-3.exe"] \
+ [list "__patchable_function_entries section 4" \
+ "--gc-sections -e _start" \
+ "" \
+ "" \
+ {pr25490-4.s} \
+ [list [list "readelf" {-SW} $pr25490_4_exp]] \
+ "pr25490-4.exe"] \
+ [list "__patchable_function_entries section 5" \
+ "--gc-sections -e _start" \
+ "" \
+ "" \
+ {pr25490-5.s} \
+ [list [list "readelf" {-SW} $pr25490_5_exp]] \
+ "pr25490-5.exe"] \
+ [list "__patchable_function_entries section 6" \
+ "--gc-sections -e _start" \
+ "" \
+ "" \
+ {pr25490-6.s} \
+ [list [list "readelf" {-SW} $pr25490_6_exp]] \
+ "pr25490-6.exe"] \
+ ]
+}
+
set LDFLAGS $old_ldflags
set ASFLAGS $old_asflags
diff --git a/ld/testsuite/ld-elf/pr24526.d b/ld/testsuite/ld-elf/pr24526.d
new file mode 100644
index 0000000..3faaa1e
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr24526.d
@@ -0,0 +1,9 @@
+#ld: --gc-sections -e _start
+#target: [check_gc_sections_available]
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] \.bar +PROGBITS +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +00 +AL .*
+#...
+ +\[ *[0-9]+\] \.zed +PROGBITS +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +00 +AL .*
+#pass
diff --git a/ld/testsuite/ld-elf/pr24526.s b/ld/testsuite/ld-elf/pr24526.s
new file mode 100644
index 0000000..7d77338
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr24526.s
@@ -0,0 +1,13 @@
+ .text
+ .globl _start
+_start:
+ .byte 0
+ .section .note,"",%note
+ .dc.a .foo
+
+ .section .foo,"a"
+ .dc.a 0
+ .section .bar,"ao",%progbits,.foo
+ .dc.a 0
+ .section .zed,"ao",%progbits,.foo
+ .dc.a 0
diff --git a/ld/testsuite/ld-elf/pr25021.d b/ld/testsuite/ld-elf/pr25021.d
new file mode 100644
index 0000000..1cb6a87
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25021.d
@@ -0,0 +1,7 @@
+#ld: --gc-sections -e _start
+#target: [check_gc_sections_available]
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] \.stack_sizes +PROGBITS +0+ +[0-9a-f]+ 0+1 +00 +L +[0-9] .*
+#pass
diff --git a/ld/testsuite/ld-elf/pr25021.s b/ld/testsuite/ld-elf/pr25021.s
new file mode 100644
index 0000000..dd71202
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25021.s
@@ -0,0 +1,22 @@
+ .section .text.live,"ax",%progbits
+ .globl live
+live:
+ .byte 0
+
+ .section .stack_sizes,"o",%progbits,.text.live,unique,0
+ .byte 1
+
+ .section .text.dead,"ax",%progbits
+ .globl dead
+dead:
+ .byte 1
+
+ .section .stack_sizes,"o",%progbits,.text.dead,unique,1
+ .byte 2
+
+ .section .text.main,"ax",%progbits
+ .globl _start
+_start:
+ .byte 0
+ .section .note,"",%note
+ .dc.a live
diff --git a/ld/testsuite/ld-elf/pr25490-2-16.rd b/ld/testsuite/ld-elf/pr25490-2-16.rd
new file mode 100644
index 0000000..2e521cf
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-2-16.rd
@@ -0,0 +1,7 @@
+#source: pr25490-2.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+2 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-2-32.rd b/ld/testsuite/ld-elf/pr25490-2-32.rd
new file mode 100644
index 0000000..8b13348
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-2-32.rd
@@ -0,0 +1,7 @@
+#source: pr25490-2.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+4 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-2-64.rd b/ld/testsuite/ld-elf/pr25490-2-64.rd
new file mode 100644
index 0000000..6533042
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-2-64.rd
@@ -0,0 +1,7 @@
+#source: pr25490-2.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+8 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-2.s b/ld/testsuite/ld-elf/pr25490-2.s
new file mode 100644
index 0000000..856bb5f
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-2.s
@@ -0,0 +1,9 @@
+ .text
+ .globl _start
+ .type _start, %function
+_start:
+ .section __patchable_function_entries,"awo",%progbits,_start
+ .dc.a .LPFE1
+ .text
+.LPFE1:
+ .byte 0
diff --git a/ld/testsuite/ld-elf/pr25490-3-16.rd b/ld/testsuite/ld-elf/pr25490-3-16.rd
new file mode 100644
index 0000000..1c2f3d1
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-3-16.rd
@@ -0,0 +1,7 @@
+#source: pr25490-3.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+2 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-3-32.rd b/ld/testsuite/ld-elf/pr25490-3-32.rd
new file mode 100644
index 0000000..eb5587f
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-3-32.rd
@@ -0,0 +1,7 @@
+#source: pr25490-3.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+4 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-3-64.rd b/ld/testsuite/ld-elf/pr25490-3-64.rd
new file mode 100644
index 0000000..9fe794b
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-3-64.rd
@@ -0,0 +1,7 @@
+#source: pr25490-3.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+8 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-3.s b/ld/testsuite/ld-elf/pr25490-3.s
new file mode 100644
index 0000000..427ad69
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-3.s
@@ -0,0 +1,18 @@
+ .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
diff --git a/ld/testsuite/ld-elf/pr25490-4-16.rd b/ld/testsuite/ld-elf/pr25490-4-16.rd
new file mode 100644
index 0000000..1f89d50
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-4-16.rd
@@ -0,0 +1,7 @@
+#source: pr25490-4.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+4 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-4-32.rd b/ld/testsuite/ld-elf/pr25490-4-32.rd
new file mode 100644
index 0000000..4562a6e
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-4-32.rd
@@ -0,0 +1,7 @@
+#source: pr25490-4.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+8 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-4-64.rd b/ld/testsuite/ld-elf/pr25490-4-64.rd
new file mode 100644
index 0000000..da295f3
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-4-64.rd
@@ -0,0 +1,7 @@
+#source: pr25490-4.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+10 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-4.s b/ld/testsuite/ld-elf/pr25490-4.s
new file mode 100644
index 0000000..5a31f8e
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-4.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 .note,"",%note
+ .dc.a bar
diff --git a/ld/testsuite/ld-elf/pr25490-5-16.rd b/ld/testsuite/ld-elf/pr25490-5-16.rd
new file mode 100644
index 0000000..b51eb53
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-5-16.rd
@@ -0,0 +1,7 @@
+#source: pr25490-5.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+4 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-5-32.rd b/ld/testsuite/ld-elf/pr25490-5-32.rd
new file mode 100644
index 0000000..8d6efb7
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-5-32.rd
@@ -0,0 +1,7 @@
+#source: pr25490-5.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+8 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-5-64.rd b/ld/testsuite/ld-elf/pr25490-5-64.rd
new file mode 100644
index 0000000..1375f9a
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-5-64.rd
@@ -0,0 +1,7 @@
+#source: pr25490-5.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+10 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-5.s b/ld/testsuite/ld-elf/pr25490-5.s
new file mode 100644
index 0000000..f9d46b8
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-5.s
@@ -0,0 +1,17 @@
+ .text
+ .type bar, %function
+bar:
+ .section __patchable_function_entries,"awo",%progbits,bar
+ .dc.a .LPFE1
+ .text
+.LPFE1:
+ .byte 0
+ .text
+ .globl _start
+ .type _start, %function
+_start:
+ .section __patchable_function_entries,"awo",%progbits,_start
+ .dc.a .LPFE2
+ .text
+.LPFE2:
+ .byte 0
diff --git a/ld/testsuite/ld-elf/pr25490-6-16.rd b/ld/testsuite/ld-elf/pr25490-6-16.rd
new file mode 100644
index 0000000..80eda13
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-6-16.rd
@@ -0,0 +1,7 @@
+#source: pr25490-6.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+6 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-6-32.rd b/ld/testsuite/ld-elf/pr25490-6-32.rd
new file mode 100644
index 0000000..3792842
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-6-32.rd
@@ -0,0 +1,7 @@
+#source: pr25490-6.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+c +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-6-64.rd b/ld/testsuite/ld-elf/pr25490-6-64.rd
new file mode 100644
index 0000000..a95ca48
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-6-64.rd
@@ -0,0 +1,7 @@
+#source: pr25490-6.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+18 +00 +WAL +[0-9] +0 +[1248]
+#pass
diff --git a/ld/testsuite/ld-elf/pr25490-6.s b/ld/testsuite/ld-elf/pr25490-6.s
new file mode 100644
index 0000000..43fbc17
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25490-6.s
@@ -0,0 +1,30 @@
+ .section .text,"axG",%progbits,bar,comdat
+ .globl bar
+ .type bar, %function
+bar:
+ .section __patchable_function_entries,"awo",%progbits,bar
+ .dc.a .LPFE1
+ .section .text,"axG",%progbits,bar,comdat
+.LPFE1:
+ .byte 0
+ .section .text,"axG",%progbits,foo,comdat
+ .globl foo
+ .type foo, %function
+foo:
+ .section __patchable_function_entries,"awo",%progbits,foo,unique,0
+ .dc.a .LPFE2
+ .section .text,"axG",%progbits,foo,comdat
+.LPFE2:
+ .byte 0
+ .section .text,"axG",%progbits,_start,comdat,unique,1
+ .globl _start
+ .type _start, %function
+_start:
+ .section __patchable_function_entries,"awoG",%progbits,_start,_start,comdat,unique,3
+ .dc.a .LPFE3
+ .section .text,"axG",%progbits,_start,comdat,unique,1
+.LPFE3:
+ .byte 0
+ .section .note,"",%note
+ .dc.a foo
+ .dc.a bar