Bug 10893 - gold doesn't support IFUNC
Summary: gold doesn't support IFUNC
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
: 11694 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-11-02 19:11 UTC by H.J. Lu
Modified: 2010-08-19 22:54 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-pc-linux-gnu
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 2009-11-02 19:11:00 UTC
Gold can't link again libc.a with multi-arch enabled:

gcctestdir/ld:
/usr/lib/gcc/x86_64-redhat-linux/4.4.1/../../../../lib64/libc.a(elf-init.o): in
function __libc_csu_init:(.text+0x65): error: undefined reference to
'__rela_iplt_end'
gcctestdir/ld:
/usr/lib/gcc/x86_64-redhat-linux/4.4.1/../../../../lib64/libc.a(elf-init.o): in
function __libc_csu_init:(.text+0x6e): error: undefined reference to
'__rela_iplt_start'
gcctestdir/ld:
/usr/lib/gcc/x86_64-redhat-linux/4.4.1/../../../../lib64/libc.a(elf-init.o): in
function __libc_csu_init:(.text+0x8a): error: undefined reference to
'__rela_iplt_start'
gcctestdir/ld:
/usr/lib/gcc/x86_64-redhat-linux/4.4.1/../../../../lib64/libc.a(elf-init.o): in
function __libc_csu_init:(.text+0x98): error: undefined reference to
'__rela_iplt_start'
gcctestdir/ld:
/usr/lib/gcc/x86_64-redhat-linux/4.4.1/../../../../lib64/libc.a(elf-init.o): in
function __libc_csu_init:(.text+0x9e): error: undefined reference to
'__rela_iplt_start'
collect2: ld returned 1 exit status
make[7]: *** [two_file_static_test] Error 1

__rela_iplt_start/__rela_iplt_end should be defined by linker.
Comment 1 cvs-commit@gcc.gnu.org 2009-11-03 15:42:04 UTC
Subject: Bug 10893

CVSROOT:	/cvs/src
Module name:	src
Changes by:	ian@sourceware.org	2009-11-03 15:41:51

Modified files:
	gold           : ChangeLog defstd.cc 

Log message:
	PR 10893
	* defstd.cc (in_section): Add entries for __rel_iplt_start,
	__rel_iplt_end, __rela_iplt_start, __rela_iplt_end, and __stack.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.339&r2=1.340
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/defstd.cc.diff?cvsroot=src&r1=1.6&r2=1.7

Comment 2 cvs-commit@gcc.gnu.org 2009-11-03 15:43:01 UTC
Subject: Bug 10893

CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_20-branch
Changes by:	ian@sourceware.org	2009-11-03 15:42:51

Modified files:
	gold           : ChangeLog defstd.cc 

Log message:
	PR 10893
	* defstd.cc (in_section): Add entries for __rel_iplt_start,
	__rel_iplt_end, __rela_iplt_start, __rela_iplt_end, and __stack.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.281.2.5&r2=1.281.2.6
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/defstd.cc.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.6&r2=1.6.8.1

Comment 3 Ian Lance Taylor 2009-11-03 15:44:41 UTC
Fixed.
Comment 4 H.J. Lu 2009-11-03 17:41:08 UTC
Gold generates those symbols. However, those special sections

+    ".rel.iplt",		// output_section
+    ".rela.iplt",		// output_section

are generated by linker. Does gold generate them now? I got

FAIL: tls_shared_gnu2_test
FAIL: script_test_2
FAIL: binary_test
Comment 5 Ian Lance Taylor 2009-11-04 07:34:28 UTC
gold does not generate the .rel.iplt or .rela.iplt sections itself.  I'm not
sure what this has to do with "multi-arched libc.a".  gold does not yet support
STT_GNU_IFUNC symbols.

It's normal for tls_shared_gnu2_test to fail, but everything else should pass.
Comment 6 H.J. Lu 2009-11-04 14:45:59 UTC
(In reply to comment #5)
> gold does not generate the .rel.iplt or .rela.iplt sections itself.  I'm not
> sure what this has to do with "multi-arched libc.a".  gold does not yet support
> STT_GNU_IFUNC symbols.
> 

multi-arched libc.a has STT_GNU_IFUNC symbols. If gold doesn't support them,
static linking may not work.
Comment 7 H.J. Lu 2009-12-04 05:20:43 UTC
Gold doesn't support IFUNC at all. Fedora 12 has many IFUNC functions
in libc.
Comment 8 cvs-commit@gcc.gnu.org 2009-12-07 17:15:25 UTC
Subject: Bug 10893

CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2009-12-07 17:14:56

Modified files:
	gold           : ChangeLog i386.cc symtab.cc symtab.h x86_64.cc 

Log message:
	2009-12-07  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR gold/10893
	* i386.cc (Target_i386::Scan::globa): Use is_func instead of
	checking elfcpp::STT_FUNC.
	(Target_i386::Relocate::relocate): Likewise.
	* x86_64.cc (Target_x86_64::Scan::global): Likewise.
	
	* symtab.cc (Symbol_table::sized_write_symbol): Turn IFUNC
	symbols from shared libraries into normal FUNC symbols.
	
	* symtab.h (Symbol): Add is_func and use it.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.377&r2=1.378
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/i386.cc.diff?cvsroot=src&r1=1.102&r2=1.103
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/symtab.cc.diff?cvsroot=src&r1=1.129&r2=1.130
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/symtab.h.diff?cvsroot=src&r1=1.96&r2=1.97
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/x86_64.cc.diff?cvsroot=src&r1=1.95&r2=1.96

Comment 9 Ian Lance Taylor 2009-12-30 22:44:53 UTC
H.J., can you add a note here about what else gold needs to support IFUNC?
Comment 10 H.J. Lu 2009-12-30 22:57:03 UTC
STT_GNU_IFUNC is specified in ifunc.txt at

http://groups.google.com/group/generic-abi

which contains some implementation notes.
Comment 11 Ian Lance Taylor 2010-08-04 08:58:19 UTC
*** Bug 11694 has been marked as a duplicate of this bug. ***
Comment 12 cvs-commit@gcc.gnu.org 2010-08-19 22:50:42 UTC
Subject: Bug 10893

CVSROOT:	/cvs/src
Module name:	src
Changes by:	ian@sourceware.org	2010-08-19 22:50:16

Modified files:
	gold           : ChangeLog configure configure.ac defstd.cc 
	                 i386.cc object.cc object.h output.cc output.h 
	                 symtab.h target-reloc.h target.h x86_64.cc 
	gold/testsuite : Makefile.am Makefile.in 
Added files:
	gold/testsuite : ifunc-sel.h ifuncdep2.c ifuncmain1.c 
	                 ifuncmain1vis.c ifuncmain2.c ifuncmain3.c 
	                 ifuncmain4.c ifuncmain5.c ifuncmain6pie.c 
	                 ifuncmain7.c ifuncmod1.c ifuncmod3.c 
	                 ifuncmod5.c ifuncmod6.c 

Log message:
	PR 10893
	* i386.cc (class Output_data_plt_i386): Update declarations.
	Define Global_ifunc and Local_ifunc types.  Add global_ifuncs_ and
	local_ifuncs_ fields.
	(Target_i386::do_plt_section_for_global): New function.
	(Target_i386::do_plt_section_for_local): New function.
	(Output_data_plt_i386::Output_data_plt_i386): Add symtab
	parameter; change all callers.  Initialize global_ifuncs_ and
	local_ifuncs_.  If doing a static link define __rel_iplt_start and
	__rel_iplt_end.
	(Output_data_plt_i386::add_entry): Handle IFUNC symbols.
	(Output_data_plt_i386::add_local_ifunc_entry): New function.
	(Output_data_plt_i386::do_write): Fix GOT entries for IFUNC
	symbols.
	(Target_i386::make_plt_section): New function, broken out of
	make_plt_entry.  Set sh_info field of .rel.plt to point to .plt.
	(Target_i386::make_plt_entry): Call make_plt_section.
	(Target_i386::make_local_ifunc_plt_entry): New function.
	(Target_i386::Scan::reloc_needs_iplt_for_ifunc): New function.
	(Target_i386::Scan::local): Handle IFUNC symbols.  Add
	R_386_IRELATIVE to switch.
	(Target_i386::Scan::global): Likewise.
	(Target_i386::Relocate::relocate): Likewise.
	(Target_i386::Relocatable_size_for_reloc): Add R_386_IRELATIVE to
	switch.
	* x86_64.cc (class Output_data_plt_x86_64): Update declarations.
	(Target_x86_64::do_plt_section_for_global): New function.
	(Target_x86_64::do_plt_section_for_local): New function.
	(Output_data_plt_x86_64::Output_data_plt_x86_64): Add symtab
	parameter; change all callers.  If doing a static link define
	__rela_iplt_start and __rela_iplt_end.
	(Output_data_plt_x86_64::add_entry): Handle IFUNC symbols.
	(Output_data_plt_x86_64::add_local_ifunc_entry): New function.
	(Target_x86_64::make_plt_section): Set sh_info field of .rel.plt
	to point to .plt.
	(Target_x86_64::make_local_ifunc_plt_entry): New function.
	(Target_x86_64::Scan::check_non_pic): Add R_X86_64_IRELATIVE to
	switch.
	(Target_x86_64::Scan::reloc_needs_iplt_for_ifunc): New function.
	(Target_x86_64::Scan::local): Handle IFUNC symbols.  Add
	R_X86_64_IRELATIVE to switch.
	(Target_x86_64::Scan::global): Likewise.
	(Target_x86_64::Relocate::relocate): Likewise.
	(Target_x86_64::Relocatable_size_for_reloc): Add R_X86_64_IRELATIVE to
	switch.
	* target.h (class Target): Add plt_section_for_global and
	plt_section_for_local functions.  Add do_plt_section_for_global
	and do_plt_section_for_local virtual functions.
	* symtab.h (Symbol::needs_plt_entry): Handle IFUNC symbol.  Add
	clarifying comments.
	(Symbol::use_plt_offset): Handle IFUNC symbol.
	* object.cc (Sized_relobj::Sized_relobj): Initialize
	local_plt_offsets_.
	(Sized_relobj::local_has_plt_offset): New function.
	(Sized_relobj::local_plt_offset): New function.
	(Sized_relobj::set_local_plt_offset): New function.
	(Sized_relobj::do_count): Handle IFUNC symbol.
	* object.h (class Symbol_value): Add is_ifunc_symbol_ field.  Take
	a bit away from input_shndx_ field.  Add set_is_func_symbol and
	is_ifunc_symbol functions.
	(class Sized_relobj): Update declarations.  Remove Tls_got_entry
	and Local_tls_got_offsets.  Define Local_plt_offsets.  Add
	local_plt_offsets_ field.
	(Sized_relobj::clear_local_symbols): Clear local_plt_offsets_.
	* output.h (class Output_section_data): Add non-const
	output_section function.
	(class Output_data_got): Update declarations.
	(class Output_data_got::Got_entry): Add use_plt_offset_ field.
	Add use_plt_offset parameter to global and local constructors.
	Change all callers.  Change local_sym_index_ field to 31 bits.
	Change GSYM_CODE and CONSTANT_CODE accordingly.
	* output.cc (Output_data_reloc_base::do_adjust_output_section): If
	doing a static link don't set sh_link field.
	(Output_data_got::Got_entry::write): Use PLT offset if
	appropriate.
	(Output_data_got::add_global_plt): New function.
	(Output_data_got::add_local_plt): New function.
	* target-reloc.h (relocate_section): Handle IFUNC symbol.
	* defstd.cc (in_section): Remove entries for __rel_iplt_start,
	__rel_iplt_end, __rela_iplt_start, and __rela_iplt_end.
	* configure.ac: Set IFUNC automake conditional for glibc >= 2.11.
	* testsuite/Makefile.am: Add a bunch of IFUNC tests, all within
	IFUNC conditional.
	* testsuite/ifunc-sel.h: New file.
	* testsuite/ifuncmain1.c: New file.
	* testsuite/ifuncmain1vis.c: New file.
	* testsuite/ifuncmod1.c: New file.
	* testsuite/ifuncdep2.c: New file.
	* testsuite/ifuncmain2.c: New file.
	* testsuite/ifuncmain3.c: New file.
	* testsuite/ifuncmod3.c: New file.
	* testsuite/ifuncmain4.c: New file.
	* testsuite/ifuncmain5.c: New file.
	* testsuite/ifuncmod5.c: New file.
	* testsuite/ifuncmain6pie.c: New file.
	* testsuite/ifuncmod6.c: New file.
	* testsuite/ifuncmain7.c: New file.
	* configure, testsuite/Makefile.in: Rebuild.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.617&r2=1.618
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/configure.diff?cvsroot=src&r1=1.59&r2=1.60
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/configure.ac.diff?cvsroot=src&r1=1.57&r2=1.58
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/defstd.cc.diff?cvsroot=src&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/i386.cc.diff?cvsroot=src&r1=1.122&r2=1.123
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/object.cc.diff?cvsroot=src&r1=1.128&r2=1.129
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/object.h.diff?cvsroot=src&r1=1.100&r2=1.101
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/output.cc.diff?cvsroot=src&r1=1.132&r2=1.133
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/output.h.diff?cvsroot=src&r1=1.111&r2=1.112
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/symtab.h.diff?cvsroot=src&r1=1.111&r2=1.112
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/target-reloc.h.diff?cvsroot=src&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/target.h.diff?cvsroot=src&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/x86_64.cc.diff?cvsroot=src&r1=1.114&r2=1.115
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifunc-sel.h.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncdep2.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncmain1.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncmain1vis.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncmain2.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncmain3.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncmain4.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncmain5.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncmain6pie.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncmain7.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncmod1.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncmod3.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncmod5.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/ifuncmod6.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/Makefile.am.diff?cvsroot=src&r1=1.140&r2=1.141
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/Makefile.in.diff?cvsroot=src&r1=1.148&r2=1.149

Comment 13 Ian Lance Taylor 2010-08-19 22:54:18 UTC
Fixed for i386 and x86_64.  If you find any problems, please open a new bug 
report.