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

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

    <bug>
          <bug_id>13177</bug_id>
          
          <creation_ts>2011-09-11 08:41:00 +0000</creation_ts>
          <short_desc>garbage collector retains zombie references to external libraries</short_desc>
          <delta_ts>2012-02-22 03:35:16 +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.22</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/msg00076.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>13232</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Rene">prr</reporter>
          <assigned_to>unassigned</assigned_to>
          <cc>amodra</cc>
    
    <cc>hjl.tools</cc>
          <cf_gcchost></cf_gcchost>
          <cf_gcctarget></cf_gcctarget>
          <cf_gccbuild></cf_gccbuild>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>50563</commentid>
    <comment_count>0</comment_count>
    <who name="Rene">prr</who>
    <bug_when>2011-09-11 08:41:31 +0000</bug_when>
    <thetext>If shared library is compiled and linked with garbage collection enabled,
zombie references to external libraries are retained that result future link failure.
(ld 2.21, gcc 4.5.2, Ubuntu 11.04)

Steps to repro:
* Create file shared.c
--8&lt;--
#include &lt;dlfcn.h&gt;
void opt_out(const char *name)
{
	dlopen(name, RTLD_LAZY);
}
__attribute__ ((visibility (&quot;default&quot;))) int add_two(int number)
{
	return number+2;
}
--&gt;8--

* Create shared library by running
gcc -fpic -shared -ffunction-sections -fdata-sections -Wl,--gc-sections -fvisibility=hidden -o libtest.so shared.c -static-libgcc
Result: SUCCESS, no errors.

* Verify created library references by running
ldd -r libtest.so
Resukt: SUCCESS. No unreferenced symbols and expected list of library bindings.

* Create file main.c:
--8&lt;--
int add_two(int);
int main()
{
	return add_two(-2);
}
--&gt;8--

* Create a program by running:
gcc -o main main.c -L. -ltest
Expected result: Program compailes and links correctly.
Acttual result: FAIL. ld returns:
  ./libtest.so: undefined reference to &apos;dlopen&apos; 
  collect2: ld returned 1 exit status</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50625</commentid>
    <comment_count>1</comment_count>
    <who name="H.J. Lu">hjl.tools</who>
    <bug_when>2011-09-14 19:15:38 +0000</bug_when>
    <thetext>A patch is posted at

http://sourceware.org/ml/binutils/2011-09/msg00076.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50649</commentid>
    <comment_count>2</comment_count>
    <who name="cvs-commit@gcc.gnu.org">cvs-commit</who>
    <bug_when>2011-09-16 01:17:19 +0000</bug_when>
    <thetext>CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2011-09-16 01:17:16

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

Log message:
	Also hide symbols without PLT nor GOT references.
	
	bfd/
	
	2011-09-15  H.J. Lu  &lt;hongjiu.lu@intel.com&gt;
	
	PR ld/13177
	* elflink.c (elf_gc_sweep_symbol): Also hide symbols without PLT
	nor GOT references.
	
	ld/testsuite/
	
	2011-09-15  H.J. Lu  &lt;hongjiu.lu@intel.com&gt;
	
	PR ld/13177
	* ld-elf/pr13177.d: New.
	* ld-elf/pr13177.s: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&amp;r1=1.1458&amp;r2=1.1459
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr13177.d.diff?cvsroot=src&amp;r1=NONE&amp;r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr13177.s.diff?cvsroot=src&amp;r1=NONE&amp;r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&amp;r1=1.5470&amp;r2=1.5471
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&amp;r1=1.419&amp;r2=1.420</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50653</commentid>
    <comment_count>3</comment_count>
    <who name="H.J. Lu">hjl.tools</who>
    <bug_when>2011-09-16 04:25:18 +0000</bug_when>
    <thetext>Fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51218</commentid>
    <comment_count>4</comment_count>
    <who name="cvs-commit@gcc.gnu.org">cvs-commit</who>
    <bug_when>2011-10-18 19:06:54 +0000</bug_when>
    <thetext>CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_22-branch
Changes by:	hjl@sourceware.org	2011-10-18 19:06:50

Modified files:
	ld/testsuite   : ChangeLog 
	bfd            : ChangeLog elflink.c 
Removed files:
	ld/testsuite/ld-elf: pr13177.d pr13177.s 

Log message:
	Revert the fix for PR ld/13177.
	
	bfd/
	
	2011-10-18  H.J. Lu  &lt;hongjiu.lu@intel.com&gt;
	
	PR ld/13177
	* elflink.c (elf_gc_sweep_symbol): Don&apos;t hide symbols without PLT
	nor GOT references.
	
	ld/testsuite/
	
	2011-10-18  H.J. Lu  &lt;hongjiu.lu@intel.com&gt;
	
	PR ld/13177
	* ld-elf/pr13177.d: Removed.
	* ld-elf/pr13177.s: 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.2.2&amp;r2=1.1460.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr13177.d.diff?cvsroot=src&amp;only_with_tag=binutils-2_22-branch&amp;r1=1.2&amp;r2=NONE
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/pr13177.s.diff?cvsroot=src&amp;only_with_tag=binutils-2_22-branch&amp;r1=1.2&amp;r2=NONE
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.5&amp;r2=1.5473.2.6
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.2&amp;r2=1.420.2.3</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51219</commentid>
    <comment_count>5</comment_count>
    <who name="H.J. Lu">hjl.tools</who>
    <bug_when>2011-10-18 19:08:03 +0000</bug_when>
    <thetext>Patch is reverted on 2.22 branch,</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51231</commentid>
    <comment_count>6</comment_count>
    <who name="cvs-commit@gcc.gnu.org">cvs-commit</who>
    <bug_when>2011-10-19 07:17:27 +0000</bug_when>
    <thetext>CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-10-19 07:17:21

Modified files:
	bfd            : ChangeLog elf32-arm.c elf32-bfin.c elf32-cris.c 
	                 elf32-frv.c elf32-i386.c elf32-m32r.c 
	                 elf32-m68k.c elf32-ppc.c elf32-s390.c 
	                 elf32-sh.c elf32-spu.c elf32-tilepro.c 
	                 elf32-xtensa.c elf64-alpha.c elf64-ppc.c 
	                 elf64-s390.c elf64-sh64.c elf64-x86-64.c 
	                 elflink.c elf-m10300.c elfxx-sparc.c 
	                 elfxx-tilegx.c 
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-elf: elf.exp 
	ld/testsuite/ld-gc: gc.exp 
	ld/testsuite/lib: ld-lib.exp 
Added files:
	ld/testsuite/ld-gc: libpersonality.s personality.d personality.s 

Log message:
	PR ld/13177
	bfd/
	* elflink.c (_bfd_elf_gc_mark_rsec): Set symbol &quot;mark&quot;.
	(elf_gc_sweep_symbol): Don&apos;t test plt/got refcounts, instead test
	&quot;mark&quot;.  Hide undefweak too.  Clear def_regular and ref_regular.
	* elf-m10300.c (mn10300_elf_relocate_section): Ignore unresolved
	reloc errors from garbage-collected code.
	* elf32-arm.c (elf32_arm_relocate_section): Likewise.
	* elf32-bfin.c (bfin_relocate_section): Likewise.
	(bfinfdpic_relocate_section): Likewise.
	* elf32-cris.c (cris_elf_relocate_section): Likewise.
	* elf32-frv.c (elf32_frv_relocate_section): Likewise.
	* elf32-i386.c (elf_i386_relocate_section): Likewise.
	* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
	* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
	* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
	* elf32-s390.c (elf_s390_relocate_section): Likewise.
	* elf32-sh.c (sh_elf_relocate_section): Likewise.
	* elf32-spu.c (spu_elf_relocate_section): Likewise.
	* elf32-tilepro.c (tilepro_elf_relocate_section): Likewise.
	* elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
	* elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
	* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
	* elf64-s390.c (elf_s390_relocate_section): Likewise.
	* elf64-sh64.c (sh_elf64_relocate_section): Likewise.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.
	* elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise.
	ld/testsuite/
	* ld-elf/elf.exp: Move test for shared lib support..
	* lib/ld-lib.exp (check_shared_lib_support): ..to here. Add m68hc1*,
	and s/ms1/mt/.
	(check_gc_sections_available): Match hppa*64 not hppa64.  Comment.
	* ld-gc/libpersonality.s: New.
	* ld-gc/personality.s, * ld-gc/personality.d: New.
	* ld-gc/gc.exp: Run personality test.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&amp;r1=1.5494&amp;r2=1.5495
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-arm.c.diff?cvsroot=src&amp;r1=1.277&amp;r2=1.278
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-bfin.c.diff?cvsroot=src&amp;r1=1.54&amp;r2=1.55
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-cris.c.diff?cvsroot=src&amp;r1=1.116&amp;r2=1.117
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-frv.c.diff?cvsroot=src&amp;r1=1.73&amp;r2=1.74
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-i386.c.diff?cvsroot=src&amp;r1=1.260&amp;r2=1.261
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-m32r.c.diff?cvsroot=src&amp;r1=1.102&amp;r2=1.103
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-m68k.c.diff?cvsroot=src&amp;r1=1.126&amp;r2=1.127
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-ppc.c.diff?cvsroot=src&amp;r1=1.302&amp;r2=1.303
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-s390.c.diff?cvsroot=src&amp;r1=1.108&amp;r2=1.109
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-sh.c.diff?cvsroot=src&amp;r1=1.172&amp;r2=1.173
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-spu.c.diff?cvsroot=src&amp;r1=1.101&amp;r2=1.102
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-tilepro.c.diff?cvsroot=src&amp;r1=1.3&amp;r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-xtensa.c.diff?cvsroot=src&amp;r1=1.130&amp;r2=1.131
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-alpha.c.diff?cvsroot=src&amp;r1=1.181&amp;r2=1.182
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-ppc.c.diff?cvsroot=src&amp;r1=1.366&amp;r2=1.367
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-s390.c.diff?cvsroot=src&amp;r1=1.108&amp;r2=1.109
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-sh64.c.diff?cvsroot=src&amp;r1=1.87&amp;r2=1.88
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=src&amp;r1=1.239&amp;r2=1.240
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&amp;r1=1.427&amp;r2=1.428
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-m10300.c.diff?cvsroot=src&amp;r1=1.108&amp;r2=1.109
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elfxx-sparc.c.diff?cvsroot=src&amp;r1=1.61&amp;r2=1.62
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elfxx-tilegx.c.diff?cvsroot=src&amp;r1=1.3&amp;r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&amp;r1=1.1470&amp;r2=1.1471
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/elf.exp.diff?cvsroot=src&amp;r1=1.30&amp;r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-gc/libpersonality.s.diff?cvsroot=src&amp;r1=NONE&amp;r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-gc/personality.d.diff?cvsroot=src&amp;r1=NONE&amp;r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-gc/personality.s.diff?cvsroot=src&amp;r1=NONE&amp;r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-gc/gc.exp.diff?cvsroot=src&amp;r1=1.11&amp;r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/lib/ld-lib.exp.diff?cvsroot=src&amp;r1=1.85&amp;r2=1.86</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>53396</commentid>
    <comment_count>7</comment_count>
    <who name="Alan Modra">amodra</who>
    <bug_when>2012-02-22 03:35:16 +0000</bug_when>
    <thetext>Fixed mainline</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>