[PATCH 0/5][Bug ld/20828] GC-ed DSO symbols make corresponding symbols defined by a linker script local

Maciej W. Rozycki macro@imgtec.com
Mon Jan 23 11:34:00 GMT 2017


On Fri, 20 Jan 2017, Maciej W. Rozycki wrote:

> On Thu, 19 Jan 2017, Nick Clifton wrote:
> 
> > Checking Binutils in: bfin-elf ... LD REGRESSION: PR ld/20828 dynamic symbols with 
> 
>  As noted before, `_edata' is removed with `--gc-sections' and 
> `--version-script' combined, where it is supposed to be exported.  This is 
> regardless of the presence of `libpr20828.so' in the link, so it does not 
> seem related to PR ld/20828 (same with `bfin-uclinux', so this is a 
> genuine backend bug).

 This has turned out to be a version script problem with targets that set 
their `bfd_get_symbol_leading_char' to `_'.  Test cases fixed with 2/5 in 
this patch series, covering all the targets affected; see the patch 
description for details.

> > Checking Binutils in: riscv32-elf ... LD REGRESSION: PR ld/20828 dynamic symbols with 
> 
>  LD segfaults with the initial `libpr20828.so' link (same with 
> `riscv32-linux' BTW), so this is not related to PR ld/20828.  
> Consequently all the subsequent dependent tests fail.
> 
>  It may be something missing from the linker script used, which is 
> required by this port, but then LD should complain rather than crash (ISTR 
> `aarch64' and `arm' ports segfaulting too if `.got' and/or `.got.plt' 
> sections were discarded from output; this may be something worth looking 
> into and handling gracefully as well).

 Indeed it is, as `riscv' targets crash when there's no `.plt' in output.  
This can probably be trivially fixed, but I'll leave it up to the port 
maintainers.  Test case failures worked around with 3/5 in this patch 
series, covering all the targets affected.

> > Checking Binutils in: x86_64-solaris2 ... LD REGRESSION: PR ld/20828 dynamic symbols with
> 
>  There are two issues here -- one is trivial with `libpr20828.so' having 
> extra symbols between `_fdata' and `_edata':
> 
> Symbol table '.dynsym' contains 6 entries:
>    Num:    Value          Size Type    Bind   Vis      Ndx Name
>      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
>      1: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    1 _fdata
>      2: 0000000000000000     0 OBJECT  GLOBAL DEFAULT    1 _DYNAMIC
>      3: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS _PROCEDURE_LINKAGE_TABLE_
>      4: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    1 _edata
>      5: 00000000000001b8     0 OBJECT  GLOBAL DEFAULT    4 _GLOBAL_OFFSET_TABLE_
> 
> so this will be a straightforward dump pattern fix.

 Fixed with 1/5 in this patch series, which also serves as a preparation 
for 2/5; see the comment with the patch itself.

>  The other is tricky -- the sole version script used is as follows:
> 
> { global: _edata; local: *; };
> 
> and yet LD complains:
> 
> ld: anonymous version tag cannot be combined with other version tags
> 
> (so where's the non-anonymous version tag?).  I'll look into it.

 This looks like a genuine port bug to me, which is however easy to fix I 
believe.  Fix proposed with 4/5.

> > Checking Binutils in: score-elf ... LD REGRESSION: PR ld/20828 dynamic symbols with
> 
>  As noted before, `_fdata' is exported with `--gc-sections' and 
> `--version-script' combined, where it is supposed to be removed.  This 
> only happens in the presence of `libpr20828.so' in the link, so it may be 
> related to PR ld/20828.  I'll have a look into it.

 Fix proposed with 5/5 now too, although it required a redesign of the 
original change, making it more complex.  See the patch description for 
details.

 Apologies for the breakage.

  Maciej



More information about the Binutils mailing list