Commit Graph

316 Commits

Author SHA1 Message Date
Hans-Peter Nilsson 10455f89a6 * elf-bfd.h (struct elf_backend_data): New member got_elt_size.
(_bfd_elf_default_got_elt_size): Declare.
	* elflink.c (struct alloc_got_off_arg): Replace member got_elt_size
	by new member info.
	(elf_gc_allocate_got_offsets): Adjust for calling bed->got_elt_size
	to get the element size instead of using a gofarg entry.
	(bfd_elf_gc_common_finalize_got_offsets): Similar.
	(_bfd_elf_default_got_elt_size): New function.
	* elfxx-target.h: New macro elf_backend_got_elt_size.
	(elfNN_bed): Use it.
2008-11-21 00:02:37 +00:00
Alan Modra 58217f2928 * elflink.c (bfd_elf_final_link): Move code reading relocs to..
* elf32-spu.c (spu_elf_count_relocs): ..here.  Adjust params.
	* elf-bfd.h (struct elf_backend_data): Update elf_backend_count_relocs
	params.
2008-10-20 10:57:33 +00:00
Alan Modra bef264833b * elflink.c (bfd_elf_final_link): Use d_ptr rather than d_val
where Elf_Internal_Dyn holds an address.
2008-10-20 10:50:37 +00:00
Alan Modra bcacc0f587 bfd/
* elf.c (bfd_elf_set_group_contents): Assign sh_info for ld -r when
	the signature symbol is global.
	* elflink.c (elf_link_input_bfd): Ensure group signature symbol
	is output when ld -r.  Set group sh_info when local.
	* linker.c (default_indirect_link_order): Handle group sections
	specially.
ld/
	* ldemul.c (ldemul_place_orphan): Add "name" param.
	* ldemul.h (ldemul_place_orphan): Update prototype.
	(struct ld_emulation_xfer_struct <place_orphan>): Likewise.
	* ldlang.c (lang_place_orphans): Generate unique section names here..
	* emultempl/elf32.em (place_orphan): ..rather than here.  Don't
	directly use an existing output section statement that has no
	bfd section.
	* emultempl/pe.em (place_orphan): Likewise.
	* emultempl/pep.em (place_orphan): Likewise.
	* emultempl/beos.em (place_orphan): Adjust.
	* emultempl/spuelf.em (spu_place_special_section): Adjust
	place_orphan call.
	* emultempl/genelf.em (gld${EMULATION_NAME}_after_open): New function.
	(LDEMUL_AFTER_OPEN): Define.
2008-10-03 09:40:49 +00:00
Alan Modra 33177bb154 * elflink.c (elf_link_add_object_symbols): Don't ignore returned
value of check_directives.
2008-09-30 04:47:50 +00:00
Alan Modra 9659de1cb3 * elf.c (_bfd_elf_init_private_section_data): Tweak union copy.
(bfd_section_from_shdr): Don't change SHT_GROUP section name.
	* elflink.c (section_signature): New function.
	(_bfd_elf_section_already_linked): Use it.
2008-09-28 13:30:35 +00:00
H.J. Lu 0a36a439ee bfd/
2008-09-16  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/6877
	* elflink.c (_bfd_elf_merge_symbol): Allow a common symbol to
	override the function in a shared library.

ld/testsuite/

2008-09-16  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/6877
	* ld-elf/comm1.c: New.
	* ld-elf/func1.c: Likewise.

	* ld-elf/shared.exp: Add tests for libfunc1.so and comm1.
2008-09-16 14:09:34 +00:00
Jan Kratochvil b2064611d4 bfd/
Fix PR ld/3290 regression for cross-files DW_FORM_ref_addr relocations.
	* elflink.c (elf_link_add_object_symbols): Make debug symbols local
	now only for non-RELOCATABLE targets.

ld/testsuite/
	* ld-x86-64/dwarfreloc.exp, ld-x86-64/dwarfreloc.rd,
	ld-x86-64/dwarfreloc1.s, ld-x86-64/dwarfreloc2.s: New test.
2008-08-22 08:32:40 +00:00
Alan Modra 4dd07732f2 * elf.c (bfd_elf_get_elf_syms): Don't leak memory on error.
* elflink.c (_bfd_elf_link_read_relocs): bfd_release on error.
	(elf_link_add_object_symbols): Don't leak memory on error.
	(bfd_elf_size_dynsym_hash_dynstr): Likewise.
	(elf_fixup_link_order): Free sections.
2008-08-08 08:00:14 +00:00
Richard Sandiford d35fd65983 bfd/
* elf-bfd.h (elf_backend_data): Add a "rela_plts_and_copies_p" field.
	* elfxx-target.h (elf_backend_rela_plts_and_copies_p): New macro.
	(elfNN_bed): Use it.
	* elf.c (_bfd_elf_get_synthetic_symtab): Use rela_plts_and_copies_p
	instead of default_use_rela_p to choose between ".rel.plt" and
	".rela.plt".
	* elflink.c (_bfd_elf_create_dynamic_sections): Use
	rela_plts_and_copies_p instead of default_use_rela_p to choose
	between ".rel.plt" and ".rela.plt", and between ".rel.bss" and
	".rela.bss".
2008-08-07 20:04:32 +00:00
Chris Demetriou bda987c255 2008-07-22 Simon Baldwin <simonb@google.com>
* elflink.c (elf_link_output_extsym): Set st_size to zero for
        symbols from dynamic libraries.
2008-07-22 04:58:33 +00:00
H.J. Lu 88ba32a0f9 2008-07-21 H.J. Lu <hongjiu.lu@intel.com>
PR ld/4424
	* elflink.c (_bfd_elf_merge_symbol): Call bed->relocs_compatible
	to check if 2 inputs are compatible.
2008-07-21 16:13:27 +00:00
Daniel Jacobowitz 266b05cf76 * elf.c (_bfd_elf_get_dynamic_reloc_upper_bound)
(_bfd_elf_canonicalize_dynamic_reloc): Find dynamic relocations
	even if they are not loaded.
	* elflink.c (_bfd_elf_init_2_index_sections): Set data_index_section
	first.

	* ld-arm/symbian-seg1.s, ld-arm/symbian-seg1.d: New files.
	* ld-arm/arm-elf.exp: Run symbian-seg1.
2008-04-29 11:53:45 +00:00
Alan Modra a94b9d2d3a * elflink.c (bfd_elf_size_dynamic_sections): Ignore GNU-stack note
in EXEC_P bfds.
2008-04-08 05:41:19 +00:00
Alan Modra 72de500931 include/elf/
* internal.h (Elf_Internal_Shdr): Change sh_link and sh_info from
	unsigned long to unsigned int.  Change sh_addralign to bfd_vma.
	Order struct as for external version.
bfd/
	* elf.c (_bfd_elf_make_section_from_shdr): Remove unnecessary cast.
	(_bfd_elf_assign_file_position_for_section): Simplify align.
	(_bfd_elf_init_reloc_shdr): Ensure shift expression wide enough
	for sh_addralign.
	(elf_fake_sections, swap_out_syms): Likewise.
	* elflink.c (bfd_elf_final_link): Likewise.
binutils/
	* readelf.c: Use %u throughout when printing sh_link or sh_info,
	%lu when printing sh_addralign.
	(process_version_sections): Use identical formats when printing
	all offset and sh_link fields.
2008-03-13 05:27:42 +00:00
Alan Modra 4fbb74a605 include/elf/
PR 5900
	* common.h (SHN_BAD): Delete.
	(SHN_LORESERVE .. SHN_HIRESERVE): Move to..
	* external.h: ..here.
	* internal.h (SHN_LORESERVE, SHN_HIRESERVE): Define.
	(SHN_LOPROC, SHN_HIPROC, SHN_LOOS, SHN_HIOS): Define.
	(SHN_ABS, SHN_COMMON, SHN_XINDEX, SHN_BAD): Define.
bfd/
	PR 5900
	* elf-bfd.h: Include elf/internal.h after elf/external.h.
	* elfcode.h (elf_swap_symbol_in): Map reserved shndx range.
	(elf_swap_symbol_out): Adjust SHN_XINDEX test.
	(elf_swap_ehdr_out): Mask SHN_LORESERVE and SHN_XINDEX to values
	seen in external structs.
	(valid_section_index_p): Delete.
	(elf_object_p): Don't increment section numbers over reserved range.
	Simplify test for valid sh_link, sh_info and e_shstrndx fields.
	(elf_write_shdrs_and_ehdr): Mask SHN_LORESERVE and SHN_XINDEX to values
	seen in external structs.  Don't increment section numbers over
	reserved range.
	* elf.c (bfd_elf_sym_name): Remove redundant tests on st_shndx.
	(bfd_section_from_shdr): Likewise.
	(group_signature): Range check before accessing elf_elfsections.
	(_bfd_elf_setup_sections): Likewise.
	(bfd_section_from_shdr): Likewise.
	(bfd_section_from_shdr): Don't increment section number over
	reserved sections.
	(assign_file_positions_for_non_load_sections): Likewise.
	(assign_file_positions_except_relocs): Likewise.
	(_bfd_elf_write_object_contents): Likewise.
	(assign_section_numbers): Likewise.  Adjust for changed SHN_*.
	(prep_headers): Delete unused variable.
	* elflink.c (bfd_elf_link_record_local_dynamic_symbol): Adjust
	for changed SHN_* values.
	(check_dynsym, elf_link_input_bfd): Likewise.
	(bfd_elf_final_link): Likewise.  Don't skip over reserved section
	range.
	(elf_fixup_link_order): Check that sh_link field is valid.
	* elf-hppa.h (elf_hppa_add_symbol_hook): Make "index" unsigned.
	* elf32-arm.c (elf32_arm_gc_mark_extra_sections): Range check before
	accesssing elf_elfsections.
	* elf32-avr.c (elf32_avr_size_stubs): Likewise.
	* elf32-hppa.c (elf32_hppa_size_stubs): Likewise.
	* elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Likewise.
	* elf64-hppa.c (elf64_hppa_check_relocs): Adjust for changed
	SHN_* defines.  Test for SHN_BAD return from
	_bfd_elf_section_from_bfd_section
binutils/
	PR 5900
	* readelf.c (SECTION_HEADER_INDEX, SECTION_HEADER_NUM): Delete.
	Remove use throughout file.
	(SECTION_HEADER): Likewise.
	(dump_relocations): Don't adjust st_shndx for reserved range.
	(process_file_header): Mask SHN_XINDEX to values seen in external
	elf structs.  Simplify valid section index tests.
	(get_32bit_elf_symbols, get_64bit_elf_symbols): Mask SHN_XINDEX.
	Map reserved st_shndx to internal form.
	(process_section_groups): Test that group symbol st_shndx is in
	range, not just non-zero.  Delete reserved range check.
	(get_symbol_index_type): Mask "type" to 16 bits when printing PRC,
	OS or RSV.
gdb/
	PR 5900
	* elfread.c (elf_symtab_read): Make shndx an unsigned int.
	* mipsread.c: Include elf/internal.h.
	(read_alphacoff_dynamic_symtab): Map external reserved sym_shndx
	to internal range.
ld/testsuite/
	PR 5900
	* ld-elf/sec64k.exp: Update.
2008-03-12 08:37:09 +00:00
Alan Modra cb33740c88 * elf-bfd.h (_bfd_elf_section_from_bfd_section): Update prototype.
* elf.c (_bfd_elf_section_from_bfd_section): Return unsigned int,
	SHN_BAD on error.
	(_bfd_elf_print_private_bfd_data): Test for SHN_BAD result from
	_bfd_elf_section_from_bfd_section, not -1.
	(swap_out_syms): Likewise.
	* elflink.c (elf_link_add_object_symbols): Likewise.
	(bfd_elf_get_bfd_needed_list): Likewise.
	(bfd_elf_match_symbols_in_sections): Likewise.
	(elf_link_add_object_symbols): Don't bother testing for symbols
	using normal sections before calling bfd_section_from_elf_index.
	(elf_link_input_bfd, bfd_elf_final_link): Likewise.
	(bfd_elf_reloc_symbol_deleted_p): Likewise.
	* elfcode.h (elf_slurp_symbol_table): Likewise.
	* elf32-spu.c (get_sym_h): Likewise.
	* elf32-xtensa.c (get_elf_r_symndx_section): Likewise.
	* elf64-ppc.c (opd_entry_value, get_sym_h, ppc64_elf_edit_toc): Ditto.
	* elf64-sh64.c (sh_elf64_get_relocated_section_contents): Likewise.
2008-03-11 23:23:23 +00:00
H.J. Lu d95edcac72 2008-03-02 H.J. Lu <hongjiu.lu@intel.com>
PR ld/5789
	* elflink.c (_bfd_elf_symbol_refs_local_p): Always return true
	for hidden and local symbols.
2008-03-02 22:26:09 +00:00
H.J. Lu 3ae181ee89 2008-02-22 H.J. Lu <hongjiu.lu@intel.com>
PR ld/5788
	* elflink.c (elf_create_symbuf): Correct buffer size and
	position.
2008-02-23 00:02:05 +00:00
Nick Clifton 515ef31dec PR 868
* libbfd.c (bfd_realloc_or_free): New function.  Performs like
   bfd_realloc, but if the (re)allocation fails, the pointer is
   freed.
   * libbfd-in.h: Prototype.
   * libbfd.h: Regenerate.
   * bfdio.c (bfd_bwrite): Use the new function.
   (bfd_seek): Likewise.
   * bfdwin.c:(bfd_get_file_window): Likewise.
   * elf-strtab.c (_bfd_elf_strtab_add): Likewise.
   * elf32-ppc.c (ppc_elf_relax_section): Likewise.
   * elf32-xtensa.c (vsprintf_msg): Likewise.
   * mach-o.c (bfd_mach_o_core_fetch_environment): Likewise.
   * stabs.c (_bfd_link_seciton_stabs): Likewise.
   * vms-misc.c (_bfd_vms_get_record): Likewise.
   * vms-tir.c (check_section): Likewise.
   * vms.c (vms_new_section_hook): Likewise.
   * elf32-arm.c (elf32_arm_section_map_add): Check that the
   allocation of sec_data->map succeeded before using it.
   * elflink.c (elf_link_output_sym): Do not overwrite finfo->
   symshndxbuf until it is known that the reallocation succeeded.
2008-02-20 17:42:36 +00:00
Alan Modra f13a99db51 include/
* bfdlink.h (struct bfd_link_hash_table): Delete creator field.
	(struct bfd_link_info): Add output_bfd.
bfd/
	* elflink.c: Replace all accesses to hash->creator field with
	output_bfd->xvec.
	* cofflink.c: Likewise.
	* coff-h8300.c: Likewise.
	* ecoff.c: Likewise.
	* elf32-m68hc1x.c: Likewise.
	* elf32-ppc.c: Likewise.
	* elf64-alpha.c: Likewise.
	* elf64-ppc.c: Likewise.
	* elf64-sparc.c: Likewise.
	* elfxx-mips.c: Likewise.
	* i386linux.c: Likewise.
	* m68klinux.c: Likewise.
	* sparclinux.c: Likewise.
	* sunos.c: Likewise.
	* xcofflink.c: Likewise.
	* linker.c: Likewise.
	(_bfd_link_hash_table_init): Don't store creator.
ld/
	* ldmain.h (output_bfd): Delete.
	* ldmain.c (output_bfd): Delete.
	Replace all occurrences of output_bfd with link_info.output_bfd.
	* ldcref.c: Likewise.
	* ldctor.c: Likewise.
	* ldemul.c: Likewise.
	* ldexp.c: Likewise.
	* ldfile.c: Likewise.
	* ldlang.c: Likewise.
	* ldmisc.c: Likewise.
	* ldwrite.c: Likewise.
	* pe-dll.c: Likewise.
	* emultempl/aix.em: Likewise.
	* emultempl/alphaelf.em: Likewise.
	* emultempl/armcoff.em: Likewise.
	* emultempl/armelf.em: Likewise.
	* emultempl/avrelf.em: Likewise.
	* emultempl/beos.em: Likewise.
	* emultempl/elf-generic.em: Likewise.
	* emultempl/elf32.em: Likewise.
	* emultempl/gld960.em: Likewise.
	* emultempl/hppaelf.em: Likewise.
	* emultempl/irix.em: Likewise.
	* emultempl/linux.em: Likewise.
	* emultempl/lnk960.em: Likewise.
	* emultempl/m68hc1xelf.em: Likewise.
	* emultempl/mmix-elfnmmo.em: Likewise.
	* emultempl/mmo.em: Likewise.
	* emultempl/pe.em: Likewise.
	* emultempl/pep.em: Likewise.
	* emultempl/ppc32elf.em: Likewise.
	* emultempl/ppc64elf.em: Likewise.
	* emultempl/scoreelf.em: Likewise.
	* emultempl/sh64elf.em: Likewise.
	* emultempl/spuelf.em: Likewise.
	* emultempl/sunos.em: Likewise.
	* emultempl/vanilla.em: Likewise.
	* emultempl/vxworks.em: Likewise.
	* emultempl/xtensaelf.em: Likewise.
	* emultempl/z80.em: Likewise.
	* ldlang.c (open_output): Don't return output, instead write
	link_info_output_bfd directly.
	* emultempl/alphaelf.em: Replace occurrences of link_info.hash->creator
	with link_info.output_bfd->xvec.
	* emultempl/hppaelf.em: Likewise.
	* emultempl/ppc32elf.em: Likewise.
	* emultempl/ppc64elf.em: Likewise.
	* emultempl/spuelf.em: Likewise.
2008-02-15 03:35:53 +00:00
Alan Modra d40f3da904 * elflink.c (compute_bucket_count): Warning fixes. 2008-02-14 08:31:47 +00:00
Alan Modra 297d8443d0 * elflink.c (_bfd_elf_link_output_relocs): Correct error return. 2008-01-21 03:53:07 +00:00
Alan Modra 74f0fb5065 bfd/
PR 5604
	* elf-bfd.h (struct elf_backend_data): Add gc_keep.  Remove param
	names from others.
	(_bfd_elf_gc_keep): Declare.
	* elfxx-target.h (elf_backend_gc_keep): Define.
	(elfNN_bed): Init new field.
	* elflink.c (_bfd_elf_gc_keep): New function.
	(bfd_elf_gc_sections): Call gc_keep.
	* elf64-ppc.c (elf_backend_gc_keep): Define.
	(struct _ppc64_elf_section_data): Move .opd related fields to
	a struct so they don't occupy the same storage.  Adjust accesses
	throughout file.
	(ppc64_elf_gc_keep): New function, split out from..
	(ppc64_elf_gc_mark_hook): ..here.  Don't call _bfd_elf_gc_mark
	to mark .opd section, just set gc_mark.
	(ppc64_elf_edit_opd): Remove no_opd_opt parm.  Don't set opd->adjust
	unless we are changing .opd.  Test non-NULL opd->adjust at all
	accesses throughout file.
	* elf64-ppc.h (ppc64_elf_edit_opd): Update prototype.
ld/
	PR 5604
	* ldlang.c (lang_gc_sections): Move code to set SEC_KEEP on entry
	syms to _bfd_elf_gc_keep.
	* emultempl/ppc64elf.em (ppc_before_allocation): Don't call
	ppc64_elf_edit_opd if no_opd_opt.
2008-01-15 07:25:49 +00:00
Tristan Gingold 7dda2462a7 2008-01-11 Tristan Gingold <gingold@adacore.com>
Eric Botcazou  <ebotcazou@adacore.com>

	* elf32-ppc.c (ppc_elf_gc_sweep_hook): Exit early if generating a
	relocatable.
	* elf32-arm.c (elf32_arm_gc_sweep_hook): Likewise.
	* elf32-cris.c (cris_elf_gc_sweep_hook): Likewise.
	* elf32-hppa.c (elf32_hppa_gc_sweep_hook): Likewise.
	* elf32-i386.c (elf_i386_gc_sweep_hook): Likewise.
	* elf32-m32r.c (m32r_elf_gc_sweep_hook): Likewise.
	* elf32-m68k.c (elf_m68k_gc_sweep_hook): Likewise.
	* elf32-s390.c (elf_s390_gc_sweep_hook): Likewise.
	* elf32-sh.c (sh_elf_gc_sweep_hook): Likewise.
	* elf32-vax.c (elf_vax_gc_sweep_hook): Likewise.
	* elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Likewise.
	* elf64-x86-64.c (elf64_x86_64_gc_sweep_hook): Likewise.
	* elf64-s390.c (elf_s390_gc_sweep_hook): Likewise.
	* elf64-ppc.c (ppc64_elf_gc_sweep_hook): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_gc_sweep_hook): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_gc_sweep_hook): Likewise.
	* elflink.c (bfd_elf_gc_sections): Do not punt on relocatable output
	or executable output with relocations.
2008-01-11 09:07:04 +00:00
H.J. Lu ace7938838 bfd/
2008-01-07  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/5522
	* elflink.c (elf_link_input_bfd): Don't write out a section if
	its output section is marked with SEC_NEVER_LOAD.

ld/testsuite/

2008-01-07  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/5522
	* ld-elf/noload-3.d: New file.
	* ld-elf/noload-3.s: Likewise.
	* ld-elf/noload-3.t: Likewise.
2008-01-07 16:45:35 +00:00
Richard Sandiford 9d0a14d3f3 bfd/
* elf-bfd.h (eh_cie_fde): Add u.fde.next_for_section and
	u.cie.gc_mark.
	(bfd_elf_section_data): Add fde_list.
	(elf_fde_list): New macro.
	(elf_obj_tdata): Add eh_frame_section.
	(elf_eh_frame_section): New macro.
	(_bfd_elf_gc_mark_reloc): Remove last parameter.
	(_bfd_elf_gc_mark_fdes): Declare.
	* elf-eh-frame.c (_bfd_elf_get_eh_frame_sec_info): Chain the FDEs
	for each input section.
	(mark_entry, _bfd_elf_gc_mark_fdes): New functions.
	* elflink.c (_bfd_elf_gc_mark_reloc): Remove is_eh parameter.
	(_bfd_elf_gc_mark): Update call accordingly.  Mark the relocations
	againts the section's FDEs.  Don't mark the bfd's elf_eh_frame_section.
	(bfd_elf_gc_sections): Parse each input bfd's .eh_frame before
	marking any input sections.  Remove the current EH handling.
	* section.c (bfd_section): Remove gc_mark_from_eh.
	* ecoff.c (bfd_debug_section): Update initializer accordingly.
2007-12-15 09:34:48 +00:00
Richard Sandiford ca92cecbbe bfd/
* elf-bfd.h (eh_cie_fde): Add u.cie.  Document how u.fde.cie_inf
	changes when removed == 0.
	(eh_frame_hdr_info): Add parsed_eh_frames.
	(_bfd_elf_begin_eh_frame_parsing): Declare.
	(_bfd_elf_parse_eh_frame): Declare.
	(_bfd_elf_end_eh_frame_parsing): Declare.
	* elf-eh-frame.c (_bfd_elf_begin_eh_frame_parsing): New function.
	(_bfd_elf_parse_eh_frame): New function, split out from
	_bfd_elf_discard_section_eh_frame.  Make a first pass through the
	buffer to calculate the number of entries and CIEs.  Allocate memory
	for them before the main loop.  Replace current extended cie
	representation with a pair of pointers, one to the local eh_cie_fde
	and one to the full struct cie.  Allocate a separate array of struct
	cies if not merging.  Merge CIEs during the main loop and set up each
	u.cie.merged field.  Point an FDE's cie_inf field directly at the
	local CIE.  Initially assume that all entries should be removed.
	(_bfd_elf_end_eh_frame_parsing): New function.
	(_bfd_elf_discard_section_eh_frame): Assume that the section has
	already been parsed.  Use a separate pass to mark entries that
	need to be kept.  Use the u.cie.merged field to track a CIE's
	group representative.
	* elflink.c (bfd_elf_discard_info): Call _bfd_elf_parse_eh_frame
	before _bfd_elf_discard_section_eh_frame.  Wrap loop with calls to
	_bfd_elf_begin_eh_frame_parsing and _bfd_elf_end_eh_frame_parsing.
2007-12-15 09:33:51 +00:00
Richard Sandiford 5241d85325 bfd/
* elf-bfd.h (_bfd_elf_gc_mark_rsec, _bfd_elf_gc_mark_reloc): Declare.
	(_bfd_elf_gc_mark): Use elf_gc_mark_hook_fn.
	* elflink.c (init_reloc_cookie, fini_reloc_cookie)
	(init_reloc_cookie_rels, fini_reloc_cookie_rels): New functions,
	split out from...
	(bfd_elf_discard_info): ...here.
	(init_reloc_cookie_for_section): New function.
	(fini_reloc_cookie_for_section): Likewise.
	(_bfd_elf_gc_mark_rsec, _bfd_elf_gc_mark_reloc): New functions,
	split out from...
	(_bfd_elf_gc_mark): ...here.  Use init_reloc_cookie_for_section
	and fini_reloc_cookie_for_section.
2007-12-15 09:31:41 +00:00
Nick Clifton 430a16a51d * elflink.c (elf_link_output_extsym): Weaken assertion: if --gc-section is set, there may be no TLS segment.
* lib/ld-lib.exp (check_gc_sections_available): New proc, based on the version in gcc/testsuite/lib/target-supports.exp.
* ld-elf/eld.exp: Use check_gc_sections_available.
2007-11-20 15:08:25 +00:00
Alan Modra cdfeee4f47 * elf-bfd.h (bfd_elf_perform_complex_relocation): Update prototype.
* elflink.c (bfd_elf_perform_complex_relocation): Return status.
	Don't print reloc overflow message.
	* elf32-mep.c (mep_elf_relocate_section): Handle status from
	bfd_elf_perform_complex_relocation.
2007-11-19 02:19:39 +00:00
Alan Modra 8f317e3169 * elf-bfd.h (bfd_elf_match_symbols_in_sections): Don't declare.
* elflink.c (bfd_elf_match_symbols_in_sections): Make static.
	Remove section name comparisons.
2007-10-31 07:36:46 +00:00
Alan Modra 13285a1b2c PR ld/4424
* config.bfd (targ_selvecs): Add bfd_elf64_alpha_vec for
	alpha/FreeBSD.  Add bfd_elf64_sparc_vec for sparc64/FreeBSD.
	Add bfd_elf32_i386_vec and bfd_efi_app_ia32_vec for i386/FreeBSD.
	(targ64_selvecs): Set for i386/FreeBSD.
	* elf-bfd.h (elf_backend_data): Add relocs_compatible.
	(_bfd_elf_default_relocs_compatible): Declare.
	(_bfd_elf_relocs_compatible): Declare.
	* elfxx-target.h (elf_backend_relocs_compatible): Define.
	(elfNN_bed): Init new relocs_compatible field.
	* elflink.c (_bfd_elf_default_relocs_compatible): New function.
	(_bfd_elf_relocs_compatible): New function.
	(elf_link_add_object_symbols): Call bed->relocs_compatible.
	* elf32-i386.c (elf_backend_relocs_compatible): Define.
	* elf64-alpha.c: Likewise.
	* elf64-sparc.c: Likewise.
	* elf64-x86-64.c: Likewise.
2007-10-18 09:13:51 +00:00
Bob Wilson 1dd2625faa * elflink.c (_bfd_elf_check_kept_section): Use the section rawsize
values if they are set.
2007-10-16 15:51:38 +00:00
Nick Clifton 4b93929bf9 PR 5160
* elflink.c (eval_symbol): Remove bufsz variable and use sizeof(symbuf) where necessary.
2007-10-12 16:25:21 +00:00
Alan Modra a0c8462faf * elflink.c: Formatting. 2007-09-30 13:43:23 +00:00
Alan Modra 0f02bbd9f8 bfd/
* elflink.c (resolve_symbol): Handle symbols in SEC_MERGE
	sections.  Don't test symbol st_shndx.  Don't bother with
	bfd_link_hash_common symbols.  Print longs rather than ints
	in debug messages.
	(eval_symbol): Replace "sym" and "advanced" params with "symp".
	Replace "addr" and "section_offset" params with "dot".  Don't
	cast bfd_vma values to signed, cast them to bfd_signed_vma.
	(bfd_elf_perform_complex_relocation): Delete "output_bfd", "info",
	"local_syms" and "local_sections" params.  Add "relocation".
	Delete code calculating relocation value.
	(evaluate_complex_relocation_symbols): Delete function.  Fold into..
	(elf_link_input_bfd): ..existing code examining relocs.
	* elf-bfd.h (bfd_elf_perform_complex_relocation): Update prototype.
	* elf32-mep.c (mep_elf_check_relocs): Delete function.
	(mep_elf_gc_sweep_hook, mep_elf_gc_mark_hook): Likewise.
	(mep_elf_object_p): Don't set elf_bad_symtab.
	(elf_backend_check_relocs): Don't define.
	(elf_backend_gc_mark_hook, elf_backend_gc_sweep_hook): Likewise.
	(elf_backend_can_gc_sections, USE_RELA): Likwise.
	(mep_elf_relocate_section): Move bfd_elf_perform_complex_relocation
	call after we have calculated reloc value.  Delete local sym
	debug code.  Use RELOC_FOR_GLOBAL_SYMBOL.  Delete addend
	adjusting code..
	(elf_backend_rela_normal): ..instead define this.
ld/testsuite/
	* ld-selective/sel-dump.exp: Add am33, m88k, mep to xfails.
	* ld-selective/selective.exp: Don't run for same target list
	we xfail sel-dump.
2007-09-30 13:33:04 +00:00
Alan Modra 8977835cde * elflink.c (set_symbol_value): Add isymbuf and locsymcount
params.  Change symidx to a size_t.  Don't access past end
	of symbol buffer.
	(resolve_symbol): Add isymbuf param and use instead of
	finfo->internal_syms.
	(eval_symbol, evaluate_complex_relocation_symbols): Likewise.
	(elf_link_input_bfd): Don't read symbols specially for
	evaluate_complex_relocation_symbols.
2007-09-26 12:29:41 +00:00
Alan Modra 14b1c01e04 * elf.c (bfd_section_from_shdr): Check bfd_alloc return.
(elfcore_write_note): Check realloc return.
	* elflink.c (_bfd_elf_link_find_version_dependencies): Check
	bfd_zalloc return.
	(_bfd_elf_link_assign_sym_version): Check bfd_malloc return.
	(elf_link_add_object_symbols): Likewise.
	(struct hash_codes_info): New.
	(elf_collect_hash_codes): Return bfd_malloc error.
	(struct collect_gnu_hash_codes): Add "error".
	(elf_collect_gnu_hash_codes): Return bfd_malloc error.
	(bfd_elf_size_dynamic_sections): Check return status of
	_bfd_elf_link_find_version_dependencies.
	(bfd_elf_size_dynsym_hash_dynstr): Adjust for elf_collect_hash_codes
	and elf_collect_gnu_hash_codes changes.
	(elf_sym_name_compare): Formatting.
	(elf_fixup_link_order): Use bfd_malloc, not xmalloc.
2007-09-18 08:17:06 +00:00
H.J. Lu b10a8ae01c bfd/
2007-09-17  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/3281
	PR binutils/5037
	* elf-bfd.h (elf_obj_tdata): Remove relro.

	* elf.c (get_program_header_size): Check info->relro instead
	of elf_tdata (abfd)->relro.
	(_bfd_elf_map_sections_to_segments): Likewise.
	(assign_file_positions_for_load_sections): Don't set
	PT_GNU_RELRO segment alignment here.
	(assign_file_positions_for_non_load_sections): Properly set up
	PT_GNU_RELRO segment for copying executable/shared library.
	(rewrite_elf_program_header): Remove PT_GNU_RELRO segment.
	(copy_elf_program_header): Set p_size and p_size_valid fields for
	PT_GNU_RELRO segment.

include/elf/

2007-09-17  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/3281
	PR binutils/5037
	* internal.h (elf_segment_map): Add p_size and p_size_valid.
	(ELF_IS_SECTION_IN_SEGMENT): Allow SHF_TLS sections in
	PT_GNU_RELRO segments.

ld/

2007-09-17  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/3281
	PR binutils/5037
	* ldexp.h (ldexp_control): Add relro, relro_start_stat and
	relro_end_stat.

	* ldexp.c (fold_binary): Set expld.dataseg.relro to
	exp_dataseg_relro_start or exp_dataseg_relro_end when
	seeing DATA_SEGMENT_ALIGN or DATA_SEGMENT_RELRO_END,
	respectively.

	* ldlang.c (lang_size_sections_1): Properly set
	expld.dataseg.relro_start_stat and
	expld.dataseg.relro_end_stat.
	(find_relro_section_callback): New function.
	(lang_find_relro_sections_1): Likewise.
	(lang_find_relro_sections): Likewise.
	(lang_process): Call lang_find_relro_sections for
	non-relocatable link.

ld/testsuite/

2007-09-17  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/3281
	PR binutils/5037
	* ld-elf/binutils.exp: Update "-z relro" tests to use relro1.s.
	Add "-z relro" tests with relro2.s.  Add "-z relro" tests with
	TLS for objcopy.

	* ld-elf/relro1.s: New file.
	* ld-elf/relro2.s: Likewise.
2007-09-18 00:25:07 +00:00
Nick Clifton 461686a323 Revision of previous delta using bfd_vma cast instead of 1L. 2007-08-20 13:23:41 +00:00
Nick Clifton 75ea273619 * elflink.c (elf_fixup_link_order): Rewrite conversion of s->alignment_power
into an offset mask in order to avoid a gcc error message.
2007-08-20 08:26:35 +00:00
Michael Snyder a6626e8c30 2007-07-26 Michael Snyder <msnyder@svkmacdonelllnx>
* linker.c (bfd_section_already_linked_table_insert): Change
	return type from void to boolean.  Return FALSE on failure.
	(_bfd_generic_section_already_linked): Test return value of
	bfd_section_already_linked_table_insert, call fatal on error.

	* elflink.c (_bfd_elf_section_already_linked): Test return value
	of bfd_section_already_linked_table_insert, call fatal on error.

	* libbfd-in.h (bfd_section_already_linked_table_insert): Update
	return type to bfd_boolean.

	* libbfd.h: Regenerate.
2007-07-27 01:04:29 +00:00
Alan Modra 33774f084b * elflink.c (_bfd_elf_fix_symbol_flags): Remove unnecessary
check on dynobj.  Remove bed shadow.
2007-07-26 13:45:59 +00:00
Michael Snyder d0f16d5ece 2007-07-24 Michael Snyder <msnyder@access-company.com>
* elflink.c (bfd_elf_final_link): Avoid redundant frees -- return
	on bfd_malloc error rather than goto error_return.
2007-07-24 19:54:01 +00:00
Alan Modra 4d269e42e3 * elflink.c (_bfd_elf_link_just_syms, merge_sections_remove_hook,
_bfd_elf_merge_sections, _bfd_elf_link_hash_newfunc,
	_bfd_elf_link_hash_copy_indirect, _bfd_elf_link_hash_hide_symbol,
	_bfd_elf_link_hash_table_init, _bfd_elf_link_hash_table_create,
	bfd_elf_set_dt_needed_name, bfd_elf_get_dyn_lib_class,
	bfd_elf_set_dyn_lib_class, bfd_elf_get_needed_list,
	bfd_elf_get_runpath_list, bfd_elf_get_dt_soname,
	bfd_elf_get_bfd_needed_list, struct elf_symbuf_symbol,
	struct elf_symbuf_head, struct elf_symbol, elf_sort_elf_symbol,
	elf_sym_name_compare, elf_create_symbuf,
	bfd_elf_match_symbols_in_sections,
	_bfd_elf_match_sections_by_type): Move to here..
	* elf.c: ..from here.
2007-07-24 08:09:20 +00:00
Richard Sandiford a26587bab5 bfd/
* elflink.c (_bfd_elf_fix_symbol_flags): Only assert the type
	of weakdef->root.type if weakdef has no regular definition.

ld/testsuite/
	* ld-elf/weak-dyn-1a.s, ld-elf/weak-dyn-1b.s, ld-elf/weak-dyn-1.ld,
	* ld-elf/weak-dyn-1.rd: New test.
	* ld-elf/elf.exp: Run it.
2007-07-23 09:56:19 +00:00
H.J. Lu 00cbee0aa8 2007-07-09 H.J. Lu <hongjiu.lu@intel.com>
* elflink.c (bfd_elf_record_link_assignment): Handle indirect
	symbol.
	(_bfd_elf_merge_symbol): Properly update normal symbol when
	overriding the versioned symbol from a dynamic library.
2007-07-10 02:40:31 +00:00
Alan Modra 9af2a943ee * elflink.c (elf_link_add_object_symbols): Return via
error_free_vers on "notice" failure.
2007-07-06 02:29:10 +00:00
Nick Clifton cd123cb70c Switch sources over to use the GPL version 3 2007-07-03 14:26:43 +00:00