ELF: Support the section flag 'o' in .section directive
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 7 Feb 2020 02:04:58 +0000 (18:04 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 7 Feb 2020 02:05:10 +0000 (18:05 -0800)
commitb7d072167715829eed0622616f6ae0182900de3e
tree5015f461be45da594a9a8b5e80356e083033224e
parent3c83b08abfff01d45ce78cabd29e83923b270c3b
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.
44 files changed:
bfd/ChangeLog
bfd/bfd-in2.h
bfd/elflink.c
bfd/section.c
gas/ChangeLog
gas/config/obj-elf.c
gas/config/obj-elf.h
gas/doc/as.texi
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/elf/section18.d [new file with mode: 0644]
gas/testsuite/gas/elf/section18.s [new file with mode: 0644]
gas/testsuite/gas/elf/section19.d [new file with mode: 0644]
gas/testsuite/gas/elf/section19.s [new file with mode: 0644]
gas/testsuite/gas/elf/section20.d [new file with mode: 0644]
gas/testsuite/gas/elf/section20.s [new file with mode: 0644]
gas/testsuite/gas/elf/section21.d [new file with mode: 0644]
gas/testsuite/gas/elf/section21.l [new file with mode: 0644]
gas/testsuite/gas/elf/section21.s [new file with mode: 0644]
ld/ChangeLog
ld/testsuite/ld-elf/elf.exp
ld/testsuite/ld-elf/pr24526.d [new file with mode: 0644]
ld/testsuite/ld-elf/pr24526.s [new file with mode: 0644]
ld/testsuite/ld-elf/pr25021.d [new file with mode: 0644]
ld/testsuite/ld-elf/pr25021.s [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-2-16.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-2-32.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-2-64.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-2.s [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-3-16.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-3-32.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-3-64.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-3.s [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-4-16.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-4-32.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-4-64.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-4.s [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-5-16.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-5-32.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-5-64.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-5.s [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-6-16.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-6-32.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-6-64.rd [new file with mode: 0644]
ld/testsuite/ld-elf/pr25490-6.s [new file with mode: 0644]