bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/19908] MIPS/ELF: Hidden and internal dynamic symbols produced


From: cvs-commit at gcc dot gnu.org
Subject: [Bug ld/19908] MIPS/ELF: Hidden and internal dynamic symbols produced
Date: Tue, 05 Apr 2016 14:19:20 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=19908

--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot 
gnu.org> ---
The master branch has been updated by Maciej W. Rozycki <address@hidden>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1f599d0e7b5039c814731293043e247304ec006b

commit 1f599d0e7b5039c814731293043e247304ec006b
Author: Maciej W. Rozycki <address@hidden>
Date:   Tue Apr 5 15:10:05 2016 +0100

    ELF/LD: Avoid producing hidden and internal dynamic symbols

    Always turn hidden and internal symbols which have a dynamic index into
    local ones.  This is required by the the ELF gABI[1]:

    "A hidden symbol contained in a relocatable object must be either
    removed or converted to STB_LOCAL binding by the link-editor when the
    relocatable object is included in an executable file or shared object."

    "An internal symbol contained in a relocatable object must be either
    removed or converted to STB_LOCAL binding by the link-editor when the
    relocatable object is included in an executable file or shared object."

    The ELF linker usually respects this requirement, however in the case
    where a dynamic symbol has been preallocated due to a reference of the
    default export class aka visibility from the object being linked, and
    then merged with a hidden or internal symbol definition from within the
    same object, then the original export class is carried over to the
    output dynamic symbol table, because while merging the generic ELF
    linker only converts affected dynamic symbols to local when they are
    defined or referenced by the object being linked and a dynamic object
    involved in the link both at a time.

    The dynamic symbol produced confuses then the dynamic loader at the run
    time -- the hidden or internal export class is ignored and the symbol
    follows preemption rules as with the default export class.

    In the MIPS target it happens when `mips_elf_record_global_got_symbol'
    creates a dynamic symbol when a call relocation is encountered.
    Additionally if the undefined symbol referred by such a relocation does
    specify the intended export class, then a local dynamic symbol is
    created instead, which is harmless and allowed, but useless.  Normally
    no local dynamic symbols are created, except for a single dummy one at
    the beginning.

    Correct the problem by removing the extra check for a dynamic symbol
    being defined or referenced by the object being linked and a dynamic
    object involved in the link both at a time.  The test cases included
    cover the internal and hidden symbol cases, as well as a protected
    symbol for a reference, the handling of which is unchanged by this fix.
    Both cases described above are covered, that is where an internal or
    hidden dynamic symbol is produced and where a local one is.

    NB this change affects CRIS results where some symbols in the static
    table produced in a final link are now converted from STV_HIDDEN to
    STB_LOCAL.  This happens whenever the `elf_backend_hide_symbol' handler
    is called, so the affected symbols must have been chosen for entering
    into the dynamic symbol table, except in these test cases no such symbol
    table is produced.  In fully linked binaries the static symbol table is
    only used for debugging though, so such a change is fine.

    References:

    [1] "System V Application Binary Interface - DRAFT - 24 April 2001",
        The Santa Cruz Operation, Inc., "Symbol Table",
        <http://www.sco.com/developers/gabi/2001-04-24/ch4.symtab.html>

        bfd/
        PR ld/19908
        * elflink.c (elf_link_add_object_symbols): Always turn hidden
        and internal symbols which have a dynamic index into local
        ones.

        ld/
        PR ld/19908
        * testsuite/ld-cris/tls-e-20.d: Adjust for hidden symbol
        handling fix.
        * testsuite/ld-cris/tls-e-20a.d: Likewise.
        * testsuite/ld-cris/tls-e-21.d: Likewise.
        * testsuite/ld-cris/tls-e-23.d: Likewise.
        * testsuite/ld-cris/tls-e-80.d: Likewise.
        * testsuite/ld-cris/tls-gd-3h.d: Likewise.
        * testsuite/ld-cris/tls-leie-19.d: Likewise.
        * testsuite/ld-mips-elf/export-class-ref-lib.sd: New test.
        * testsuite/ld-mips-elf/export-hidden-ref.sd: New test.
        * testsuite/ld-mips-elf/export-internal-ref.sd: New test.
        * testsuite/ld-mips-elf/export-protected-ref.sd: New test.
        * testsuite/ld-mips-elf/export-class-ref-f0.s: New test source.
        * testsuite/ld-mips-elf/export-class-ref-f1.s: New test source.
        * testsuite/ld-mips-elf/export-class-ref-f2.s: New test source.
        * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.

-- 
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]