Commit Graph

4884 Commits

Author SHA1 Message Date
Nick Clifton 886a250647 New ARC implementation.
bfd	* archures.c: Remove support for older ARC. Added support for new
	ARC cpus (ARC600, ARC601, ARC700, ARCV2).
	* bfd-in2.h: Likewise.
	* config.bfd: Likewise.
	* cpu-arc.c: Likewise.
	* elf32-arc.c: Totally changed file with a refactored
	inplementation of the ARC port.
	* libbfd.h: Added ARC specific relocation types.
	* reloc.c: Likewise.

gas     * config/tc-arc.c: Revamped file for ARC support.
        * config/tc-arc.h: Likewise.
        * doc/as.texinfo: Add new ARC options.
        * doc/c-arc.texi: Likewise.

ld	* configure.tgt: Added target arc-*-elf* and arc*-*-linux-uclibc*.
	* emulparams/arcebelf_prof.sh: New file
	* emulparams/arcebelf.sh: Likewise.
	* emulparams/arceblinux_prof.sh: Likewise.
	* emulparams/arceblinux.sh: Likewise.
	* emulparams/arcelf_prof.sh: Likewise.
	* emulparams/arcelf.sh: Likewise.
	* emulparams/arclinux_prof.sh: Likewise.
	* emulparams/arclinux.sh: Likewise.
	* emulparams/arcv2elfx.sh: Likewise.
	* emulparams/arcv2elf.sh: Likewise.
	* emultempl/arclinux.em: Likewise.
	* scripttempl/arclinux.sc: Likewise.
	* scripttempl/elfarc.sc: Likewise.
	* scripttempl/elfarcv2.sc: Likewise
	* Makefile.am: Add new ARC emulations.
	* Makefile.in: Regenerate.
	* NEWS: Mention the new feature.

opcodes * arc-dis.c: Revamped file for ARC support
	* arc-dis.h: Likewise.
	* arc-ext.c: Likewise.
	* arc-ext.h: Likewise.
	* arc-opc.c: Likewise.
	* arc-fxi.h: New file.
	* arc-regs.h: Likewise.
	* arc-tbl.h: Likewise.

binutils * readelf.c (get_machine_name): Remove A5 reference. Add ARCompact
	and ARCv2.
	(get_machine_flags): Handle EM_ARCV2 and EM_ARCOMPACT.
	(guess_is_rela): Likewise.
	(dump_relocations): Likewise.
	(is_32bit_abs_reloc): Likewise.
	(is_16bit_abs_reloc): Likewise.
	(is_none_reloc): Likewise.
	* NEWS: Mention the new feature.

include	* dis-asm.h (arc_get_disassembler): Correct declaration.
	* arc-reloc.def: Macro file with definition of all relocation
	types.
	* arc.h: Changed macros for the newly supported ARC cpus.  Altered
	enum defining the supported relocations.
	* common.h: Changed EM_ARC_A5 definition to EM_ARC_COMPACT. Added
	macro for EM_ARC_COMPACT2.
        * arc-func.h: New file.
        * arc.h: Likewise.
2015-10-07 14:20:19 +01:00
H.J. Lu a0d49154d4 Don't re-export common symbols
For ELF linker, a common symbol isn't a definition.  When we decide if a
symbol should be re-exported, we should check if the symbol isn't
undefined, not if it is a definition.

bfd/

	PR ld/18914
	* elflink.c (elf_link_add_object_symbols): Don't re-export a
	symbol if it isn't undefined.

ld/testsuite/

	PR ld/18914
	* ld-elf/exclude.exp: Also check exclude_common.
	* ld-elf/exclude2.s: Add exclude_common.
2015-10-05 14:45:17 -07:00
H.J. Lu d00c2bc9c0 Enable IAMCU and PEI for Solaris2/x86
bfd/

	* config.bfd (targ_selvecs, targ64_selvecs): Add iamcu_elf32_vec,
	i386_pei_vec and x86_64_pei_vec for Solaris2/x86.

ld/

	* configure.tgt (targ_extra_emuls): Add elf_iamcu for Solaris2/x86.
2015-10-04 07:42:43 -07:00
Renlin Li 3ebe65c0ff [LD][AARCH64]Add TLSIE relaxation support under large memory model.
bfd/
2015-10-02  Renlin Li <renlin.li@arm.com>

	* elfnn-aarch64.c (IS_AARCH64_TLS_RELAX_RELOC): Add
	TLSIE_MOVW_GOTTPREL_G1.
	(aarch64_tls_transition_without_check): Add
	TLSIE_MOVW_GOTTPREL_G1 to TLSLE_MOVW_TPREL_G2
	transition for local symbol.
	(elfNN_aarch64_tls_relax): Add a argument to pass tp offset.
	Add TLSIE_MOVW_GOTTPREL_G1 relaxation.
	(elfNN_aarch64_relocate_section): Call elfNN_aarch64_tls_relax
	with new argument.

ld/testsuite/
2015-10-02  Renlin Li <renlin.li@arm.com>

	* ld-aarch64/aarch64-elf.exp (tls-relax-large-le-ie): Run new test.
	* ld-aarch64/tls-relax-large-ie-le.d: New.
	* ld-aarch64/tls-relax-large-ie-le.s: New.
2015-10-02 17:56:09 +01:00
Renlin Li 0484b4549e [LD][AARCH64]Add TLSDESC support for large memory model.
bfd/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* elfnn-aarch64.c (aarch64_tls_transition_without_check):  Add
	relax transitions for TLSDESC_ADD, TLSDESC_LDR, TLSDESC_OFF_G0_NC,
	TLSDESC_OFF_G1.
	(aarch64_tls_transition_without_check): Add relaxation support.
	(aarch64_reloc_got_type): Add support.
	(elfNN_aarch64_final_link_relocate): Likewise.
	(elfNN_aarch64_tls_relax): Likewise.
	(elfNN_aarch64_relocate_section): Likewise.
	(elfNN_aarch64_gc_sweep_hook): Likewise.
	(elfNN_aarch64_check_relocs): Likewise.
	* elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
	(_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* ld-aarch64/aarch64-elf.exp: Run new test.
	* ld-aarch64/tls-large-desc.d: New.
	* ld-aarch64/tls-large-desc.s: New.
	* ld-aarch64/tls-relax-large-desc-ie.d: New.
	* ld-aarch64/tls-relax-large-desc-ie.s: New.
	* ld-aarch64/tls-relax-large-desc-le.d: New.
	* ld-aarch64/tls-relax-large-desc-le.s: New.
2015-10-02 17:56:09 +01:00
Renlin Li ac73473248 [BFD][AARCH64]Add TLSGD relaxation support under large memory model.
bfd/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* elfnn-aarch64.c(IS_AARCH64_TLS_RELAX_RELOC):
	Add relaxation support for TLSGD_MOVW_G0_NC and TLSGD_MOVW_G1.
	(aarch64_tls_transition_without_check): Likewise
	(elfNN_aarch64_tls_relax): Likwise.

ld/testsuite/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* ld-aarch64/aarch64-elf.exp: run new test
	* ld-aarch64/tls-relax-large-gd-ie.d: New.
	* ld-aarch64/tls-relax-large-gd-ie.s: New.
	* ld-aarch64/tls-relax-large-gd-le.d: New.
	* ld-aarch64/tls-relax-large-gd-le.s: New.
2015-10-02 17:56:09 +01:00
Renlin Li 3b957e5b07 [Binutils][AARCH64]Add TLS IE large memory support.
bfd/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* reloc.c: Make AARCH64_TLSIE_MOVW_GOTTPREL_G1 and
	AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC defined in alphabetical order.
	* libbfd.h: Regenerate.
	* bfd-in2.h: Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_howto_table): Make
	TLSIE_MOVW_GOTTPREL_G1 check overflow.
	(aarch64_reloc_got_type): Add support for TLSIE_MOVW_GOTTPREL_G1
	and TLSIE_MOVW_GOTTPREL_G0_NC.
	(elfNN_aarch64_final_link_relocate): Likewise.
	(elfNN_aarch64_relocate_section): Likewise.
	(elfNN_aarch64_gc_sweep_hook): Likewise.
	(elfNN_aarch64_check_relocs): Likewise.
	* elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
	(_bfd_aarch64_elf_resolve_relocation): Likewise.

gas/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* config/tc-aarch64.c (reloc_table): Add two entries for
	gottprel_g0_nc and gottprel_g1.
	(process_movw_reloc_info): Add support.
	(md_apply_fix): Likewise.
	(aarch64_force_relocation): Likewise.

gas/testsuite/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* gas/aarch64/reloc-gottprel_g0_nc.d: New.
	* gas/aarch64/reloc-gottprel_g0_nc.s: New.
	* gas/aarch64/reloc-gottprel_g1.d: New.
	* gas/aarch64/reloc-gottprel_g1.s: New.

ld/testsuite/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* ld-aarch64/tls-large-ie.d: New.
	* ld-aarch64/tls-large-ie.s: New.
	* ld-aarch64/aarch64-elf.exp: Run new test.
2015-10-02 17:56:08 +01:00
Renlin Li 7ba7cfe431 [LD][AARCH64]Add BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC support.
bfd/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* elfnn-aarch64.c (aarch64_reloc_got_type): Add
	BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC support.
	(elfNN_aarch64_final_link_relocate): Likewise.
	(elfNN_aarch64_relocate_section): Likewise.
	(elfNN_aarch64_gc_sweep_hook): Likewise.
	(elfNN_aarch64_check_relocs): Likewise.
	* elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
	(_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* ld-aarch64/emit-relocs-516.d: New.
	* ld-aarch64/emit-relocs-516.s: New.
	* ld-aarch64/aarch64-elf.exp: Run new test.
2015-10-02 17:56:08 +01:00
Renlin Li 94facae337 [LD][AARCH64]Add BFD_RELOC_AARCH64_TLSGD_MOVW_G1 support.
bfd/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* elfnn-aarch64.c (aarch64_reloc_got_type): Add
	BFD_RELOC_AARCH64_TLSGD_MOVW_G1 support.
	(elfNN_aarch64_final_link_relocate): Likewise.
	(elfNN_aarch64_relocate_section): Likewise.
	(elfNN_aarch64_gc_sweep_hook): Likewise.
	(elfNN_aarch64_check_relocs): Likewise.
	* elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
	(_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite

2015-10-02  Renlin Li <renlin.li@arm.com>

	* ld-aarch64/emit-relocs-515.d: New.
	* ld-aarch64/emit-relocs-515.s: New.
	* ld-aarch64/aarch64-elf.exp: Run new test.
2015-10-02 17:56:08 +01:00
Renlin Li dc8008f508 [LD][AARCH64]Add BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC Support.
bfd/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* elfnn-aarch64.c (aarch64_reloc_got_type): Add
	BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC support.
	(elfNN_aarch64_final_link_relocate): Likewise.
	(elfNN_aarch64_gc_sweep_hook): Likewise.
	(elfNN_aarch64_check_relocs): Likewise.
	* elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
	(_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/

2015-10-02  Renlin Li <renlin.li@arm.com>

	* ld-aarch64/aarch64-elf.exp: Run new test.
	* ld-aarch64/emit-relocs-301.d: New.
	* ld-aarch64/emit-relocs-301.s: New.
2015-10-02 17:56:07 +01:00
Renlin Li 74a1bfe1d6 [LD][AARCH64]Add BFD_RELOC_AARCH64_MOVW_GOTOFF_G1 Support.
bfd/

2015-10-02  Renlin Li  <renlin.li@arm.com>

	* elfnn-aarch64.c (aarch64_reloc_got_type): Add support
	for BFD_RELOC_AARCH64_MOVW_GOTOFF_G1.
	(elfNN_aarch64_gc_sweep_hook): Likewise.
	(elfNN_aarch64_check_relocs): Likewise
	* elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
	(_bfd_aarch64_elf_resolve_relocation): Likewise
	(elfNN_aarch64_final_link_relocate): Calculate offset within GOT.

ld/testsuite/

2015-10-02  Renlin Li  <renlin.li@arm.com>

	* ld-aarch64/emit-relocs-302.d: New.
	* ld-aarch64/emit-relocs-302.s: New.
	* ld-aarch64/aarch64-elf.exp: Run the new test.
2015-10-02 17:56:07 +01:00
Renlin Li a2e1db00c7 [LD][AARCH64]Add BFD_RELOC_AARCH64_LD64_GOTOFF_LO15 Support.
bfd/

2015-10-02  Renlin Li  <renlin.li@arm.com>

	* elfnn-aarch64.c (aarch64_reloc_got_type): Add
	BFD_RELOC_AARCH64_LD_64_GOTOFF_LO15 support.
	(elfNN_aarch64_gc_sweep_hook): Likewise.
	(elfNN_aarch64_check_relocs): Likewise
	* elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
	(_bfd_aarch64_elf_resolve_relocation): Likewise
	(elfNN_aarch64_final_link_relocate): Calculate offset within GOT.

ld/testsuite/

2015-10-02  Renlin Li  <renlin.li@arm.com>

	* ld-aarch64/emit-relocs-310.d: New.
	* ld-aarch64/emit-relocs-310.s: New.
	* ld-aarch64/aarch64-elf.exp: Run the test.
2015-10-02 17:56:07 +01:00
H.J. Lu 5db4f0d383 Create a PLT entry for R_X86_64_PC32 in non-code sections
Since something like ".long foo - ." may be used as pointer, we make
sure that PLT is used if foo is a function defined in a shared library.

bfd/

	PR ld/19031
	* elf64-x86-64.c (elf_x86_64_check_relocs): Set
	pointer_equality_needed for R_X86_64_PC32 reloc in non-code
	sections.

ld/testsuite/

	PR ld/19031
	* ld-x86-64/x86-64.exp: Run PR ld/19031 test.
	* ld-x86-64/pr19031.out: New file.
	* ld-x86-64/pr19031a.c: Likewise.
	* ld-x86-64/pr19031b.S: Likewise.
	* ld-x86-64/pr19031c.c: Likewise.
2015-10-01 10:49:33 -07:00
Renlin Li 73524045d3 [BFD][AARCH64]Emit single AARCH64_MAP_INSN symbol for the whole plt.
bfd/

2015-10-01  Renlin Li  <renlin.li@arm.com>

	* elfnn-aarch64.c (elfNN_aarch64_output_plt_map): Remove.
	(elfNN_aarch64_output_arch_local_syms): Emit AARCH64_MAP_INSN once.

ld/testsuite/

2015-10-01  Renlin Li  <renlin.li@arm.com>

	* ld-aarch64/plt_mapping_symbol.d: New.
	* ld-aarch64/plt_mapping_symbol.s: New.
	* ld-aarch64/aarch64-elf.exp: Run the new test.
2015-10-01 14:27:56 +01:00
Kaz Kojima 0e1e4a7512 ld/configure.tgt: Drop non-linux non-fdpic stuff from the last change of targ_extra_emuls for sh*-linux cases 2015-10-01 14:19:53 +09:00
Alan Modra c220e327e3 Update ld-x86-64/pr19013-nacl.d
* ld-x86-64/pr19013-nacl.d: Update.
2015-10-01 09:31:16 +09:30
Alan Modra 017e6bceee Revert "Also check e_machine when merging sections"
Commit 9865bd0d added a bogus check in _bfd_elf_merge_sections.

bfd/
	PR ld/19013
	* elflink.c (_bfd_elf_merge_sections): Revert last change.
ld/testsuite/
	* ld-x86-64/pr19013-x32.d: Update.
2015-10-01 07:41:28 +09:30
H.J. Lu b8836e409e Pass -m elf_x86_64 to ld for 64-bit test
* ld-x86-64/pr19013.d (ld): Add -m elf_x86_64.
2015-09-30 10:20:34 -07:00
H.J. Lu 4b627c1844 Create a PLT entry for R_386_PC32 in non-code sections
Since something like ".long foo - ." may be used as pointer, we make
sure that PLT is used if foo is a function defined in a shared library.

bfd/

	PR ld/19031
	* elf32-i386.c (elf_i386_check_relocs): Set
	pointer_equality_needed for R_386_PC32 reloc in non-code
	sections.

ld/testsuite/

	PR ld/19031
	* ld-i386/i386.exp: Run PR ld/19031 test.
	* ld/testsuite/ld-i386/pr19031.out: New file.
	* ld/testsuite/ld-i386/pr19031a.c: Likewise.
	* ld/testsuite/ld-i386/pr19031b.S: Likewise.
	* ld/testsuite/ld-i386/pr19031c.c: Likewise.
2015-09-30 08:45:13 -07:00
H.J. Lu 9865bd0da6 Also check e_machine when merging sections
When we check consistency for merge ELF sections, we should not only
check EI_CLASS, but also compatible e_machine.

bfd/

	PR ld/19013
	* elflink.c (_bfd_elf_merge_sections): Only merge input bfds
	that have the compatible ELF machine code with the output bfd.

ld/testsuite/

	PR ld/19013
	* ld-x86-64/pr19013-nacl.d: New file.
	* ld-x86-64/pr19013-x32.d: Likewise.
	* ld-x86-64/pr19013.d: Likewise.
	* ld-x86-64/pr19013.s: Likewise.
	* ld-x86-64/x86-64.exp: Run PR ld/19013 tests.
2015-09-30 05:37:49 -07:00
Rich Felker a39d2e820d Add fdpic and misc emulations to configure.tgt for sh*-*-linux* 2015-09-30 14:35:53 +09:00
H.J. Lu c68c163716 Adjust the output section size to skip gap fills
In objcopy, copy_object calls copy_section to copy contents of input
section to output section.  When --gap-fill= is used, objcopy extends
the size of output sectios to fill gaps between output sections with
gap fills.  In this case, we adjust the output section size to skip
gap files to avoid reading beypond the input section buffer before
calling copy_section and restore the output section size after input
sections have been copied.

binutils/

	PR binutils/19005
	* objcopy.c (copy_object): Adjust the output section size to
	skip gap fills between sections when copying from input sections
	to output sections.

ld/testsuite/

	PR binutils/19005
	* ld-elf/pr19005.d: New file.
	* ld-elf/pr19005.s: Likewise.
	* ld-elf/pr19005.t: Likewise.
2015-09-29 06:33:24 -07:00
Nick Clifton 56e6cf80bd PR/19014: Fix a spelling mistake in the linker documentation. 2015-09-29 10:55:23 +01:00
Peter Zotov 8a9e7a9121 Correct the generation of OR1K pc-relative relocations.
gas	PR ld/18759
	* config/tc-or1k.c (tc_gen_reloc): Correct computation of PC
	relative relocs.
	* config/tc-or1k.h (GAS_CGEN_PRCEL_R_TYPE): Delete.

bfd	* elf32-or1k.c (R_OR1K_32_PCREL): Set pcrel_offset to TRUE.
	(R_OR1K_16_PCREL): Likewise.
	(R_OR1K_8_PCREL): Likewise.

ld/tests * ld-elf/eh-frame-hdr: Expect to pass on the or1k-linux target.
2015-09-25 15:21:14 +01:00
Alan Modra 3074964fcf Relative DT_RPATH/DT_RUNPATH vs. sysroot capable ld.
This fixes two problems.  First, the --sysroot option wasn't available
with a ld configured without --with-sysroot, a historical accident.
This led to people configuring binutils with --with-sysroot=/ in order
to enable sysroot support, which exposes a case where ld wrongly
prepends the sysroot to a relative path.

	PR ld/18992
	* ldmain.c (main): Always enable --sysroot.
	* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Don't
	prepend sysroot to relative rpath/runpath.
2015-09-24 22:35:04 +09:30
Nick Clifton b6518b3871 Fix compile time warnings generated when compiling with clang.
bfd	* bout.c (b_out_slurp_reloc_table): Cast constant to unsigned in
	order to avoid problems with left shifting negative values.
	(abs32code): Likewise.
	* mach-o.c (FILE_ALIGN): Likewise.
	* coff-rs6000.c (xcoff_debug_sections): Delete unused static
	array.
	* elf32-visium.c (visium_reloc_map): Likewise.
	* elf32-arm.c (elf32_arm_final_link_relocate): Remove useless
	calls to abs function.
	* elf32-frv.c (_frvfdpic_relax_tls_entries): Likewise.
	* elf32-score.c (score_elf_final_link_relocate): Likewise.
	* elf32-score7.c (score_elf_final_link_relocate): Likewise.
	* elf32-i860.c (i860_howto_pc26_reloc): Use multiplication instead
	of shifting to create a negative mask.
	* elf32-msp430.c (elf_backend_special_sections): Define.
	* elfxx-mips.c (got_ofst_reloc_p): Delete unused function.
	(got_hi16_reloc_p): Delete unused function.
	* ppcboot.c (ppcboot_bfd_print_private_bfd_data): Fix test of
	partition name.

gas	* config/tc-ppc.c (insn_validate): Cast PPC_OPSHIFT_INV to an int.

opcode	* ppc.h (PPC_OPSHIFT_INV): Use an unsigned constant when left
	shifting.

ld	* emultempl/elf32.em (ehdr_start_empty): New static variable.
	(before_allocation): Use it to initialise ehdr_start_save.
	* emultempl/pe.em (write_build_id): Remove useless double
	parenthesis.
	* emultempl/pep.em (write_build_id): Likewise.

opcodes	* bfin-dis.c (fmtconst): Remove unnecessary call to the abs
	function.
	* tic30-dis.c (print_branch): Likewise.
	* cgen-asm.c (cgen_parse_signed_integer): Cast integer to signed
	value before left shifting.
	* fr30-ibld.c (fr30_cgen_extract_operand): Likewise.
	* hppa-dis.c (print_insn_hppa): Likewise.
	* mips-dis.c (mips_cp0sel_names_mipsr5900): Delete unused static
	array.
	* msp430-dis.c (msp430_singleoperand): Likewise.
	(msp430_doubleoperand): Likewise.
	(print_insn_msp430): Likewise.
	* nds32-asm.c (parse_operand): Likewise.
	* sh-opc.h (MASK): Likewise.
	* v850-dis.c (get_operand_value): Likewise.
2015-09-23 18:05:16 +01:00
H.J. Lu 0a6b6047cf Update MIPS PIE tests for DF_1_PIE change
Since linker now sets the DF_1_PIE bit in the DT_FLAGS_1 tag for PIE,
we need to update MIPS PIE tests for it.

	* ld-mips-elf/pie-n32.d: Updated.
	* ld-mips-elf/pie-n64.d: Likewise.
	* ld-mips-elf/pie-o32.d: Likewise.
2015-09-22 11:12:01 -07:00
H.J. Lu 5fe2850dd9 Set DF_1_PIE in gld${EMULATION_NAME}_after_parse
We can't add OPTION_PIE to gld${EMULATION_NAME}_handle_option since
it has been handled in parse_args in lexsup.c.  This patch moves
setting DF_1_PIE to gld${EMULATION_NAME}_after_parse.

ld/

	* emultempl/alphaelf.em (alpha_after_parse): Call
	gld${EMULATION_NAME}_after_parse instead of
	after_parse_default.
	* emultempl/cr16elf.em (cr16elf_after_parse): Likewise.
	* emultempl/crxelf.em (crxelf_after_parse); Likewise.
	* emultempl/hppaelf.em (hppaelf_after_parse): Likewise.
	* emultempl/mipself.em (mips_after_parse): Likewise.
	* emultempl/nds32elf.em (nds32_elf_after_parse): Likewise.
	* emultempl/elf32.em: Don't include ldlex.h.
	(gld${EMULATION_NAME}_after_parse): New function.
	(gld${EMULATION_NAME}_handle_option) [GENERATE_PIE_SCRIPT]
	<OPTION_PIE>: Removed.
	(ld_${EMULATION_NAME}_emulation): Replace after_parse_default
	with gld${EMULATION_NAME}_after_parse.
	* emultempl/ia64elf.em (gld${EMULATION_NAME}_after_parse):
	Renamed to ...
	(ia64elf_after_parse): This.  Call
	gld${EMULATION_NAME}_after_parse instead of after_parse_default.
	(LDEMUL_AFTER_PARSE): Replace gld${EMULATION_NAME}_after_parse
	with ia64elf_after_parse.

ld/testsuite/

	* ld-elf/pie.d: New test.
2015-09-22 06:08:55 -07:00
Rainer Orth 5c383f0262 Solaris PIE support
include/elf:
	* common.h (DF_1_STUB, DF_1_PIE): Define.

	ld:
	* emulparams/solaris2.sh (GENERATE_PIE_SCRIPT): Set to yes.

	* emultempl/elf32.em: Include ldlex.h.
	(gld${EMULATION_NAME}_handle_option) [GENERATE_PIE_SCRIPT]
	<OPTION_PIE>: Set DF_1_PIE.

	binutils:
	* readelf.c (process_dynamic_section): Handle DF_1_STUB, DF_1_PIE.
2015-09-22 11:12:51 +02:00
Alan Modra 95421fb9b7 Format ld option items
* ld.texinfo: Put --dotsyms/--no-dotsyms on separate lines.
	Ditto for --save-restore-funcs and --tls-get-addr-optimize.
2015-09-22 09:20:43 +09:30
Rich Felker 9b8b325a1f Add --no-dynamic-linker option to ld, for static PIE use
Inhibits output of .interp section in ELF executables.

include/
	* bfdlink.h (struct bfd_link_info): Add "nointerp" field.
bfd/
	* elflink.c (_bfd_elf_link_create_dynamic_sections): Don't create
	.interp when info->nointerp.
	(bfd_elf_size_dynamic_sections): Adjust assert.
	* elf32-arm.c (elf32_arm_size_dynamic_sections): Don't size .interp
	when info->nointerp.
	* elf32-bfin.c (elf32_bfinfdpic_size_dynamic_sections): Likewise.
	* elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise.
	* elf32-cris.c (elf_cris_size_dynamic_sections): Likewise.
	* elf32-frv.c (elf32_frvfdpic_size_dynamic_sections): Likewise.
	* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise.
	* elf32-i370.c (i370_elf_size_dynamic_sections): Likewise.
	* elf32-i386.c (elf_i386_size_dynamic_sections): Likewise.
	* elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise.
	* elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise.
	* elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
	* elf32-metag.c (elf_metag_size_dynamic_sections): Likewise.
	* elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise.
	* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise.
	* elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise.
	* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
	* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
	* elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_size_dynamic_sections): Likewise.
	* elf32-sh.c (sh_elf_size_dynamic_sections): Likewise.
	* elf32-tic6x.c (elf32_tic6x_size_dynamic_sections): Likewise.
	* elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise.
	* elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
	* elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Likewise.
	* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
	* elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise.
	* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Likewise.
	* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
	* elf64-sh64.c (sh64_elf64_size_dynamic_sections): Likewise.
	* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Likewise.
	* elfnn-ia64.c (elfNN_ia64_size_dynamic_sections): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise.
	* elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise.
ld/
	* ld.texinfo (--no-dynamic-linker): Document.
	* ldlex.h (enum option_values): Add OPTION_NO_DYNAMIC_LINKER.
	* lexsup.c (ld_options, parse_args): Handle --no-dynamic-linker.
2015-09-20 15:52:27 +09:30
Alan Modra 7ae4ea7d0d Add missing PowerPC64 ld --save-restore-funcs doc
* ld.texinfo: Document --{no-,}save-restore-funcs.
2015-09-18 16:43:06 +09:30
Alan Modra 7c9cf41584 Add PowerPC64 ld --tls-get-addr-optimize.
Sometimes it may be of benefit to force use of the __tls_get_addr_opt
call stub even when the glibc being used during linking does not
advertise __tls_get_addr_opt.

bfd/
	* elf64-ppc.h (struct ppc64_elf_params <tls_get_addr_opt>): Rename
	from no_tls_get_addr_opt.
	* elf64-ppc.c: Update for rename and inversion of tls_get_addr_opt.
	(ppc64_elf_tls_setup): Set tls_get_addr_opt to 0 only when at
	default of -1.
ld/
	* emultempl/ppc64elf.em (params): Init tls_get_addr_opt field to -1.
	(OPTION_TLS_GET_ADDR_OPT): Define.
	(PARSE_AND_LIST_LONGOPTS): Handle --tls-get-addr-opt.
	(PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Likewise.
	* ld.texinfo: Document --tls-get-addr-optimize and
	--no-tls-get-addr-optimize.
2015-09-18 16:38:03 +09:30
Alan Modra 975f8a9e31 Delay converting linker script defined symbols from absolute
Giving linker script symbols defined outside of output sections a
section-relative value early, leads to them being used in expressions
as if they were defined inside an output section.  This can mean loss
of the section VMA, and wrong results.

ld/
	PR ld/18963
	* ldexp.h (struct ldexp_control): Add rel_from_abs.
	(ldexp_finalize_syms): Declare.
	* ldexp.c (new_rel_from_abs): Keep absolute for expressions
	outside of output section statements.  Set rel_from_abs.
	(make_abs, exp_fold_tree, exp_fold_tree_no_dot): Clear rel_from_abs.
	(struct definedness_hash_entry): Add final_sec, and comment.
	(update_definedness): Set final_sec.
	(set_sym_sections, ldexp_finalize_syms): New functions.
	* ldlang.c (lang_process): Call ldexp_finalize_syms.
ld/testsuite
	PR ld/18963
	* ld-scripts/pr18963.d,
	* ld-scripts/pr18963.t: New test.
	* ld-scripts/expr.exp: Run it.
	* ld-elf/provide-hidden-2.ld: Explicitly make "dot" absolute.
	* ld-mips-elf/gp-hidden.sd: Don't care about _gp section.
	* ld-mips-elf/no-shared-1-n32.d: Don't care about symbol shown at
	start of .data section.
	* ld-mips-elf/no-shared-1-n64.d: Likewise.
	* ld-mips-elf/no-shared-1-o32.d: Likewise.
2015-09-18 12:39:16 +09:30
H.J. Lu 6d636d8c77 Add "ld -r" tests for PR ld/15323
Weak defined function is turned into non-weak defined function by
"ld -r -flto" with GCC 5 due to a GCC 5 regression:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67548

Add "ld -r" tests for PR ld/15323 to make sure that any linker change
won't introduce linker regression for PR ld/15323.

	* ld-plugin/lto.exp (lto_link_tests): Add a "ld -r" test for
	PR ld/15323.
	(lto_run_tests): Add a "ld -r" test for PR ld/15323.
2015-09-11 10:02:57 -07:00
Nick Clifton 64597d827f Another updated version of the simplified Chinese translation.
* po/zh_CN.po: Updated simplified Chinese translation.
2015-09-10 12:50:34 +01:00
jamesbowman ea4a7f9986 FT32 linker script now parameterized for flash and RAM size.
2015-09-09  James Bowman  <james.bowman@ftdichip.com>

ld/
    * scripttempl/ft32.sc: default linker script RAM and
    FLASH size symbols
2015-09-09 09:44:44 -07:00
Jiong Wang 259364adb8 [AArch64] Relax TLS local dynamic traditional into local executable
The linker relaxation logic will be:

Code sequence I (tiny):

    0x00 adr  x0, :tlsldm:x
    0x04 bl   __tls_get_addr
         |
         V
    0x00 mrs  x0, tpidr_el0
    0x04 add  x0, x0, TCB_SIZE

Code sequence II (small):

    0x00 adrp a0, :tlsldm:x
    0x04 add  a0, #:tlsldm_lo12:x
    0x08 bl   __tls_get_addr
         |
         V
    0x00 mrs  x0, tpidr_el0
    0x04 add  x0, x0, TCB_SIZE
    0x08 nop

2015-09-09  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (aarch64_tls_transition_without_check): Support
  three TLS local dynamic traditional relocations types.
  (elfNN_aarch64_tls_relax): Support TLS local dynamic traditional to
  local executable relaxation.

ld/testsuite/
  * ld-aarch64/tls-relax-ld-le-tiny.s: New testcase.
  * ld-aarch64/tls-relax-ld-le-small.s: Likewise.
  * ld-aarch64/tls-relax-ld-le-tiny.d: New expectation file.
  * ld-aarch64/tls-relax-ld-le-small.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new testcases.
2015-09-09 14:19:28 +01:00
Nick Clifton 081bb924c9 Update the simplified Chinese translation.
* po/zh_CN.po: Updated simplified Chinese translation.
2015-09-09 09:55:07 +01:00
Nick Clifton 5707d2add4 Extend the descriptiopn of how to access linker defined symbols from C.
* ld.texinfo (Source Code Reference): Extend description to
	include an example using arrays.
2015-09-08 09:36:02 +01:00
Andrew Burgess 3d476d8d59 ld: Fix failures in new orphan handling tests.
The new orphan handling tests added in commit c005eb9 fail on a range of
targets.  Some of the failures were fixed in commit e32aa93 but not
all.  This commit should address the remaining failures.

Update results to account for orphan sections being placed in different
orders, and for other, target specific sections, being discarded.

ld/testsuite/ChangeLog:

	* ld-elf/orphan-7.map: Allow for other discarded sections.
	* ld-elf/orphan-8.map: Updated to allow for different section
	ordering on different targets.
	* ld-elf/orphan.ld: Place .sbss section.
2015-09-07 23:28:04 +01:00
H.J. Lu e32aa9338f Update ld-elf/orphan-8.map to support 32-bit targets
* ld-elf/orphan-8.map: Updated to support 32-bit targets.
2015-09-05 06:44:53 -07:00
Andrew Burgess c005eb9e34 ld: Extend options for altering orphan handling behaviour.
Replace the options --warn-orphan and --no-warn-orphan with a single
option --orphan-handling=MODE, where mode can be place, warn, error, and
discard.

Mode 'place' is the default, and is the current behaviour, placing the
orphan section into a suitable output section.

Mode 'warn' is the same as '--warn-orphan'.  The orphan is also placed
using the same algorithm as for 'place'.

Mode 'error' is the same as '--warn-orphan' and '--fatal-warnings'.

Mode 'discard' assigns all output sections to the /DISCARD/ section.

ld/ChangeLog:

	* ld.h (enum orphan_handling_enum): New.
	(ld_config_type): Remove warn_orphan, add orphan_handling.
	* ldemul.c (ldemul_place_orphan): Remove warning about orphan
	sections.
	* ldlang.c (ldlang_place_orphan): New function.
	(lang_place_orphans): Call ldlang_place_orphan.
	* ldlex.h (enum option_values): Remove OPTION_WARN_ORPHAN and
	OPTION_NO_WARN_ORPHAN, add OPTION_ORPHAN_HANDLING.
	* lexsup.c (ld_options): Remove 'warn-orphan' and
	'no-warn-orphan', add 'orphan-handling'.
	(parse_args): Remove handling for OPTION_WARN_ORPHAN and
	OPTION_NO_WARN_ORPHAN, add handling for OPTION_ORPHAN_HANDLING.
	* NEWS: Replace text about --warn-orphan with --orphan-handling.
	* ld.texinfo (Options): Remove --warn-orphan entry and add
	entry on --orphan-handling.
	(Orphan Sections): Add reference to relevant command line options.

ld/testsuite/ChangeLog:

	* ld-elf/elf.exp: Switch to rely on run_dump_test.
	* ld-elf/orphan-5.l: Update expected output.
	* ld-elf/orphan-5.d: New file.
	* ld-elf/orphan-6.d: New file.
	* ld-elf/orphan-6.l: New file.
	* ld-elf/orphan-7.d: New file.
	* ld-elf/orphan-7.map: New file.
	* ld-elf/orphan-8.d: New file.
	* ld-elf/orphan-8.map: New file.
2015-09-04 22:30:55 +01:00
Nick Clifton a5e406b5ad Fix typo in desription of linker script symbols.
(Source Code Reference): Fix off-by-one typo in example of how to
	use linker script symbols in C source code.
2015-09-03 16:49:18 +01:00
Nick Clifton 6033bf41cc Fix a typo in the linker documentation: The COFF section .build-id should be .buildid. 2015-09-03 12:55:57 +01:00
H.J. Lu 8c650f161a Add ifunc tests for call, jmp, add, test
* ld-ifunc/ifunc-21-i386.s: Add tests for call, jmp, add, test.
	* ld-ifunc/ifunc-21-x86-64.s: Likewise.
	* ld-ifunc/ifunc-22-i386.s: Likewise.
	* ld-ifunc/ifunc-22-x86-64.s: Likewise.
	* ld-ifunc/ifunc-21-i386.d: Updated.
	* ld-ifunc/ifunc-21-x86-64.d: Likewise.
	* ld-ifunc/ifunc-22-i386.d: Likewise.
	* ld-ifunc/ifunc-22-x86-64.d: Likewise.
2015-09-03 04:03:13 -07:00
H.J. Lu 0762fbb6a7 Add 2 ifunc tests for i386 and x86-64
* ld-ifunc/ifunc-21-i386.d: Likewise.
	* ld-ifunc/ifunc-21-i386.s: Likewise.
	* ld-ifunc/ifunc-21-x86-64.d: Likewise.
	* ld-ifunc/ifunc-21-x86-64.s: Likewise.
	* ld-ifunc/ifunc-22-i386.d: Likewise.
	* ld-ifunc/ifunc-22-i386.s: Likewise.
	* ld-ifunc/ifunc-22-x86-64.d: Likewise.
	* ld-ifunc/ifunc-22-x86-64.s: Likewise.
2015-09-02 15:30:32 -07:00
H.J. Lu 04ebc307f9 Skip PLT for function pointer initialization
We use its PLT entry to initialize function pointer at run-time.  If
there is no other usage for the PLT entry, we can generate run-time
function pointer relocations in read-write section, which can be
resolved by dynamic linker, to initialize function pointers.  It avoids
the extra indirect branch overhead in PLT.

bfd/

	PR ld/18900
	* elf32-i386.c (elf_i386_link_hash_entry): Add
	func_pointer_refcount.
	(elf_i386_link_hash_newfunc): Clear func_pointer_refcount.
	(elf_i386_get_local_sym_hash): Likewise.
	(elf_i386_copy_indirect_symbol): Also copy
	func_pointer_refcount.
	(elf_i386_check_relocs): Increment func_pointer_refcount.
	(elf_i386_gc_sweep_hook): Decrement func_pointer_refcount.
	(elf_i386_allocate_dynrelocs): Don't create the PLT entry if
	there are only function pointer relocations which can be
	resolved at run-time.  Keep dynanamic relocations for run-time
	function pointer initialization.
	(elf_i386_relocate_section): Copy dynamic function pointer
	relocations.
	* elf64-x86-64.c (elf_x86_64_link_hash_entry): Add
	func_pointer_refcount.
	(elf_x86_64_link_hash_newfunc): Clear func_pointer_refcount.
	(elf_x86_64_get_local_sym_hash): Likewise.
	(elf_x86_64_copy_indirect_symbol): Also copy
	func_pointer_refcount.
	(elf_x86_64_check_relocs): Increment func_pointer_refcount.
	(elf_x86_64_gc_sweep_hook): Decrement func_pointer_refcount.
	(elf_x86_64_allocate_dynrelocs): Don't create the PLT entry if
	there are only function pointer relocations which can be
	resolved at run-time.  Keep dynanamic relocations for run-time
	function pointer initialization.
	(elf_x86_64_relocate_section): Copy dynamic function pointer
	relocations.

ld/testsuite/

	PR ld/18900
	* ld-i386/i386.exp: Run tests for PR ld/18900.
	* ld-x86-64/x86-64.exp: Likewise.
	* ld-i386/pr18900.out: New file.
	* ld-i386/pr18900a.c: Likewise.
	* ld-i386/pr18900a.c: Likewise.
	* ld-i386/pr18900a.rd: Likewise.
	* ld-i386/pr18900b.c: Likewise.
	* ld-i386/pr18900b.rd: Likewise.
	* ld-i386/pr18900c.c: Likewise.
	* ld-x86-64/pr18900.out: Likewise.
	* ld-x86-64/pr18900a.c: Likewise.
	* ld-x86-64/pr18900a.rd: Likewise.
	* ld-x86-64/pr18900b.c: Likewise.
	* ld-x86-64/pr18900b.rd: Likewise.
	* ld-x86-64/pr18900c.c: Likewise.
	* ld-x86-64/mpx3.dd: Updated.
2015-09-01 05:06:33 -07:00
Alan Modra 1cb0b71f5a Add reloc sort test
* ld-powerpc/relocsort.s, * ld-powerpc/relocsort.d: New test.
	* ld-powerpc/powerpc.exp: Run it.
2015-08-27 23:21:21 +09:30
Matthew Fortune c97c330ba8 Select MIPS ABi based upon abiflags rather than e_flags.
bfd	PR ld/18401
	* elfxx-mips.c (bfd_mips_isa_ext_mach): New function: Converts an
	ISA value to a bfd machine number.
	(bfd_mips_isa_ext): Update the ISA level and revision if
	necessary.  Use mips_mach_extends_p to decide if the ISA extension
	needs to be set.
	(_bfd_mips_elf_merge_private_bfd_data): Allow the ISA extension to
	be inferred from the ABI setting.  Set the ISA level from the
	maximum of the incoming and outgoing ISA levels.

tests
	* ld-mips-elf/mips-elf-flags.exp: Add more ISA conflict tests.
2015-08-26 14:42:56 +01:00