diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-02-06 18:04:58 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-02-06 18:05:10 -0800 |
commit | b7d072167715829eed0622616f6ae0182900de3e (patch) | |
tree | 5015f461be45da594a9a8b5e80356e083033224e /gas/testsuite | |
parent | 3c83b08abfff01d45ce78cabd29e83923b270c3b (diff) | |
download | gdb-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 'gas/testsuite')
-rw-r--r-- | gas/testsuite/gas/elf/elf.exp | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/section18.d | 8 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/section18.s | 13 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/section19.d | 8 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/section19.s | 13 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/section20.d | 17 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/section20.s | 13 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/section21.d | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/section21.l | 5 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/section21.s | 15 |
10 files changed, 98 insertions, 0 deletions
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp index 08c6830..0f9b267 100644 --- a/gas/testsuite/gas/elf/elf.exp +++ b/gas/testsuite/gas/elf/elf.exp @@ -249,6 +249,10 @@ if { [is_elf_format] } then { run_dump_test "section16a" run_dump_test "section16b" run_dump_test "section17" + run_dump_test "section18" + run_dump_test "section19" + run_dump_test "section20" + run_dump_test "section21" run_dump_test "dwarf2-1" $dump_opts run_dump_test "dwarf2-2" $dump_opts run_dump_test "dwarf2-3" $dump_opts diff --git a/gas/testsuite/gas/elf/section18.d b/gas/testsuite/gas/elf/section18.d new file mode 100644 index 0000000..f4f2930 --- /dev/null +++ b/gas/testsuite/gas/elf/section18.d @@ -0,0 +1,8 @@ +#readelf: -SW +#name: linked-to section 1 + +#... + +\[ *[0-9]+\] +__patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+[248] +00 +WAL +.* +#... + +\[ *[0-9]+\] +__patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+[248] +00 +WAL +.* +#pass diff --git a/gas/testsuite/gas/elf/section18.s b/gas/testsuite/gas/elf/section18.s new file mode 100644 index 0000000..d51eb68 --- /dev/null +++ b/gas/testsuite/gas/elf/section18.s @@ -0,0 +1,13 @@ + .text +foo: + .section __patchable_function_entries,"awo",%progbits,foo + .dc.a .LPFE1 + .text +.LPFE1: + .byte 0 + .section __patchable_function_entries,"awo",%progbits,bar + .dc.a .LPFE2 + .text +bar: +.LPFE2: + .byte 0 diff --git a/gas/testsuite/gas/elf/section19.d b/gas/testsuite/gas/elf/section19.d new file mode 100644 index 0000000..edf2b94 --- /dev/null +++ b/gas/testsuite/gas/elf/section19.d @@ -0,0 +1,8 @@ +#readelf: -SW +#name: linked-to section 2 + +#... + +\[ *[0-9]+\] +__patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+[248] +00 +WAL +.* +#... + +\[ *[0-9]+\] +__patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+[248] +00 +WAL +.* +#pass diff --git a/gas/testsuite/gas/elf/section19.s b/gas/testsuite/gas/elf/section19.s new file mode 100644 index 0000000..7d30ea1 --- /dev/null +++ b/gas/testsuite/gas/elf/section19.s @@ -0,0 +1,13 @@ + .section .text,"ax",%progbits,unique,20 +foo: + .section __patchable_function_entries,"awo",%progbits,foo,unique,2 + .dc.a .LPFE1 + .section .text,"ax",%progbits,unique,20 +.LPFE1: + .byte 0 + .section __patchable_function_entries,"awo",%progbits,bar,unique,102 + .dc.a .LPFE2 + .section .text,"ax",%progbits,unique,2 +bar: +.LPFE2: + .byte 0 diff --git a/gas/testsuite/gas/elf/section20.d b/gas/testsuite/gas/elf/section20.d new file mode 100644 index 0000000..cd7ab5e --- /dev/null +++ b/gas/testsuite/gas/elf/section20.d @@ -0,0 +1,17 @@ +#readelf: -SWg +#name: linked-to section 3 + +#... + +\[ *[0-9]+\] +__patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+[248] +00 +WALG +.* +#... + +\[ *[0-9]+\] +__patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+[248] +00 +WALG +.* +#... +COMDAT group section \[[ 0-9]+\] `.group' \[foo\] contains [0-9]+ sections: + \[Index\] Name +#... + \[[ 0-9]+\] __patchable_function_entries +#... +COMDAT group section \[[ 0-9]+\] `.group' \[bar\] contains [0-9]+ sections: +#... + \[[ 0-9]+\] __patchable_function_entries +#pass diff --git a/gas/testsuite/gas/elf/section20.s b/gas/testsuite/gas/elf/section20.s new file mode 100644 index 0000000..1e9639e --- /dev/null +++ b/gas/testsuite/gas/elf/section20.s @@ -0,0 +1,13 @@ + .section .text,"axG",%progbits,foo,comdat +foo: + .section __patchable_function_entries,"awoG",%progbits,foo,foo,comdat + .dc.a .LPFE1 + .section .text,"axG",%progbits,foo,comdat +.LPFE1: + .byte 0 + .section __patchable_function_entries,"awoG",%progbits,bar,bar,comdat,unique,4 + .dc.a .LPFE2 + .section .text,"axG",%progbits,bar,comdat,unique,24 +bar: +.LPFE2: + .byte 0 diff --git a/gas/testsuite/gas/elf/section21.d b/gas/testsuite/gas/elf/section21.d new file mode 100644 index 0000000..54fa9d4 --- /dev/null +++ b/gas/testsuite/gas/elf/section21.d @@ -0,0 +1,2 @@ +#name: incorrect linked-to symbols +#error_output: section21.l diff --git a/gas/testsuite/gas/elf/section21.l b/gas/testsuite/gas/elf/section21.l new file mode 100644 index 0000000..50342ec --- /dev/null +++ b/gas/testsuite/gas/elf/section21.l @@ -0,0 +1,5 @@ +[^:]*: Assembler messages: +[^:]*:11: Error: junk at end of line, first unrecognized character is `1' +#... +[^:]*: Error: undefined linked-to symbol `bar' on section `__patchable_function_entries' +[^:]*: Error: undefined linked-to symbol `foo' on section `__patchable_function_entries' diff --git a/gas/testsuite/gas/elf/section21.s b/gas/testsuite/gas/elf/section21.s new file mode 100644 index 0000000..ae5f848 --- /dev/null +++ b/gas/testsuite/gas/elf/section21.s @@ -0,0 +1,15 @@ + .section __patchable_function_entries,"awo",%progbits,bar + .dc.a .LPFE1 + .text +.LPFE1: + .byte 0 + .section __patchable_function_entries,"awo",%progbits,foo + .dc.a .LPFE2 + .text +.LPFE2: + .dc.a foo + .section __patchable_function_entries,"awo",%progbits,1foo + .dc.a .LPFE3 + .text +.LPFE3: + .byte 0 |