Commit Graph

343 Commits

Author SHA1 Message Date
H.J. Lu 64e77c6d5f 2009-06-17 H.J. Lu <hongjiu.lu@intel.com>
* elf32-arm.c (create_got_section): Get existing .rela.got
	section.
	* elf32-hppa.c (elf32_hppa_create_dynamic_sections): Likewise.
	* elf32-lm32.c (create_got_section): Likewise.
	* elf32-m32r.c (create_got_section): Likewise.
	* elf32-ppc.c (ppc_elf_create_got): Likewise.
	* elf32-s390.c (create_got_section): Likewise.
	* elf32-sh.c (create_got_section): Likewise.
	* elf32-xtensa.c (elf_xtensa_create_dynamic_sections): Likewise.
	* elf64-s390.c (create_got_section): Likewise.
	* elfxx-sparc.c (create_got_section): Likewise.

	* elflink.c (_bfd_elf_create_got_section): Properly initialize
	the GOT size.
2009-06-17 18:08:35 +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 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 3aa14d16c6 bfd/
2009-06-01  H.J. Lu  <hongjiu.lu@intel.com>

	* elf-bfd.h (struct bfd_elf_section_data): Remove indirect_relocs.
	(_bfd_elf_make_ifunc_reloc_section): Removed.
	(_bfd_elf_is_ifunc_symbol): Likewise.
	(_bfd_elf_create_static_ifunc_sections): New.

	* elflink.c (_bfd_elf_adjust_dynamic_symbol): Move STT_GNU_IFUNC
	symbol check to ...
	(elf_link_add_object_symbols): Here.
	(_bfd_elf_link_hash_hide_symbol): Don't clean plt on
	STT_GNU_IFUNC symbol.
	(elf_link_output_extsym): Call elf_backend_finish_dynamic_symbol
	if a STT_GNU_IFUNC symbol is referenced in a non-shared object.
	(IFUNC_INFIX): Removed.
	(get_ifunc_reloc_section_name): Likewise.
	(_bfd_elf_make_ifunc_reloc_section): Likewise.
	(_bfd_elf_is_ifunc_symbol): Likewise.
	(_bfd_elf_create_static_ifunc_sections): New.

ld/

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

	* scripttempl/elf.sc (PLT): Add "*(.iplt)".
	(GOT): Add "*(.igot.plt)a" and "*(.igot)".
	(GOTPLT): Add "*(.igot)".
	(__rel_iplt_start): New.
	(__rel_iplt_end): Likewise.
	(__rela_iplt_start): Likewise.
	(__rela_iplt_end): Likewise.
2009-06-01 12:53:00 +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
Alan Modra 930e005c64 * elflink.c (elf_link_input_bfd): Correct *pindex change in last
commit.
2009-05-21 14:32:29 +00:00
Alan Modra 6e0b88f1b8 * elf-bfd.h (struct elf_backend_data
<elf_backend_link_output_symbol_hook>): Return an int.
	* elf64-ppc.c (ppc64_elf_output_symbol_hook): Return 2 to drop
	symbols on deleted .opd entries.
	* elflink.c (elf_link_output_sym): Return without outputting sym
	if output_symbol_hook returns 2.
	(elf_link_output_extsym): Don't assign h->indx when symbol discarded.
	Abort if we must not discard sym.
	(elf_link_input_bfd): Similarly, don't set finfo->indices for
	local syms.
	(bfd_elf_final_link): Adjust elf_link_output_sym calls.
	* elf-vxworks.c (elf_vxworks_link_output_symbol_hook): Adjust for
	elf_backend_link_output_symbol_hook return type change.
	* elf32-arm.c (output_arch_syminfo): Likewise.
	(elf32_arm_output_map_sym, elf32_arm_output_stub_sym): Likewise.
	(elf32_arm_output_arch_local_syms): Likewise.
	* elf32-cr16c.c (elf32_cr16c_link_output_symbol_hook): Likewise.
	* elf32-score.c (s3_bfd_score_elf_link_output_symbol_hook): Likewise.
	(bfd_score_elf_link_output_symbol_hook): Likewise.
	* elf32-score.h (s7_bfd_score_elf_link_output_symbol_hook): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_link_output_symbol_hook): Likewise.
	* elf32-sh64.c (sh64_elf_link_output_symbol_hook): Likewise.
	* elf32-spu.c (spu_elf_output_symbol_hook): Likewise.
	* elf32-v850.c (v850_elf_link_output_symbol_hook): Likewise.
	* elf64-hppa.c (elf64_hppa_link_output_symbol_hook): Likewise.
	* elf64-mmix.c (mmix_elf_link_output_symbol_hook): Likewise.
	* elf64-sh64.c (sh64_elf64_link_output_symbol_hook): Likewise.
	* elf64-sparc.c (elf64_sparc_output_arch_syms): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_link_output_symbol_hook): Likewise.
	* elfxx-mips.h (_bfd_mips_elf_link_output_symbol_hook): Likewise.
2009-05-21 14:15:50 +00:00
Dave Korn 09e2aba432 bfd/ChangeLog
* elflink.c (find_version_for_sym):  Remove from here, ...
	* linker.c (bfd_find_version_for_sym):  ... rename, replace
	here, make public and update all callers.
	* bfd-in2.h:  Regenerate.

ld/ChangeLog

	* NEWS:  Mention new feature.
	* ld.texinfo (--version-script):  Document extent of PE support.
	(WIN32):  Mention --version-script.  Extend auto-export description.
	* pe-dll.c (process_def_file):  Use version script info to filter
	symbols from auto-export.
	* testsuite/ld-pe/vers-script-1.d:  New file.
	* testsuite/ld-pe/vers-script-2.d:  New file.
	* testsuite/ld-pe/vers-script-3.d:  New file.
	* testsuite/ld-pe/vers-script-4.d:  New file.
	* testsuite/ld-pe/vers-script-1.ver:  New file.
	* testsuite/ld-pe/vers-script-2.ver:  New file.
	* testsuite/ld-pe/vers-script-3.ver:  New file.
	* testsuite/ld-pe/vers-script-4.ver:  New file.
	* testsuite/ld-pe/vers-script-dll.c:  New file.
	* testsuite/ld-pe/vers-script.exp:  New test script.
2009-05-04 12:09:30 +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 a0c402a564 bfd/
2009-04-08  H.J. Lu  <hongjiu.lu@intel.com>

	* elflink.c (elf_link_add_object_symbols): Warn alternate ELF
	machine code.

include/

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

	* bfdlink.h (bfd_link_info): Add warn_alternate_em.

ld/

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

	* lexsup.c (option_values): Add OPTION_WARN_ALTERNATE_EM.
	(ld_options): Likewise.
	(parse_args): Likewise.

	* ld.texinfo: Document --warn-alternate-em.

	* NEWS: Mention --warn-alternate-em.
2009-04-08 16:04:50 +00:00
H.J. Lu bb6198d224 2009-04-07 H.J. Lu <hongjiu.lu@intel.com>
* elflink.c (_bfd_elf_section_already_linked): Add `\n' for
	info->callbacks->einfo.
	* linker.c (_bfd_generic_section_already_linked): Likewise.
2009-04-07 20:04:08 +00:00
DJ Delorie c301e70067 * elflink.c (elf_link_input_bfd): Don't try to resolve complex
relocs when doing a relocatable link.
2009-03-31 01:42:29 +00:00
Nick Clifton ce98a316e9 PR 9934
* elf-bfd.h (NUM_SHDR_ENTRIES): Cope with an empty section.
        * elflink.c (elf_link_read_relocs_from_section): Use
        NUM_SHDR_ENTRIES.  Gracefully handle the case where there are
        relocs but no symbol table.
        * elf32-arm.c (elf32_arm_check_relocs): Likewise.
2009-03-13 11:34:43 +00:00
Nick Clifton 2c2b4ed43a PR 9827
* elflink.c (bfd_elf_final_link): When counting the relocations,
        if the header size has not been set yet then assume that it will
        match the output section's reloc type.
2009-02-12 15:06:55 +00:00
Alan Modra 010e5ae26e binutils/
* NEWS: Mention --as-needed change.
ld/
	* ld.texinfo (--as-needed): Update.
bfd/
	* elflink.c (on_needed_list): New function.
	(elf_link_add_object_symbols): Link in --as-needed libs if they
	satisfy undefined symbols in other libs.
2009-01-31 11:44:38 +00:00
Joseph Myers d334575b76 2009-01-29 Daniel Jacobowitz <dan@codesourcery.com>
Mark Shinwell  <shinwell@codesourcery.com>
            Catherine Moore  <clm@codesourcery.com>

	* elf-attrs.c, elflink.c, elfxx-mips.c: Correct typos in comments.
2009-01-29 16:35:03 +00:00
Alan Modra 1e8fa21e6d PR 6022
* elflink.c (find_version_for_sym): New function split out from,
	but without export_dynamic test, ..
	(_bfd_elf_link_assign_sym_version): ..here.
	(_bfd_elf_export_symbol): Use it.
2009-01-24 03:10:43 +00:00
Alan Modra 28caa1861d * elf-bfd.h (struct elf_assign_sym_version_info): Delete.
(struct elf_info_failed, struct elf_find_verdep_info): Move to..
	* elflink.c: ..here, somewhat modified.
	* elf-bfd.h (_bfd_elf_add_default_symbol, _bfd_elf_export_symbol,
	_bfd_elf_link_find_version_dependencies,
	_bfd_elf_link_assign_sym_version, _bfd_elf_link_size_reloc_section,
	_bfd_elf_fix_symbol_flags, _bfd_elf_adjust_dynamic_symbol,
	_bfd_elf_link_sec_merge_syms, bfd_elf_link_mark_dynamic_symbol): Don't
	declare..
	* elflink.c: ..and make static here.
	(_bfd_elf_link_find_version_dependencies): Adjust for removal
	of output_bfd from struct elf_find_verdep_info.
	(_bfd_elf_link_assign_sym_version): Similarly adjust to use
	struct elf_info_failed.
	(bfd_elf_size_dynamic_sections): Adjust.
2009-01-23 12:15:27 +00:00
H.J. Lu a33dafc30d bfd/
2009-01-14  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/9727
	* elflink.c (elf_gc_sweep): Exclude the group section if the
	first member of the section group is excluded.

ld/testsuite/

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

	PR ld/9727
	* ld-elf/group8.s: New.
	* ld-elf/group8a.d: Likewise.
	* ld-elf/group8b.d: Likewise.
	* ld-elf/group9.s: Likewise.
	* ld-elf/group9a.d: Likewise.
	* ld-elf/group9b.d: Likewise.
2009-01-14 21:52:49 +00:00
Jan Kratochvil 80c29487db bfd/
* elflink.c (_bfd_elf_section_already_linked): Handle g++-3.4
	relocations in `.gnu.linkonce.r.*' referencing its `.gnu.linkonce.t.*'.

ld/testsuite/
	* ld-elf/linkoncerdiff.d, ld-elf/linkoncerdiff1.s,
	ld-elf/linkoncerdiff2.s: New.
2009-01-11 21:09:49 +00:00
H.J. Lu 9dbe889014 2009-01-03 H.J. Lu <hongjiu.lu@intel.com>
* coff-ppc.c: Add 2009 to Copyright.
	* elf32-cris.c: Likewise.
	* elflink.c: Likewise.
2009-01-03 16:19:52 +00:00
H.J. Lu 54ac0771d7 bfd/
2009-01-02  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/9679
	* elflink.c (elf_merge_st_other): New.
	(_bfd_elf_merge_symbol): Use it on skipped weak definitions and
	hide them if needed.
	(elf_link_add_object_symbols): Updated.

ld/testsuite/

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

	PR ld/9679
	* ld-elf/pr9679-1.c: New.
	* ld-elf/pr9679-2.c: Likewise.
	* ld-elf/pr9679.rd: Likewise.

	* ld-elf/shared.exp (build_tests): Add test for libpr9679.so.
2009-01-02 19:29:38 +00:00
H.J. Lu d88805311b bfd/
2009-01-02  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/9676
	* elflink.c (elf_link_add_object_symbols): Update def_dynamic,
	ref_dynamic and dynamic_def fields when setting def_regular
	to 1.

ld/testsuite/

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

	PR ld/9676
	* ld-elf/pr9676-1.c: New.
	* ld-elf/pr9676-2.c: Likewiswe.
	* ld-elf/pr9676-3.c: Likewiswe.
	* ld-elf/pr9676-4.c: Likewiswe.
	* ld-elf/pr9676.rd: Likewiswe.

	* ld-elf/shared.exp (build_tests): Add tests for libpr9676-1.a,
	libpr9676-2.a, libpr9676-3.so, libpr9676-4.so and
	libpr9676-4a.so.

	* lib/ld-lib.exp (ar_simple_create): New.
	(run_ld_link_tests): Support archive.
	(run_cc_link_tests): Likewiswe.
2009-01-02 16:48:11 +00:00
Nick Clifton 0f88be7a13 Remove STT_IFUNC support. 2008-12-23 09:01:51 +00:00
Nick Clifton e7c3341679 include/elf/
* common.h (STT_IFUNC): Define.
elfcpp/
            * elfcpp.h (enum STT): Add STT_IFUNC.
bfd/
            * syms.c (struct bfd_symbol): Add new flag BSF_INDIRECT_FUNCTION.
            Remove redundant flag BFD_FORT_COMM_DEFAULT_VALUE.  Renumber flags
            to remove gaps.
            (bfd_print_symbol_vandf): Return 'i' for BSF_INDIRECT_FUNCTION.
            (bfd_decode_symclass): Likewise.
            * elf.c (swap_out_syms): Translate BSF_INDIRECT_FUNCTION into
            STT_IFUNC.
            (elf_find_function): Treat STT_IFUNC in the same way as STT_FUNC.
            (_bfd_elf_is_function_type): Likewise.
            * elf32-arm.c (arm_elf_find_function): Likewise.
            (elf32_arm_adjust_dynamic_symbol): Likewise.
            (elf32_arm_swap_symbol_in): Likewise.
            (elf32_arm_additional_program_headers): Likewise.
            * elf32-i386.c (is_indirect_symbol): New function.
            (elf_i386_check_relocs): Also generate dynamic relocs for
            relocations against STT_IFUNC symbols.
            (allocate_dynrelocs): Likewise.
            (elf_i386_relocate_section): Likewise.
            * elf64-x86-64.c (is_indirect_symbol): New function.
            (elf64_x86_64_check_relocs): Also generate dynamic relocs for
            relocations against STT_IFUNC symbols.
            (allocate_dynrelocs): Likewise.
            (elf64_x86_64_relocate_section): Likewise.
            * elfcode.h (elf_slurp_symbol_table): Translate STT_IFUNC into
            BSF_INDIRECT_FUNCTION.
            * elflink.c (_bfd_elf_adjust_dynamic_reloc_section): Add support
            for STT_IFUNC symbols.
            (get_ifunc_reloc_section_name): New function.
            (_bfd_elf_make_ifunc_reloc_section): New function.
            * elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs field.
            * bfd-in2.h: Regenerate.
gas/
            * config/obj-elf.c (obj_elf_type): Add support for STT_IFUNC type.
            * doc/as.texinfo: Document new feature.
            * NEWS: Mention new feature.
gas/testsuite/
            * gas/elf/type.s: Add test of STT_IFUNC symbol type.
            * gas/elf/type.e: Update expected disassembly.
            * gas/elf/elf.exp: Update grep of symbol types.
ld/
            * NEWS: Mention new feature.
            * pe-dll.c (process_def_file): Replace use of redundant
            BFD_FORT_COMM_DEFAULT_VALUE with 0.
            * scripttempl/elf.sc: Add .rel.ifunc.dyn and .rela.ifunc.dyn
            sections.
ld/testsuite/
            * ld-mips-elf/reloc-1-n32.d: Updated expected output for reloc
            descriptions.
            * ld-mips-elf/reloc-1-n64.d: Likewise.
            * ld-i386/ifunc.d: New test.
            * ld-i386/ifunc.s: Source file for the new test.
            * ld-i386/i386.exp: Run the new test.
2008-12-03 14:51:00 +00:00
Alan Modra ae5a359786 include/
PR 7047
	* bfdlink.h (struct bfd_elf_version_expr): Delete "symbol".
	Add "literal".
bfd/
	PR 7047
	* configure.in: Bump version.
	* configure: Regenerate.
	* elflink.c (_bfd_elf_link_assign_sym_version): Continue matching
	against version nodes when a global match is a wildcard.  Similarly
	continue matching on local wildcard matches, rather than only
	continuing for "*".  Have any global wildcard match override a
	local wildcard match.  Correct logic hiding unversioned symbol.
	(bfd_elf_size_dynamic_sections): Update for changes to struct
	bfd_elf_version_expr.
ld/
	PR 7047
	* emultempl/ppc64elf.em (gld${EMULATION_NAME}_new_vers_pattern): Update
	for changes to struct bfd_elf_version_expr.
	* ldlang.c (lang_vers_match, version_expr_head_hash): Likewise.
	(version_expr_head_eq, lang_finalize_version_expr_head): Likewise.
	(lang_register_vers_node): Likewise.
	(lang_new_vers_pattern): Likewise.  Ensure "literal" is set when
	no glob chars found in "pattern".
	(realsymbol): Correct backslash quote logic.
	* ld.texinfo (VERSION): Warn about global wildcards.
2008-11-26 01:04:17 +00:00
Nick Clifton 83bac4b010 * elflink.c (is_reloc_section): New function. Returns true if the
given name matches the name of the reloc-containing section
        associated with the given section.
        (get_dynamic_reloc_section_name): New function.  Computes the name
        of the section that contains the dynamic relocs associated with
        the given section.
        (_bfd_elf_get_dynamic_reloc_section): New function.  Returns a
        pointer to the section containing the dynamic relocs associated
        with the given section.
        (_bfd_elf_make_dynamic_reloc_section): New function.  Creates a
        section to contain the dynamic relocs associated with a given
        section.
        * elf-bfd.h: Prototype the new functions.
        * elf-m10300.c (mn10300_elf_check_relocs): Use new functions.
        (mn10300_elf_final_link_relocs): Likewise.
        * elf32-arm.c (reloc_section_p): Delete - replaced by new
        functions.
        (elf32_arm_final_link_relocate): Use new functions.
        (elf32_arm_check_relocs): Likewise.
        * elf32-cris.c (cris_elf_relocate_section): Likewise.
        (elf_cris_check_relocs): Likewise.
        * elf32-hppa.c (elf32_hppa_check_relocs): Likewise.
        * elf32-i370.c (i370_elf_check_relocs): Likewise.
        (i370_elf_relocate_section): Likewise.
        * elf32-i386.c (elf_i386_check_relocs): Likewise.
        * elf32-m32r.c (m32r_elf_relocate_section): Likewise.
        (m32r_elf_check_relocs): Likewise.
        * elf32-m68k.c (elf_m68k_check_relocs): Likewise.
        * elf32_ppc.c (ppc_elf_check_relocs): Likewise.
        (ppc_elf_relocate_section): Likewise.
        * elf32-s390.c (elf_s390_check_relocs): Likewise.
        * elf32-sh.c (sh_elf_relocate_section): Likewise.
        (sh_elf_check_relocs): Likewise.
        * elf32-vax.c (elf_vax_check_relocs): Likewise.
        (elf_vax_relocate_section): Likewise.
        * elf64-alpha.c (elf64_alpha_check_relocs): Likewise.
        * elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
        * elf64-s390.c (elf_s390_check_relocs): Likewise.
        * elf64-sh64.c (sh_elf64_relocate_section): Likewise.
        * elf64-x86-64.c (elf64_x86_64_check_relocs): Likewise.
        * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
        * elf32-bfin.c (bfin_check_relocs): Remove redundant local
        variable 'sreloc'.
        (bfin_relocate_section): Likewise.
        * elf32-v850.c (v850_elf_check_relocs): Likewise.
2008-11-25 13:03:56 +00:00
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