bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/20828] [MIPS] produces invalid dynamic symbol table when --gc-se


From: james410 at cowgill dot org.uk
Subject: [Bug ld/20828] [MIPS] produces invalid dynamic symbol table when --gc-sections is used since PR ld/13177 fix
Date: Fri, 25 Nov 2016 17:31:45 +0000

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

--- Comment #10 from James Cowgill <james410 at cowgill dot org.uk> ---
(In reply to Maciej W. Rozycki from comment #8)
> By the MIPS psABI's definition you shall not have external GGA_NONE
> symbols as any GGA_NONE symbols will be assigned to the local GOT part,
> whose entries are only relocated by the base address at the load time.
> Symbols in the GGA_NONE class will normally not have dynsym entries,
> except from selected section symbols.

The psABI says:
The dynamic symbol table, like all ELF symbol tables, is divided into local and
global parts. The global part of the dynamic symbol table is further divided
into two parts: symbols that do not have GOT entries associated with them and
symbols that do have GOT entries associated with them.

Surly this implies that it is legitimate for an external symbol to be GGA_NONE?
The case illustrated here where a symbol is defined but not used within a
shared library seems like a good use case for this.

Since LOCAL symbols must be GGA_NONE, the local symbol handler in my patch
could probably be simplified a little.

[...]
> I agree the presence of (non-section) local symbols in the dynsym table
> is a generic issue, and given that `elf_gc_sweep_symbol' appears to be
> the only place where they are created I think that rather than
> adjusting this piece of code to assign these symbols to the GGA_NONE
> class it will make sense to discard them altogether.  Unless there is
> an actual need for them, that is, which I yet need to be told about.
> FAOD it is not incorrect to have them -- it is just useless.

It breaks the ld-elf/provide-hidden testcase, but that can be adjusted to not
look for local dynamic symbols. This patch implements what you suggest
(dropping symbols defined in the linker script dynamic symbol table if they are
definitely local) and on its own fixes this bug as well.

--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -669,7 +669,8 @@ bfd_elf_record_link_assignment (bfd *output_bfd,
        || h->ref_dynamic
        || bfd_link_dll (info)
        || elf_hash_table (info)->is_relocatable_executable)
-      && h->dynindx == -1)
+      && h->dynindx == -1
+      && h->forced_local == 0)
     {
       if (! bfd_elf_link_record_dynamic_symbol (info, h))
        return FALSE;

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