Bug 12371 - Garbage collection for STT_GNU_IFUNC symbols in shared library
Summary: Garbage collection for STT_GNU_IFUNC symbols in shared library
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on: 11791
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-06 15:56 UTC by H.J. Lu
Modified: 2011-05-25 17:41 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2011-01-06 15:56:46 UTC
+++ This bug was initially created as a clone of Bug #11791 +++

[hjl@gnu-6 intel64-2]$ cat foo.s
        .section .text.foo,"ax",@progbits
        .type foo, @function
foo:
        movl ifunc@GOTPCREL(%rip), %eax
        movl ifunc(%rip), %eax
	call ifunc@PLT
	call ifunc
        movl xxx(%rip), %eax
        ret

        .section .text.bar,"ax",@progbits
        .type bar, @function
bar:
        .global bar
        ret

        .section .text.ifunc,"ax",@progbits
        .type ifunc, @gnu_indirect_function
ifunc:
        ret

        .section .data.foo,"aw",@progbits
xxx:
	.quad ifunc 
[hjl@gnu-6 intel64-2]$ make LD=ld
as  -o foo.o foo.s
ld -shared -e bar --gc-sections -o foo  foo.o
make: *** [foo] Segmentation fault
make: *** Deleting file `foo'
Comment 1 Sourceware Commits 2011-01-06 18:45:09 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2011-01-06 18:45:05

Modified files:
	bfd            : ChangeLog elf-ifunc.c elf32-i386.c 
	                 elf64-x86-64.c 
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-ifunc: ifunc-10-i386.s ifunc-10-x86-64.s 
	                       ifunc-11-i386.s ifunc-11-x86-64.s 
Added files:
	ld/testsuite/ld-ifunc: ifunc-12-i386.d ifunc-12-i386.s 
	                       ifunc-12-x86-64.d ifunc-12-x86-64.s 
	                       ifunc-13-i386.d ifunc-13-x86-64.d 
	                       ifunc-13a-i386.s ifunc-13a-x86-64.s 
	                       ifunc-13b-i386.s ifunc-13b-x86-64.s 

Log message:
	Handle STT_GNU_IFUNC symols when building shared library.
	
	bfd/
	
	2012-01-06  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/12366
	PR ld/12371
	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Properly
	handle symbols marked with regular reference, but not non-GOT
	reference when building shared library.
	
	* elf32-i386.c (elf_i386_gc_sweep_hook): Properly handle
	local and global STT_GNU_IFUNC symols when building shared
	library.
	* elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise.
	
	ld/testsuite/
	
	2012-01-06  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/12366
	PR ld/12371
	* ld-ifunc/ifunc-10-i386.s: Add more tests.
	* ld-ifunc/ifunc-10-x86-64.s: Likewise.
	* ld-ifunc/ifunc-11-i386.s: Likewise.
	* ld-ifunc/ifunc-11-x86-64.s: Likewise.
	
	* ld-ifunc/ifunc-12-i386.d: New.
	* ld-ifunc/ifunc-12-i386.s: Likewise.
	* ld-ifunc/ifunc-12-x86-64.d: Likewise.
	* ld-ifunc/ifunc-12-x86-64.s: Likewise.
	* ld-ifunc/ifunc-13-i386.d: Likewise.
	* ld-ifunc/ifunc-13-x86-64.d: Likewise.
	* ld-ifunc/ifunc-13a-i386.s: Likewise.
	* ld-ifunc/ifunc-13a-x86-64.s: Likewise.
	* ld-ifunc/ifunc-13b-i386.s: Likewise.
	* ld-ifunc/ifunc-13b-x86-64.s: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5223&r2=1.5224
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-ifunc.c.diff?cvsroot=src&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-i386.c.diff?cvsroot=src&r1=1.241&r2=1.242
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=src&r1=1.204&r2=1.205
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1348&r2=1.1349
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-i386.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-i386.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-x86-64.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-x86-64.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13-i386.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13-x86-64.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13a-i386.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13b-i386.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-10-i386.s.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-10-x86-64.s.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-11-i386.s.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-11-x86-64.s.diff?cvsroot=src&r1=1.1&r2=1.2
Comment 2 H.J. Lu 2011-01-06 18:47:33 UTC
Fixed.
Comment 3 Sourceware Commits 2011-05-25 17:41:40 UTC
CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_21-branch
Changes by:	hjl@sourceware.org	2011-05-25 17:41:35

Modified files:
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-ifunc: ifunc-10-i386.s ifunc-10-x86-64.s 
	                       ifunc-11-i386.s ifunc-11-x86-64.s 
	bfd            : ChangeLog elf-ifunc.c elf32-i386.c 
	                 elf64-x86-64.c 
Added files:
	ld/testsuite/ld-ifunc: ifunc-12-i386.d ifunc-12-i386.s 
	                       ifunc-12-x86-64.d ifunc-12-x86-64.s 
	                       ifunc-13-i386.d ifunc-13-x86-64.d 
	                       ifunc-13a-i386.s ifunc-13a-x86-64.s 
	                       ifunc-13b-i386.s ifunc-13b-x86-64.s 

Log message:
	Handle STT_GNU_IFUNC symols when building shared library.
	
	bfd/
	
	2012-05-25  H.J. Lu  <hongjiu.lu@intel.com>
	
	Backport from mainline
	2012-01-06  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/12366
	PR ld/12371
	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Properly
	handle symbols marked with regular reference, but not non-GOT
	reference when building shared library.
	
	* elf32-i386.c (elf_i386_gc_sweep_hook): Properly handle
	local and global STT_GNU_IFUNC symols when building shared
	library.
	* elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise.
	
	ld/testsuite/
	
	2012-05-25  H.J. Lu  <hongjiu.lu@intel.com>
	
	Backport from mainline
	2012-01-06  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/12366
	PR ld/12371
	* ld-ifunc/ifunc-10-i386.s: Add more tests.
	* ld-ifunc/ifunc-10-x86-64.s: Likewise.
	* ld-ifunc/ifunc-11-i386.s: Likewise.
	* ld-ifunc/ifunc-11-x86-64.s: Likewise.
	
	* ld-ifunc/ifunc-12-i386.d: New.
	* ld-ifunc/ifunc-12-i386.s: Likewise.
	* ld-ifunc/ifunc-12-x86-64.d: Likewise.
	* ld-ifunc/ifunc-12-x86-64.s: Likewise.
	* ld-ifunc/ifunc-13-i386.d: Likewise.
	* ld-ifunc/ifunc-13-x86-64.d: Likewise.
	* ld-ifunc/ifunc-13a-i386.s: Likewise.
	* ld-ifunc/ifunc-13a-x86-64.s: Likewise.
	* ld-ifunc/ifunc-13b-i386.s: Likewise.
	* ld-ifunc/ifunc-13b-x86-64.s: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1322.2.11&r2=1.1322.2.12
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-i386.d.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-i386.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-x86-64.d.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-12-x86-64.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13-i386.d.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13-x86-64.d.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13a-i386.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13b-i386.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-10-i386.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-10-x86-64.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-11-i386.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-11-x86-64.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.5180.2.33&r2=1.5180.2.34
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-ifunc.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.4&r2=1.4.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-i386.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.241.2.1&r2=1.241.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.202.2.1&r2=1.202.2.2