Bug 19244 - Gold makes stdout local with version script
Summary: Gold makes stdout local with version script
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.27
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-13 20:59 UTC by Ferdinand
Modified: 2015-12-10 13:50 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ferdinand 2015-11-13 20:59:49 UTC
Building mplayer with current gold, it segfaults on start.
The reason was this version script:

= = = = = = = = =

MPLAYER_1 {
  # to support glibcs abhorrent backwards-compatibility hack
  global: _IO_stdin_used;
  local: *;
};

= = = = = = = = =

Which resulted in this:

$ readelf --syms --use-dynamic mplayer

Symbol table of `.gnu.hash' for image:
  Num Buc:    Value          Size   Type   Bind Vis      Ndx Name
  631   1: 0000000000000000     0 OBJECT  GLOBAL DEFAULT ABS MPLAYER_1



Now ld.bfd doesn't do this, and it's a regression, which I narrowed down
to the fix for PR gold/18548 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=5417c94d1a944d1a27f99240e5d62a6d7cd324f1
Because this is the result after reverting that patch:


$ readelf --syms --use-dynamic mplayer

Symbol table of `.gnu.hash' for image:
  Num Buc:    Value          Size   Type   Bind Vis      Ndx Name
  628   0: 00000000015ac8c0     8 OBJECT  GLOBAL DEFAULT  29 stdout
  629   0: 00000000015ac998     0 NOTYPE  GLOBAL DEFAULT ABS _end
  630   0: 0000000000fc7450     0 NOTYPE  GLOBAL DEFAULT ABS _edata
  631   0: 0000000000000000     0 OBJECT  GLOBAL DEFAULT ABS MPLAYER_1
  632   1: 00000000015ac8e0     8 OBJECT  GLOBAL DEFAULT  29 stderr
  633   1: 00000000015ac900   152 OBJECT  GLOBAL DEFAULT  29 vpx_codec_vp8_dx_algo
  634   1: 0000000000fc7450     0 NOTYPE  GLOBAL DEFAULT ABS __bss_start



And here is the result of ld.bfd, the result that the patch presumably meant to generate:

$ readelf --syms --use-dynamic mplayer

Symbol table of `.gnu.hash' for image:
  Num Buc:    Value          Size   Type   Bind Vis      Ndx Name
  629   0: 00000000011c34a0     8 OBJECT  GLOBAL DEFAULT  28 stdout
  630   0: 0000000000000000     0 OBJECT  GLOBAL DEFAULT ABS MPLAYER_1
  631   1: 00000000011c34c0   152 OBJECT  GLOBAL DEFAULT  28 vpx_codec_vp8_dx_algo
  632   1: 00000000011c3560     8 OBJECT  GLOBAL DEFAULT  28 stderr


Workaround with gold is to add stdout and stderr to global in the version script.
Comment 1 cvs-commit@gcc.gnu.org 2015-11-14 19:04:48 UTC
The master branch has been updated by Cary Coutant <ccoutant@sourceware.org>:

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

commit db1ff0288b923bc17d2408a6172a016b7ba0a6a4
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Sat Nov 14 11:04:01 2015 -0800

    Fix problem where bss symbols for copy relocations are marked local.
    
    gold/
    	PR gold/19244
    	PR gold/18548
    	* symtab.cc (Symbol_table::do_define_in_output_data): Check for forced
    	local symbols only for predefined symbols.
Comment 2 Cary Coutant 2015-11-14 19:14:49 UTC
Fixed on trunk. We should not have been marking symbols added to support COPY relocations as local.
Comment 3 cvs-commit@gcc.gnu.org 2015-12-10 13:50:33 UTC
The binutils-2_26-branch branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit 3d3ef1fccd86e7b18609a30187027d271c7fc8a5
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Sat Nov 14 11:04:01 2015 -0800

    Fix problem where bss symbols for copy relocations are marked local.
    
    gold/
    	PR gold/19244
    	PR gold/18548
    	* symtab.cc (Symbol_table::do_define_in_output_data): Check for forced
    	local symbols only for predefined symbols.