[PATCH] ELF: Support the section flag 'o' in .section directive

H.J. Lu hjl.tools@gmail.com
Thu Feb 6 19:23:00 GMT 2020


On Wed, Feb 5, 2020 at 11:46 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Mon, Feb 03, 2020 at 06:37:17AM -0800, H.J. Lu wrote:
> > bfd/
> >
> >       PR gas/25381
> >       * bfd-in2.h: Regenerated.
> >       * elf32-arm.c (elf32_arm_gc_mark_extra_sections): Call
> >       _bfd_elf_gc_mark_extra_sections last.
> >       * elf32-csky.c (_bfd_elf_gc_mark_extra_sections): Likewise.
> >       * elf32-tic6x.c (elf32_tic6x_gc_mark_extra_sections): Likewise.
> >       * elfxx-mips.c (_bfd_mips_elf_gc_mark_extra_sections): Likewise.
> >       * elflink.c (_bfd_elf_gc_mark_extra_sections): Set gc_mark only
> >       if gc_mark of any of its linked-to section 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-32.rd: Likewise.
> >       * testsuite/ld-elf/pr25490-2-64.rd: Likewise.
> >       * testsuite/ld-elf/pr25490-2.s: 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-32.rd: Likewise.
> >       * testsuite/ld-elf/pr25490-4-64.rd: Likewise.
> >       * testsuite/ld-elf/pr25490-4.s: 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-32.rd: Likewise.
> >       * testsuite/ld-elf/pr25490-6-64.rd: Likewise.
> >       * testsuite/ld-elf/pr25490-6.s: Likewise.
>
> I see rather a lot of fails for the new testcases.  Some changes to
> the testcases clearly are needed before this can go in.  A quick
> glance shows two major problems:
> 1) You don't want to run a testcase requiring --gc-sections on a
>    target that doesn't support --gc-sections.

Fixed.

> 2) You assume .dc.a sizes are only 4 or 8 but we have a number of
>    targets that have 16-bit addresses.

Fixed.

> Also, for sh-linux, I see this in pr25490-2.o
>   [ 4] __patchable_function_entries PROGBITS        00000000 000038 000004 00 WAL  1   0  4

4 is sh_addralign.  sh_link is 1.

> Linking to itself?  Please do look into all these fails.
>
> avr-elf  +FAIL: linked-to section 1
> avr-elf  +FAIL: linked-to section 2
> avr-elf  +FAIL: linked-to section 3
> avr-elf  +FAIL: __patchable_function_entries section 2
> avr-elf  +FAIL: __patchable_function_entries section 3
> avr-elf  +FAIL: __patchable_function_entries section 4
> avr-elf  +FAIL: __patchable_function_entries section 5
> avr-elf  +FAIL: __patchable_function_entries section 6
> bfin-linux-uclibc  +FAIL: ld-elf/pr24526
> bfin-linux-uclibc  +FAIL: ld-elf/pr25021
> bfin-linux-uclibc  +FAIL: __patchable_function_entries section 4
> bfin-linux-uclibc  +FAIL: __patchable_function_entries section 6
> d30v-elf  +FAIL: ld-elf/pr24526
> d30v-elf  +FAIL: ld-elf/pr25021
> dlx-elf  +FAIL: ld-elf/pr24526
> dlx-elf  +FAIL: ld-elf/pr25021
> frv-linux  +FAIL: ld-elf/pr24526
> frv-linux  +FAIL: ld-elf/pr25021
> frv-linux  +FAIL: __patchable_function_entries section 4
> frv-linux  +FAIL: __patchable_function_entries section 6
> h8300-elf  +FAIL: linked-to section 1
> h8300-elf  +FAIL: linked-to section 2
> h8300-elf  +FAIL: linked-to section 3
> h8300-elf  +FAIL: __patchable_function_entries section 2
> h8300-elf  +FAIL: __patchable_function_entries section 3
> h8300-elf  +FAIL: __patchable_function_entries section 4
> h8300-elf  +FAIL: __patchable_function_entries section 5
> h8300-elf  +FAIL: __patchable_function_entries section 6
> h8300-linux  +FAIL: linked-to section 1
> h8300-linux  +FAIL: linked-to section 2
> h8300-linux  +FAIL: linked-to section 3
> h8300-linux  +FAIL: __patchable_function_entries section 2
> h8300-linux  +FAIL: __patchable_function_entries section 3
> h8300-linux  +FAIL: __patchable_function_entries section 4
> h8300-linux  +FAIL: __patchable_function_entries section 5
> h8300-linux  +FAIL: __patchable_function_entries section 6
> hppa64-hp-hpux11.23  +FAIL: ld-elf/pr24526
> hppa64-hp-hpux11.23  +FAIL: ld-elf/pr25021
> hppa64-linux  +FAIL: ld-elf/pr24526
> hppa64-linux  +FAIL: ld-elf/pr25021
> ip2k-elf  +FAIL: linked-to section 1
> ip2k-elf  +FAIL: linked-to section 2
> ip2k-elf  +FAIL: linked-to section 3
> ip2k-elf  +FAIL: __patchable_function_entries section 2
> ip2k-elf  +FAIL: __patchable_function_entries section 3
> ip2k-elf  +FAIL: __patchable_function_entries section 4
> ip2k-elf  +FAIL: __patchable_function_entries section 5
> ip2k-elf  +FAIL: __patchable_function_entries section 6
> lm32-linux  +FAIL: ld-elf/pr24526
> lm32-linux  +FAIL: ld-elf/pr25021
> lm32-linux  +FAIL: __patchable_function_entries section 4
> lm32-linux  +FAIL: __patchable_function_entries section 6
> m68hc11-elf  +FAIL: linked-to section 1
> m68hc11-elf  +FAIL: linked-to section 2
> m68hc11-elf  +FAIL: linked-to section 3
> m68hc11-elf  +FAIL: __patchable_function_entries section 2
> m68hc11-elf  +FAIL: __patchable_function_entries section 3
> m68hc11-elf  +FAIL: __patchable_function_entries section 4
> m68hc11-elf  +FAIL: __patchable_function_entries section 5
> m68hc11-elf  +FAIL: __patchable_function_entries section 6
> mep-elf  +FAIL: ld-elf/pr24526
> mep-elf  +FAIL: ld-elf/pr25021
> mips64el-openbsd  +FAIL: --gc-sections with relocations in debug section
> mips64-openbsd  +FAIL: --gc-sections with relocations in debug section
> mipstx39-elf  +FAIL: Build pr22649-2a.so
> mipstx39-elf  +FAIL: Build pr22649-2b.so
> mn10200-elf  +FAIL: ld-elf/pr24526
> mn10200-elf  +FAIL: ld-elf/pr25021
> nios2-linux  +FAIL: __patchable_function_entries section 2
> nios2-linux  +FAIL: __patchable_function_entries section 3
> nios2-linux  +FAIL: __patchable_function_entries section 4
> nios2-linux  +FAIL: __patchable_function_entries section 5
> nios2-linux  +FAIL: __patchable_function_entries section 6
> pj-elf  +FAIL: ld-elf/pr24526
> pj-elf  +FAIL: ld-elf/pr25021
> pru-elf  +FAIL: ld-elf/pr24526
> pru-elf  +FAIL: ld-elf/pr25021
> s12z-elf  +FAIL: ld-elf/pr24526
> s12z-elf  +FAIL: ld-elf/pr25021
> shle-unknown-netbsdelf  +FAIL: incorrect linked-to symbols
> shle-unknown-netbsdelf  +FAIL: __patchable_function_entries section 2
> shle-unknown-netbsdelf  +FAIL: __patchable_function_entries section 3
> shle-unknown-netbsdelf  +FAIL: __patchable_function_entries section 4
> shle-unknown-netbsdelf  +FAIL: __patchable_function_entries section 5
> shle-unknown-netbsdelf  +FAIL: __patchable_function_entries section 6
> sh-linux  +FAIL: incorrect linked-to symbols
> sh-linux  +FAIL: __patchable_function_entries section 2
> sh-linux  +FAIL: __patchable_function_entries section 3
> sh-linux  +FAIL: __patchable_function_entries section 4
> sh-linux  +FAIL: __patchable_function_entries section 5
> sh-linux  +FAIL: __patchable_function_entries section 6
> sh-nto  +FAIL: incorrect linked-to symbols
> sh-nto  +FAIL: __patchable_function_entries section 2
> sh-nto  +FAIL: __patchable_function_entries section 3
> sh-nto  +FAIL: __patchable_function_entries section 4
> sh-nto  +FAIL: __patchable_function_entries section 5
> sh-nto  +FAIL: __patchable_function_entries section 6
> sh-rtems  +FAIL: incorrect linked-to symbols
> sh-rtems  +FAIL: __patchable_function_entries section 2
> sh-rtems  +FAIL: __patchable_function_entries section 3
> sh-rtems  +FAIL: __patchable_function_entries section 4
> sh-rtems  +FAIL: __patchable_function_entries section 5
> sh-rtems  +FAIL: __patchable_function_entries section 6
> xc16x-elf  +FAIL: linked-to section 1
> xc16x-elf  +FAIL: linked-to section 2
> xc16x-elf  +FAIL: linked-to section 3
> xc16x-elf  +FAIL: __patchable_function_entries section 2
> xc16x-elf  +FAIL: __patchable_function_entries section 3
> xc16x-elf  +FAIL: __patchable_function_entries section 4
> xc16x-elf  +FAIL: __patchable_function_entries section 5
> xc16x-elf  +FAIL: __patchable_function_entries section 6
> xgate-elf  +FAIL: ld-elf/pr24526
> xgate-elf  +FAIL: ld-elf/pr25021
> z80-elf  +FAIL: linked-to section 1
> z80-elf  +FAIL: linked-to section 2
> z80-elf  +FAIL: linked-to section 3
> z80-elf  +FAIL: ld-elf/pr24526
> z80-elf  +FAIL: ld-elf/pr25021
> z80-elf  +FAIL: __patchable_function_entries section 2
> z80-elf  +FAIL: __patchable_function_entries section 3
> z80-elf  +FAIL: __patchable_function_entries section 4
> z80-elf  +FAIL: __patchable_function_entries section 5
> z80-elf  +FAIL: __patchable_function_entries section 6
>

All fixed.   Here is the updated patch.  The only bfd changes are

* 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.

I changed  _bfd_elf_gc_mark_extra_sections to call mark_hook
instead of setting gc_mark directly.

OK for master?

Thanks.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ELF-Support-the-section-flag-o-in-.section-directive.patch
Type: text/x-patch
Size: 36030 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20200206/d4e95a77/attachment.bin>


More information about the Binutils mailing list