Commit Graph

504 Commits

Author SHA1 Message Date
H.J. Lu 40101021d4 Update comments for the last commit 2014-01-21 05:37:45 -08:00
H.J. Lu 22ef172a21 Don't check shared/export_dynamic/ref_dynamic for type mismatch
There is nothing linker can do when a type mismatched default definition
are made dynamic by info->shared, info->export_dynamic or h->ref_dynamic.
But we do want to avoid exporting it when building PIE.  Let's remove
those checks.

bfd/

	PR ld/2404
	* elflink.c (_bfd_elf_merge_symbol): Don't check info->shared,
	info->export_dynamic, nor !h->ref_dynamic for type mismatch when
	adding the default version.

ld/testsuite/

	PR ld/2404
	* ld-elf/shared.exp: Add a PIE test for PR ld/2404.
2014-01-21 05:33:48 -08:00
Alan Modra 57fa7b8c7e Correct elf_merge_st_other arguments for weak symbols
* elflink.c (_bfd_elf_merge_symbol): If merging a new weak
	symbol that will be skipped, we don't have a new definition.
2013-12-14 13:14:03 +10:30
Alan Modra 68c88cd461 Fix --as-needed undefined symbol references from dynamic libraries.
libx.so refers to some_sym, liby.so provides some_sym@some_version
wasn't seen as satisfying the reference.

	* elf64-ppc.c (_bfd_elf_add_default_symbol): Set dynamic_def
	and ref_dynamic_nonweak when chaining together indirect
	symbols.
2013-12-08 15:33:29 +10:30
Jan Beulich 34a79995c4 ld/ELF: refine fake STT_FILE symbol emission
There's no real need to emit these always: They're needed only if we
indeed want to emit a localized symbol. Hence defer emission until we
at least did the basic early checks that would lead to no such symbol
getting emitted. This in particular avoids emitting such a symbol in
the majority of (if not all) "ld -r" cases.

I hope my set of cross build tests caught all the test cases needing
adjustment - please forgive if I missed a few.

bfd/
2013-10-29  Jan Beulich <jbeulich@suse.com>

	* elflink.c (struct elf_outext_info): Add field file_sym_done.
	(bfd_elf_final_link): Initialize new field. Move fake STT_FILE
	symbol emission from here ...
	(elf_link_output_extsym): ... to here.

gas/testsuite/
2013-10-29  Jan Beulich <jbeulich@suse.com>

	* gas/microblaze/relax_size.elf: Drop expectation of no longer
	present STT_FILE symbol.
	* gas/microblaze/relax_size2.elf: Likewise.

ld/testsuite/
2013-10-29  Jan Beulich <jbeulich@suse.com>

	* ld-cris/tls-e-tpoffcomm1.d: Drop expectation of no longer
	present STT_FILE symbol.
	* ld-mmix/bpo-18.d: Likewise.
	* ld-mmix/bpo-22.d: Likewise.
	* ld-mmix/greg-6.d: Likewise.
	* ld-mmix/greg-7.d: Likewise.
	* ld-mmix/loc4.d: Likewise.
	* ld-mmix/local1.d: Likewise.
	* ld-mmix/local3.d: Likewise.
	* ld-mmix/local5.d: Likewise.
	* ld-mmix/local7.d: Likewise.
	* ld-mmix/loct-1.d: Likewise.
	* ld-sh/sh64/abi32.xd: Likewise.
	* ld-sh/sh64/abi64.xd: Likewise.
	* ld-sh/sh64/cmpct1.xd: Likewise.
	* ld-sh/sh64/crange1.rd: Likewise.
	* ld-sh/sh64/crange2.rd: Likewise.
	* ld-sh/sh64/crange3-cmpct.rd: Likewise.
	* ld-sh/sh64/crange3-media.rd: Likewise.
	* ld-sh/sh64/crange3.rd: Likewise.
	* ld-sh/sh64/crangerel1.rd: Likewise.
	* ld-sh/sh64/crangerel2.rd: Likewise.
	* ld-sh/sh64/mix1.xd: Likewise.
	* ld-sh/sh64/mix2.xd: Likewise.
	* ld-sh/sh64/shdl32.xd: Likewise.
	* ld-sh/sh64/shdl64.xd: Likewise.
2013-10-29 17:52:24 +01:00
Alan Modra e5034e59e0 * elf-bfd.h (struct elf_backend_data): Remove as_needed_cleanup.
Add notice_as_needed.
	* elf64-ppc.c (elf_backend_as_needed_cleanup): Don't define.
	(elf_backend_notice_as_needed): Define.
	(ppc64_elf_as_needed_cleanup): Rename and adjust..
	(ppc64_elf_notice_as_needed): ..to this.
	* elflink.c (_bfd_elf_notice_as_needed): New function, extracted..
	(elf_link_add_object_symbols): ..from here.
	* elfxx-target.h (elf_backend_as_needed_cleanup): Don't define.
	(elf_backend_notice_as_needed): Define..
	(elfNN_bed): ..and use here.
2013-08-27 01:06:43 +00:00
Alan Modra 934bce08d2 * elflink.c (_bfd_elf_merge_symbol): Set *poldbfd, *poldweak,
and *poldalignment before exiting when !relocs_compatible.
2013-08-21 04:09:30 +00:00
Alan Modra 00b7642b8a * elflink.c (_bfd_elf_define_linkage_sym): Don't set STV_INTERNAL
symbols to STV_HIDDEN.
2013-08-21 03:45:44 +00:00
Alan Modra db6a5d5f90 PR ld/15762
PR ld/12761
	* elflink.c (elf_link_add_object_symbols): Correct test in
	last patch.  Remove unnecessary code.
2013-07-25 00:14:11 +00:00
Alan Modra 436e1ebacc PR ld/15762
PR ld/12761
	* elflink.c (elf_link_add_object_symbols): Don't clobber
	.gnu.warning.symbol sections when shared.
2013-07-20 09:50:16 +00:00
Alan Modra 012b2306cc * elflink.c (elf_link_add_object_symbols): Don't omit reading
of symbols when hashes already exist.
2013-05-08 23:31:38 +00:00
Alan Modra f45794cb51 * elflink.c (elf_link_add_object_symbols): Don't save symbol
hashes around loading as-needed library.  Zero them on allocation,
	and restore to initial all-zero state if library not needed.
	Arrange to reuse hashes if we load library again later.
2013-05-06 08:45:40 +00:00
Nick Clifton ed54588daf PR binutils/15417
* elflink.c (elf_link_add_object_symbols): Initialise 'idx' to
	zero.
2013-04-30 12:13:09 +00:00
Alan Modra b829706801 * elflink.c (bfd_elf_record_link_assignment): Dont make
STV_INTERNAL symbols STV_HIDDEN.
2013-04-30 01:05:18 +00:00
Nick Clifton b40bf0a255 * elflink.c (_bfd_elf_gc_mark_extra_sections): Remove mark from
fragmented .debug_line sections associated with unmarked code
	sections.

	* dwarf.c (read_debug_line_header): New function.  Reads in a
	header in a .debug_line section.
	(display_debug_lines_raw): Use new function.  Handle fragmentary
	.debug_line sections.
	(display_debug_lines_decoded): Likewise.
	* readelf.c (process_section_headers): Handle fragmenatry
	.debug_line sections.
	(display_debug_section): Likewise.

	* as.c (Options): Add -gdwarf-sections.
	(parse_args): Likewise.
	* as.h (flag_dwarf_sections): Declare.
	* dwarf2dbg.c (emit_fixed_inc_line_addr): Skip section changes.
	(process_entries): When -gdwarf-sections is enabled generate
	fragmentary .debug_line sections.
	(out_debug_line): Set the section for the .debug_line section end
	symbol.
	* doc/as.texinfo: Document -gdwarf-sections.
	* NEWS: Mention -gdwarf-sections.

	* gas/elf/dwarf2-3.d: Fix expected readelf output.

	* scripttempl/DWARF.sc: Add support for .debug_line.* and
	.debug_line_end.
2013-04-29 13:38:59 +00:00
Nick Clifton ad83dabf1c oops - revert accidental commit 2013-04-24 13:24:30 +00:00
Nick Clifton 544008aaf7 * ecoff.c: casting the return value of BFD_ALIGN to int
* elf32-tic6x.c: removing unused variables
	* elf32-v850.c: redefine the type of a variable (int -> bfd_vma)
	* vms-alpha.c: initialize a variable
2013-04-24 13:19:27 +00:00
Nick Clifton c69ba956e3 * elflink.c (elf_link_add_object_symbols): Revert accidental commit. 2013-04-05 09:08:28 +00:00
Alan Modra ff5ac77bf5 * bfd.c (bfd_error_type, bfd_errmsgs): Add bfd_error_missing_dso.
* bfd-in2.h: Regenerate.
	* elflink.c (elf_link_add_object_symbols): Use new error.
2013-04-04 14:38:01 +00:00
Alan Modra 7e612e9848 * elf-bfd.h (enum elf_reloc_type_class): Add reloc_class_ifunc.
(struct elf_backend_data <elf_backed_reloc_type_class>): Add
	bfd_link_info* and asection* params.
	(_bfd_elf_reloc_type_class): Likewise.
	* elf.c (_bfd_elf_reloc_type_class): Likewise.
	* elflink.c (elf_link_sort_cmp2): Sort first on reloc class.
	(elf_link_sort_relocs): Update elf_backed_reloc_type_class call.
	* elf32-ppc.c (ppc_elf_reloc_type_class): Return reloc_class_ifunc
	for any reliplt reloc.  Don't return reloc_class_plt for
	R_PPC_REL24 and R_PPC_ADDR24.
	* elf64-ppc.c (allocate_got): Formatting.
	(ppc64_elf_reloc_type_class): Return reloc_class_ifunc for any
	reliplt reloc.
	* elf-m10300.c, * elf32-arm.c, * elf32-bfin.c, * elf32-cr16.c,
	* elf32-cris.c, * elf32-hppa.c, * elf32-i386.c, * elf32-lm32.c,
	* elf32-m32r.c, * elf32-m68k.c, * elf32-metag.c, * elf32-nios2.c,
	* elf32-s390.c, * elf32-sh.c, * elf32-sparc.c, * elf32-tilepro.c,
	* elf32-vax.c, * elf32-xtensa.c, * elf64-aarch64.c, * elf64-alpha.c,
	* elf64-hppa.c, * elf64-ia64-vms.c, * elf64-s390.c, * elf64-sparc.c,
	* elf64-x86-64.c, * elfnn-ia64.c, * elfxx-tilegx.c, * elfxx-tilegx.h:
	Add extra params to the various reloc_type_class functions.
2013-03-27 13:37:51 +00:00
Alan Modra ffd65175b8 * elflink.c (_bfd_elf_add_default_symbol): Preserve section
over _bfd_elf_merge_symbol calls.
2013-03-26 07:02:52 +00:00
Alan Modra 3a81e8251e * elflink.c (elf_link_add_object_symbols): Add assertion for
common override alignment check code.  Formatting.
2013-03-26 06:08:14 +00:00
Alan Modra 4f3fedcf68 * elflink.c (_bfd_elf_merge_symbol): Set old_alignment for
usual common symbols as well as for dynamic.  Add poldbfd param.
	Save old bfd.  Adjust callers.
	(_bfd_elf_add_default_symbol): Add poldbfd param.  Pass "section"
	and "value" by value, not pointer.  Adjust caller.
	(elf_link_add_object_symbols): Combine undef_bfd and old_bfd vars.
	Delete code to set same.  Use old_bfd and old_alignment from
	_bfd_elf_merge_symbol instead.  Add default symbol before
	alignment and size checks.  Wrap overlong lines.
2013-03-25 06:12:06 +00:00
Alan Modra e3c9d23467 * elflink.c (_bfd_elf_add_default_symbol): Delete "override" param.
(elf_link_add_object_symbols): Don't call _bfd_elf_add_default_symbol
	when override is true.
2013-03-25 06:06:35 +00:00
Alan Modra 6c9b78e691 * elflink.c (_bfd_elf_merge_symbol): Use local var holding value
of *sym_hash.
2013-03-25 06:03:48 +00:00
Alan Modra 191c0c4245 * elflink.c (_bfd_elf_merge_symbol): Don't discard TLS symbols here.
Wrap long lines.
	(elf_link_add_object_symbols): Discard TLS symbols for --just-syms
	early in symbol loop.
2013-03-25 06:02:28 +00:00
Alan Modra 5d13b3b319 * elf-bfd.h (struct elf_backend_data <merge_symbol>): Update proto.
(_bfd_elf_init_reloc_shdr): Delete.
	* elf.c (_bfd_elf_init_reloc_shdr): Make static.
	* elf64-x86-64.c (elf_x86_64_merge_symbol): Trim parameters to
	just what is needed.
	* elflink.c (_bfd_elf_merge_symbol): Update bed->merge_symbol call.
2013-03-25 06:00:06 +00:00
Alan Modra 8a56bd0251 * elf-bfd.h (_bfd_elf_merge_symbol): Delete declaration.
* elflink.c (_bfd_elf_merge_symbol): Make static.
	* elf32-sh-symbian.c (sh_symbian_relocate_section): Don't call
	_bfd_elf_merge_symbol, call _bfd_generic_link_add_one_symbol.
2013-03-23 10:25:02 +00:00
Alan Modra 96f29d96af PR ld/15270
* elflink.c (elf_link_add_object_symbols): Don't set def_regular
	or ref_regular for BFD_PLUGIN owned syms, or have them affect
	def_dynamic/ref_dynamic.
	(_bfd_elf_fix_symbol_flags): Don't set def_regular for BFD_PLUGIN
	owned syms.
2013-03-22 23:35:55 +00:00
Nick Clifton 81f5558e3d * elf32-h8300 (h8_relax_section): Add new relaxation of mov
@(disp:32,ERx) to mov @(disp:16,ERx).
	(R_H8_DISP32A16): New reloc.
	Comments added and corrected.
	* reloc.c (BFD_RELOC_H8_DISP32A16): New reloc.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.

	* ld.texinfo (H8/300): Add description of relaxation of
	mov @(disp:32,ERx) to mov @(disp:16,ERx).

	* ld-h8300/h8300.exp: Add new relax-7 test on ELF.
	* ld-h8300/relax-2.s: Add other direction and .w/.l variants of
	mov insns.
	* ld-h8300/relax-2.d: Update expected disassembly.
	* ld-h8300/relax-7a.s: New: tests for mov @(disp:32,ERx) -> mov
	@(disp:16,ERx).
	* ld-h8300/relax-7b.s: New: Likewise.
	* ld-h8300/relax-7.d: New: expected disassembly.

	* config/tc-h8300.c (do_a_fix_imm): Add relaxation of mov
	@(disp:32,ERx) to mov @(disp:16,ERx) insns by new reloc
	R_H8_DISP32A16.
	* config/tc-h8300.h: Remove duplicated defines.
2013-03-21 16:08:07 +00:00
Alan Modra 8877b5e517 bfd/
* elflink.c (_bfd_elf_make_dynamic_reloc_section): Override
	sh_type according to is_rela.
ld/testsuite/
	* ld-elf/rel.c, ld-elf/relmain.c, ld-elf/relmain.out: New test.
	* ld-elf/shared.exp: Build and run it.
2013-03-20 03:44:56 +00:00
Alan Modra ffa9430db1 PR ld/12549
bfd/
	* elflink.c (elf_link_add_object_symbols): Exclude weak refs when
	considering whether an --as-needed library is needed.
ld/
	* ld.texinfo (--as-needed): Update.
ld/testsuite/
	* ld-elf/pr14862.out: Expect no output.
2013-03-18 02:47:03 +00:00
H.J. Lu 35399224a1 Set unique_global only for definition
bfd/

	PR ld/15167
	* elf64-ia64-vms.c (elf64_vms_link_add_object_symbols): Set
	unique_global only for definition.
	* elflink.c (_bfd_elf_merge_symbol): Don't set unique_global
	here.
	(elf_link_add_object_symbols): Set unique_global only
	for definition.

ld/testsuite/

	PR ld/15167
	* ld-unique/unique.exp: Add a test for shared library with
	reference.
2013-02-22 01:20:48 +00:00
Alan Modra 12bd695738 bfd/
* elf-bfd.h (struct elf_obj_tdata): Rename segment_map to seg_map.
	Delete num_locals and num_globals.
	(elf_num_locals, elf_num_globals): Don't define.
	(elf_seg_map, elf_next_file_pos, elf_eh_frame_hdr, elf_linker,
	elf_stack_flags, elf_strtab_sec, elf_shstrtab_sec): Define.
	* bfd.c, * elf-eh-frame.c, * elf-nacl.c, * elf-vxworks.c, * elf.c,
	* elf32-arm.c, * elf32-lm32.c, * elf32-ppc.c, * elf32-rx.c,
	* elf32-spu.c, * elf64-hppa.c, * elfcode.h, * elflink.c,
	* elfnn-ia64.c, * elfxx-mips.c: Use newly defined elf_obj_tdata
	accessor macros.
	* elf.c (elf_map_symbols): Add pnum_locals param.  Return
	number of locals syms via new param.
	(swap_out_syms): Adjust to suit elf_map_symbols change.
ld/
	* emultempl/elf-generic.em: Use newly defined elf_obj_tdata
	accessor macros.
2013-02-21 02:29:11 +00:00
Alan Modra d45f8bdadc PR ld/12549
* elf-bfd.h (_bfd_elf_strtab_clear_refs): Delete.
	(_bfd_elf_strtab_clear_all_refs): Declare.
	(_bfd_elf_strtab_resize): Declare.
	* elf-strtab.c (_bfd_elf_strtab_clear_refs): Delete.
	(_bfd_elf_strtab_clear_all_refs): New function.
	(_bfd_elf_strtab_resize): Likewise.
	* elflink.c (elf_link_add_object_symbols): Use _bfd_elf_strtab_resize.
2013-02-18 10:40:19 +00:00
H.J. Lu 3d5bef4c08 Don't add DT_NEEDED for references from the dummy bfd
bfd/

	PR ld/15146
	* elflink.c (elf_link_add_object_symbols): Don't add DT_NEEDED
	for references from the dummy bfd.

ld/

	PR ld/15146
	* plugin.c (plugin_notice): Replace the undefined dummy bfd with
	the real one.

ld/testsuite/

	PR ld/15146
	* ld-plugin/pr15146.d: New file.
	* ld-plugin/pr15146a.c: Likewise.
	* ld-plugin/pr15146b.c: Likewise.
	* ld-plugin/pr15146c.c: Likewise.
	* ld-plugin/pr15146d.c: Likewise.

	* ld-plugin/lto.exp: Add tests for PR ld/15146.
2013-02-16 17:54:37 +00:00
H.J. Lu 313ed4a9b0 Also track weak references
PR ld/15149
	* elflink.c (elf_link_add_object_symbols): Also track weak
	references.
2013-02-16 17:48:57 +00:00
Alan Modra 9f7c3e5e99 * elfcode.h (elf_checksum_contents): Free contents.
* elf-bfd.h (_bfd_elf_link_hash_table_free): Declare.
	* elflink.c (_bfd_elf_link_hash_table_free): New function.
	(elf_final_link_free): New function, extracted from..
	(bfd_elf_final_link): ..here.  Always call
	_bfd_elf_write_section_eh_frame_hdr.
	* elfxx-target.h (bfd_elfNN_bfd_link_hash_table_free): Default to
	_bfd_elf_link_hash_table_free.
	* libbfd-in.h (_bfd_merge_sections_free): Declare.
	* libbfd.h: Regenerate.
	* merge.c (_bfd_merge_sections_free): New function.
	* elf-eh-frame.c (_bfd_elf_write_section_eh_frame_hdr): Free
	hdr_info->array.
	* elf-m10300.c (elf32_mn10300_link_hash_table_free): Call
	_bfd_elf_link_hash_table_free.
	* elf32-arm.c (elf32_arm_link_hash_table_free): Likewise.
	* elf32-avr.c (elf32_avr_link_hash_table_free): Likewise.
	* elf32-hppa.c (elf32_hppa_link_hash_table_free): Likewise.
	* elf32-i386.c (elf_i386_link_hash_table_free): Likewise.
	* elf32-m68hc1x.c (m68hc11_elf_hash_table_free): Likewise.
	* elf32-m68k.c (elf_m68k_link_hash_table_free): Likewise.
	* elf32-metag.c (elf_metag_link_hash_table_free): Likewise.
	* elf32-xgate.c (xgate_elf_bfd_link_hash_table_free): Likewise.
	* elf64-aarch64.c (elf64_aarch64_link_hash_table_free): Likewise.
	* elf64-ia64-vms.c (elf64_ia64_hash_table_free): Likewise.
	* elf64-ppc.c (ppc64_elf_link_hash_table_free): Likewise.
	* elf64-x86-64.c (elf_x86_64_link_hash_table_free): Likewise.
	* elfnn-ia64.c (elfNN_ia64_hash_table_free): Likewise.
	* elf32-cr16.c (elf32_cr16_link_hash_table_free): Delete.
	(bfd_elf32_bfd_link_hash_table_free): Don't define.
	* elf32-tic6x.c (elf32_tic6x_link_hash_table_free): Delete.
	(bfd_elf32_bfd_link_hash_table_free): Dont' define.
2013-02-11 05:30:54 +00:00
Alan Modra 7bf52ea2ca * coff-arm.c (coff_arm_link_hash_table_create): Use bfd_zmalloc.
* coff-h8300.c (h8300_coff_link_hash_table_create): Likewise.
	* m68klinux.c (linux_link_hash_table_create): Likewise.
	* sparclinux.c (linux_link_hash_table_create): Likewise.
	* sunos.c (sunos_link_hash_table_create): Likewise.
	* xcofflink.c (_bfd_xcoff_bfd_link_hash_table_create): Likewise.
	* elf-m10300.c (elf32_mn10300_link_hash_table_create): Likewise.
	* elf32-arm.c (elf32_arm_link_hash_table_create): Likewise.
	* elf32-avr.c (elf32_avr_link_hash_table_create): Likewise.
	* elf32-cr16.c (elf32_cr16_link_hash_table_create): Likewise.
	* elf32-cris.c (elf_cris_link_hash_table_create): Likewise.
	* elf32-hppa.c (elf32_hppa_link_hash_table_create): Likewise.
	* elf32-i386.c (elf_i386_link_hash_table_create): Likewise.
	* elf32-lm32.c (lm32_elf_link_hash_table_create): Likewise.
	* elf32-m32r.c (m32r_elf_link_hash_table_create): Likewise.
	* elf32-m68hc1x.c (m68hc11_elf_hash_table_create): Likewise.
	* elf32-m68k.c (elf_m68k_link_hash_table_create): Likewise.
	* elf32-metag.c (elf_metag_link_hash_table_create): Likewise.
	* elf32-nios2.c (nios2_elf32_link_hash_table_create): Likewise.
	* elf32-s390.c (elf_s390_link_hash_table_create): Likewise.
	* elf32-score.c (elf32_score_link_hash_table_create): Likewise.
	* elf32-spu.c (spu_elf_link_hash_table_create): Likewise.
	* elf32-tic6x.c (elf32_tic6x_link_hash_table_create): Likewise.
	* elf32-vax.c (elf_vax_link_hash_table_create): Likewise.
	* elf32-xgate.c (xgate_elf_bfd_link_hash_table_create): Likewise.
	* elf32-xtensa.c (elf_xtensa_link_hash_table_create): Likewise.
	* elf64-aarch64.c (elf64_aarch64_link_hash_table_create): Likewise.
	* elf64-s390.c (elf_s390_link_hash_table_create): Likewise.
	* elf64-sh64.c (sh64_elf64_link_hash_table_create): Likewise.
	* elf64-x86-64.c (elf_x86_64_link_hash_table_create): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_link_hash_table_create): Likewise.
	* elflink.c (_bfd_elf_link_hash_table_create): Likewise.
	(_bfd_elf_link_hash_table_init): Assume zero fill table on entry.
2013-02-10 04:36:33 +00:00
H.J. Lu 02acbe2250 Set STB_GNU_UNIQUE only if symbol is defined in regular object
bfd/

	PR ld/15107
	* elflink.c (elf_link_output_extsym): Set STB_GNU_UNIQUE only if
	symbol is defined in regular object.

ld/testsuite/

	PR ld/15107
	* ld-unique/unique_empty.s: Add reference to "b".
2013-02-08 01:33:01 +00:00
Mike Frysinger b1b00fcc61 ld: change --enable-new-dtags to only generate new dtags
The "new" dtags options have been around for 14+ years, so there
shouldn't be a need to generate both new & old tags anymore.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-01-18 17:43:58 +00:00
Alan Modra ee659f1f4b * elf-bfd.h (struct elf_link_hash_entry): Delete dynamic_weak.
Add ref_dynamic_nonweak.
	* elflink.c (_bfd_elf_mark_dynamic_def_weak): Delete.
	(_bfd_elf_merge_symbol): Don't call above function.  Move
	setting of ref_dynamic_nonweak and dynamic_def earlier.  Don't
	clear dynamic_def.
	(elf_link_add_object_symbols): Delete redundant "override" test.
	Don't set dynamic_def here.
	(elf_link_output_extsym): Update.
2013-01-13 12:32:10 +00:00
Alan Modra 02be4619f1 * elf-bfd.h (_bfd_elf_strtab_refcount): Declare.
* elf-strtab.c (_bfd_elf_strtab_refcount): New function.
	* elflink.c (elf_add_dt_needed_tag): Use _bfd_elf_strtab_refcount.
2013-01-11 14:09:59 +00:00
Alan Modra a4542f1b23 PR ld/12549
* elf-bfd.h (_bfd_elf_strtab_clear_refs): Declare.
	(_bfd_elf_strtab_clear_all_refs): Define.
	* elf-strtab.c (_bfd_elf_strtab_clear_refs): New function.
	(_bfd_elf_strtab_clear_all_refs): Delete.
	* elflink.c (elf_link_add_object_symbols): Clear out added
	strtab refs.  Correct handling of warning common symbols.
2013-01-11 13:55:02 +00:00
H.J. Lu 68ffbac672 Remove trailing white spaces in bfd
* aout0.c: Remove trailing white spaces.
	* archive.c: Likewise.
	* archures.c: Likewise.
	* bfd-in.h: Likewise.
	* bfd-in2.h: Likewise.
	* coff-alpha.c: Likewise.
	* coff-i860.c: Likewise.
	* coff-mips.c: Likewise.
	* coff-ppc.c: Likewise.
	* coff-tic80.c: Likewise.
	* coff-x86_64.c: Likewise.
	* coff-z80.c: Likewise.
	* coffcode.h: Likewise.
	* coffgen.c: Likewise.
	* cofflink.c: Likewise.
	* compress.c: Likewise.
	* corefile.c: Likewise.
	* cpu-arm.c: Likewise.
	* cpu-avr.c: Likewise.
	* cpu-bfin.c: Likewise.
	* cpu-cr16.c: Likewise.
	* cpu-cr16c.c: Likewise.
	* cpu-crx.c: Likewise.
	* cpu-h8300.c: Likewise.
	* cpu-i386.c: Likewise.
	* cpu-lm32.c: Likewise.
	* cpu-m68k.c: Likewise.
	* cpu-moxie.c: Likewise.
	* cpu-msp430.c: Likewise.
	* cpu-sh.c: Likewise.
	* cpu-xc16x.c: Likewise.
	* dwarf2.c: Likewise.
	* ecofflink.c: Likewise.
	* ecoffswap.h: Likewise.
	* elf-ifunc.c: Likewise.
	* elf-m10300.c: Likewise.
	* elf-vxworks.c: Likewise.
	* elf32-avr.c: Likewise.
	* elf32-avr.h: Likewise.
	* elf32-cr16.c: Likewise.
	* elf32-cr16c.c: Likewise.
	* elf32-cris.c: Likewise.
	* elf32-crx.c: Likewise.
	* elf32-frv.c: Likewise.
	* elf32-hppa.c: Likewise.
	* elf32-i860.c: Likewise.
	* elf32-ip2k.c: Likewise.
	* elf32-iq2000.c: Likewise.
	* elf32-m32c.c: Likewise.
	* elf32-m68hc1x.c: Likewise.
	* elf32-msp430.c: Likewise.
	* elf32-mt.c: Likewise.
	* elf32-ppc.c: Likewise.
	* elf32-rl78.c: Likewise.
	* elf32-s390.c: Likewise.
	* elf32-score.h: Likewise.
	* elf32-sh-symbian.c: Likewise.
	* elf32-sh.c: Likewise.
	* elf32-spu.c: Likewise.
	* elf32-tic6x.c: Likewise.
	* elf32-v850.c: Likewise.
	* elf32-xc16x.c: Likewise.
	* elf32-xtensa.c: Likewise.
	* elf64-alpha.c: Likewise.
	* elf64-hppa.c: Likewise.
	* elf64-ppc.c: Likewise.
	* elf64-s390.c: Likewise.
	* elfcore.h: Likewise.
	* elflink.c: Likewise.
	* elfxx-mips.c: Likewise.
	* elfxx-sparc.c: Likewise.
	* elfxx-tilegx.c: Likewise.
	* ieee.c: Likewise.
	* libcoff.h: Likewise.
	* libpei.h: Likewise.
	* libxcoff.h: Likewise.
	* linker.c: Likewise.
	* mach-o-i386.c: Likewise.
	* mach-o-target.c: Likewise.
	* mach-o.c: Likewise.
	* mach-o.h: Likewise.
	* mmo.c: Likewise.
	* opncls.c: Likewise.
	* pdp11.c: Likewise.
	* pe-x86_64.c: Likewise.
	* peXXigen.c: Likewise.
	* pef-traceback.h: Likewise.
	* pei-x86_64.c: Likewise.
	* peicode.h: Likewise.
	* plugin.c: Likewise.
	* reloc.c: Likewise.
	* riscix.c: Likewise.
	* section.c: Likewise.
	* som.c: Likewise.
	* syms.c: Likewise.
	* tekhex.c: Likewise.
	* ticoff.h: Likewise.
	* vaxbsd.c: Likewise.
	* xcofflink.c: Likewise.
	* xtensa-isa.c: Likewise.
2013-01-10 20:03:55 +00:00
Nick Clifton 9b239e0e1f * elflink.c (get_value): Prevent the use of an undefined shift
operation.  Add sanity checks.
2013-01-03 15:47:46 +00:00
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 dda8ddc56f Remove ref_dynamic_nonweak added by accident
bfd/

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

	PR ld/14862
	* elf-bfd.h (elf_link_hash_entry): Remove ref_dynamic_nonweak
	added by accident.
	(elf_link_add_object_symbols): Don't set nor check
	ref_dynamic_nonweak.

ld/testsuite/

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

	PR ld/14862
	* ld-elf/shared.exp (build_tests): Build libpr14862-1.o and
	libpr14862.so.
	(run_tests): Test pr14862.

	* ld-elf/pr14862-1.c: New file.
	* ld-elf/pr14862-2.c: Likewise.
	* ld-elf/pr14862.map: Likewise.
	* ld-elf/pr14862.out: Likewise.
2012-11-20 22:17:27 +00:00
Nick Clifton 3bfcb6528e bfd:
* elf32-arm.c (elf32_arm_print_private_bfd_data): Recognise and
        display the new ARM hard-float/soft-float ABI flags for EABI_VER5
        (elf32_arm_post_process_headers): Add the hard-float/soft-float
        ABI flag as appropriate for ET_DYN/ET_EXEC in EABI_VER5.

binutils:
        * readelf.c (decode_ARM_machine_flags): Recognise and display the
        new ARM hard-float/soft-float ABI flags for EABI_VER5. Split out
        the code for EABI_VER4 and EABI_VER5 to allow this.

elfcpp:
        * arm.h: New enum for EABI soft- and hard-float flags.

gold:
        * gold.cc (Target_arm::do_adjust_elf_header): Add the
        hard-float/soft-float ABI flag as appropriate for ET_DYN/ET_EXEC
        in EABI_VER5.

include:
        * elf/arm.h (EF_ARM_ABI_FLOAT_SOFT): New define.
        (EF_ARM_ABI_FLOAT_HARD): Likewise.

ld/testsuite:
        * ld-arm/eabi-hard-float.s: New test source.
        * ld-arm/eabi-soft-float.s: New test source.
        * ld-arm/eabi-hard-float.d: New test.
        * ld-arm/eabi-soft-float.d: New test.
        * ld-arm/eabi-soft-float-ABI4.d: New test.
        * ld-arm/eabi-soft-float-r.d: New test.
        * ld-arm/arm-elf.xp: Use the new tests.

binutils:
	PR binutils/14779
	* configure.in: Add checks for wchar.h and mbstate_t.
	* config.in: Regenerate.
	* configure: Regenerate.
	* readelf.c: Conditionally include wchar.h.
	(print_symbol): Conditionally use mbstate_t.
2012-10-30 12:44:58 +00:00
Nathan Sidwell 04c3a75556 bfd/
* bfd-in.h (bfd_elf_stack_segment_size): Declare.
	* bfd-in2.h: Rebuilt.
	* elfxx-target.h (elf_backend_stack_align): New.
	(elfNN_bed): Add it.
	* elf-bfd.h (struct elf_backend_data): Add stack_align field.
	* elf.c (bfd_elf_map_sections_to_segments): Pay attention to
	stack_align and stacksize for PT_GNU_STACK segment.
	(assign_file_positions_for_non_load_sections): Set p_memsz for
	PT_GNU_STACK segment.
	(copy_elf_program_header): Copy PT_GNU_STACK size.
	* elflink.c (bfd_elf_stack_segment_size): New function, taken from
	uclinux backends.
	(bfd_elf_size_dynamic_sections): Determine
	PT_GNU_STACK requirements after calling backend.  Pay attention to
	stacksize.
	* elf32-bfin.c (elf32_bfinfdpic_always_size_sections): Call
	bfd_elf_stack_segment_size.
	(elf32_bfinfdpic_modify_program_headers): Delete.
	(elf32_bfingfdpic_copy_private_bfd_data): Don't copy PT_GNU_STACK
	here.
	(elf_backend_stack_align): Override.
	(elf_backend_modify_program_headers): Don't override.
	* elf32-frv.c (frvfdpic_always_size_sections): Call
	bfd_elf_stack_segment_size.
	(elf32_frvfdpic_modify_program_headers): Delete.
	(elf32_frvfdpic_copy_private_bfd_data): Don't copy PT_GNU_STACK
	here.
	(elf_backend_stack_align): Override.
	(elf_backend_modify_program_headers): Don't override.
	* elf32-lm32.c (lm32_elf_always_size_sections): Leave
	PT_GNU_STACK creation to underlying elf support.  Check
	__stacksize here for backwards compatibility, and set it if
	needed.
	(lm32_elf_modify_segment_map): Delete.
	(lm32_elf_modify_program_headers): Delete.
	(elf_backend_stack_align): Override.
	(elf_backend_modify_segment_map): Don't override.
	(elf_backend_modify_program_headers): Don't override.
	* elf32-sh.c (sh_elf_always_size_sections): Call
	bfd_elf_stack_segment_size.
	(sh_elf_modify_program_headers): Delete.
	(sh_elf_copy_private_data): Don't copy PT_GNU_STACK
	here.
	(elf_backend_stack_align): Override.
	(elf_backend_modify_program_headers): Don't override.
	* elf32-tic6x.c (elf32_tic6x_always_size_sections): Call
	bfd_elf_stack_segment_size.
	(elf32_tic6x_modify_program_headers): Delete.
	(elf32_tic6x_copy_private_data): Delete.
	(elf_backend_stack_align): Override.
	(bfd_elf32_bfd_copy_private_bfd_data): Don't override.
	(elf_backend_modify_program_headers): Don't override.

	include/
	* bfdlink.h (struct bfd_link_info): Add stacksize option.

	ld/
	* ld.texinfo (stack-size): New option.
	* emultempl/elf32.em: Add stack-size option.

	ld/testsuite/
	* ld-elf/binutils.exp: Add -z stack-size=0.
	* ld-elf/elf.exp: Add stack-exec and stack-size tests.
	* ld-elf/orphan-region.d: Add stack-size option. Remove xfail.
	* ld-elf/stack-exec.rd: New.
	* ld-elf/stack-size.rd: New.
	* ld-elf/stack.s: New.
	* ld-scripts/empty-aligned.d: Add stack-size option.
	* ld-sh/fdpic-stack-set.d: New.
	* ld-tic6x/shlib-1.rd: Remove __stacksize symbol.
	* ld-tic6x/shlib-1b.rd: Likewise.
	* ld-tic6x/shlib-1r.rd: Likewise.
	* ld-tic6x/shlib-1rb.rd: Likewise.
	* ld-tic6x/shlib-app-1.rd: Likewise.
	* ld-tic6x/shlib-app-1b.rd: Likewise.
	* ld-tic6x/shlib-app-1r.rd: Likewise.
	* ld-tic6x/shlib-app-1rb.rd: Likewise.
	* ld-tic6x/shlib-noindex.rd: Likewise.
	* ld-tic6x/static-app-1.rd: Likewise.
	* ld-tic6x/static-app-1b.rd: Likewise.
	* ld-tic6x/static-app-1r.rd: Likewise.
	* ld-tic6x/static-app-1rb.rd: Likewise.
2012-10-23 09:33:56 +00:00