Commit Graph

341 Commits

Author SHA1 Message Date
H.J. Lu 59d6ffb2c9 Fix and use elf_append_rel
* elf32-i386.c (elf_i386_relocate_section): Replace
	bfd_elf32_swap_reloc_out with elf_append_rel.
	(elf_i386_finish_dynamic_symbol): Likewise.

	* elflink.c (elf_append_rel): Call swap_reloc_out instead of
	swap_reloca_out.
2012-12-19 19:45:43 +00:00
H.J. Lu 13ca314985 Reindent elf_i386_finish_dynamic_symbol
* elf32-i386.c (elf_i386_finish_dynamic_symbol): Reindent.
2012-12-19 19:41:18 +00:00
H.J. Lu ad1e85de41 Don't check IFUNC relocations in elf_*_check_relocs
* elf32-i386.c (elf_i386_check_relocs): Don't check IFUNC
	relocations here.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
2012-12-16 23:01:13 +00:00
H.J. Lu 73bcf23385 Also check local IFUNC references
bfd/

	PR ld/14968
	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Also check
	local IFUNC references.
	* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.

ld/testsuite/

	PR ld/14968
	* ld-ifunc/ifunc-18a-i386.d: New file.
	* ld-ifunc/ifunc-18a-x86-64.d: Likewise.
	* ld-ifunc/ifunc-18a.s: Likewise.
	* ld-ifunc/ifunc-18b-i386.d: Likewise.
	* ld-ifunc/ifunc-18b-x86-64.d: Likewise.
	* ld-ifunc/ifunc-18b.s: Likewise.
	* ld-ifunc/ifunc-19a-i386.d: Likewise.
	* ld-ifunc/ifunc-19a-x86-64.d: Likewise.
	* ld-ifunc/ifunc-19a.s: Likewise.
	* ld-ifunc/ifunc-19b-i386.d: Likewise.
	* ld-ifunc/ifunc-19b-x86-64.d: Likewise.
	* ld-ifunc/ifunc-19b.s: Likewise.
2012-12-16 20:31:08 +00:00
H.J. Lu 5ca5bb3545 Check local IFUNC calls
bfd/

2012-12-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/14956
	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Check local
	IFUNC calls.
	* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.

ld/testsuite/

2012-12-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/14956
	* ld-ifunc/ifunc-14-i386.d: Renamed to ...
	* ld-ifunc/ifunc-14a-i386.d: This.

	* ld-ifunc/ifunc-14-x86-64.d: Renamed to ...
	* ld-ifunc/ifunc-14a-x86-64.d: This.

	* ld-ifunc/ifunc-14b-i386.d: New file.
	* ld-ifunc/ifunc-14b-x86-64.d: Likewise.
	* ld-ifunc/ifunc-14c-i386.d: Likewise.
	* ld-ifunc/ifunc-14c-x86-64.d: Likewise.
	* ld-ifunc/ifunc-14d-i386.d: Likewise.
	* ld-ifunc/ifunc-14d-x86-64.d: Likewise.
2012-12-13 21:07:16 +00:00
H.J. Lu 9d4b2dba0e Replace _GLOBAL_OFFSET_TABLE_ lookup with htab->elf.hgot
* elf32-i386.c (elf_i386_size_dynamic_sections): Replace
	_GLOBAL_OFFSET_TABLE_ lookup with htab->elf.hgot.
	* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise.
2012-10-25 13:36:08 +00:00
H.J. Lu fbdc86d9c9 Ignore discarded section when converting mov to lea
* elf32-i386.c (elf_i386_convert_mov_to_lea): Ignore discarded
	section.
	* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise.
2012-09-18 00:41:59 +00:00
H.J. Lu cec7f46ac2 Replace return FALSE with abort in x86 finish_dynamic_symbol
* elf32-i386.c (elf_i386_finish_dynamic_symbol): Replace return
	FALSE with abort.
	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.
2012-09-17 18:31:15 +00:00
H.J. Lu 9637f6ef78 Add hdynamic to elf_link_hash_table for _DYNAMIC
* elf-bfd.h (elf_link_hash_table): Add hdynamic for the
	_DYNAMIC symbol.

	* elflink.c (_bfd_elf_link_create_dynamic_sections): Set
	hdynamic.

	* elf-m10300.c (_bfd_mn10300_elf_finish_dynamic_symbol): Check
	hdynamic instead of "_DYNAMIC".
	* elf32-arm.c (elf32_arm_finish_dynamic_symbol): Likewise.
	* elf32-cr16.c (elf32_arm_finish_dynamic_symbol): Likewise.
	* elf32-cris.c (elf_cris_finish_dynamic_symbol): Likewise.
	* elf32-hppa.c (elf32_hppa_finish_dynamic_symbol): Likewise.
	* elf32-i386.c (elf_i386_convert_mov_to_lea): Likewise.
	* elf32-lm32.c (lm32_elf_finish_dynamic_symbol): Likewise.
	* elf32-m32r.c (m32r_elf_finish_dynamic_symbol): Likewise.
	* elf32-s390.c (elf_s390_finish_dynamic_symbol): Likewise.
	* elf32-sh.c (sh_elf_finish_dynamic_symbol): Likewise.
	* elf32-tic6x.c (elf32_tic6x_finish_dynamic_symbol): Likewise.
	* elf32-tilepro.c (tilepro_elf_finish_dynamic_symbol): Likewise.
	* elf32-vax.c (elf_vax_finish_dynamic_symbol): Likewise.
	* elf32-xtensa.c (elf_xtensa_finish_dynamic_symbol): Likewise.
	* elf64-aarch64.c elf64_aarch64_finish_dynamic_symbol(): Likewise.
	* elf64-alpha.c (elf64_alpha_finish_dynamic_symbol): Likewise.
	* elf64-ia64-vms.c (elf64_ia64_finish_dynamic_symbol): Likewise.
	* elf64-s390.c (elf_s390_finish_dynamic_symbol): Likewise.
	* elf64-sh64.c (sh64_elf64_finish_dynamic_symbol): Likewise.
	* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise.
	* elfnn-ia64.c (elfNN_ia64_finish_dynamic_symbol): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_symbol): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_symbol): Likewise.
	* elfxx-tilegx.c (tilegx_elf_finish_dynamic_symbol): Likewise.

	* elf32-microblaze.c (microblaze_elf_finish_dynamic_symbol): Check
	hdynamic, hgot, hplt instead of _DYNAMIC, _GLOBAL_OFFSET_TABLE_,
	_PROCEDURE_LINKAGE_TABLE_.
	* elf32-score.c (s3_bfd_score_elf_finish_dynamic_symbol): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_finish_dynamic_symbol): Likewise.
2012-09-02 12:17:27 +00:00
H.J. Lu 3f65f59941 Don't optimize relocation against _DYNAMIC
bfd/

	* elf32-i386.c (elf_i386_convert_mov_to_lea): Don't optimize
	_DYNAMIC.
	* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise.

ld/testsuite/

	* ld-i386/i386.exp: Run mov1a, mov1b.
	* ld-x86-64/x86-64.exp: Run mov1a, mov1b, mov1c, mov1d.

	* ld-i386/mov1.s: New file.
	* ld-i386/mov1a.d: Likewise.
	* ld-i386/mov1b.d: Likewise.
	* ld-x86-64/mov1.s: Likewise.
	* ld-x86-64/mov1a.d: Likewise.
	* ld-x86-64/mov1b.d: Likewise.
	* ld-x86-64/mov1c.d: Likewise.
	* ld-x86-64/mov1d.d: Likewise.
2012-09-01 02:50:14 +00:00
H.J. Lu daa6760707 Convert mov to lea in size_dynamic_sections
bfd/

	* elf32-i386.c (elf_i386_convert_mov_to_lea): New.
	(elf_i386_size_dynamic_sections): Use it on input sections.
	(elf_i386_relocate_section): Don't convert
	"mov foo@GOT(%reg), %reg" to "lea foo@GOTOFF(%reg), %reg"
	for local symbols here.

	* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): New.
	(elf_x86_64_size_dynamic_sections): Use it on input sections.
	(elf_x86_64_relocate_section): Don't convert
	"mov foo@GOTPCREL(%rip), %reg" to "lea foo@GOTOFF(%reg), %reg"
	for local symbols.

ld/testsuite/

	* ld-i386/i386.exp: Run lea1d, lea1f, lea1f.
	* ld-x86-64/x86-64.exp: Run lea1g, lea1h, lea1i, lea1j, lea1k,
	lea1l.

	* ld-ifunc/ifunc-13-i386.d: Remove R_386_RELATIVE entry.

	* ld-i386/lea1d.d: New file.
	* ld-i386/lea1e.d: Likewise.
	* ld-i386/lea1f.d: Likewise.
	* ld-x86-64/lea1g.d: Likewise.
	* ld-x86-64/lea1h.d: Likewise.
	* ld-x86-64/lea1i.d: Likewise.
	* ld-x86-64/lea1j.d: Likewise.
	* ld-x86-64/lea1k.d: Likewise.
	* ld-x86-64/lea1l.d: Likewise.
2012-08-31 20:41:41 +00:00
H.J. Lu 80d873266d Convert mov to lea for loading local function address
bfd/

	* elf32-i386.c (elf_i386_relocate_section): Convert
	"mov foo@GOT(%reg), %reg" to "lea foo@GOTOFF(%reg), %reg"
	for local symbols.

	* elf64-x86-64.c (elf_x86_64_relocate_section): Convert
	"mov foo@GOTPCREL(%rip), %reg" to "lea foo(%rip), %reg"
	for local symbols.

ld/testsuite/

	* ld-i386/i386.exp: Run lea1a, lea1b, lea1c.
	* ld-x86-64/x86-64.exp: Run lea1a, lea1b, lea1c, lea1d, lea1e,
	lea1f.

	* ld-i386/lea1.s: New file.
	* ld-i386/lea1a.d: Likewise.
	* ld-i386/lea1b.d: Likewise.
	* ld-i386/lea1c.d: Likewise.
	* ld-x86-64/lea1.s: Likewise.
	* ld-x86-64/lea1a.d: Likewise.
	* ld-x86-64/lea1b.d: Likewise.
	* ld-x86-64/lea1c.d: Likewise.
	* ld-x86-64/lea1d.d: Likewise.
	* ld-x86-64/lea1e.d: Likewise.
	* ld-x86-64/lea1f.d: Likewise.
2012-08-31 04:26:17 +00:00
Alan Modra 3d4d4302b9 * section.c (bfd_get_linker_section): New function.
* elf32-arm.c: When retrieving SEC_LINKER_CREATED sections, use
	the above throughout rather than bfd_get_section_by_name.  Use
	bfd_make_section_anyway rather than bfd_make_section when creating
	them.
	* elf32-bfin.c: Likewise.
	* elf32-cr16.c: Likewise.
	* elf32-cris.c: Likewise.
	* elf32-frv.c: Likewise.
	* elf32-hppa.c: Likewise.
	* elf32-i370.c: Likewise.
	* elf32-i386.c: Likewise.
	* elf32-lm32.c: Likewise.
	* elf32-m32c.c: Likewise.
	* elf32-m32r.c: Likewise.
	* elf32-m68k.c: Likewise.
	* elf32-microblaze.c: Likewise.
	* elf32-ppc.c: Likewise.
	* elf32-rl78.c: Likewise.
	* elf32-s390.c: Likewise.
	* elf32-score.c: Likewise.
	* elf32-score7.c: Likewise.
	* elf32-sh.c: Likewise.
	* elf32-tic6x.c: Likewise.
	* elf32-tilepro.c: Likewise.
	* elf32-vax.c: Likewise.
	* elf32-xstormy16.c: Likewise.
	* elf32-xtensa.c: Likewise.
	* elf64-alpha.c: Likewise.
	* elf64-hppa.c: Likewise.
	* elf64-ia64-vms.c: Likewise.
	* elf64-ppc.c: Likewise.
	* elf64-s390.c: Likewise.
	* elf64-sh64.c: Likewise.
	* elf64-sparc.c: Likewise.
	* elf64-x86-64.c: Likewise.
	* elfnn-ia64.c: Likewise.
	* elfxx-mips.c: Likewise.
	* elfxx-sparc.c: Likewise.
	* elfxx-tilegx.c: Likewise.
	* elflink.c: Likewise.
	* elf-vxworks.c: Likewise.
	* elf-m10300.c: Likewise.  Also make use of htab plt, got and
	gotplt shortcuts.
	* bfd-in2.h: Regenerate.
	* elf32-lm32.c (lm32_elf_check_relocs): Use the correct bfd when
	calling create_rofixup_section.
	* elflink.c (bfd_elf_final_link): Simplify test for .dynstr.
2012-06-29 14:46:03 +00:00
H.J. Lu bbf96e4eef Don't use dynamic_sec_flags on PLT .eh_frame section
* elf32-i386.c (elf_i386_create_dynamic_sections): Don't use
	dynamic_sec_flags to create PLT .eh_frame section.
	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Likewise.
2012-05-25 16:20:15 +00:00
Alan Modra 9a2a56cc5a PR ld/13909
* elf-eh-frame.c (_bfd_elf_eh_frame_present): New function.
	(_bfd_elf_maybe_strip_eh_frame_hdr): Use it here.
	* elf-bfd.h (_bfd_elf_eh_frame_present): Declare.
	* elflink.c (bfd_elf_size_dynamic_sections): Let the backend
	size dynamic sections before stripping eh_frame_hdr.
	(bfd_elf_gc_sections): Handle multiple .eh_frame sections.
	* elf32-ppc.c (ppc_elf_size_dynamic_sections): Drop glink_eh_frame
	if no other .eh_frame sections exist.
	* elf64-ppc.c (ppc64_elf_size_stubs): Likewise.
	* elf32-i386.c (elf_i386_create_dynamic_sections): Don't size
	or alloc plt_eh_frame here..
	(elf_i386_size_dynamic_sections): ..do it here instead.  Don't
	specially keep sgotplt, iplt, tgotplt, sdynbss for symbols.
	(elf_i386_finish_dynamic_sections): Check plt_eh_frame->contents
	before writing plt offset.
	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Don't size
	or alloc plt_eh_frame here..
	(elf_x86_64_size_dynamic_sections): ..do it here instead.
	(elf_x86_64_finish_dynamic_sections): Check plt_eh_frame->contents
	before writing plt offset.
2012-05-25 01:12:20 +00:00
H.J. Lu e4de50d447 Revert the change for PR ld/r13909
bfd/

	PR ld/13909
	* elf32-i386.c (elf_i386_create_dynamic_sections): Revert the
	last change.
	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Likewise.

ld/testsuite/

2012-05-22  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13909
	* ld-i386/i386.exp: Revert the last change.
	* ld-x86-64/x86-64.exp: Likewise.

	* ld-i386/dummy.s: Removed.
	* ld-i386/pr13909.d: Likewise.
	* ld-x86-64/pr13909.d: Likewise.
2012-05-22 15:55:01 +00:00
H.J. Lu 5d4f7eb2f0 Create PLT eh_frame section if there is .eh_frame section
bfd/

	PR ld/13909
	* elf32-i386.c (elf_i386_create_dynamic_sections): Create PLT
	eh_frame section if there is an input .eh_frame section.
	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Likewise.

ld/testsuite/

	PR ld/13909
	* ld-i386/i386.exp: Run pr13909.
	* ld-x86-64/x86-64.exp: Likewise.

	* ld-i386/dummy.s: New file.
	* ld-i386/pr13909.d: Likewise.
	* ld-x86-64/pr13909.d: Likewise.
2012-05-22 14:46:44 +00:00
H.J. Lu 2fe0fd0638 Always create PLT eh_frame section for i386/x86-64
bfd/

2012-05-22  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/14105
	* elf32-i386.c (elf_i386_create_dynamic_sections): Always
	create PLT eh_frame section with SEC_LINKER_CREATED.
	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Likewise.

ld/testsuite/

2012-05-20  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/14105
	* ld-elf/eh4.d: Add PLT eh_frame.

	* ld-i386/i386.exp: Run pr12570a and pr12570b.
	* ld-x86-64/x86-64.exp: Likewise.

	* ld-i386/pr12570a.d: New file.
	* ld-i386/pr12570a.s: Likewise.
	* ld-i386/pr12570b.s: Likewise.
	* ld-i386/pr12570b.s: Likewise.
	* ld-x86-64/pr12570a.d: Likewise.
	* ld-x86-64/pr12570a.s: Likewise.
	* ld-x86-64/pr12570b.d: Likewise.
	* ld-x86-64/pr12570b.s: Likewise.
2012-05-22 14:05:21 +00:00
H.J. Lu 220cf8092f Don't make _DYNAMIC/_GLOBAL_OFFSET_TABLE_ absolute
bfd/

	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Don't make
	_DYNAMIC nor _GLOBAL_OFFSET_TABLE_ absolute.
	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.

ld/testsuite/

	* ld-i386/tlsdesc-nacl.rd: Update for dynamic sym changes.
	* ld-i386/tlsdesc.rd: Likewise.
	* ld-i386/tlsgdesc-nacl.rd: Likewise.
	* ld-i386/tlsgdesc.rd: Likewise.
	* ld-i386/tlsnopic-nacl.rd: Likewise.
	* ld-i386/tlsnopic.rd: Likewise.
	* ld-i386/tlspic-nacl.rd: Likewise.
	* ld-i386/tlspic.rd: Likewise.
	* ld-x86-64/tlsdesc-nacl.rd: Likewise.
	* ld-x86-64/tlsdesc.rd: Likewise.
	* ld-x86-64/tlsgdesc-nacl.rd: Likewise.
	* ld-x86-64/tlsgdesc.rd: Likewise.
	* ld-x86-64/tlspic-nacl.rd: Likewise.
	* ld-x86-64/tlspic.rd: Likewise.
2012-05-18 22:26:18 +00:00
Maciej W. Rozycki 545fd46b6b * elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Handle compound
relocations.
	* elfxx-mips.c (mips_reloc_against_discarded_section): New
	function.
	(_bfd_mips_elf_relocate_section): Call it, in place of
	RELOC_AGAINST_DISCARDED_SECTION.
	* elf-m10200.c (mn10200_elf_relocate_section): Update arguments
	to RELOC_AGAINST_DISCARDED_SECTION.
	* elf-m10300.c (mn10300_elf_relocate_section): Likewise.
	* elf32-arm.c (elf32_arm_relocate_section): Likewise.
	* elf32-avr.c (elf32_avr_relocate_section): Likewise.
	* elf32-bfin.c (bfin_relocate_section): Likewise.
	(bfinfdpic_relocate_section): Likewise.
	* elf32-cr16.c (elf32_cr16_relocate_section): Likewise.
	* elf32-cr16c.c (elf32_cr16c_relocate_section): Likewise.
	* elf32-cris.c (cris_elf_relocate_section): Likewise.
	* elf32-crx.c (elf32_crx_relocate_section): Likewise.
	* elf32-d10v.c (elf32_d10v_relocate_section): Likewise.
	* elf32-epiphany.c (epiphany_elf_relocate_section): Likewise.
	* elf32-fr30.c (fr30_elf_relocate_section): Likewise.
	* elf32-frv.c (elf32_frv_relocate_section): Likewise.
	* elf32-h8300.c (elf32_h8_relocate_section): Likewise.
	* elf32-hppa.c (elf32_hppa_relocate_section): Likewise.
	* elf32-i370.c (i370_elf_relocate_section): Likewise.
	* elf32-i386.c (elf_i386_relocate_section): Likewise.
	* elf32-i860.c (elf32_i860_relocate_section): Likewise.
	* elf32-ip2k.c (ip2k_elf_relocate_section): Likewise.
	* elf32-iq2000.c (iq2000_elf_relocate_section): Likewise.
	* elf32-lm32.c (lm32_elf_relocate_section): Likewise.
	* elf32-m32c.c (m32c_elf_relocate_section): Likewise.
	* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
	* elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Likewise.
	* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
	* elf32-mcore.c (mcore_elf_relocate_section): Likewise.
	* elf32-mep.c (mep_elf_relocate_section): Likewise.
	* elf32-moxie.c (moxie_elf_relocate_section): Likewise.
	* elf32-msp430.c (elf32_msp430_relocate_section): Likewise.
	* elf32-mt.c (mt_elf_relocate_section): Likewise.
	* elf32-openrisc.c (openrisc_elf_relocate_section): Likewise.
	* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
	* elf32-rl78.c (rl78_elf_relocate_section): Likewise.
	* elf32-rx.c (rx_elf_relocate_section): Likewise.
	* elf32-s390.c (elf_s390_relocate_section): Likewise.
	* elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise.
	* elf32-sh.c (sh_elf_relocate_section): Likewise.
	* elf32-spu.c (spu_elf_relocate_section): Likewise.
	* elf32-tic6x.c (elf32_tic6x_relocate_section): Likewise.
	* elf32-tilepro.c (tilepro_elf_relocate_section): Likewise.
	* elf32-v850.c (v850_elf_relocate_section): Likewise.
	* elf32-vax.c (elf_vax_relocate_section): Likewise.
	* elf32-xc16x.c (elf32_xc16x_relocate_section): Likewise.
	* elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise.
	* elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
	* elf64-alpha.c (elf64_alpha_relocate_section_r): Likewise.
	(elf64_alpha_relocate_section): Likewise.
	* elf64-hppa.c (elf64_hppa_relocate_section): Likewise.
	* elf64-mmix.c (mmix_elf_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.
	* elfnn-ia64.c (elfNN_ia64_relocate_section): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.
	* elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise.
2012-05-07 03:27:52 +00:00
Alan Modra dbaa201145 PR ld/13991
bfd/
	* bfd/elf-bfd.h (_bfd_elf_link_just_syms): Define as
	_bfd_generic_link_just_syms.
	* bfd/elflink.c (_bfd_elf_link_just_syms): Delete.
	* bfd/linker.c (_bfd_generic_link_just_syms): Set sec_info_type.

	* bfd/bfd-in.h (discarded_section): Renamed from elf_discarded_section.
	* bfd/section.c (SEC_INFO_TYPE_NONE, SEC_INFO_TYPE_STABS,
	SEC_INFO_TYPE_MERGE, SEC_INFO_TYPE_EH_FRAME,
	SEC_INFO_TYPE_JUST_SYMS): Renamed from corresponding ELF_INFO_TYPE.
	* bfd/elf-eh-frame.c, * bfd/elf-m10200.c, * bfd/elf-m10300.c,
	* bfd/elf.c, * bfd/elf32-arm.c, * bfd/elf32-avr.c, * bfd/elf32-bfin.c,
	* bfd/elf32-cr16.c, * bfd/elf32-cr16c.c, * bfd/elf32-cris.c,
	* bfd/elf32-crx.c, * bfd/elf32-d10v.c, * bfd/elf32-epiphany.c,
	* bfd/elf32-fr30.c, * bfd/elf32-frv.c, * bfd/elf32-h8300.c,
	* bfd/elf32-hppa.c, * bfd/elf32-i370.c, * bfd/elf32-i386.c,
	* bfd/elf32-i860.c, * bfd/elf32-ip2k.c, * bfd/elf32-iq2000.c,
	* bfd/elf32-lm32.c, * bfd/elf32-m32c.c, * bfd/elf32-m32r.c,
	* bfd/elf32-m68hc1x.c, * bfd/elf32-m68k.c, * bfd/elf32-mcore.c,
	* bfd/elf32-mep.c, * bfd/elf32-moxie.c, * bfd/elf32-msp430.c,
	* bfd/elf32-mt.c, * bfd/elf32-openrisc.c, * bfd/elf32-ppc.c,
	* bfd/elf32-rl78.c, * bfd/elf32-rx.c, * bfd/elf32-s390.c,
	* bfd/elf32-score.c, * bfd/elf32-score7.c, * bfd/elf32-sh.c,
	* bfd/elf32-spu.c, * bfd/elf32-tic6x.c, * bfd/elf32-tilepro.c,
	* bfd/elf32-v850.c, * bfd/elf32-vax.c, * bfd/elf32-xc16x.c,
	* bfd/elf32-xstormy16.c, * bfd/elf32-xtensa.c, * bfd/elf64-alpha.c,
	* bfd/elf64-hppa.c, * bfd/elf64-ia64-vms.c, * bfd/elf64-mmix.c,
	* bfd/elf64-ppc.c, * bfd/elf64-s390.c, * bfd/elf64-sh64.c,
	* bfd/elf64-x86-64.c, * bfd/elflink.c, * bfd/elfnn-ia64.c,
	* bfd/elfxx-mips.c, * bfd/elfxx-sparc.c, * bfd/elfxx-tilegx.c,
	* bfd/reloc.c: Update all references.
	* bfd/bfd-in2.h: Regenerate.
ld/
	* ld/ldlang.c (size_input_section): Use sec_info_type rather than
	usrdata->flags.just_syms.
	* ld/ldwrite.c (build_link_order): Likewise.
	* ld/emultempl/hppaelf.em (build_section_lists): Likewise.
	* ld/emultempl/ppc64elf.em (build_toc_list): Likewise.
	* ld/emultempl/armelf.em (build_section_lists): Likewise.
	(after_allocation): Update for renamed sec_info_type value.
	* ld/emultempl/tic6xdsbt.em: Likewise.
2012-04-24 05:12:40 +00:00
Roland McGrath 5a68afcf73 bfd/
2012-04-03  Roland McGrath  <mcgrathr@google.com>

	* elf-nacl.c: New file.
	* elf-nacl.h: New file.
	* elf32-i386.c (elf_backend_modify_segment_map): Define for
	bfd_elf32_i386_nacl_vec.
	(elf_backend_modify_program_headers): Likewise.
	* elf64-x86-64.c (elf_backend_modify_segment_map): Define for
	bfd_elf64_x86_64_nacl_vec and bfd_elf32_x86_64_nacl_vec.
	(elf_backend_modify_program_headers): Likewise.
	* Makefile.am (BFD32_BACKENDS, BFD64_BACKENDS): Add elf-nacl.lo here.
	(BFD32_BACKENDS_CFILES, BFD64_BACKENDS_CFILES): Add elf-nacl.c here.
	* Makefile.in: Regenerated.
	* configure.in (bfd_elf64_x86_64_nacl_vec): Add elf-nacl.o to tb here.
	(bfd_elf32_x86_64_nacl_vec): Likewise.
	(bfd_elf64_x86_64_vec, bfd_elf32_x86_64_vec): Likewise.
	(bfd_elf64_x86_64_freebsd_vec, bfd_elf64_x86_64_sol2_vec): Likewise.
	(bfd_elf64_l1om_vec, bfd_elf64_l1om_freebsd_vec): Likewise.
	(bfd_elf64_k1om_vec, bfd_elf64_k1om_freebsd_vec): Likewise.
	(bfd_elf32_i386_nacl_vec): Likewise.
	(bfd_elf32_i386_sol2_vec, bfd_elf32_i386_freebsd_vec): Likewise.
	(bfd_elf32_i386_vxworks_vec, bfd_elf32_i386_vec): Likewise.
	* configure: Regenerated.

binutils/testsuite/
2012-04-03  Roland McGrath  <mcgrathr@google.com>

	* lib/binutils-common.exp (is_elf_format): Consider *-*-nacl* to
	be ELF too.

	* binutils-all/elfedit-4.d: Add "#as: --64" option.

	* binutils-all/i386/i386.exp: Accept nacl targets too.
	* binutils-all/x86-64/x86-64.exp: Likewise.

gas/testsuite/
2012-04-03  Roland McGrath  <mcgrathr@google.com>

	* gas/i386/k1om.d: Add not-target match for *-*-nacl*.
	* gas/i386/l1om.d: Likewise.

ld/
2012-04-03  Roland McGrath  <mcgrathr@google.com>

	* configure.tgt (i[3-7]86-*-nacl*, x86_64-*-nacl*): Handle them.
	* emulparams/elf_nacl.sh: New file.
	* emulparams/elf_i386_nacl.sh: New file.
	* emulparams/elf32_x86_64_nacl.sh: New file.
	* emulparams/elf_x86_64_nacl.sh: New file.
	* Makefile.am (ALL_EMULATION_SOURCES): Add eelf_i386_nacl.c here.
	(ALL_64_EMULATION_SOURCES): Add eelf32_x86_64_nacl.c and
	eelf_x86_64_nacl.c here.
	(eelf_i386_nacl.c, eelf32_x86_64_nacl.c, eelf_x86_64_nacl.c):
	New targets.
	* Makefile.in: Regenerated.

	* scripttempl/elf.sc: Handle SEPARATE_CODE cases.

ld/testsuite/
2012-04-03  Roland McGrath  <mcgrathr@google.com>

	* ld-x86-64/ilp32-4-nacl.d: New file.
	* ld-x86-64/x86-64.exp: Run it.

	* ld-discard/discard.exp: Accept nacl targets too.
	* ld-elf/binutils.exp: Likewise.
	* ld-elf/comm-data.exp: Likewise.
	* ld-elf/elf.exp: Likewise.
	* ld-elf/tls_common.exp: Likewise.
	* ld-elfvers/vers.exp: Likewise.
	* ld-elfvsb/elfvsb.exp: Likewise.
	* ld-elfweak/elfweak.exp: Likewise.
	* ld-gc/gc.exp: Likewise.
	* ld-ifunc/binutils.exp: Likewise.
	* ld-ifunc/ifunc.exp: Likewise.
	* ld-linkonce/linkonce.exp:Likewise.
	* ld-pie/pie.exp: Likewise.
	* ld-shared/shared.exp: Likewise.
	* ld-undefined/weak-undef.exp: Likewise.
	* ld-unique/unique.exp: Likewise.
	* ld-x86-64/dwarfreloc.exp: Likewise.
	* ld-x86-64/line.exp: Likewise.

	* lib/ld-lib.exp (slurp_options): Support global array
	options_regsub to apply substitutions to the contents
	of options lines read from the file.
	* ld-i386/emit-relocs.d: Renamed to ...
	* ld-i386/emit-relocs.rd: ... this.
	* ld-i386/i386.exp: Accept nacl targets too.
	For them, use options_regsub to replace elf_i386 with
	elf_i386_nacl in run_dump_test cases; apply the same
	substitution in $i386tests; replace foo.rd expectations
	files with foo-nacl.rd in $i386tests.
	(i386tests): Change emit-relocs.d to emit-relocs.rd here.
	* ld-i386/emit-relocs-nacl.rd: New file.
	* ld-i386/plt-nacl.pd: New file.
	* ld-i386/plt-pic-nacl.pd: New file.
	* ld-i386/tlsbin-nacl.rd: New file.
	* ld-i386/tlsbindesc-nacl.rd: New file.
	* ld-i386/tlsdesc-nacl.rd: New file.
	* ld-i386/tlsgdesc-nacl.rd: New file.
	* ld-i386/tlsnopic-nacl.rd: New file.
	* ld-i386/tlspic-nacl.rd: New file.
	* ld-x86-64/x86-64.exp: Accept nacl targets too.
	For them, use options_regsub to replace elf_x86_64 with
	elf_x86_64_nacl in run_dump_test cases; apply the same
	substitution in $x86_64tests; replace foo.rd expectations
	files with foo-nacl.rd in $x86_64tests.
	Add explicit -melf_x86_64 to ld options in tests that need it,
	in case the default emulation is x32 (as it is for x86_64-nacl).
	* ld/testsuite/ld-x86-64/plt-nacl.pd: New file.
	* ld/testsuite/ld-x86-64/split-by-file-nacl.rd: New file.
	* ld/testsuite/ld-x86-64/tlsbin-nacl.rd: New file.
	* ld/testsuite/ld-x86-64/tlsbindesc-nacl.rd: New file.
	* ld/testsuite/ld-x86-64/tlsdesc-nacl.pd: New file.
	* ld/testsuite/ld-x86-64/tlsdesc-nacl.rd: New file.
	* ld/testsuite/ld-x86-64/tlsgdesc-nacl.rd: New file.
	* ld/testsuite/ld-x86-64/tlspic-nacl.rd: New file.

	* ld-i386/hidden2.d: Loosen regexps to match any file format variant,
	and not to depend on exact addresses, displacements, etc. where
	they are irrelevant.
	* ld-i386/pcrel16.d: Likewise.
	* ld-i386/pcrel16abs.d: Likewise.
	* ld-i386/pr12718.d: Likewise.
	* ld-i386/pr12921.d: Likewise.
	* ld-i386/reloc.d: Likewise.
	* ld-i386/tlsbin.dd: Likewise.
	* ld-i386/tlsbin.sd: Likewise.
	* ld-i386/tlsbin.td: Likewise.
	* ld-i386/tlsbindesc.dd: Likewise.
	* ld-i386/tlsbindesc.sd: Likewise.
	* ld-i386/tlsbindesc.td: Likewise.
	* ld-i386/tlsdesc.dd: Likewise.
	* ld-i386/tlsdesc.sd: Likewise.
	* ld-i386/tlsdesc.td: Likewise.
	* ld-i386/tlsg.sd: Likewise.
	* ld-i386/tlsgdesc.dd: Likewise.
	* ld-i386/tlsindntpoff.dd: Likewise.
	* ld-i386/tlsnopic.dd: Likewise.
	* ld-i386/tlsnopic.sd: Likewise.
	* ld-i386/tlspic.dd: Likewise.
	* ld-i386/tlspic.sd: Likewise.
	* ld-i386/tlspic.td: Likewise.
	* ld-i386/tlspie2.d: Likewise.
	* ld-x86-64/hidden2.d: Likewise.
	* ld-x86-64/pcrel16.d: Likewise.
	* ld-x86-64/pr12718.d: Likewise.
	* ld-x86-64/pr12921.d: Likewise.
	* ld-x86-64/protected3.d: Likewise.
	* ld-x86-64/tlsbin.dd: Likewise.
	* ld-x86-64/tlsbin.sd: Likewise.
	* ld-x86-64/tlsbin.td: Likewise.
	* ld-x86-64/tlsbindesc.dd: Likewise.
	* ld-x86-64/tlsbindesc.sd: Likewise.
	* ld-x86-64/tlsbindesc.td: Likewise.
	* ld-x86-64/tlsdesc.dd: Likewise.
	* ld-x86-64/tlsdesc.sd: Likewise.
	* ld-x86-64/tlsdesc.td: Likewise.
	* ld-x86-64/tlsg.sd: Likewise.
	* ld-x86-64/tlsgd5.dd: Likewise.
	* ld-x86-64/tlsgd6.dd: Likewise.
	* ld-x86-64/tlsgdesc.dd: Likewise.
	* ld-x86-64/tlspic.dd: Likewise.
	* ld-x86-64/tlspic.sd: Likewise.
	* ld-x86-64/tlspic.td: Likewise.

	* ld-x86-64/ilp32-8.d: Match any file format variant.
	Use a -Ttext and adjust expected results, to handle variant layouts.
	* ld-x86-64/ilp32-9.d: Likewise.

	* ld-i386/alloc.t: Remove superfluous OUTPUT_FORMAT statement.
	* ld-i386/pr12627.t: Likewise.

	* ld-x86-64/abs-l1om.d: Add target: constraint.
	* ld-x86-64/protected2-l1om.d: Likewise.
	* ld-x86-64/protected3-l1om.d: Likewise.
	* ld-x86-64/ilp32-4.d: Likewise.

	* ld-x86-64/plt.s: New file.
	* ld-x86-64/pltlib.s: New file.
	* ld-x86-64/plt.pd: New file.
	* ld-x86-64/x86-64.exp (x86_64tests): Add them.

	* ld-i386/plt.s: New file.
	* ld-i386/pltlib.s: New file.
	* ld-i386/plt.pd: New file.
	* ld-i386/plt-pic.s: New file.
	* ld-i386/plt-pic.pd: New file.
	* ld-i386/i386.exp (i386tests): Add them.
2012-04-03 16:01:38 +00:00
H.J. Lu bdb892b995 Handle relocation against protected function for -Bsymbolic
bfd/

2012-03-20  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13880
	* elf32-i386.c (elf_i386_relocate_section): Don't issue an error
	for R_386_GOTOFF relocation against protected function if
	SYMBOLIC_BIND is true.

	* elf64-x86-64.c (elf_x86_64_relocate_section): Don't issue an
	error for R_X86_64_GOTOFF64 relocation against protected function
	when building executable or SYMBOLIC_BIND is true.

ld/testsuite/

2012-03-20  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13880
	* ld-i386/i386.exp: Run protected4 and protected5.
	* ld-x86-64/x86-64.exp: Likewise.

	* ld-i386/protected4.d: New.
	* ld-i386/protected4.s: Likewise.
	* ld-i386/protected5.d: Likewise.
	* ld-i386/protected5.s: Likewise.
	* ld-x86-64/protected4.d: Likewise.
	* ld-x86-64/protected4.s: Likewise.
	* ld-x86-64/protected5.d: Likewise.
	* ld-x86-64/protected5.s: Likewise.
2012-03-20 18:16:38 +00:00
Roland McGrath caa0075c38 * elf32-i386.c (elf_i386_nacl_pic_plt0_entry): Initialize up
to the full size, padding out with nop instructions.
2012-03-14 19:32:11 +00:00
Alan Modra 1d7e9d183f * elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Don't error
on zero size dynbss symbol.
	* elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise.
	* elf32-cr16.c (_bfd_cr16_elf_adjust_dynamic_symbol): Likewise.
	* elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise.
	* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise.
	* elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise.
	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Likewise.
	* elf32-lm32.c (lm32_elf_adjust_dynamic_symbol): Likewise.
	* elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise.
	* elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
	* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise.
	* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
	* elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise.
	* elf32-tic6x.c (elf32_tic6x_adjust_dynamic_symbol): Likewise.
	* elf32-tilepro.c (tilepro_elf_adjust_dynamic_symbol): Likewise.
	* elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise.
	* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
	* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
	* elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise.
	* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_adjust_dynamic_symbol): Likewise.
	* elfxx-tilegx.c (tilegx_elf_adjust_dynamic_symbol): Likewise.
2012-03-13 06:04:37 +00:00
H.J. Lu 56b8aada47 Restore R_386_IRELATIVE and R_X86_64_IRELATIVE
bfd/

2012-03-09  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13817
	* bfd/elf32-i386.c (elf_i386_relocate_section): Restore
	R_386_IRELATIVE.

	* * elf64-x86-64.c (elf_x86_64_relocate_section): Restore
	R_X86_64_IRELATIVE.

ld/testsuite/

2012-03-09  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13817
	* ld-i386/pr13302.d: Updated.
	* ld-x86-64/pr13082-5b.d: Likewise.
	* ld-x86-64/pr13082-6a.d: Likewise.
	* ld-x86-64/pr13082-6b.d: Likewise.
2012-03-09 16:28:38 +00:00
H.J. Lu 9892017203 Replace IRELATIVE relocations with RELATIVE in .rel.dyn.
bfd/

2011-10-21  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13302
	* elf32-i386.c (elf_i386_relocate_section): Replace
	R_386_IRELATIVE with R_386_RELATIVE.

	* elf64-x86-64.c (elf_x86_64_relocate_section): Replace
	R_X86_64_IRELATIVE with R_X86_64_RELATIVE.

ld/testsuite/

2011-10-21  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13302
	* ld-i386/i386.exp: Run pr13302.

	* ld-i386/pr13302.d: New.
	* ld-i386/pr13302.s: Likewise.

	* ld-x86-64/pr13082-5b.d: Updated.
	* ld-x86-64/pr13082-6a.d: Likewise.
	* ld-x86-64/pr13082-6b.d: Likewise.
2011-10-21 19:37:15 +00:00
H.J. Lu c293fa4964 Fix a typo in comments.
2011-10-21  H.J. Lu  <hongjiu.lu@intel.com>.

	* elf32-i386.c (elf_i386_relocate_section): Fix a typo in
	comments.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
2011-10-21 16:16:51 +00:00
H.J. Lu e1f987424b Put IRELATIVE relocations after JUMP_SLOT.
bfd/

2011-10-21  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13302
	* elf32-i386.c (elf_i386_link_hash_table): Add next_jump_slot_index
	and next_irelative_index.
	(elf_i386_link_hash_table_create): Initialize next_jump_slot_index
	and next_irelative_index.
	(elf_i386_allocate_dynrelocs): Increment reloc_count instead of
	next_tls_desc_index.
	(elf_i386_size_dynamic_sections): Set next_tls_desc_index and
	next_irelative_index from reloc_count.
	(elf_i386_finish_dynamic_symbol): Put R_386_IRELATIVE after
	R_386_JUMP_SLOT.

	* elf64-x86-64.c (elf_x86_64_link_hash_table): Add
	next_jump_slot_index and next_irelative_index.
	(elf_x86_64_link_hash_table_create): Initialize
	next_jump_slot_index and next_irelative_index.
	(elf_x86_64_size_dynamic_sections): Set next_irelative_index
	from reloc_count.
	(elf_x86_64_finish_dynamic_symbol): Put R_X86_64_IRELATIVE after
	R_X86_64_JUMP_SLOT.

ld/testsuite/

2011-10-21  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13302
	* ld-ifunc/ifunc-16-i386.d: New.
	* ld-ifunc/ifunc-16-x86-64.d: Likewise.
	* ld-ifunc/ifunc-16-x86.s: Likewise.
2011-10-21 15:13:37 +00:00
Alan Modra fa289a5fde * elf32-i386.c (i386_opcode16): Delete.
(elf_i386_check_tls_transition): Use memcmp to compare contents.
	* elf64-x86-64.c (x86_64_opcode16, x86_64_opcode32): Delete.
	(elf_x86_64_check_tls_transition): Use memcmp to compare contents.
2011-10-19 23:02:50 +00:00
Alan Modra 1d5316ab67 PR ld/13177
bfd/
	* elflink.c (_bfd_elf_gc_mark_rsec): Set symbol "mark".
	(elf_gc_sweep_symbol): Don't test plt/got refcounts, instead test
	"mark".  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.
2011-10-19 07:17:21 +00:00
Roland McGrath a27e437177 BFD vector for elf32-i386-nacl:
bfd/
	* elf32-i386.c (NACL_PLT_ENTRY_SIZE, NACLMASK): New macros.
	(elf_i386_nacl_plt0_entry): New variable.
	(elf_i386_plt_entry): New variable.
	(elf_i386_nacl_pic_plt0_entry): New variable.
	(elf_i386_nacl_pic_plt_entry): New variable.
	(elf_i386_nacl_plt, elf_i386_nacl_arch_bed): New variables.
	(elf_backend_arch_data): New macro setting for elf_i386_nacl_vec stanza.
	(elf_backend_plt_alignment): Likewise.

	* config.bfd: Handle i[3-7]86-*-nacl*.
	* elf32-i386.c (bfd_elf32_i386_nacl_vec): New backend vector stanza.
	* targets.c: Support bfd_elf32_i386_nacl_vec.
	* configure.in: Likewise.
	* configure: Regenerated.
2011-07-28 22:35:15 +00:00
Roland McGrath 25e762b98d Parameterize elf32-i386 PLT generation:
* elf32-i386.c (struct elf_i386_plt_layout): New type.
	(GET_PLT_ENTRY_SIZE): New macro.
	(elf_i386_plt): New variable.
	(struct elf_i386_backend_data): New member `plt'.
	(elf_i386_arch_bed): Add initializer for it.
	(elf_i386_vxworks_arch_bed): Likewise.
	(elf_i386_allocate_dynrelocs): Use GET_PLT_ENTRY_SIZE.
	(elf_i386_plt_sym_val): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_finish_dynamic_symbol): Likewise.
	Also use other elf_i386_plt_layout members for PLT details.
	(elf_i386_finish_dynamic_sections): Likewise.
2011-07-28 18:47:56 +00:00
Roland McGrath 23209a7853 Clean up elf32-i386-vxworks:
* elf32-i386.c (struct elf_i386_backend_data): New type.
	(get_elf_i386_backend_data): New macro.
	(elf_i386_arch_bed): New variable.
	(elf_backend_arch_data): New macro.
	(struct elf_i386_link_hash_table): Remove plt0_pad_byte and is_vxworks.
	(elf_i386_link_hash_table_create): Don't initialize them.
	(elf_i386_create_dynamic_sections): Find is_vxworks flags in
	elf_i386_backend_data, not elf_i386_link_hash_table.
	(elf_i386_adjust_dynamic_symbol): Likewise.
	(elf_i386_allocate_dynrelocs): Likewise.
	(elf_i386_readonly_dynrelocs): Likewise.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_finish_dynamic_symbol): Likewise.
	(elf_i386_finish_dynamic_sections): Likewise.  Same for plt0_pad_byte.
	(elf_i386_vxworks_link_hash_table_create): Function removed.
	(elf_i386_vxworks_arch_bed): New variable.
	(elf_backend_arch_data): New macro in elf32-i386-vxworks stanza.

	* elf-bfd.h (elf_backend_data): New member arch_backend_data.
	* elfxx-target.h (elf_backend_arch_data): New macro.
	(elfNN_bed): Use it as initializer for the new member.
2011-07-28 17:39:20 +00:00
Ian Lance Taylor 28ede8be33 * elf32-i386.c (elf_i386_eh_frame_plt): Correct expression: change
DW_OP_lit3 to DW_OP_lit2.
2011-07-01 22:14:56 +00:00
Jan Kratochvil 332ce62bf3 bfd/
* elf64-x86-64.c (elf_x86_64_link_hash_table_create): Initialize
	PLT_EH_FRAME.
	* elf32-i386.c (elf_i386_link_hash_table): Likewise.
2011-06-25 00:43:15 +00:00
Jakub Jelinek e41b3a1379 PR ld/12570
include/
	* bfdlink.h (struct bfd_link_info): Add no_ld_generated_unwind_info
	option.
ld/
	* emultempl/elf32.em (OPTION_LD_GENERATED_UNWIND_INFO,
	OPTION_NO_LD_GENERATED_UNWIND_INFO): Define.
	(gld${EMULATION_NAME}_handle_option): Handle
	--ld-generated-unwind-info and --no-ld-generated-unwind-info.
	* ld.texinfo (--ld-generated-unwind-info,
	--no-ld-generated-unwind-info): Document.
bfd/
	* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Allow no relocations
	at all for linker created .eh_frame sections.
	(_bfd_elf_discard_section_eh_frame): Handle linker created
	.eh_frame sections with no relocations.
	* elf64-x86-64.c: Include dwarf2.h.
	(elf_x86_64_eh_frame_plt): New variable.
	(PLT_CIE_LENGTH, PLT_FDE_LENGTH, PLT_FDE_START_OFFSET,
	PLT_FDE_LEN_OFFSET): Define.
	(struct elf_x86_64_link_hash_table): Add plt_eh_frame field.
	(elf_x86_64_create_dynamic_sections): Create and fill in
	.eh_frame section for .plt section.
	(elf_x86_64_size_dynamic_sections): Write .plt section size
	into .eh_frame FDE covering .plt section.
	(elf_x86_64_finish_dynamic_sections): Write .plt section
	start into .eh_frame FDE covering .plt section.  Call
	_bfd_elf_write_section_eh_frame on htab->plt_eh_frame section.
	(elf_backend_plt_alignment): Define to 4.
	* elf32-i386.c: Include dwarf2.h.
	(elf_i386_eh_frame_plt): New variable.
	(PLT_CIE_LENGTH, PLT_FDE_LENGTH, PLT_FDE_START_OFFSET,
	PLT_FDE_LEN_OFFSET): Define.
	(struct elf_i386_link_hash_table): Add plt_eh_frame field.
	(elf_i386_create_dynamic_sections): Create and fill in
	.eh_frame section for .plt section.
	(elf_i386_size_dynamic_sections): Write .plt section size
	into .eh_frame FDE covering .plt section.
	(elf_i386_finish_dynamic_sections): Write .plt section
	start into .eh_frame FDE covering .plt section.  Call
	_bfd_elf_write_section_eh_frame on htab->plt_eh_frame section.
	(elf_backend_plt_alignment): Define to 4.
ld/testsuite/
	* ld-x86-64/x86-64.exp: Link some testcases with
	--no-ld-generated-unwind-info.
	* ld-x86-64/tlsbin.rd: Add --no-ld-generated-unwind-info to ld
	comment.
	* ld-x86-64/tlsdesc.dd: Likewise.
	* ld-x86-64/tlspic.dd: Likewise.
	* ld-x86-64/tlsdesc.sd: Likewise.
	* ld-x86-64/tlspic.rd: Likewise.
	* ld-x86-64/tlsbindesc.rd: Likewise.
	* ld-x86-64/tlsbindesc.sd: Likewise.
	* ld-x86-64/tlsbin.td: Likewise.
	* ld-x86-64/tlsdesc.pd: Likewise.
	* ld-x86-64/tlsdesc.td: Likewise.
	* ld-x86-64/tlsbindesc.dd: Likewise.
	* ld-x86-64/tlsbin.dd: Likewise.
	* ld-x86-64/tlsgdesc.rd: Likewise.
	* ld-x86-64/tlspic.sd: Likewise.
	* ld-x86-64/tlsbindesc.td: Likewise.
	* ld-x86-64/tlspic.td: Likewise.
	* ld-x86-64/tlsbin.sd: Likewise.
	* ld-x86-64/ilp32-4.d: Likewise.
	* ld-x86-64/tlsgdesc.dd: Add --no-ld-generated-unwind-info to ld
	comment.  Adjust.
	* ld-x86-64/tlsdesc.rd: Likewise.
	* ld-x86-64/tlsgd6.dd: Adjust.
	* ld-x86-64/tlsgd5.dd: Likewise.
	* ld-i386/i386.exp: Link some testcases with
	--no-ld-generated-unwind-info.
	* ld-i386/tlsbin.rd: Add --no-ld-generated-unwind-info to ld
	comment..
	* ld-i386/tlsdesc.dd: Likewise.
	* ld-i386/tlspic.dd: Likewise.
	* ld-i386/tlsdesc.sd: Likewise.
	* ld-i386/tlsgdesc.dd: Likewise.
	* ld-i386/tlsnopic.sd: Likewise.
	* ld-i386/tlspic.rd: Likewise.
	* ld-i386/tlsdesc.rd: Likewise.
	* ld-i386/tlsbindesc.rd: Likewise.
	* ld-i386/tlsbindesc.sd: Likewise.
	* ld-i386/tlsbin.td: Likewise.
	* ld-i386/tlsdesc.td: Likewise.
	* ld-i386/tlsnopic.dd: Likewise.
	* ld-i386/tlsbindesc.dd: Likewise.
	* ld-i386/tlsbin.dd: Likewise.
	* ld-i386/tlsgdesc.rd: Likewise.
	* ld-i386/tlspic.sd: Likewise.
	* ld-i386/tlsnopic.rd: Likewise.
	* ld-i386/tlsbindesc.td: Likewise.
	* ld-i386/tlspic.td: Likewise.
	* ld-i386/tlsbin.sd: Likewise.
2011-06-20 13:18:52 +00:00
Alan Modra 7686d77de3 * linker.c (bfd_link_hash_traverse): Follow warning symbol link.
(_bfd_generic_link_write_global_symbol, fix_syms): Don't handle
	warning symbols here.
	* elf-m10300.c (elf32_mn10300_finish_hash_table_entry): Likewise.
	* elf32-arm.c (allocate_dynrelocs_for_symbol,
	elf32_arm_readonly_dynrelocs): Likewise.
	* elf32-bfin.c (bfin_discard_copies): Likewise.
	* elf32-cris.c (elf_cris_adjust_gotplt_to_got,
	elf_cris_discard_excess_dso_dynamics,
	elf_cris_discard_excess_program_dynamics): Likewise.
	* elf32-hppa.c (allocate_plt_static, allocate_dynrelocs,
	clobber_millicode_symbols, readonly_dynrelocs): Likewise.
	* elf32-i370.c (i370_elf_adjust_dynindx): Likewise.
	* elf32-i386.c (elf_i386_allocate_dynrelocs,
	elf_i386_readonly_dynrelocs): Likewise.
	* elf32-lm32.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
	* elf32-m32c.c (m32c_relax_plt_check, m32c_relax_plt_realloc): Likewise.
	* elf32-m32r.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
	* elf32-m68k.c (elf_m68k_discard_copies): Likewise.
	* elf32-microblaze.c (allocate_dynrelocs): Likewise.
	* elf32-ppc.c (allocate_dynrelocs, maybe_set_textrel): Likewise.
	* elf32-s390.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
	* elf32-score.c (score_elf_sort_hash_table_f): Likewise.
	* elf32-score7.c (score_elf_sort_hash_table_f): Likewise.
	* elf32-sh.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
	* elf32-tic6x.c (elf32_tic6x_allocate_dynrelocs,
	elf32_tic6x_readonly_dynrelocs): Likewise.
	* elf32-vax.c (elf_vax_discard_copies): Likewise.
	* elf32-xstormy16.c (xstormy16_relax_plt_check,
	xstormy16_relax_plt_realloc): Likewise.
	* elf32-xtensa.c (elf_xtensa_allocate_dynrelocs): Likewise.
	* elf64-alpha.c (elf64_alpha_output_extsym,
	elf64_alpha_calc_got_offsets_for_symbol,
	elf64_alpha_calc_dynrel_sizes, elf64_alpha_size_rela_got_1): Likewise.
	* elf64-hppa.c (elf64_hppa_mark_exported_functions,
	allocate_global_data_opd, elf64_hppa_mark_milli_and_exported_functions,
	elf_hppa_unmark_useless_dynamic_symbols,
	elf_hppa_remark_useless_dynamic_symbols): Likewise.
	* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref, func_desc_adjust,
	adjust_opd_syms, adjust_toc_syms, allocate_dynrelocs,
	readonly_dynrelocs, merge_global_got, reallocate_got,
	undo_symbol_twiddle): Likewise.
	* elf64-s390.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
	* elf64-sh64.c (sh64_elf64_discard_copies): Likewise.
	* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs,
	elf_x86_64_readonly_dynrelocs): Likewise.
	* elflink.c (elf_link_renumber_hash_table_dynsyms,
	elf_link_renumber_local_hash_table_dynsyms, _bfd_elf_export_symbol,
	_bfd_elf_link_find_version_dependencies,
	_bfd_elf_link_assign_sym_version, _bfd_elf_adjust_dynamic_symbol,
	_bfd_elf_link_sec_merge_syms, elf_adjust_dynstr_offsets,
	elf_collect_hash_codes, elf_collect_gnu_hash_codes,
	elf_renumber_gnu_hash_syms, elf_gc_sweep_symbol,
	elf_gc_propagate_vtable_entries_used,
	elf_gc_smash_unused_vtentry_relocs, bfd_elf_gc_mark_dynamic_ref_symbol,
	elf_gc_allocate_got_offsets): Likewise.
	* elfnn-ia64.c (elfNN_ia64_global_dyn_info_free,
	elfNN_ia64_global_dyn_sym_thunk): Likewise.
	* elfxx-mips.c (mips_elf_check_symbols, mips_elf_output_extsym,
	mips_elf_sort_hash_table_f, allocate_dynrelocs): Likewise.
	* elfxx-sparc.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
	* i386linux.c (linux_tally_symbols): Likewise.
	* m68klinux.c (linux_tally_symbols): Likewise.
	* sparclinux.c (linux_tally_symbols): Likewise.
	* sunos.c (sunos_scan_dynamic_symbol): Likewise.
	* xcofflink.c (xcoff_post_gc_symbol): Likewise.

	* elflink.c (elf_link_output_extsym): Make it a bfd_hash_traverse
	function.  Update all callers.
	* aoutx.h (aout_link_write_other_symbol): Likewise.
	* pdp11.c (aout_link_write_other_symbol): Likewise.
	* cofflink.c (_bfd_coff_write_global_sym): Likewise.
	* ecoff.c (ecoff_link_write_external): Likewise.
	* xcofflink.c (xcoff_write_global_symbol): Likewise.
	* vms-alpha.c (alpha_vms_link_output_symbol): Likewise.  Handle
	warning symbols.
	* ecoff.c (ecoff_link_hash_traverse): Delete.
	* coff-ppc.c (ppc_bfd_coff_final_link): Use bfd_hash_traverse for
	_bfd_coff_write_global_sym.
	* libcoff-in.h (_bfd_coff_write_global_sym): Update prototype.
	* libcoff.h: Regenerate.
2011-06-13 00:59:15 +00:00
H.J. Lu 4b819e1f6e Properly warn relocation in readonly section in a shared object.
2011-06-01  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c (elf_i386_size_dynamic_sections): Properly warn
	relocation in readonly section in a shared object.
	* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise.
2011-06-01 19:42:01 +00:00
Alan Modra 9d4057ee3b PR ld/12718
* elf32-i386.c (elf_i386_check_relocs): Ensure dynobj set before
	creating ifunc sections.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
2011-05-01 12:04:10 +00:00
H.J. Lu b70321a200 Warn relocation in readonly section in a shared object.
2011-04-22  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c (elf_i386_readonly_dynrelocs): Warn relocation
	in readonly section in a shared object.
	(elf_i386_size_dynamic_sections): Likewise.
	* elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.
	(elf_x86_64_size_dynamic_sections): Likewise.
2011-04-23 01:16:31 +00:00
H.J. Lu aa71524235 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.
2011-04-21 22:25:39 +00:00
H.J. Lu f6df62c820 Return false on dynamic symbol error.
2011-04-21  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Return false
	on dynamic symbol error.
	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.
2011-04-21 21:16:51 +00:00
H.J. Lu 2a750708dc Fix the array access for BFD_RELOC_386_IRELATIVE.
2011-04-11  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c (elf_i386_reloc_type_lookup): Fix the out of bound
	array access for BFD_RELOC_386_IRELATIVE.
2011-04-11 18:27:23 +00:00
Nick Clifton f64b2e8d60 PR 10549
* elf-bfd.h (has_ifunc_symbols): Renamed to has_gnu_symbols.
	(has_gnu_symbols): Renamed from has_ifunc_symbols.
	* elf.c (_bfd_elf_set_osabi): Use new has_gnu_symbols name.
	* elf32-arm.c (elf32_arm_add_symbol_hook): Set has_gnu_symbols
	also if STB_GNU_UNIQUE symbol binding was seen.
	* elf32-i386.c (elf_i386_add_symbol_hook): Likewise.
	* elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
	* elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise.
	* elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise.
	* elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise.
	* elf64-x86-64.c (elf_x86_64_add_symbol_hook): Likewise.

	* ld-unique: New directory.
	* ld-unique/unique.exp: New file: Run the UNIQUE tests.
	* ld-unique/unique.s: New test file.
	* ld-unique/unique_empty.s: Likewise.
	* ld-unique/unique_shared.s: Likewise.
2011-04-11 08:13:22 +00:00
H.J. Lu 9f973f2842 Update copyright year.
2011-04-09  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c: Update copyright year.
	* elf64-x86-64.c: Likewise.
2011-04-09 16:48:39 +00:00
H.J. Lu 62d7890874 Return relocation error on unsupported relocation.
2011-04-09  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c (elf_i386_relocate_section): Return relocation
	error on unsupported relocation.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
2011-04-09 15:37:57 +00:00
H.J. Lu 959b0961c9 Properly handle R_386_TLS_LDO_32 for PIE.
bfd/

2011-04-08  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/12654
	* elf32-i386.c (elf_i386_relocate_section): Check !executable
	instead of shared for R_386_TLS_LDO_32.

ld/testsuite/

2011-04-08  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/12654
	* ld-i386/i386.exp: Run tlspie2.

	* ld-i386/tlspie2.d: New.
	* ld-i386/tlspie2.s: Likewise.
2011-04-08 16:14:49 +00:00
Michael Snyder d59a60e937 2011-03-06 Michael Snyder <msnyder@vmware.com>
* elf32-i386.c (elf_i386_relocate_section): Document fall through.
2011-03-06 18:22:36 +00:00
H.J. Lu 3db2e7dda6 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.
2011-01-06 18:45:05 +00:00
Rainer Orth 7dc98aeaf1 * elf-bfd.h (struct elf_backend_data): New member
static_tls_alignment.
	* elfxx-target.h (elf_backend_static_tls_alignment): Provide
	default.
	(elfNN_bed): Initialize static_tls_alignment.
	* elflink.c (bfd_elf_final_link): Don't round end of TLS section
	if static TLS has special alignment requirements.
	* elf32-i386.c (elf_i386_tpoff): Define bed, static_tls_size.
	Consider static_tls_alignment.
	(elf_backend_static_tls_alignment): Redefine for Solaris 2.
	Undef again for VxWorks.
	* elf64-x86-64.c (elf64_x86_64_tpoff):  Define bed,
	static_tls_size.
	Consider static_tls_alignment.
	(elf_backend_static_tls_alignment): Redefine for Solaris 2.
	Undef again for Intel L1OM.
2010-10-21 12:29:02 +00:00
H.J. Lu e28df02b6c Clear non_elf on ELF linker defined symbols.
2010-09-30  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11812
	* elf32-i386.c (elf_i386_size_dynamic_sections): Don't
	 allocate .got.plt section if there are no GOT nor PLT
	 entries and there is no refeence to _GLOBAL_OFFSET_TABLE_.
	 * elf64-x86-64.c (elf64_x86_64_size_dynamic_sections): Li.kewise.

	* elflink.c (_bfd_elf_define_linkage_sym): Clear non_elf.
2010-10-01 04:28:04 +00:00
H.J. Lu ae95ffa628 Add target_id to elf_backend_data.
2010-08-25  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11944
	* elf-bfd.h (elf_backend_data): Add target_id.
	(bfd_elf_make_generic_object): Renamed to ...
	(bfd_elf_make_object): This.

	* elf.c (bfd_elf_make_generic_object): Removed.
	(bfd_elf_make_object): New.
	(bfd_elf_mkcorefile): Really treat it as an object file.

	* elf-m10300.c (ELF_TARGET_ID): New.
	* elf32-arm.c (ELF_TARGET_ID): Likewise.
	* elf32-bfin.c (ELF_TARGET_ID): Likewise.
	* elf32-cris.c (ELF_TARGET_ID): Likewise.
	* elf32-frv.c (ELF_TARGET_ID): Likewise.
	* elf32-i386.c (ELF_TARGET_ID): Likewise.
	* elf32-lm32.c (ELF_TARGET_ID): Likewise.
	* elf32-m32r.c (ELF_TARGET_ID): Likewise.
	* elf32-m68hc11.c (ELF_TARGET_ID): Likewise.
	* elf32-m68hc12.c (ELF_TARGET_ID): Likewise.
	* elf32-m68k.c (ELF_TARGET_ID): Likewise.
	* elf32-microblaze.c (ELF_TARGET_ID): Likewise.
	* elf32-ppc.c (ELF_TARGET_ID): Likewise.
	* elf32-s390.c (ELF_TARGET_ID): Likewise.
	* elf32-sh.c (ELF_TARGET_ID): Likewise.
	* elf32-sparc.c (ELF_TARGET_ID): Likewise.
	* elf32-spu.c (ELF_TARGET_ID): Likewise.
	* elf32-tic6x.c (ELF_TARGET_ID): Likewise.
	* elf32-xtensa.c (ELF_TARGET_ID): Likewise.
	* elf64-alpha.c (ELF_TARGET_ID): Likewise.
	* elf64-hppa.c (ELF_TARGET_ID): Likewise.
	* elf64-ppc.c (ELF_TARGET_ID): Likewise.
	* elf64-s390.c (ELF_TARGET_ID): Likewise.
	* elf64-x86-64.c (ELF_TARGET_ID): Likewise.
	* elfxx-ia64.c (ELF_TARGET_ID): Likewise.

	* elf32-hppa.c (elf32_hppa_mkobject): Removed.
	(bfd_elf32_mkobject): Likewise.
	(ELF_TARGET_ID): New.

	* elf32-mips.c (ELF_TARGET_ID): New.
	(bfd_elf32_mkobject): Removed.

	* elf64-mips.c (ELF_TARGET_ID): New.
	(bfd_elf64_mkobject): Removed.

	* elfn32-mips.c (ELF_TARGET_ID): New.
	(bfd_elf32_mkobject): Removed.

	* elfxx-mips.c (_bfd_mips_elf_mkobject): Removed.
	* elfxx-mips.h (_bfd_mips_elf_mkobject): Likewise.

	* elfxx-target.h (bfd_elfNN_mkobject): Default to
	bfd_elf_make_object.
	(ELF_TARGET_ID): New.  Default to GENERIC_ELF_DATA.
	(elfNN_bed): Initialize target_id.
2010-08-25 14:53:45 +00:00
Pedro Alves 261b8d0859 2010-08-18 Pedro Alves <pedro@codesourcery.com>
PR corefile/8210

	bfd/
	* bfd-in2.h: Regenerate.
	* corefile.c (bfd_core_file_pid): New.

	* targets.c (BFD_JUMP_TABLE_CORE): Add NAME##_core_file_pid.
	(struct bfd_target) <_core_file_pid>: New.

	* libbfd-in.h (_bfd_nocore_core_file_pid): Declare.
	* libbfd.c (_bfd_nocore_core_file_pid): New.

	* elf-bfd.h (bfd_elf32_core_file_pid, bfd_elf64_core_file_pid):
	Declare.
	* elfcode.h (elf_core_file_pid): New define.
	* elfcore.h (elf_core_file_pid): New function.

	* elf.c (elfcore_make_pid): Rewrite.
	(elfcore_grok_prstatus): Only set core_pid if not set yet.
	(elfcore_grok_prstatus) [!HAVE_PRSTATUS_T_PR_WHO]: Fallback to
	getting the lwpid from prstat.pr_pid.

	* elf64-x86-64.c (elf64_x86_64_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	(elf64_x86_64_grok_psinfo): Extract the the main process's PID,
	and store it in elf_tdata's core_pid field.
	* elf32-i386.c (elf_i386_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	(elf_i386_grok_psinfo): Extract the the main process's PID, and
	store it in elf_tdata's core_pid field.

	* elf32-am33lin.c (elf32_am33lin_grok_prstatus): Write the LWPID
	to elf_tdata's core_lwpid instead of to core_pid.
	* elf32-arm.c (elf32_arm_nabi_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	* elf32-cris.c (cris_elf_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	* elf32-frv.c (elf32_frv_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	* elf32-hppa.c (elf32_hppa_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	* elf32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	* elf32-ppc.c (ppc_elf_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	* elf32-s390.c (elf_s390_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	* elf32-score.c (s3_bfd_score_elf_grok_prstatus): Write the LWPID
	to elf_tdata's core_lwpid instead of to core_pid.
	* elf32-score7.c (s7_bfd_score_elf_grok_prstatus): Write the LWPID
	to elf_tdata's core_lwpid instead of to core_pid.
	* elf32-sh.c (elf32_shlin_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	* elf32-xtensa.c (elf_xtensa_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	* elf64-hppa.c (elf64_hppa_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	* elf64-mips.c (elf64_mips_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	* elf64-ppc.c (ppc64_elf_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.
	* elfn32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to
	elf_tdata's core_lwpid instead of to core_pid.

	* plugin.c (bfd_plugin_core_file_pid): New function.
	* aout-target.h (MY_core_file_pid): Define.
	* aout-tic30.c (MY_core_file_pid, MY_core_file_p): New defines.
	* coff-rs6000.c (coff_core_file_pid): New define.
	(rs6000coff_vec, pmac_xcoff_vec): Use BFD_JUMP_TABLE_CORE.
	* coff64-rs6000.c (coff_core_file_pid): New define.
	(rs6000coff64_vec): Use BFD_JUMP_TABLE_CORE.
	(xcoff64_core_file_pid): New define.
	(aix5coff64_vec): Use BFD_JUMP_TABLE_CORE.
	* mach-o-target.c (bfd_mach_o_core_file_pid): New define.
	* aix386-core.c (aix386_core_file_pid): New define.
	* hppabsd-core.c (hppabsd_core_core_file_pid): New define.
	* hpux-core.c (hpux_core_core_file_pid): New define.
	* irix-core.c (irix_core_core_file_pid): New define.
	* lynx-core.c (lynx_core_file_pid): New define.
	* osf-core.c (osf_core_core_file_pid): New define.
	* ptrace-core.c (ptrace_unix_core_file_pid): New define.
	* sco5-core.c (sco5_core_file_pid): New define.
	* xcoff-target.h (coff_core_file_pid): New define.
	* netbsd-core.c (netbsd_core_core_file_pid): New define.

gdb/
2010-08-18  Pedro Alves  <pedro@codesourcery.com>

	PR corefile/8210

	gdb/
	* corelow.c (add_to_thread_list): Don't use
	gdbarch_core_reg_section_encodes_pid.  Use bfd_core_file_pid.
	(get_core_register_section): Don't use
	gdbarch_core_reg_section_encodes_pid.

	* gdbarch.sh (core_reg_section_encodes_pid): Delete.
	* gdbarch.h, gdbarch.c: Regenerate.
	* amd64-sol2-tdep.c (amd64_sol2_init_abi): Don't set
	gdbarch_core_reg_section_encodes_pid.
	* i386-sol2-tdep.c (i386_sol2_init_abi): Ditto.
	* sparc-sol2-tdep.c (sparc32_sol2_init_abi): Ditto.
	* sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Ditto.
2010-08-18 12:24:13 +00:00
H.J. Lu 56d4289c6c Check if .got.plt section is discarded before using it.
bfd/

2010-08-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11913
	* elf32-i386.c (elf_i386_finish_dynamic_sections): Check if
	 .got.plt section is discarded.
	 * elf64-x86-64.c (elf64_x86_64_finish_dynamic_sections): Likewise.

ld/testsuite/

2010-08-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11913
	* ld-i386/discarded1.d: New.
	* ld-i386/discarded1.s: Likewise.
	* ld-i386/discarded1.t: Likewise.
	* ld-x86-64/discarded1.d: Likewise.
	* ld-x86-64/discarded1.s: Likewise.
	* ld-x86-64/discarded1.t: Likewise.

	* ld-i386/i386.exp: Run discarded1.
	* ld-x86-64/x86-64.exp: Likewise.
2010-08-13 20:50:27 +00:00
H.J. Lu a7b16ceb92 Don't allocate .got.plt section if there are no GOT nor PLT entries.
bfd/

2010-07-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11812
	* elf32-i386.c (elf_i386_size_dynamic_sections): Don't
	 allocate .got.plt section if there are no GOT nor PLT
	 entries.
	 * elf64-x86-64.c (elf64_x86_64_size_dynamic_sections): Likewise.

ld/testsuite/

2010-07-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11812
	* ld-elf/exclude3b.d: Don't run on ia64-*-*.  Replace .got with
	.dynamic.

	* ld-elf/exclude3d.d: New.
	* ld-i386/nogot1.d: Likewise.
	* ld-i386/nogot1.s: Likewise.
	* ld-x86-64/nogot1.d: Likewise.
	* ld-x86-64/nogot1.s: Likewise.

	* ld-i386/i386.exp: Run nogot1.
	* ld-x86-64/x86-64.exp: Likewise.
2010-07-14 00:30:57 +00:00
H.J. Lu bb1cb422ae Support garbage collection against STT_GNU_IFUNC symbols.
bfd/

2010-07-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11791
	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Support
	garbage collection against STT_GNU_IFUNC symbols.

	* elf32-i386.c (elf_i386_get_local_sym_hash): Don't set
	elf.plt.offset/elf.got.offset to -1.
	(elf_i386_tls_transition): Skip TLS transition for functions.
	(elf_i386_gc_sweep_hook): Support STT_GNU_IFUNC symbols.

	* elf64-x86-64.c (elf64_x86_64_get_local_sym_hash): Don't set
	elf.plt.offset/elf.got.offset to -1.
	(elf64_x86_64_tls_transition): Skip TLS transition for functions.
	(elf64_x86_64_gc_sweep_hook): Support STT_GNU_IFUNC symbols.

ld/testsuite/

2010-07-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11791
	* ld-ifunc/ifunc-10-i386.d: New.
	* ld-ifunc/ifunc-10-i386.s: Likewise.
	* ld-ifunc/ifunc-10-x86-64.d: Likewise.
	* ld-ifunc/ifunc-10-x86-64.s: Likewise.
	* ld-ifunc/ifunc-11-i386.d: Likewise.
	* ld-ifunc/ifunc-11-i386.s: Likewise.
	* ld-ifunc/ifunc-11-x86-64.d: Likewise.
	* ld-ifunc/ifunc-11-x86-64.s: Likewise.
2010-07-13 16:59:14 +00:00
H.J. Lu 9fff0c3957 Re-indent elf32-i386.c.
2010-07-12  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c (elf_i386_check_relocs): Re-indent.
	(elf_i386_relocate_section): Likewise.
2010-07-12 21:13:24 +00:00
H.J. Lu 0672748ac0 Remove relocation against discarded sections for relocatable link.
bfd/

2010-04-30  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11542
	* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): New.

	* elf32-i386.c (elf_i386_relocate_section): Use it.
	* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.

ld/testsuite/

2010-04-30  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/11542
	* ld-elf/discard.ld: New.
	* ld-elf/discard1.d: Likewise.
	* ld-elf/discard1.s: Likewise.
	* ld-elf/discard2.d: Likewise.
	* ld-elf/discard2.s: Likewise.
	* ld-elf/discard3.d: Likewise.
2010-04-30 18:27:32 +00:00
Nick Clifton 3d540e936b bfd/ChangeLog
2010-04-09  Nick Clifton  <nickc@redhat.com>

        * aoutx.h (aout_link_input_bfd): Remove unused variable sym_count.
        * elf-eh-frame.c (_bfd_elf_eh_frame_section_offset): Remove unused
        variables htab and hdr_info and mark info parameter as unused.
        * elf.c (prep_headers): Remove unused variable i_phdrp.
        (_bfd_elf_write_object_contents): Remove unused variable i_ehdrp.
        * elf32-i386.c (elf_i386_relocate_section): Mark variabled warned
        as unused.
        * peXXigen.c (pe_print_reloc): Remove unused variable datasize.
        * verilog.c (verilog_write_section): Remove unused variable
        address.

binutils/ChangeLog
2010-04-09  Nick Clifton  <nickc@redhat.com>

        * dwarf.c (process_debug_info): Remove unused variable
        cu_abbrev_offset_ptr.
        (display_debug_lines_decoded): Remove unused variable prev_line.
        * elfedit.c (process_archive): Remove unused variable
        file_name_size.
        * ieee.c (ieee_start_compilation_unit): Remove unused variable
        nindx.
        (ieee_set_type): Remove unused variables info, targetindx and
        baseindx.
        * objdump.c (disassmble_byte): Remove unused variable done_dot.
        * rddbg.c (read_section_stabs_debugging_info): Remove unused
        variable other.
        * readelf.c (dump_section_as_strings): Remove unused variable
        addr.
        (process_archive): Remove unused variable file_name_size.
        * stabs.c (parse_stab_string): Mark desc parameter as unused.
        Remove unused variable lineno.
        (parse_stab_struct_type): Remove unused variable orig.
        (stab_demangle_type): Remove unused variables constp, volatilep
        and hold.

gas/ChangeLog
2010-04-09  Nick Clifton  <nickc@redhat.com>

        * as.c (create_obj_attrs_section): Remove unused variable addr.
        * listing.c (listing_listing): Remove unused variable message.
        * read.c: Remove unnecessary register type qualifiers.
        (s_mri): Only define/use old_flag variable if MRI_MODE_CHANGE is
        defined.

ld/ChangeLog
2010-04-09  Nick Clifton  <nickc@redhat.com>

        * ldlang.c (wild_sort): Remove unused variable section_name.

opcodes/ChangeLog
2010-04-09  Nick Clifton  <nickc@redhat.com>

        * i386-dis.c (print_insn): Remove unused variable op.
        (OP_sI): Remove unused variable mask.
2010-04-09 14:40:18 +00:00
Rainer Orth a6cc6b3bc4 ld:
* Makefile.am (ALL_EMULATIONS): Add eelf32_sparc_sol2.o,
	eelf_i386_sol2.o.
	(ALL_64_EMULATIONS): Add eelf_x86_64_sol2.o, eelf64_sparc_sol2.o.
	(eelf32_sparc_sol2.c): New rule.
	(eelf64_sparc_sol2.c): Likewise.
	(eelf_x86_64_sol2.c): Likewise.
	(eelf_i386_sol2.c): Likewise.
	* Makefile.in: Regenerate.
	* configure.tgt (i[3-7]86-*-solaris2*): Change targ_emul to
	elf_i386_sol2.
	Add elf_i386_ldso, elf_x86_64_sol2 to targ_extra_emuls.
	(x86_64-*-solaris2*): Change targ_emul to elf_x86_64_sol2.
	Add elf_x86_64, elf_i386_sol2, elf_i386 to targ_extra_emuls.
	(sparc-*-solaris2.[0-6]*): Change targ_emul to elf32_sparc_sol2.
	Add target_extra_emuls.
	(sparc-*-solaris2*): Change targ_emul to elf32_sparc_sol2.
	Add elf32_sparc, elf64_sparc_sol2 to targ_extra_emuls.
	(sparcv9-*-solaris2*): Change targ_emul to elf64_sparc_sol2.
	Add elf64_sparc, elf32_sparc_sol2 to target_extra_emuls.
	* emulparams/elf32_sparc_sol2.sh: New file.
	* emulparams/elf64_sparc_sol2.sh: New file.
	* emulparams/elf_i386_sol2.sh: New file.
	* emulparams/elf_x86_64_sol2.sh: New file.
	* emultempl/solaris2.em: New file.

	bfd:
	* elflink.c (bfd_elf_size_dynamic_sections): Don't emit base
	version twice.
	Skip it when constructing def.vd_next.

	* elf32-i386.c (TARGET_LITTLE_SYM): Redefine to
	bfd_elf32_i386_sol2_vec.
	(TARGET_LITTLE_NAME): Redefine to elf32-i386-sol2.
	(elf32_bed): Redefine to elf32_i386_sol2_bed.
	(elf_backend_want_plt_sym): Redefine to 1.

	* elf64-x86-64.c (TARGET_LITTLE_SYM): Redefine to
	bfd_elf64_x86_64_sol2_vec.
	(TARGET_LITTLE_NAME): Redefine to elf64-x86-64-sol2.
	(elf64_bed): Redefine to elf64_x86_64_sol2_bed.
	(elf_backend_want_plt_sym): Redefine to 1.

	* config.bfd (i[3-7]86-*-solaris2*): Set targ_defvec to
	bfd_elf32_i386_sol2_vec.
	Replace bfd_elf64_x86_64_vec by bfd_elf64_x86_64_sol2_vec in
	targ64_selvecs.
	(x86_64-*-solaris2*): Set targ_defvec to bfd_elf32_i386_sol2_vec.
	Replace bfd_elf64_x86_64_vec by bfd_elf64_x86_64_sol2_vec in
	targ_selvecs.

	* configure.in: Handle bfd_elf32_i386_sol2_vec,
	bfd_elf64_x86_64_sol2_vec.
	* configure: Regenerate.

	* targets.c (bfd_elf32_i386_sol2_vec): Declare.
	(bfd_elf64_x86_64_sol2_vec): Declare.
	(_bfd_target_vector): Add bfd_elf32_i386_sol2_vec,
	bfd_elf64_x86_64_sol2_vec.
2010-03-05 19:49:00 +00:00
H.J. Lu c16153aed7 Don't set ELFOSABI_LINUX in dynamic ifunc-using executable.
bfd/

2010-02-18  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c (elf_i386_add_symbol_hook): Don't set
	has_ifunc_symbols if the symbol comes from a shared library.
	* elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
	* elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise.
	* elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise.
	* elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise.
	* elf64-x86-64.c (elf64_x86_64_add_symbol_hook): Likewise.

ld/testsuite/

2010-02-18  H.J. Lu  <hongjiu.lu@intel.com>

	* ld-ifunc/ifunc.exp: Expect System V OSABI in dynamic
	ifunc-using executable.
2010-02-19 05:07:50 +00:00
H.J. Lu 6bbec50578 Remove trailing white spaces.
2010-02-05  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c: Remove trailing white spaces.
	* elf64-x86-64.c: Likewise.
2010-02-05 14:58:11 +00:00
Nick Clifton 4dfe6ac6fe * elf-bfd.h (emum elf_object_id): Rename to elf_target_id. Add
entries for other architectures.
        (struct elf_link_hash_table): Add hash_table_id field.
        (elf_hash_table_id): New accessor macro.
        * elflink.c (_bfd_elf_link_hash_table_init): Add target_id
        parameter.
        * elf-m10300.c (elf32_mn10300_hash_table): Check table id before
        returning cast pointer.
        (elf32_mn10300_link_hash_table_create): Identify new table as
        containing MN10300 extensions.
        (mn10300_elf_relax_section): Check pointer returned by
        elf32_mn10300_hash_table.
        * elf32-arm.c: Likewise, except using ARM extensions.
        * elf32-avr.c: Likewise, except using AVR extensions.
        * elf32-bfin.c: Likewise, except using BFIN extensions.
        * elf32-cris.c: Likewise, except using CRIS extensions.
        * elf32-frv.c: Likewise, except using FRV extensions.
        * elf32-hppa.c: Likewise, except using HPPA32 extensions.
        * elf32-i386.c: Likewise, except using I386 extensions.
        * elf32-lm32.c: Likewise, except using LM32 extensions.
        * elf32-m32r.c: Likewise, except using M32RM extensions.
        * elf32-m68hc11.c: Likewise, except using M68HC11 extensions.
        * elf32-m68hc1x.c: Likewise, except using M68HC11 extensions.
        * elf32-m68hc1x.h: Likewise, except using M68HC11 extensions.
        * elf32-m68k.c: Likewise, except using M68K extensions.
        * elf32-microblaze.c: Likewise, except using MICROBLAZE extensions.
        * elf32-ppc.c: Likewise, except using PPC32 extensions.
        * elf32-s390.c: Likewise, except using S390 extensions.
        * elf32-sh.c: Likewise, except using SH extensions.
        * elf32-spu.c: Likewise, except using SPU extensions.
        * elf32-xtensa.c: Likewise, except using XTENSA extensions.
        * elf64-alpha.c: Likewise, except using ALPHA extensions.
        * elf64-hppa.c: Likewise, except using HPPA64 extensions.
        * elf64-ppc.c: Likewise, except using PPC64 extensions.
        * elf64-s390.c: Likewise, except using S390 extensions.
        * elf64-x86-64.c: Likewise, except using X86_64 extensions.
        * elfxx-ia64.c: Likewise, except using IA64 extensions.
        * elfxx-mips.c: Likewise, except using MIPS extensions.
        * elfxx-sparc.c: Likewise, except using SPARC extensions.
        * elfxx-sparc.h: Likewise, except using SPARC extensions.
        * elf32-cr16.c (struct elf32_cr16_link_hash_table): Delete
        redundant structure.
        (elf32_cr16_hash_table): Delete unused macro.
        (elf32_cr16_link_hash_traverse): Delete unused macro.
        * elf32-score.c: Likewise.
        * elf32-score7.c: Likewise.
        * elf32-vax.c: Likewise.
        * elf64-sh64.c: Likewise.

        * emultempl/alphaelf.em: Update value expected from elf_object_id.
        * emultempl/hppaelf.em: Likewise.
        * emultempl/mipself.em: Likewise.
        * emultempl/ppc32elf.em: Likewise.
        * emultempl/ppc64elf.em: Likewise.
2010-02-04 09:16:43 +00:00
Nick Clifton 91d6fa6a03 Add -Wshadow to the gcc command line options used when compiling the binutils.
Fix up all warnings generated by the addition of this switch.
2009-12-11 13:42:17 +00:00
H.J. Lu cd2b2c108e 2009-10-13 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/10763
	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Declare plt
	earlier.
2009-10-13 16:37:39 +00:00
Nick Clifton a50b1753d4 Updated soruces in bfd/* to compile cleanly with -Wc++-compat.
* bfd/aoutx.h: Add casts.
        * bfd/archive.c: Add casts.
        * bfd/archive64.c: Add casts.
        * bfd/archures.c: Add casts.
        * bfd/bfd-in2.h: Regenerated.
        * bfd/bfd.c: Add casts. (enum bfd_direction): Move out to top
        level.
        * bfd/bfdio.c: Add casts.
        * bfd/binary.c: Add casts.
        * bfd/cache.c (cache_bseek,cache_bread_1,cache_bwrite): Updated
        parameter to use enum value instead of int.
        * bfd/coffcode.h: Add casts.
        * bfd/coffgen.c: Add casts.
        * bfd/cofflink.c: Add casts.
        * bfd/compress.c: Add casts.
        * bfd/dwarf1.c: Add casts.
        * bfd/dwarf2.c: Add casts. (struct dwarf2_debug): Rename member
        bfd to bfd_ptr. Update code to use new name.
        * bfd/elf-attrs.c: Add casts.
        * bfd/elf-bfd.h (elf_link_virtual_table_entry): Gives name to
        anonymous struct. (union gotplt_union, struct
        elf_link_virtual_table_entry): Move to top level.
        * bfd/elf-eh-frame.c: Add casts.
        * bfd/elf-strtab.c: Add casts.
        * bfd/elf.c: Add casts. (_bfd_elm_make_Section_from_phdr): Change
        argument name from typename to type_name.
        * bfd/elf32-i386.c: Add casts.
        * bfd/elf64-x86-64.c: Add casts.
        * bfd/elfcode.h: Add casts.
        * bfd/elfcore.h: Add casts.
        * bfd/elflink.c: Add casts.
        * bfd/format.c: Add casts.
        * bfd/hash.c: Add casts.
        * bfd/ihex.c: Add casts.
        * bfd/libaout.h (enum aout_subformat, enum aout_magic): Move to
        top level.
        * bfd/libbfd.c: Add casts.
        * bfd/linker.c: Add casts.
        * bfd/merge.c: Add casts.
        * bfd/opncls.c: Add casts.
        * bfd/peXXigen.c: Add casts.
        * bfd/peicode.h: Add casts.
        * bfd/reloc.c: Add casts.
        * bfd/section.c: Add casts.
        * bfd/simple.c: Add casts.
        * bfd/srec.c: Add casts.
        * bfd/stabs.c: Add casts.
        * bfd/syms.c: Add casts.
        * bfd/targets.c: Add casts.
        * bfd/tekhex.c: Add casts.
        * bfd/verilog.c: Add casts.
        * include/bfdlink.h (struct bfd_link_hash_common_entry): Move to
        top level.
2009-09-09 21:38:59 +00:00
Alan Modra aa820537ea update copyright dates 2009-09-02 07:25:43 +00:00
H.J. Lu 883c74100f 2009-08-30 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_finish_dynamic_symbol): Revert the
	accidental checkin.
	* elf64-x86-64.c (elf64_x86_64_finish_dynamic_symbol): Likwise.
2009-08-30 18:31:53 +00:00
Nick Clifton d3ce72d070 Updated sources to avoid using the identifier name "new", which is a
keyword in c++.

        * bfd/aoutx.h (NAME (aout, make_empty_symbol)): Rename variable
        new to new_symbol.
        * bfd/coffgen.c (coff_make_empty_symbol)
        (coff_bfd_make_debug_symbol): Rename variable new to new_symbol.
        * bfd/cpu-ia64-opc.c (ext_reg, ins_imms_scaled): Rename variable
        new to new_insn.
        * bfd/doc/chew.c (newentry, add_intrinsic): Rename variable new to
        new_d.
        * bfd/ecoff.c (_bfd_ecoff_make_empty_symbol): Rename variable new
        to new_symbol.
        * bfd/elf32-m68k.c (elf_m68k_get_got_entry_type): Rename argument
        new to new_reloc.
        * bfd/hash.c (bfd_hash_lookup): Rename variable new to new_string.
        * bfd/ieee.c (ieee_make_empty_symbol): Rename variable new to
        new_symbol.
        * bfd/linker.c (bfd_new_link_order): Rename variable new to
        new_lo.
        * bfd/mach-o.c (bfd_mach_o_sizeof_headers): Rename variable new to
        symbol.
        * bfd/oasys.c (oasys_make_empty_symbol): Rename variable new to
        new_symbol_type.
        * bfd/pdp11.c (NAME (aout, make_empty_symbol)): Rename variable
        new to new_symbol_type.
        * bfd/plugin.c (bfd_plugin_make_empty_symbol): Rename variable new
        to new_symbol.
        * bfd/rs6000-core.c (CoreHdr, VmInfo): Rename union member new to
        new_dump.
        (read_hdr, rs6000coff_core_p)
        (rs6000coff_core_file_matches_executable_p)
        (rs6000coff_core_file_failing_command)
        (rs6000coff_core_file_failing_signal): Updated function to use new
        union member name.
        * bfd/som.c (som_make_empty_symbol): Rename variable new to
        new_symbol_type.
        * bfd/syms.c (_bfd_generic_make_empty_symbol): Rename variable new
        to new_symbol.
        * bfd/tekhex.c (first_phase, tekhex_make_empty_symbol): Rename
        variable new to new_symbol.
        * binutils/nlmconv.c (main): Rename variable new to new_name.
        * gas/config/tc-arm.c (insert_reg_alias): Rename variable new to
        new_reg.
        * gas/config/tc-dlx.c (parse_operand): Rename variable new to
        new_pos.
        * gas/config/tc-ia64.c (ia64_gen_real_reloc_type): Rename variable
        new to newr.
        * gas/config/tc-mcore.c (parse_exp, parse_imm): Rename variable
        new to new_pointer.
        * gas/config/tc-microblaze.c (parse_exp, parse_imm, check_got):
        Change name from new to new_pointer.
        * gas/config/tc-or32.c (parse_operand): Rename variable new to
        new_pointer.
        * gas/config/tc-pdp11.c (md_assemble): Rename variable new to
        new_pointer.
        * gas/config/tc-pj.c (alias): Change argument new to new_name.
        * gas/config/tc-score.c (s3_build_score_ops_hsh): Rename variable
        new to new_opcode. (s3_build_dependency_insn_hsh) Rename variable
        new to new_i2n. (s3_convert): Rename variables old and new to
        r_old and r_new.
        * gas/config/tc-score7.c (s7_build_score_ops_hsh): Rename variable
        new to new_opcode. (s7_build_dependency_insn_hsh): Rename variable
        new to new_i2d. (s7_b32_relax_to_b16, s7_convert_frag): Rename
        variables old and new to r_old and r_new.
        * gas/config/tc-sh.c (parse_exp): Rename variable new to
        new_pointer.
        * gas/config/tc-sh64.c (shmedia_parse_exp): Rename variable new to
        new_pointer.
        * gas/config/tc-tic4x.c (tic4x_operand_parse): Rename variable new
        to new_pointer.
        * gas/config/tc-z8k.c (parse_exp): Rename variable new to
        new_pointer.
        * gas/listing.c (listing_newline): Rename variable new to new_i.
        * ld/ldexp.c (exp_intop, exp_bigintop, exp_relop, exp_binop)
        (exp_trinop, exp_unop, exp_nameop, exp_assop): Rename variable new
        to new_e.
        * ld/ldfile.c (ldfile_add_library_path): Rename variable new to
        new_dirs. (ldfile_add_arch): Rename variable new to new_arch.
        * ld/ldlang.c (new_statement, lang_final, lang_add_wild)
        (lang_target, lang_add_fill, lang_add_data, lang_add_assignment)
        (lang_add_insert): Rename variable new to new_stmt. (new_afile):
        Added missing cast. (lang_memory_region_lookup): Rename variable
        new to new_region. (init_os): Rename variable new to
        new_userdata. (lang_add_section): Rename variable new to
        new_section. (ldlang_add_undef): Rename variable new to
        new_undef. (realsymbol): Rename variable new to new_name.
        * opcodes/z8kgen.c (internal, gas): Rename variable new to new_op.

        Updated sources to avoid using the identifier name "template",
        which is a keyword in c++.

        * bfd/elf32-arm.c (struct stub_def): Rename member template to
        template_sequence. (arm_build_one_stub,
        find_stub_size_and_template, arm_size_one_stub, arm_map_one_stub):
        Rename variable template to template_sequence.
        * bfd/elfxx-ia64.c (elfNN_ia64_relax_br, elfNN_ia64_relax_brl):
        Rename variable template to template_val.
        * gas/config/tc-arm.c (struct asm_cond, struct asm_psr, struct
        asm_barrier_opt): Change member template to
        template_name. (md_begin): Update code to reflect new member
        names.
        * gas/config/tc-i386.c (struct templates, struct _i386_insn)
        (match_template, cpu_flags_match, match_reg_size, match_mem_size)
        (operand_size_match, md_begin, i386_print_statistics, pi)
        (build_vex_prefix, md_assemble, parse_insn, optimize_imm)
        (optimize_disp): Updated code to use new names. (parse_insn):
        Added casts.
        * gas/config/tc-ia64.c (dot_template, emit_one_bundle): Updated
        code to use new names.
        * gas/config/tc-score.c (struct s3_asm_opcode): Renamed member
        template to template_name. (s3_parse_16_32_inst, s3_parse_48_inst,
        s3_do_macro_ldst_label, s3_build_score_ops_hsh): Update code to
        use new names.
        * gas/config/tc-score7.c (struct s7_asm_opcode): Renamed member
        template to template_name. (s7_parse_16_32_inst,
        s7_do_macro_ldst_label, s7_build_score_ops_hsh): Update code to
        use new names.
        * gas/config/tc-tic30.c (md_begin, struct tic30_insn)
        (md_assemble): Update code to use new names.
        * gas/config/tc-tic54x.c (struct _tic54x_insn, md_begin)
        (optimize_insn, tic54x_parse_insn, next_line_shows_parallel):
        Update code to use new names.
        * include/opcode/tic30.h (template): Rename type template to
        insn_template. Updated code to use new name.
        * include/opcode/tic54x.h (template): Rename type template to
        insn_template.
        * opcodes/cris-dis.c (bytes_to_skip): Update code to use new name.
        * opcodes/i386-dis.c (putop): Update code to use new name.
        * opcodes/i386-gen.c (process_i386_opcodes): Update code to use
        new name.
        * opcodes/i386-opc.h (struct template): Rename struct template to
        insn_template. Update code accordingly.
        * opcodes/i386-tbl.h (i386_optab): Update type to use new name.
        * opcodes/ia64-dis.c (print_insn_ia64): Rename variable template
        to template_val.
        * opcodes/tic30-dis.c (struct instruction, get_tic30_instruction):
        Update code to use new name.
        * opcodes/tic54x-dis.c (has_lkaddr, get_insn_size)
        (print_parallel_instruction, print_insn_tic54x, tic54x_get_insn):
        Update code to use new name.
        * opcodes/tic54x-opc.c (tic54x_unknown_opcode, tic54x_optab):
        Update type to new name.
2009-08-29 22:11:02 +00:00
H.J. Lu 1d85728fd7 2009-08-02 H.J. Lu <hongjiu.lu@intel.com>
Jakub Jelinek  <jakub@redhat.com>

	PR ld/6443
	* elf32-i386.c (elf_i386_tls_transition): Check executable
	instead of shared for TLS when building PIE.
	(elf_i386_check_relocs): Likewise.
	(elf_i386_allocate_dynrelocs): Likewise.
	(elf_i386_relocate_section): Likewise.

	* elf64-x86-64.c (elf64_x86_64_tls_transition): Check executable
	instead of shared for TLS when building PIE.
	(elf64_x86_64_check_relocs): Likewise.
	(elf64_x86_64_allocate_dynrelocs): Likewise.
	(elf64_x86_64_relocate_section): Likewise.

ld/testsuite/

2009-08-02  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/6443
	* ld-i386/i386.exp: Run tlspie1.
	* ld-x86-64/x86-64.exp: tlspie1.

	* ld-i386/tlspie1.d: New.
	* ld-i386/tlspie1.s: Likewise.
	* ld-x86-64/tlspie1.d: Likewise.
	* ld-x86-64/tlspie1.s: Likewise.
2009-08-02 23:55:49 +00:00
H.J. Lu 1f85278f17 bfd/
2009-07-16  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c (elf_i386_relocate_section): Don't get local
	STT_GNU_IFUNC symbol for relocatable link.
	* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.

ld/testsuite/

2009-07-16  H.J. Lu  <hongjiu.lu@intel.com>

	* ld-ifunc/ifunc-5r-local-i386.d: New.
	* ld-ifunc/ifunc-5r-local-x86-64.d: Likewise.
2009-07-16 14:23:12 +00:00
Alan Modra 7ae26bc141 * elf-bfd.h (struct elf_link_hash_entry): Clarify ref_regular
and ref_regular_nonweak comment.
	* elflink.c (elf_link_output_extsym): Special case ifunc syms
	when def_regular, not ref_regular.
	(elf_link_add_object_symbols): Don't set needs_plt on ifunc syms,..
	* elf32-i386.c (elf_i386_check_relocs): ..set it here instead..
	* elf64-x86-64.c (elf64_x86_64_check_relocs): ..and here.
2009-07-10 10:04:20 +00:00
H.J. Lu 09a24cbf39 2009-06-19 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_check_relocs): Properly check local
	symbol on error.
	* elf64-x86-64.c (elf64_x86_64_check_relocs): Likewise.
2009-06-20 00:43:21 +00:00
H.J. Lu 4c5448074d bfd/
2009-06-19  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c (elf_i386_tls_transition): Add a parameter,
	r_symndx.  Report local symbol name on error.
	(elf_i386_check_relocs): Updated.  Report local symbol name on
	error.
	(elf_i386_gc_sweep_hook): Updated.
	(elf_i386_relocate_section): Likewise.

	* elf64-x86-64.c (elf64_x86_64_tls_transition): Add a parameter,
	r_symndx.  Report local symbol name on error.
	(elf64_x86_64_check_relocs): Updated.  Report local symbol name
	on error.
	(elf64_x86_64_gc_sweep_hook): Updated.
	(elf64_x86_64_relocate_section): Likewise.

ld/testsuite/

2009-06-19  H.J. Lu  <hongjiu.lu@intel.com>

	* ld-i386/i386.exp: Run tlsgd2.

	* ld-i386/tlsgd2.d: New.
	* ld-i386/tlsgd2.s: Likewise.

	* ld-x86-64/tlsgd3.d: Updated.
2009-06-19 16:00:33 +00:00
H.J. Lu c2e61a4e93 2009-06-18 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_check_relocs): Remove isymbuf and use
	bfd_sym_from_r_symndx.
	* elf64-x86-64.c (elf64_x86_64_check_relocs): Likewise.
2009-06-18 15:49:39 +00:00
Alan Modra 87d72d41b0 * elf-bfd.h (struct sym_sec_cache): Delete.
(struct sym_cache): New.
	(bfd_section_from_r_symndx): Delete prototype.
	(bfd_sym_from_r_symndx): Define prototype.
	* elf.c (bfd_section_from_r_symndx): Delete, replace with..
	(bfd_sym_from_r_symndx): ..new function.
	* elf32-arm.c: Update all uses of struct sym_sec_cache and
	bfd_section_from_r_symndx to new struct and function.
	* elf32-bfin.c: Likewise.
	* elf32-hppa.c: Likewise.
	* elf32-i386.c: Likewise.
	* elf32-m32r.c: Likewise.
	* elf32-m68hc1x.c: Likewise.
	* elf32-m68hc1x.h: Likewise.
	* elf32-m68k.c: Likewise.
	* elf32-ppc.c: Likewise.
	* elf32-s390.c: Likewise.
	* elf32-sh.c: Likewise.
	* elf64-ppc.c: Likewise.
	* elf64-s390.c: Likewise.
	* elf64-x86-64.c: Likewise.
	* elfxx-sparc.c: Likewise.
	* elfxx-sparc.h: Likewise.
2009-06-18 14:18:29 +00:00
H.J. Lu 14aae7232b 2009-06-18 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_check_relocs): Cache or free isymbuf.
	* elf64-x86-64.c (elf64_x86_64_check_relocs): Likewise.
2009-06-18 12:49:41 +00:00
H.J. Lu e03a8ed803 2009-06-17 H.J. Lu <hongjiu.lu@intel.com>
* elf-bfd.h (_bfd_elf_allocate_ifunc_dyn_relocs): New.
	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Likewise.
	* elf32-i386.c (elf_i386_allocate_dynrelocs): Use it.
	* elf64-x86-64.c (elf64_x86_64_allocate_dynrelocs): Likewise.

2009-06-17  H.J. Lu  <hongjiu.lu@intel.com>

	* elf-bfd.h (_bfd_elf_create_ifunc_dyn_reloc): New.
	* elf-ifunc.c (_bfd_elf_create_ifunc_dyn_reloc): Likewise.
	* elf32-i386.c (elf_i386_check_relocs): Use it.
	* elf64-x86-64.c (elf64_x86_64_check_relocs): Likewise.

2009-06-17  H.J. Lu  <hongjiu.lu@intel.com>

	* elf-bfd.h (elf_dyn_relocs): New.

	* elf32-i386.c (elf_i386_dyn_relocs): Removed.
	(elf_i386_link_hash_entry): Replace elf_i386_dyn_relocs with
	elf_dyn_relocs.
	(elf_i386_copy_indirect_symbol): Likewise.
	(elf_i386_check_relocs): Likewise.
	(elf_i386_gc_sweep_hook): Likewise.
	(elf_i386_allocate_dynrelocs): Likewise.
	(elf_i386_readonly_dynrelocs): Likewise.
	(elf_i386_size_dynamic_sections): Likewise.

	* elf64-x86-64.c (elf64_x86_64_dyn_relocs): Removed.
	(elf64_x86_64_link_hash_entry): Replace elf64_x86_64_dyn_relocs
	with elf_dyn_relocs.
	(elf64_x86_64_copy_indirect_symbol): Updated.
	(elf64_x86_64_check_relocs): Likewise.
	(elf64_x86_64_gc_sweep_hook): Likewise.
	(elf64_x86_64_adjust_dynamic_symbol): Likewise.
	(elf64_x86_64_allocate_dynrelocs): Likewise.
	(elf64_x86_64_readonly_dynrelocs): Likewise.
	(elf64_x86_64_size_dynamic_sections): Likewise.
2009-06-18 00:45:14 +00:00
H.J. Lu d2149d727f 2009-06-16 H.J. Lu <hongjiu.lu@intel.com>
* elf-bfd.h (ELF_LOCAL_SYMBOL_HASH): New.

	* elf32-i386.c (elf_i386_local_hash): Removed.
	(elf_i386_local_htab_hash): Use ELF_LOCAL_SYMBOL_HASH.
	(elf_i386_get_local_sym_hash): Likewise.

	* elf64-x86-64.c (elf64_x86_64_local_hash): Removed.
	(elf64_x86_64_local_htab_hash): Use ELF_LOCAL_SYMBOL_HASH.
	(elf64_x86_64_get_local_sym_hash): Likewise.
	* elfxx-ia64.c (elfNN_ia64_local_htab_hash): Likewise.
	(get_local_sym_hash): Likewise.
2009-06-16 17:45:08 +00:00
H.J. Lu 6de2ae4a2a 2009-06-16 H.J. Lu <hongjiu.lu@intel.com>
* configure.in (elf): Add elf-ifunc.lo.

	* configure: Regenerated.
	* Makefile.in: Likewise.

	* elf-bfd.h (elf_link_hash_table): Add sgot, sgotplt,
	srelgot, splt, srelplt, igotplt, iplt, irelplt and irelifunc.

	* elf32-i386.c (elf_i386_link_hash_table): Remove sgot,
	sgotplt, srelgot, splt, srelplt, igotplt, iplt, irelplt and
	irelifunc.
	(elf_i386_link_hash_table_create): Likewise.
	(elf_i386_create_dynamic_sections): Likewise.
	(elf_i386_check_relocs): Likewise.
	(elf_i386_allocate_dynrelocs): Likewise.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_finish_dynamic_symbol): Likewise.
	(elf_i386_finish_dynamic_sections): Likewise.
	(elf_i386_create_got_section): Removed.

	* elf64-x86-64.c (elf64_x86_64_link_hash_table): Remove sgot,
	sgotplt, srelgot, splt, srelplt, igotplt, iplt, irelplt and
	irelifunc.
	(elf64_x86_64_compute_jump_table_size): Updated.
	(elf64_x86_64_link_hash_table_create): Likewise.
	(elf64_x86_64_create_dynamic_sections): Likewise.
	(elf64_x86_64_check_relocs): Likewise.
	(elf64_x86_64_allocate_dynrelocs): Likewise.
	(elf64_x86_64_size_dynamic_sections): Likewise.
	(elf64_x86_64_relocate_section): Likewise.
	(elf64_x86_64_finish_dynamic_symbol): Likewise.
	(elf64_x86_64_finish_dynamic_sections): Likewise.
	(elf64_x86_64_create_got_section): Removed.

	* elflink.c (_bfd_elf_create_got_section): Use log_file_align
	for pointer alignment.  Set up section pointers.
	(_bfd_elf_create_dynamic_sections): Likewise.
	(_bfd_elf_create_ifunc_sections): Moved to ...
	* elf-ifunc.c: Here.  New.

	* Makefile.am (BFD32_BACKENDS): Add elf-ifunc.lo.
	(BFD32_BACKENDS_CFILES): Add elf-ifunc.c.
	Run "make dep-am".
2009-06-16 13:41:10 +00:00
H.J. Lu 188dbb07f1 2009-06-15 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_allocate_dynrelocs): Update comments.
	* elf64-x86-64.c (elf64_x86_64_allocate_dynrelocs): Likewise.
2009-06-15 18:25:20 +00:00
H.J. Lu 048cbda441 2009-06-15 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_check_relocs): Reformat.
	* elf64-x86-64.c (elf64_x86_64_check_relocs): Likewise.
2009-06-15 17:23:43 +00:00
H.J. Lu eba077f227 2009-06-15 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_allocate_dynrelocs): Fix a typo.
	* elf64-x86-64.c (elf64_x86_64_allocate_dynrelocs): Likewise.
2009-06-15 13:12:33 +00:00
H.J. Lu b80ee1aa0e 2009-06-14 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c: Remove duplicated comments.
2009-06-15 00:37:08 +00:00
H.J. Lu 44c4ea11d3 bfd/
2009-06-14  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/10270
	* elf32-i386.c (elf_i386_allocate_dynrelocs): Disallow
	dynamic IFUNC pointer in non-shared object.  Use .got.plt
	for IFUNC definition in PIE.
	(elf_i386_allocate_dynrelocs): Resolve IFUNC definition in
	PIE locally.

	* elf64-x86-64.c (elf64_x86_64_allocate_dynrelocs): Disallow
	dynamic IFUNC pointer in non-shared object.  Use .got.plt
	for IFUNC definition in PIE.
	(elf64_x86_64_relocate_section): Resolve IFUNC definition in
	PIE locally.

ld/testsuite/

2009-06-14  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/10270
	* ld-ifunc/ifunc-9-x86.d: New.
	* ld-ifunc/ifunc-9-x86.s: Likewise.
2009-06-14 22:13:30 +00:00
H.J. Lu 637fa7af7f 2009-06-13 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_relocate_section): Properly report
	local symbol for unhandled relocation against STT_GNU_IFUNC
	symbol.
	* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
2009-06-14 05:53:55 +00:00
H.J. Lu 8b7e29925c 2009-06-13 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_check_relocs): Properly report
	local symbol for unhandled relocation against STT_GNU_IFUNC
	symbol.
	* elf64-x86-64.c (elf64_x86_64_check_relocs):  Likewise.
2009-06-14 05:45:09 +00:00
H.J. Lu c25bc9fc0d bfd/
2009-06-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/10269
	* elf32-i386.c: Include "objalloc.h" and "hashtab.h".
	(elf_i386_link_hash_table): Add loc_hash_table and
	loc_hash_memory.
	(elf_i386_local_hash): New.
	(elf_i386_local_htab_hash): Likewise.
	(elf_i386_local_htab_eq): Likewise.
	(elf_i386_get_local_sym_hash): Likewise.
	(elf_i386_link_hash_table_free): Likewise.
	(elf_i386_allocate_local_dynrelocs): Likewise.
	(elf_i386_finish_local_dynamic_symbol): Likewise.
	(bfd_elf64_bfd_link_hash_table_free): Likewise.
	(elf_i386_link_hash_table_create): Create loc_hash_table and
	loc_hash_memory.
	(elf_i386_check_relocs): Handle local STT_GNU_IFUNC symbols.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_finish_dynamic_sections): Likewise.
	(elf_i386_finish_dynamic_symbol): Check _DYNAMIC only if sym
	isn't NULL.

	* elf64-x86-64.c: Include "objalloc.h" and "hashtab.h".
	(elf64_x86_64_link_hash_table): Add loc_hash_table and
	loc_hash_memory.
	(elf64_x86_64_local_hash): New.
	(elf64_x86_64_local_htab_hash): Likewise.
	(elf64_x86_64_local_htab_eq): Likewise.
	(elf64_x86_64_get_local_sym_hash): Likewise.
	(elf64_x86_64_link_hash_table_free): Likewise.
	(elf64_x86_64_allocate_local_dynrelocs): Likewise.
	(elf64_x86_64_finish_local_dynamic_symbol): Likewise.
	(bfd_elf64_bfd_link_hash_table_free): Likewise.
	(elf64_x86_64_link_hash_table_create): Create loc_hash_table
	and loc_hash_memory.
	(elf64_x86_64_check_relocs): Handle local STT_GNU_IFUNC
	symbols.
	(elf64_x86_64_size_dynamic_sections): Likewise.
	(elf64_x86_64_relocate_section): Likewise.
	(elf64_x86_64_finish_dynamic_sections): Likewise.
	(elf64_x86_64_finish_dynamic_symbol): Check _DYNAMIC only if
	sym isn't NULL.

gas/

2009-06-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/10269
	* config/tc-i386.c (md_apply_fix): Use TC_FORCE_RELOCATION
	instead of generic_force_reloc.

	* config/tc-i386.h (TC_FORCE_RELOCATION): New.

ld/testsuite/

2009-06-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/10269
	*: ld-ifunc/ifunc-1-local-x86.d: New.
	*: ld-ifunc/ifunc-1-local-x86.s: Likewise.
	*: ld-ifunc/ifunc-2-local-i386.d: Likewise.
	*: ld-ifunc/ifunc-2-local-i386.s: Likewise.
	*: ld-ifunc/ifunc-2-local-x86-64.d: Likewise.
	*: ld-ifunc/ifunc-2-local-x86-64.s: Likewise.
	*: ld-ifunc/ifunc-4-local-x86.d: Likewise.
	*: ld-ifunc/ifunc-4-local-x86.s: Likewise.
	*: ld-ifunc/ifunc-5-local-i386.s: Likewise.
	*: ld-ifunc/ifunc-5-local-x86-64.s: Likewise.
	*: ld-ifunc/ifunc-5a-local-i386.d: Likewise.
	*: ld-ifunc/ifunc-5a-local-x86-64.d: Likewise.
	*: ld-ifunc/ifunc-5b-local-i386.d: Likewise.
	*: ld-ifunc/ifunc-5b-local-x86-64.d: Likewise.
2009-06-14 01:39:46 +00:00
H.J. Lu 2a81c24ab1 bfd/
2009-06-06  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c (elf_i386_link_hash_table): Add irelifunc.
	(elf_i386_link_hash_table_create): Initialize irelifunc.
	(elf_i386_check_relocs): Updated.  Set up irelifunc for
	shared objects.
	(elf_i386_allocate_dynrelocs): Use irelifunc for dynamic
	relocation for non-GOT reference of STT_GNU_IFUNC symbol in
	shared objects.
	(elf_i386_relocate_section): Likewise.

	* elf64-x86-64.c (elf64_x86_64_link_hash_table): Add irelifunc.
	(elf64_x86_64_link_hash_table_create): Initialize irelifunc.
	(elf64_x86_64_check_relocs): Updated.  Set up irelifunc for
	shared objects.
	(elf64_x86_64_allocate_dynrelocs): Use irelifunc for dynamic
	relocation for non-GOT reference of STT_GNU_IFUNC symbol in
	shared objects.
	(elf64_x86_64_relocate_section): Likewise.

	* elf-bfd.h (_bfd_elf_create_static_ifunc_sections): Renamed to
	...
	(_bfd_elf_create_ifunc_sections): This.

	* elflink.c (_bfd_elf_create_static_ifunc_sections): Renamd to
	...
	(_bfd_elf_create_ifunc_sections): This.  Create .rel[a].ifunc
	for shared objects.

ld/

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

	* scripttempl/elf.sc: Add .rel.ifunc and .rela.ifunc.
2009-06-06 22:39:25 +00:00
H.J. Lu 710ab2870f 2009-06-06 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_check_relocs): Make room for dynamic
	relocation for R_386_32 against STT_GNU_IFUNC symbol when
	building shared object.  Check info->executable instead of
	!info->shared when setting non_got_ref.
	(elf_i386_allocate_dynrelocs): Allocate dynamic relocation
	for non-GOT reference of STT_GNU_IFUNC symbol in shared
	object. Allocate GOT relocation agsinst STT_GNU_IFUNC
	symbol if needed.
	(elf_i386_relocate_section): Output dynamic relocation for
	R_386_32 against STT_GNU_IFUNC symbol to get the real
	function address when building shared object.
	(elf_i386_finish_dynamic_symbol): Output R_386_GLOB_DAT
	relocation for STT_GNU_IFUNC symbol in shared object.

	* elf64-x86-64.c (elf64_x86_64_check_relocs): Make room for
	dynamic relocation for R_X86_64_64 against STT_GNU_IFUNC
	symbol when building shared object.  Check info->executable
	instead of !info->shared when setting non_got_ref.
	(elf64_x86_64_allocate_dynrelocs): Allocate dynamic relocation
	for non-GOT reference of STT_GNU_IFUNC symbol in shared
	library. Allocate GOT relocation agsinst STT_GNU_IFUNC symbol
	if needed.
	(elf64_x86_64_relocate_section): Output dynamic relocation
	for R_X86_64_64 against STT_GNU_IFUNC symbol to get the real
	function address when building shared object.
	(elf64_x86_64_finish_dynamic_symbol): Output R_X86_64_GLOB_DAT
	relocation for STT_GNU_IFUNC symbol in shared object.
2009-06-06 11:48:11 +00:00
H.J. Lu 2e75bb3530 2009-06-03 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_allocate_dynrelocs): Remove check of
	h->plt.refcount > 0 on STT_GNU_IFUNC symbol.
	* elf64-x86-64.c (elf64_x86_64_allocate_dynrelocs): Likewise.
2009-06-03 16:58:12 +00:00
H.J. Lu 0018b0a3d5 2009-06-03 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_allocate_dynrelocs): Allocate
	GOT entry for STT_GNU_IFUNC symbol with pointer equality.
	(elf_i386_relocate_section): Adjust R_386_GOT32 relocation
	against STT_GNU_IFUNC symbols for static executables.
	(elf_i386_finish_dynamic_symbol): Load GOT entry with
	PLT entry for STT_GNU_IFUNC symbol with pointer equality.

	* elf64-x86-64.c (elf64_x86_64_allocate_dynrelocs): Allocate
	GOT entry for STT_GNU_IFUNC symbol with pointer equality.
	(elf64_x86_64_finish_dynamic_symbol): Load GOT entry with
	PLT entry for STT_GNU_IFUNC symbol with pointer equality.
2009-06-03 12:35:18 +00:00
H.J. Lu 7afd84dc1f bfd/
2009-06-02  H.J. Lu  <hongjiu.lu@intel.com>

	* elf32-i386.c (elf_i386_check_relocs): Increment
	got.refcount for R_386_GOT32/R_386_GOTOFF relocations
	against STT_GNU_IFUNC symbol.
	(elf_i386_allocate_dynrelocs): Set got.refcount to 0 if
	local STT_GNU_IFUNC definition is used.
	(elf_i386_relocate_section): Handle got.offset != -1 for
	R_386_GOT32/R_386_GOTOFF relocations against STT_GNU_IFUNC
	symbol.

	* elf64-x86-64.c (elf64_x86_64_check_relocs): Increment
	got.refcount for R_X86_64_GOTPCREL/R_X86_64_GOTPCREL64
	relocations against STT_GNU_IFUNC symbol.
	(elf64_x86_64_allocate_dynrelocs): Set got.refcount to 0 if
	local STT_GNU_IFUNC definition is used.
	(elf64_x86_64_relocate_section): Handle got.offset != -1
	for R_X86_64_GOTPCREL/R_X86_64_GOTPCREL64 relocations against
	STT_GNU_IFUNC symbol.

ld/testsuite/

2009-06-02  H.J. Lu  <hongjiu.lu@intel.com>

	* ld-ifunc/ifunc-5-i386.d: Renamed to ...
	* ld-ifunc/ifunc-5a-i386.d: This.

	* ld-ifunc/ifunc-5-x86-64.d: Renamed to ...
	* ld-ifunc/ifunc-5a-x86-64.d: This.

	* ld-ifunc/ifunc-5b-i386.d: New.
	* ld-ifunc/ifunc-5b-x86-64.d: Likewise.
	* ld-ifunc/ifunc-6a-i386.d: Likewise.
	* ld-ifunc/ifunc-6a-x86-64.d: Likewise.
	* ld-ifunc/ifunc-6b-i386.d: Likewise.
	* ld-ifunc/ifunc-6b-x86-64.d: Likewise.
	* ld-ifunc/ifunc-6-i386.s: Likewise.
	* ld-ifunc/ifunc-6-x86-64.s: Likewise.
	* ld-ifunc/ifunc-7a-i386.d: Likewise.
	* ld-ifunc/ifunc-7a-x86-64.d: Likewise.
	* ld-ifunc/ifunc-7b-i386.d: Likewise.
	* ld-ifunc/ifunc-7b-x86-64.d: Likewise.
	* ld-ifunc/ifunc-7-i386.s: Likewise.
	* ld-ifunc/ifunc-7-x86-64.s: Likewise.
2009-06-02 17:31:42 +00:00
H.J. Lu cbe950e9fe bfd/
2009-06-01  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/10205
	* 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): Handle STT_GNU_IFUNC symbol first.
	(elf_i386_adjust_dynamic_symbol): Likewise.
	(elf_i386_allocate_dynrelocs): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_size_dynamic_sections): Set up .iplt and .igot.plt
	sections.
	(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): Handle STT_GNU_IFUNC symbol first.
	(elf64_x86_64_adjust_dynamic_symbol): Likewise.
	(elf64_x86_64_allocate_dynrelocs): Likewise.
	(elf64_x86_64_relocate_section): Likewise.
	(elf64_x86_64_size_dynamic_sections): Set up .iplt and .igot.plt
	sections.
	(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.

	* reloc.c (BFD_RELOC_386_IRELATIVE): New.
	(BFD_RELOC_X86_64_IRELATIVE): Likewise.

	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

include/elf/

2009-06-01  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/10205
	* i386.h (R_386_IRELATIVE): New.
	* x86-64.h (R_X86_64_IRELATIVE): Likewise.

ld/testsuite/

2009-06-01  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/10205
	* 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.
	* ld-ifunc/ifunc-2-i386.d: Likewise.
	* ld-ifunc/ifunc-2-i386.s: Likewise.
	* ld-ifunc/ifunc-2-x86-64.d: Likewise.
	* ld-ifunc/ifunc-2-x86-64.s: Likewise.
	* ld-ifunc/ifunc-3a-x86.d: Likewise.
	* ld-ifunc/ifunc-3b-x86.d: Likewise.
	* ld-ifunc/ifunc-3-x86.s: Likewise.
	* ld-ifunc/ifunc-4-x86.d: Likewise.
	* ld-ifunc/ifunc-4-x86.s: Likewise.
	* ld-ifunc/ifunc-5-i386.d: Likewise.
	* ld-ifunc/ifunc-5-i386.s: Likewise.
	* ld-ifunc/ifunc-5-x86-64.d: Likewise.
	* ld-ifunc/ifunc-5-x86-64.s: Likewise.
2009-06-01 13:11:52 +00:00
H.J. Lu eb4ff4d67f 2009-05-29 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (link_hash_newfunc): Add elf_i386_ prefix.
	(create_got_section): Likewise.
	(allocate_dynrelocs): Likewise.
	(readonly_dynrelocs): Likewise.
	(set_tls_module_base): Likewise.
	(dtpoff_base): Likewise.
	(tpoff): Likewise.
	(elf_i386_link_hash_table_create): Updated.
	(elf_i386_create_dynamic_sections): Likewise.
	(elf_i386_check_relocs): Likewise.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.

	* elf64-x86-64.c (link_hash_newfunc): Add elf64_x86_64_ prefix.
	(create_got_section): Likewise.
	(allocate_dynrelocs): Likewise.
	(readonly_dynrelocs): Likewise.
	(set_tls_module_base): Likewise.
	(dtpoff_base): Likewise.
	(tpoff): Likewise.
	(elf64_x86_64_link_hash_table_create): Updated.
	(elf64_x86_64_create_dynamic_sections): Likewise.
	(elf64_x86_64_check_relocs): Likewise.
	(elf64_x86_64_size_dynamic_sections): Likewise.
	(elf64_x86_64_relocate_section): Likewise.
2009-05-29 18:30:30 +00:00
H.J. Lu 68d7e96a43 2009-05-26 H.J. Lu <hongjiu.lu@intel.com>
* elf-bfd.h (_bfd_elf_is_ifunc_symbol): New.

	* elf32-i386.c (is_indirect_symbol): Renamed to ...
	* elflink.c (_bfd_elf_is_ifunc_symbol): This.

	* elf32-i386.c (allocate_dynrelocs): Updated.
	(elf_i386_relocate_section): Likewise.
	* elf64-x86-64.c (allocate_dynrelocs): Likewise.
	(elf64_x86_64_relocate_section): Likewise.

	* elf64-x86-64.c (is_indirect_symbol): Removed.
2009-05-26 22:18:22 +00:00
Nick Clifton d8045f234d include/elf
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * common.h (STT_GNU_IFUNC): Define.

elfcpp
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * (enum STT): Add STT_GNU_IFUNC.

gas
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * config/obj-elf.c (obj_elf_type): Add support for a
        gnu_indirect_function type.
        * config/tc-i386.c (tc_i386_fix_adjustable): Do not adjust fixups
        against indirect function symbols.
        * doc/as.texinfo (.type): Document the support for the
        gnu_indirect_function symbol type.
        * NEWS: Mention the new feature.

gas/testsuite
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * gas/elf/elf.exp: Extend type test to include an ifunc symbol.
        Provide an alternative test for targets which do not support ifunc
        symbols.
        (type.s): Add entry for an ifunc symbol.
        (type.e): Add ifunc entry to expected symbol dump.
        (section2.e-armelf): Add  entry for ifunc symbol.
        (type-noifunc.s): New file.
        (type-noifunc.e): New file.

bfd/
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs
        section pointer.
        (struct elf_obj_data): Add has_ifunc_symbols boolean.
        * elf.c (swap_out_syms): Convert BSF_GNU_INDIRECT_FUNCTION flags
        into a STT_GNU_IFUNC symbol type.
        (_bfd_elf_is_function_type): Accept STT_GNU_IFUNC as a function
        type.
        (_bfd_elf_set_osabi): Set the osasbi field to ELFOSABI_LINUX if
        the binary contains ifunc symbols.
        * elfcode.h (elf_slurp_symbol_table): Translate the STT_GNU_IFUNC
        symbol type into a BSF_GNU_INDIRECT_FUNCTION flag.
        * elf32-i386.c (is_indirect_function): New function.
        (elf_i386_check_relocs): Create an ifunc output section.
        (allocate_dynrelocs): Create dynamic relocs in the ifunc output
        section if necessary.
        (elf_i386_relocate_section): Emit a reloc against an ifunc symbol
        if necessary.
        (elf_i386_add_symbol_hook): New function. Set the
        has_ifunc_symbols field of the elf_obj_data structure if an ifunc
        symbol is encountered.
        (elf_backend_post_process_headers): Define.
        (elf_backend_add_symbol_hook): Define.
        (elf_i386_post_process_headers): Rename to
        elf_i388_fbsd_post_process_headers.
        * elf64-x86_64.c (IS_X86_64_PCREL_TYPE): New macro.
        (is_indirect_function): New function.
        (elf64_x86_64_check_relocs): Create an ifunc output section.
        (allocate_dynrelocs): Create dynamic relocs in the ifunc output
        section if necessary.
        (elf64_x86_64_relocate_section): Emit a reloc against an ifunc
        symbol if necessary.
        (elf_i386_add_symbol_hook): Set the has_ifunc_symbols field of the
        elf_obj_data structure if an ifunc symbol is encountered.
        (elf_backend_post_process_headers): Define.
        * elflink.c (_bfd_elf_adjust_dynamic_symbol): Always create a PLT
        if we have ifunc symbols to handle.
        (get_ifunc_reloc_section_name): New function.  Computes the name
        for an ifunc section.
        (_bfd_elf_make_ifunc_reloc_section): New function.  Creates a
        section to hold ifunc relocs.
        * syms.c (BSF_GNU_INDIRECT_FUNCTION): Define.
        (bfd_print_symbol_vandf): Handle ifunc symbols.
        (bfd_decode_symclass): Likewise.
        * bfd-in2.h: Regenerate.

binutils
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * readelf.c (dump_relocations): Display a relocation against an
        ifunc symbol as if it were a function invocation.
        (get_symbol_type): Handle STT_GNU_IFUNC.

ld
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * NEWS: Mention support for IFUNC symbols.

ld/testsuite
2009-04-30  Nick Clifton  <nickc@redhat.com>

        * ld-ifunc: New directory.
        * ld-ifunc/ifunc.exp: New file: Run the IFUNC tests.
        * ld-ifunc/prog.c: New file.
        * ld-ifunc/lib.c: New file.
2009-04-30 15:47:13 +00:00
H.J. Lu c4fb387b7c 2009-03-12 H.J. Lu <hongjiu.lu@intel.com>
PR ld/9938
	* elf32-i386.c (elf_i386_check_tls_transition): Use strncmp
	to check ___tls_get_addr.

	* elf64-x86-64.c (elf64_x86_64_check_tls_transition): Use
	strncmp to check __tls_get_addr.
2009-03-12 17:13:41 +00:00
H.J. Lu 09e8c3bf89 2009-03-11 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_check_tls_transition): Fix a typo in
	comments.
2009-03-11 16:42:23 +00:00