<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://sourceware.org/bugzilla/bugzilla.dtd">

<bugzilla version="4.0.10"
          urlbase="http://sourceware.org/bugzilla/"
          
          maintainer="overseers@sourceware.org"
>

    <bug>
          <bug_id>13195</bug_id>
          
          <creation_ts>2011-09-16 22:16:00 +0000</creation_ts>
          <short_desc>-ffunction-sections -Wl,--gc-sections failure with symbol versioning</short_desc>
          <delta_ts>2011-10-25 03:09:40 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>binutils</product>
          <component>ld</component>
          <version>2.24 (HEAD)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://sourceware.org/ml/binutils/2011-09/msg00103.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>13233</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="H.J. Lu">hjl.tools</reporter>
          <assigned_to>unassigned</assigned_to>
          <cc>jan.kratochvil</cc>
          <cf_gcchost></cf_gcchost>
          <cf_gcctarget></cf_gcctarget>
          <cf_gccbuild></cf_gccbuild>
          

      

      

      

          <long_desc isprivate="0">
            <commentid>50659</commentid>
            <who name="H.J. Lu">hjl.tools</who>
            <bug_when>2011-09-16 22:16:17 +0000</bug_when>
            <thetext>[hjl@gnu-6 tmp]$ cat gcsec1.C
extern &quot;C&quot; void abort (void);

int g = 0;

void raise_exception()
{
  throw 1;
}

void used()
{
  try {
    raise_exception ();
  }
  catch (int) {
    g = 1;
  }
}

void unused()
{
  try {
    raise_exception ();
  }
  catch (int) {
    g = 1;
  }
}

int main()
{
  used ();

  if (g != 1)
    abort ();

  return 0;
}
[hjl@gnu-6 tmp]$ g++ gcsec1.C -ffunction-sections -Wl,--gc-sections 
/usr/local/bin/ld: a.out: local symbol `__tls_get_addr@@GLIBC_2.3&apos; in /lib64/ld-linux-x86-64.so.2 is referenced by DSO
/usr/local/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
[hjl@gnu-6 tmp]$</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>50660</commentid>
            <who name="H.J. Lu">hjl.tools</who>
            <bug_when>2011-09-16 22:58:28 +0000</bug_when>
            <thetext>A patch is posted at

http://sourceware.org/ml/binutils/2011-09/msg00100.html</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>50667</commentid>
            <who name="H.J. Lu">hjl.tools</who>
            <bug_when>2011-09-17 20:57:58 +0000</bug_when>
            <thetext>Another bug:

[hjl@gnu-6 pr13195-ver]$ cat x.s
	.section .text.new_foo,&quot;ax&quot;,%progbits
	.globl	new_foo
	.type	new_foo, %function
new_foo:
	.byte 0
	.symver new_foo,foo@@VERS_2.0
[hjl@gnu-6 pr13195-ver]$ cat x.t
VERS_2.0 {
global:
  foo;
local:
  *;
};
[hjl@gnu-6 pr13195-ver]$ make
as   -o x.o x.s
./ld -shared --gc-sections -version-script x.t -o x.so x.o
readelf -s -D x.so

Symbol table for image:
  Num Buc:    Value          Size   Type   Bind Vis      Ndx Name
    2   0: 0000000000000000     0 OBJECT  GLOBAL DEFAULT ABS VERS_2.0
[hjl@gnu-6 pr13195-ver]$</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>50668</commentid>
            <who name="H.J. Lu">hjl.tools</who>
            <bug_when>2011-09-17 22:43:02 +0000</bug_when>
            <thetext>A updated patch is posted at

http://sourceware.org/ml/binutils/2011-09/msg00103.html</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>50796</commentid>
            <who name="H.J. Lu">hjl.tools</who>
            <bug_when>2011-09-28 18:35:55 +0000</bug_when>
            <thetext>*** Bug 13232 has been marked as a duplicate of this bug. ***</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>50806</commentid>
            <who name="cvs-commit@gcc.gnu.org">cvs-commit</who>
            <bug_when>2011-09-29 00:13:18 +0000</bug_when>
            <thetext>CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2011-09-29 00:13:14

Modified files:
	bfd            : elflink.c 
	ld/testsuite/ld-elf: elf.exp 
Added files:
	ld/testsuite/ld-elf: pr13195.c pr13195.d pr13195.s pr13195.t 

Log message:
	Fix --gc-sections failure with symbol versioning.
	
	bfd/
	
	2011-09-28  H.J. Lu  &lt;hongjiu.lu@intel.com&gt;
	
	PR ld/13195
	* elflink.c (_bfd_elf_merge_symbol): Don&apos;t set dynamic_def when
	clearing def_dynamic.
	(elf_link_add_object_symbols): Likewise.  Set dynamic_def when
	setting def_dynamic.
	(bfd_elf_gc_mark_dynamic_ref_symbol): Check if a symbol is
	versioned.
	
	ld/testsuite/
	
	2011-09-28  H.J. Lu  &lt;hongjiu.lu@intel.com&gt;
	
	PR ld/13195
	* ld-elf/elf.exp: Add a C link testcase for PR ld/13195.
	
	* ld-elf/pr13195.c: New.
	* ld-elf/pr13195.d: Likewise.
	* ld-elf/pr13195.s: Likewise.
	* ld-elf/pr13195.t: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&amp;r1=1.420&amp;r2=1.421
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr13195.c.diff?cvsroot=src&amp;r1=NONE&amp;r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr13195.d.diff?cvsroot=src&amp;r1=NONE&amp;r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr13195.s.diff?cvsroot=src&amp;r1=NONE&amp;r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr13195.t.diff?cvsroot=src&amp;r1=NONE&amp;r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/elf.exp.diff?cvsroot=src&amp;r1=1.28&amp;r2=1.29</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>50807</commentid>
            <who name="H.J. Lu">hjl.tools</who>
            <bug_when>2011-09-29 00:13:45 +0000</bug_when>
            <thetext>Fixed.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>50810</commentid>
            <who name="Jan Kratochvil">jan.kratochvil</who>
            <bug_when>2011-09-29 04:43:56 +0000</bug_when>
            <thetext>Confirming it works now, thanks.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>50893</commentid>
            <who name="cvs-commit@gcc.gnu.org">cvs-commit</who>
            <bug_when>2011-10-05 16:40:05 +0000</bug_when>
            <thetext>CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_22-branch
Changes by:	hjl@sourceware.org	2011-10-05 16:39:56

Modified files:
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-elf: elf.exp 
	bfd            : ChangeLog elflink.c 
Added files:
	ld/testsuite/ld-elf: pr13195.c pr13195.d pr13195.s pr13195.t 

Log message:
	Fix --gc-sections failure with symbol versioning.
	
	bfd/
	
	2011-09-29  H.J. Lu  &lt;hongjiu.lu@intel.com&gt;
	
	PR ld/13195
	* elflink.c (_bfd_elf_merge_symbol): Don&apos;t set dynamic_def when
	clearing def_dynamic.
	(elf_link_add_object_symbols): Likewise.  Set dynamic_def when
	setting def_dynamic.
	(bfd_elf_gc_mark_dynamic_ref_symbol): Check if a symbol is
	versioned.
	
	ld/testsuite/
	
	2011-09-29  H.J. Lu  &lt;hongjiu.lu@intel.com&gt;
	
	PR ld/13195
	* ld-elf/elf.exp: Add a C link testcase for PR ld/13195.
	
	* ld-elf/pr13195.c: New.
	* ld-elf/pr13195.d: Likewise.
	* ld-elf/pr13195.s: Likewise.
	* ld-elf/pr13195.t: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&amp;only_with_tag=binutils-2_22-branch&amp;r1=1.1460&amp;r2=1.1460.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr13195.c.diff?cvsroot=src&amp;only_with_tag=binutils-2_22-branch&amp;r1=NONE&amp;r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr13195.d.diff?cvsroot=src&amp;only_with_tag=binutils-2_22-branch&amp;r1=NONE&amp;r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr13195.s.diff?cvsroot=src&amp;only_with_tag=binutils-2_22-branch&amp;r1=NONE&amp;r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr13195.t.diff?cvsroot=src&amp;only_with_tag=binutils-2_22-branch&amp;r1=NONE&amp;r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/elf.exp.diff?cvsroot=src&amp;only_with_tag=binutils-2_22-branch&amp;r1=1.28&amp;r2=1.28.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&amp;only_with_tag=binutils-2_22-branch&amp;r1=1.5473.2.2&amp;r2=1.5473.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&amp;only_with_tag=binutils-2_22-branch&amp;r1=1.420.2.1&amp;r2=1.420.2.2</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>51165</commentid>
            <who name="cvs-commit@gcc.gnu.org">cvs-commit</who>
            <bug_when>2011-10-17 08:27:54 +0000</bug_when>
            <thetext>CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-10-17 08:27:46

Modified files:
	bfd            : ChangeLog elf64-ppc.c 

Log message:
	PR ld/12975
	PR ld/13195
	* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Apply 2011-09-15
	and 2011-09-29 bfd_elf_gc_mark_dynamic_ref_symbol changes here too.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&amp;r1=1.5490&amp;r2=1.5491
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-ppc.c.diff?cvsroot=src&amp;r1=1.365&amp;r2=1.366</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>51335</commentid>
            <who name="cvs-commit@gcc.gnu.org">cvs-commit</who>
            <bug_when>2011-10-25 03:09:40 +0000</bug_when>
            <thetext>CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_22-branch
Changes by:	amodra@sourceware.org	2011-10-25 03:09:34

Modified files:
	bfd            : ChangeLog elf64-ppc.c 

Log message:
	PR ld/12975
	PR ld/13195
	2011-10-17  Alan Modra  &lt;amodra@gmail.com&gt;
	* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Apply 2011-09-15
	and 2011-09-29 bfd_elf_gc_mark_dynamic_ref_symbol changes here too.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&amp;only_with_tag=binutils-2_22-branch&amp;r1=1.5473.2.14&amp;r2=1.5473.2.15
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-ppc.c.diff?cvsroot=src&amp;only_with_tag=binutils-2_22-branch&amp;r1=1.363.2.2&amp;r2=1.363.2.3</thetext>
          </long_desc>
      
      

    </bug>

</bugzilla>