[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/20022] --gc-sections is broken with __start_ and shared library

From: cvs-commit at gcc dot gnu.org
Subject: [Bug ld/20022] --gc-sections is broken with __start_ and shared library
Date: Tue, 13 Jun 2017 15:55:12 +0000


--- Comment #11 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot 
gnu.org> ---
The master branch has been updated by H.J. Lu <address@hidden>:


commit cbd0eecf261c2447781f8c89b0d955ee66fae7e9
Author: H.J. Lu <address@hidden>
Date:   Tue Jun 13 08:53:22 2017 -0700

    Always define referenced __start_SECNAME/__stop_SECNAME

    Currently, linker will define __start_SECNAME and __stop_SECNAME symbols
    only for orphaned sections.

    However, during garbage collection, ELF linker marks all sections with
    references to __start_SECNAME and __stop_SECNAME symbols as used even
    when section SECNAME isn't an orphaned section and linker won't define
    __start_SECNAME nor __stop_SECNAME.  And ELF linker stores the first
    input section whose name matches __start_SECNAME or __stop_SECNAME in
    u.undef.section for garbage collection.  If these symbols are provided
    in linker script, u.undef.section is set to the section where they will
    defined by linker script, which leads to the incorrect output.

    This patch changes linker to always define referenced __start_SECNAME and
    __stop_SECNAME if the input section name is the same as the output section
    name, which is always true for orphaned sections, and SECNAME is a C
    identifier.  Also __start_SECNAME and __stop_SECNAME symbols are marked
    as hidden by ELF linker so that __start_SECNAME and __stop_SECNAME symbols
    for section SECNAME in different modules are unique.  For garbage
    collection, ELF linker stores the first matched input section in the
    unused vtable field.


        PR ld/20022
        PR ld/21557
        PR ld/21562
        PR ld/21571
        * elf-bfd.h (elf_link_hash_entry): Add start_stop.  Change the
        vtable field to a union.
        (_bfd_elf_is_start_stop): Removed.
        * elf32-i386.c (elf_i386_convert_load_reloc): Also check for
        __start_SECNAME and __stop_SECNAME symbols.
        * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Likewise.
        * elflink.c (_bfd_elf_is_start_stop): Removed.
        (_bfd_elf_gc_mark_rsec): Check start_stop instead of calling
        (elf_gc_propagate_vtable_entries_used): Skip __start_SECNAME and
        __stop_SECNAME symbols.  Updated.
        (elf_gc_smash_unused_vtentry_relocs): Likewise.
        (bfd_elf_gc_record_vtinherit): Likewise.
        (bfd_elf_gc_record_vtentry): Likewise.


        PR ld/20022
        PR ld/21557
        PR ld/21562
        PR ld/21571
        * ld.texinfo: Update __start_SECNAME/__stop_SECNAME symbols.
        * ldlang.c (lang_insert_orphan): Move handling of __start_SECNAME
        and __stop_SECNAME symbols to ...
        (lang_set_startof): Here.  Also define __start_SECNAME and
        __stop_SECNAME for -Ur.
        * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Mark
        referenced __start_SECNAME and __stop_SECNAME symbols as hidden
        and set start_stop for garbage collection.
        * testsuite/ld-elf/pr21562a.d: New file.
        * testsuite/ld-elf/pr21562a.s: Likewise.
        * testsuite/ld-elf/pr21562a.t: Likewise.
        * testsuite/ld-elf/pr21562b.d: Likewise.
        * testsuite/ld-elf/pr21562b.s: Likewise.
        * testsuite/ld-elf/pr21562b.t: Likewise.
        * testsuite/ld-elf/pr21562c.d: Likewise.
        * testsuite/ld-elf/pr21562c.t: Likewise.
        * testsuite/ld-elf/pr21562d.d: Likewise.
        * testsuite/ld-elf/pr21562d.t: Likewise.
        * testsuite/ld-elf/pr21562e.d: Likewise.
        * testsuite/ld-elf/pr21562f.d: Likewise.
        * testsuite/ld-elf/pr21562g.d: Likewise.
        * testsuite/ld-elf/pr21562h.d: Likewise.
        * testsuite/ld-elf/pr21562i.d: Likewise.
        * testsuite/ld-elf/pr21562j.d: Likewise.
        * testsuite/ld-elf/pr21562k.d: Likewise.
        * testsuite/ld-elf/pr21562l.d: Likewise.
        * testsuite/ld-elf/pr21562m.d: Likewise.
        * testsuite/ld-elf/pr21562n.d: Likewise.
        * testsuite/ld-gc/pr20022.d: Likewise.
        * testsuite/ld-gc/pr20022a.s: Likewise.
        * testsuite/ld-gc/pr20022b.s: Likewise.
        * testsuite/ld-gc/gc.exp: Run PR ld/20022 tests.
        * testsuite/ld-gc/pr19161.d: Also accept local __start_SECNAME
        * testsuite/ld-gc/start.d: Likewise.
        * testsuite/ld-x86-64/lea1a.d: Updated.
        * testsuite/ld-x86-64/lea1b.d: Updated.
        * testsuite/ld-x86-64/lea1d.d: Updated.
        * testsuite/ld-x86-64/lea1e.d: Likewise.

You are receiving this mail because:
You are on the CC list for the bug.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]