Bug 12694 - Local IFUNC symbol causes TEXTREL
Summary: Local IFUNC symbol causes TEXTREL
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:
Blocks:
 
Reported: 2011-04-21 22:03 UTC by H.J. Lu
Modified: 2015-08-10 20:24 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 H.J. Lu 2011-04-21 22:03:19 UTC
[hjl@gnu-6 ifunc-textrel]$ make clean
rm -f *.o *.so
[hjl@gnu-6 ifunc-textrel]$ cat foo.c
static int
zero (int x) 
{
  return 0;
}

void * foo_ifunc (void) __asm__ ("foo");
void * foo_ifunc (void) { return zero; }
__asm__(".type foo, %gnu_indirect_function");
[hjl@gnu-6 ifunc-textrel]$ cat bar.c
extern int foo (void) __attribute__ ((visibility ("hidden")));

int
bar (void)
{
  return foo ();
}

int
bar2 ()
{
  return foo () + 3;
}
[hjl@gnu-6 ifunc-textrel]$ make
gcc -m32 -O2 -fPIC   -c -o bar.o bar.c
gcc -m32 -O2 -fPIC   -c -o foo.o foo.c
./ld -m elf_i386 -z nocombreloc -shared -o libfoo.so bar.o foo.o --version-script=libfoo.map
readelf -d libfoo.so | grep TEXTREL
 0x00000016 (TEXTREL)                    0x0
Comment 1 Sourceware Commits 2011-04-21 22:25:43 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2011-04-21 22:25:39

Modified files:
	ld/testsuite   : ChangeLog 
	bfd            : ChangeLog elf32-i386.c elf64-x86-64.c 
Added files:
	ld/testsuite/ld-ifunc: ifunc-14-i386.d ifunc-14-x86-64.d 
	                       ifunc-14a.s ifunc-14b.s 

Log message:
	Skip local IFUNC symbols when checking dynamic relocs in read-only sections.
	
	bfd/
	
	2011-04-21  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/12694
	* elf32-i386.c (elf_i386_readonly_dynrelocs): Skip local IFUNC
	symbols.
	* elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.
	
	ld/testsuite/
	
	2011-04-21  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/12694
	* ld-ifunc/ifunc-14-i386.d: New.
	* ld-ifunc/ifunc-14-x86-64.d: Likewise.
	* ld-ifunc/ifunc-14a.s: Likewise.
	* ld-ifunc/ifunc-14b.s: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1390&r2=1.1391
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-14-i386.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-14-x86-64.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-14a.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/ifunc-14b.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5316&r2=1.5317
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-i386.c.diff?cvsroot=src&r1=1.249&r2=1.250
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=src&r1=1.221&r2=1.222
Comment 2 H.J. Lu 2011-04-21 22:30:27 UTC
Fixed.