This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Rewrite STT_GNU_IFUNC with R_*_IRELATIVE


Hi,

Here is the total rewrite of STT_GNU_IFUNC support
with R_*_IRELATIVE for i386 and x86-64 on shared
library and static/dynamic executables together with
a modified glibc.  OK for trunk?

Thanks.


-- 
H.J.

bfd/

2009-05-28  H.J. Lu  <hongjiu.lu@intel.com>

	* elf-bfd.h (struct bfd_elf_section_data): Remove indirect_relocs.
        (_bfd_elf_make_ifunc_reloc_section): Removed.
	(_bfd_elf_is_ifunc_symbol): Likewise.
	(_bfd_elf_create_static_ifunc_sections): New.
	(WILL_CALL_FINISH_DYNAMIC_SYMBOL): Return TRUE for
	STT_GNU_IFUNC symbol.

	* elf32-i386.c (elf_howto_table): Add R_386_IRELATIVE.
	(elf_i386_reloc_type_lookup): Likewise.
	(R_386_tls): Removed.
	(R_386_irelative): New.
	(R_386_vt_offset): Updated.
	(elf_i386_rtype_to_howto): Likewise.
	(elf_i386_link_hash_table): Add igotplt, iplt and irelplt.
	(elf_i386_link_hash_table_create): Initialize igotplt,
	iplt and irelplt.
	(elf_i386_check_relocs): Call _bfd_elf_create_static_ifunc_sections
	instead of _bfd_elf_make_ifunc_reloc_section.  Set up igotplt,
	iplt and irelplt.
	(allocate_dynrelocs): Use .iplt, .igot.plt and .rel.iplt
	sections for STT_GNU_IFUNC symbols in static executable.  Discard
	space for relocations against forced local STT_GNU_IFUNC symbols
	for not building shared library.  Don't use indirect_relocs.
	(elf_i386_size_dynamic_sections): Set up .iplt and .igot.plt
	sections.
	(elf_i386_relocate_section): If an STT_GNU_IFUNC symbol is
	defined in executable, resolve it to its PLT entry.  Remove
	check for STT_GNU_IFUNC symbols.
	(elf_i386_finish_dynamic_symbol): When building a static
	executable, use .iplt, .igot.plt and .rel.iplt sections for
	STT_GNU_IFUNC symbols.  Generate R_386_IRELATIVE relocation for
	locally defined STT_GNU_IFUNC symbol.

	* elf64-x86-64.c (x86_64_elf_howto): Add R_X86_64_IRELATIVE.
	(x86_64_reloc_map): Likewise.
	(R_X86_64_standard): Updated.
	(elf64_x86_64_link_hash_table): Add igotplt, iplt and irelplt.
	(elf64_x86_64_link_hash_table_create): Initialize igotplt,
	iplt and irelplt.
	(elf64_x86_64_check_relocs): Call _bfd_elf_create_ifunc_sections
	instead of _bfd_elf_make_ifunc_reloc_section.  Set up igotplt,
	iplt and irelplt.
	(allocate_dynrelocs): Use .iplt, .igot.plt and .rela.iplt
	sections for STT_GNU_IFUNC symbols in static executable.  Discard
	space for relocations against forced local STT_GNU_IFUNC symbols
	for not building shared library.  Don't use indirect_relocs.
	(elf64_x86_64_size_dynamic_sections): Set up .iplt and .igot.plt
	sections.
	(elf64_x86_64_relocate_section): If an STT_GNU_IFUNC symbol is
	defined in executable, resolve it to its PLT entry and make sure
	it is reachable.  Remove check for STT_GNU_IFUNC symbols.
	(elf64_x86_64_finish_dynamic_symbol): When building a static
	executable, use .iplt, .igot.plt and .rela.iplt sections for
	STT_GNU_IFUNC symbols.  Generate R_X86_64_IRELATIVE relocation
	for locally defined STT_GNU_IFUNC symbol.

	* elflink.c (_bfd_elf_adjust_dynamic_symbol): Move STT_GNU_IFUNC
	symbol check to ...
	(elf_link_add_object_symbols): Here.
	(_bfd_elf_symbol_refs_local_p): Return FALSE on STT_GNU_IFUNC
	symbol.
	(_bfd_elf_link_hash_hide_symbol): Don't clean plt on
	STT_GNU_IFUNC symbol.
	(elf_link_output_extsym): Always call
	elf_backend_finish_dynamic_symbol for STT_GNU_IFUNC symbol.
	(IFUNC_INFIX): Removed.
	(get_ifunc_reloc_section_name): Likewise.
	(_bfd_elf_make_ifunc_reloc_section): Likewise.
	(_bfd_elf_is_ifunc_symbol): Likewise.
	(_bfd_elf_create_static_ifunc_sections): New.

	* reloc.c (BFD_RELOC_386_IRELATIVE): New.
	(BFD_RELOC_X86_64_IRELATIVE): Likewise.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

include/elf/

2009-05-28  H.J. Lu  <hongjiu.lu@intel.com>

	* i386.h (R_386_IRELATIVE): New.
	* x86-64.h (R_X86_64_IRELATIVE): Likewise.

ld/

2009-05-28  H.J. Lu  <hongjiu.lu@intel.com>

	* scripttempl/elf.sc (PLT): Add "*(.iplt)".
	(GOT): Add "*(.igot.plt)a" and "*(.igot)".
	(GOTPLT): Add "*(.igot)".
	(__rel_iplt_start): New.
	(__rel_iplt_end): Likewise.
	(__rela_iplt_start): Likewise.
	(__rela_iplt_end): Likewise.

ld/testsuite/

2009-05-28  H.J. Lu  <hongjiu.lu@intel.com>

	* ld-ifunc/ifunc.exp (contains_irelative_reloc): New.
	Use it on executable and shared library.
	Run *.d.

	* ld-ifunc/lib.c: Add a hidden alias, __GI_library_func2, for
	library_func2.
	(library_func): New.

	* ld-ifunc/ifunc-1-x86.d: New.
	* ld-ifunc/ifunc-1-x86.s: Likewise.

Attachment: binutils-ifunc-3.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]