Commit Graph

7198 Commits

Author SHA1 Message Date
Jim Wilson b7f28d873c Enable R_AARCH64_NONE for 64-bit code.
* elfnn-aarch64.c: Unconditionally enable R_AARCH64_NULL and
	R_AARCH64_NONE.  Use HOWTO64 for R_AARCH64_NULL.
	* relocs.c: Add BFD_RELOC_AARCH64_NULL.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Likewise.
2016-05-23 16:38:21 -07:00
Kuba Sejdak a2bea3245e Add support for configuring for the ARM Phoenix target.
bfd	* config.bfd: Add entry for arm-phoenix.

gas	* configuse.tgt: Add entry for arm-phoenix.

ld	* Makefile.am: Add earmelf_phoenix.c.
	* Makefile.in: Regenerate.
	* configure.tgt: Add entry for arm-phoenix.
	* emulparams/armelf_phoenix.sh: New file.
2016-05-23 13:53:07 +01:00
Thomas Preud'homme d7c5bd02f7 Support for dedicated ARM stub section with padding
2016-05-23  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* elf32-arm.c (arm_dedicated_stub_section_padding): New function.
	(elf32_arm_size_stubs): Declare stub_type in a more outer scope and
	account for padding for stub section requiring one.
	(elf32_arm_build_stubs): Add comment to stress the importance of
	zeroing veneer section content.
2016-05-23 09:41:36 +01:00
Thomas Preud'homme daa4adae63 Support for dedicated output section for some ARM veneer types
2016-05-23  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* bfd-in.h (bfd_elf32_arm_keep_private_stub_output_sections): Declare
	bfd hook.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (arm_dedicated_stub_output_section_required): New
	function.
	(arm_dedicated_stub_output_section_required_alignment): Likewise.
	(arm_dedicated_stub_output_section_name): Likewise.
	(arm_dedicated_stub_input_section_ptr): Likewise.
	(elf32_arm_create_or_find_stub_sec): Add stub type parameter and
	function description comment. Add support for dedicated output stub
	section to given stub types.
	(elf32_arm_add_stub): Add a stub type parameter and pass it down to
	elf32_arm_create_or_find_stub_sec.
	(elf32_arm_create_stub): Pass stub type down to elf32_arm_add_stub.
	(elf32_arm_size_stubs): Pass stub type when calling
	elf32_arm_create_or_find_stub_sec for Cortex-A8 erratum veneers.
	(bfd_elf32_arm_keep_private_stub_output_sections): New function.

ld/
	* emultempl/armelf.em (arm_elf_before_allocation): Call
	bfd_elf32_arm_keep_private_stub_output_sections before generic
	before_allocation function.
2016-05-23 09:38:32 +01:00
H.J. Lu 52bf37dd91 Don't check R_386_GOT32 when setting need_convert_load
Since we no longer convert R_386_GOT32, don't check R_386_GOT32 when
setting need_convert_load.

	* elf32-i386.c (elf_i386_check_relocs): Don't check R_386_GOT32
	when setting need_convert_load.
2016-05-20 09:36:48 -07:00
Maciej W. Rozycki 17c6c9d9f3 MIPS: Fix the encoding of immediates with microMIPS JALX
The microMIPS JALX instruction shares the R_MICROMIPS_26_S1 relocation
with microMIPS J/JAL/JALS instructions, however unlike the latters its
encoded immediate argument is unusually shifted left by 2 rather than 1
in calculating the value used for the operation requested.

We already handle this exception in `mips_elf_calculate_relocation' in
LD, in a scenario where JALX is produced as a result of relaxing JAL for
the purpose of making a cross-mode jump.  We also get it right in the
disassembler in `decode_micromips_operand'.

What we don't correctly do however is processing microMIPS JALX produced
by GAS from an assembly source, where a non-zero constant argument or a
symbol reference with a non-zero in-place addend has been used.  In this
case the same calculation is made as for microMIPS J/JAL/JALS, causing
the wrong encoding to be produced by GAS on making an object file, and
then again by LD in the final link.  The latter in particular causes the
calculation, where the addend fits in the relocatable field, to produce
different final addresses for the same source code depending on whether
REL or RELA relocations are used.

Correct these issues by special-casing microMIPS JALX in the places that
have been previously missed.

	bfd/
	* elfxx-mips.c (mips_elf_read_rel_addend): Adjust the addend for
	microMIPS JALX.

	gas/
	* config/tc-mips.c (append_insn): Correct the encoding of a
	constant argument for microMIPS JALX.
	(tc_gen_reloc): Correct the encoding of an in-place addend for
	microMIPS JALX.
	* testsuite/gas/mips/jalx-addend.d: New test.
	* testsuite/gas/mips/jalx-addend-n32.d: New test.
	* testsuite/gas/mips/jalx-addend-n64.d: New test.
	* testsuite/gas/mips/jalx-imm.d: New test.
	* testsuite/gas/mips/jalx-imm-n32.d: New test.
	* testsuite/gas/mips/jalx-imm-n64.d: New test.
	* testsuite/gas/mips/jalx-addend.s: New test source.
	* testsuite/gas/mips/jalx-imm.s: New test source.
	* testsuite/gas/mips/mips.exp: Run the new tests.

	ld/
	* testsuite/ld-mips-elf/jalx-addend.d: New test.
	* testsuite/ld-mips-elf/jalx-addend-n32.d: New test.
	* testsuite/ld-mips-elf/jalx-addend-n64.d: New test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2016-05-20 13:38:48 +01:00
H.J. Lu 7d4d970973 Don't convert R_386_GOT32 relocation
Don't convert R_386_GOT32 since we can't tell if it is applied
to "mov $foo@GOT, %reg" which isn't a load via GOT.

bfd/

	PR ld/20117
	* elf32-i386.c (elf_i386_convert_load_reloc): Don't check
	R_386_GOT32X.
	(elf_i386_convert_load): Don't convert R_386_GOT32.

ld/

	PR ld/20117
	* testsuite/ld-i386/i386.exp: Run pr20117.
	* testsuite/ld-i386/pr19609-1i.d: Updated.
	* testsuite/ld-i386/pr20117.d: New file.
	* testsuite/ld-i386/pr20117.s: Likewise.
2016-05-19 12:57:11 -07:00
Alan Modra 606851fbf6 Set sh_entsize for .init_array and similar.
PR gas/20118
	* elf.c (elf_fake_sections): Set sh_entsize for SHT_INIT_ARRAY,
	SHT_FINI_ARRAY, and SHT_PREINIT_ARRAY.
2016-05-20 00:35:24 +09:30
Claudiu Zissulescu 3c8adacaf9 [ARC] BFD fixes.
2016-05-19  Cupertino Miranda  <cmiranda@synopsys.com>

	* elf32-arc.c (arc_elf_final_write_processing): Changed.
	(debug_arc_reloc): Likewise.
	(elf_arc_relocate_section): Likewise.
	(elf_arc_check_relocs): Likewise.
	(elf_arc_adjust_dynamic_symbol): Likewise.
	(elf_arc_add_symbol_hook): Likewise.
2016-05-19 15:06:49 +02:00
Maciej W. Rozycki 6b200de0f7 Remove unsupported `am34-*-linux*' target triplet
The `am34-*-linux*' target cannot be configured for, `am34' is not a CPU
name recognized by `config.sub'.  It has never been, required code has
not been contributed to GNU config, neither before nor since the
addition of the target triplet to our configury with commit bfff164249
("Add MN10300 linker relaxation support for symbol differences") back in
2007.  Also there is no difference in actual tool configuration between
the `am34-*-linux*' and `am33_2.0-*-linux*' targets, except from a
different executable prefix and tooldir name.

Given the above remove the target triplet from our configuration.

	bfd/
	* config.bfd: Remove `am34-*-linux*' support.

	ld/
	* configure.tgt: Remove `am34-*-linux*' support.
2016-05-19 11:13:10 +01:00
Alan Modra 57e7d11848 Allocate ppc64 got and dynrelocs before plt
The idea being to make undefined weak syms dynamic, before deciding
whether a sym needs a plt entry.  Fixes pr19719 ld testcase.

	* elf64-ppc.c (allocate_dynrelocs): Allocate got and other dynamic
	relocs before plt relocs.
2016-05-19 14:06:56 +09:30
Alan Modra 9f284bf9da Fix ppc64le S-record test fail
Segfaults on --defsym symbol (__stack_chk_fail in this instance).

	* elf64-ppc.c (ppc64_elf_branch_reloc): Check for NULL owner
	before dereferencing.
2016-05-19 13:40:12 +09:30
Nick Clifton 5049806017 Updated Swedish translations for bfd and binutils 2016-05-18 12:44:43 +01:00
Alan Modra 7f9919700d elf32-arm.c build breakage
* elf32-arm.c (elf32_arm_size_stubs): Free or cache local syms
	for each BFD.  Don't goto error_ret_free_local from outside loop.
2016-05-18 15:46:34 +09:30
Maciej W. Rozycki a43942db49 LD/ELF: Unify STB_GNU_UNIQUE handling
Take STB_GNU_UNIQUE handling scattered across targets and gather it in
the generic ELF linker.  Update test suite infrastructure accordingly.

	bfd/
	* elf-s390-common.c (elf_s390_add_symbol_hook): Remove
	STB_GNU_UNIQUE handling.
	* elf32-arc.c (elf_arc_add_symbol_hook): Likewise.
	* elf32-arm.c (elf32_arm_add_symbol_hook): Likewise.
	* elf32-m68k.c (elf_m68k_add_symbol_hook): Likewise.
	* elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
	* elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise.
	* elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise.
	* elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise.
	* elf64-x86-64.c (elf_x86_64_add_symbol_hook): Likewise.
	* elfxx-aarch64.c (_bfd_aarch64_elf_add_symbol_hook): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_add_symbol_hook): Likewise.
	* elf32-i386.c (elf_i386_add_symbol_hook): Remove function.
	(elf_backend_add_symbol_hook): Remove macro.
	* elflink.c (elf_link_add_object_symbols): Set `has_gnu_symbols'
	for STB_GNU_UNIQUE symbols.

	binutils/
	* testsuite/lib/binutils-common.exp (supports_gnu_unique): New
	procedure.
	* testsuite/binutils-all/objcopy.exp: Use `supports_gnu_unique'
	with the `strip-10' test.

	ld/
	* testsuite/ld-unique/unique.exp: Use `is_elf_format' and
	`supports_gnu_unique' to qualify testing.
2016-05-17 12:21:40 +01:00
Maciej W. Rozycki 71de341392 V850/BFD: Call `_bfd_elf_copy_private_bfd_data' again
Correct a regression introduced with commit 685080f210 ("Adds support
for generating notes in V850 binaries.") which replaced rather than
extending the call to `_bfd_elf_copy_private_bfd_data' with
`v850_elf_copy_private_bfd_data'.  Consequently ELFOSABI_GNU marking is
not propagated to output by `objcopy' from objects containing
STB_GNU_UNIQUE symbols.

	bfd/
	* elf32-v850.c (v850_elf_copy_notes): New function, factored out
	from...
	(v850_elf_copy_private_bfd_data): ... here.  Call the new
	function and `_bfd_elf_copy_private_bfd_data'.

	binutils/
	* testsuite/binutils-all/objcopy.exp: Don't skip the `strip-10'
	test for the V850.
2016-05-16 13:31:20 +01:00
H.J. Lu 2168b2688a Don't convert GOTPCREL relocation against large section
bfd/

	PR ld/20093
	* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Don't convert
	GOTPCREL relocation against large section.

ld/

	PR ld/20093
	* testsuite/ld-x86-64/pr20093-1.d: New file.
	* testsuite/ld-x86-64/pr20093-1.s: Likewise.
	* testsuite/ld-x86-64/pr20093-2.d: Likewise.
	* testsuite/ld-x86-64/pr20093-2.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr20093-1 and pr20093-2.
2016-05-13 11:07:02 -07:00
Alan Modra 4ade44b727 Set dynamic tag VMA and size from dynamic section when possible
Rather than searching the output for a specific named section, it's
better, where possible, to use a linker created dynamic section to set
a dynamic tag's value.  That way ld doesn't depend on the output
section name, making it possibile to map dynamic sections differently.

bfd/
	* elf-m10300.c (_bfd_mn10300_elf_finish_dynamic_sections): Use
	linker dynamic sections in calculating size and address of
	* dynamic tags rather than using output sections.  Remove asserts.
	* elf32-arm.c (elf32_arm_finish_dynamic_sections): Likewise.
	* elf32-cr16.c (_bfd_cr16_elf_finish_dynamic_sections): Likewise.
	* elf32-cris.c (elf_cris_finish_dynamic_sections): Likewise.
	* elf32-i370.c (i370_elf_finish_dynamic_sections): Likewise.
	* elf32-lm32.c (lm32_elf_finish_dynamic_sections): Likewise.
	* elf32-m32r.c (m32r_elf_finish_dynamic_sections): Likewise.
	* elf32-m68k.c (elf_m68k_finish_dynamic_sections): Likewise.
	* elf32-metag.c (elf_metag_finish_dynamic_sections): Likewise.
	* elf32-microblaze.c (microblaze_elf_finish_dynamic_sections): Likewise.
	* elf32-nds32.c (nds32_elf_finish_dynamic_sections): Likewise.
	* elf32-nios2.c (nios2_elf32_finish_dynamic_sections): Likewise.
	* elf32-or1k.c (or1k_elf_finish_dynamic_sections): Likewise.
	* elf32-s390.c (elf_s390_finish_dynamic_sections): Likewise.
	* elf32-score.c (s3_bfd_score_elf_finish_dynamic_sections): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_finish_dynamic_sections): Likewise.
	* elf32-vax.c (elf_vax_finish_dynamic_sections): Likewise.
	* elf32-xtensa.c (elf_xtensa_finish_dynamic_sections): Likewise.
	* elf64-alpha.c (elf64_alpha_finish_dynamic_sections): Likewise.
	* elf64-s390.c (elf_s390_finish_dynamic_sections): Likewise.
	* elf64-sh64.c (sh64_elf64_finish_dynamic_sections): Likewise.
	* elflink.c (bfd_elf_final_link): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Likewise.
	* elfxx-sparc.c (sparc_finish_dyn): Likewise.  Adjust error message.
	* elf32-arc.c (GET_SYMBOL_OR_SECTION): Remove ASSERT arg and
	don't set doit.  Look up dynobj section.
	(elf_arc_finish_dynamic_sections): Adjust GET_SYMBOL_OR_SECTION
	invocation and dynamic tag vma calculation.  Don't test
	boolean var == TRUE.
	* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_sections): Fix
	DT_JMPREL calc.
ld/
	* testsuite/ld-arm/arm-elf.exp: Adjust for arm-no-rel-plt now passing.
	Use different output file name for static app without .rel.plt.
	* testsuite/ld-arm/arm-no-rel-plt.ld: Align .rel.dyn and .rela.dyn.
	* testsuite/ld-arm/arm-no-rel-plt.out: Delete.
	* testsuite/ld-arm/arm-no-rel-plt.r: New.
	* testsuite/ld-arm/arm-static-app.d: Don't check file name.
	* testsuite/ld-arm/arm-static-app.r: Likewise.
2016-05-13 14:34:45 +09:30
Alan Modra c8e44c6d16 ld -z combreloc elf_link_sort_relocs
A linker script may put .rela.plt in with other .rela.dyn relocs.
The change to elf_reloc_type_class puts any PLT relocs last.  This
patch makes the input section layout better match the sorted relocs.

	* elflink.c (elf_link_sort_relocs): Wrap overlong lines.  Fix
	octets_per_byte.  Put dynamic .rela.plt last in link orders.
	Assign output_offset for reloc sections rather than writing
	sorted relocs from block corresponding to output_offset.
2016-05-13 14:34:45 +09:30
Alan Modra 1997c9943a ld -z combreloc reloc sorting
PLT relocs don't appear in .rela.dyn, at least not when using
normal linker scripts.  However, if they do, then they ought to be
placed last rather than in the middle of other relocs.

	* elf-bfd.h (elf_reloc_type_class): Put reloc_class_plt last.
2016-05-13 00:17:19 +09:30
Matthew Fortune 8f4f9071ad Add MIPS32 DSPr3 support.
bfd/

	* elfxx-mips.c (print_mips_ases): Add DSPR3.

binutils/

	* readelf.c (print_mips_ases): Add DSPR3.

gas/

	* config/tc-mips.c (options): Add OPTION_DSPR3 and
	OPTION_NO_DSPR3.
	(md_longopts): Likewise.
	(md_show_usage): Add help for -mdspr3 and -mno-dspr3.
	(mips_ases): Define availability for DSPr3.
	(mips_ase_groups): Add ASE_DSPR3 to the DSP group.
	(mips_convert_ase_flags): Map ASE_DSPR3 to AFL_ASE_DSPR3.
	* doc/as.texinfo: Document -mdspr3, -mno-dspr3.  Fix -mdspr2
	formatting.
	* doc/c-mips.texi: Document -mdspr3, -mno-dspr3, .set dspr3 and
	.set nodspr3.  Fix -mdspr2 formatting.
	* testsuite/gas/mips/mips32-dspr3.d: New file.
	* testsuite/gas/mips/mips32-dspr3.s: Likewise.
	* testsuite/gas/mips/mips.exp: Run mips32-dspr3 test.

include/

	* elf/mips.h (AFL_ASE_DSPR3): New macro.
	(AFL_ASE_MASK): Update to include AFL_ASE_DSPR3.
	* opcode/mips.h (ASE_DSPR3): New macro.

opcodes/

	* mips-dis.c (mips_arch_choices): Add ASE_DSPR3 to mips32r6 and
	mips64r6.
	* mips-opc.c (D34): New macro.
	(mips_builtin_opcodes): Define bposge32c for DSPr3.
2016-05-11 17:06:13 +01:00
Alan Modra a464198b01 [HPPA] Attach linker created dynamic sections to stub bfd
bfd/
	* elf32-hppa.c (elf32_hppa_init_stub_bfd): New function.
	(elf32_hppa_check_relocs): Don't set dynobj.
	(elf32_hppa_size_stubs): Test !SEC_LINKER_CREATED for stub sections.
	(elf32_hppa_build_stubs): Likewise.
	* elf32-hppa.h (elf32_hppa_init_stub_bfd): Declare.
ld/
	* emultempl/hppaelf.em (hppaelf_create_output_section_statements):
	Call elf32_hppa_init_stub_bfd.
2016-05-11 22:51:14 +09:30
Alan Modra 3bd43ebcb6 ld --gc-sections fail with __tls_get_addr_opt
When --gc-sections is active, __tls_get_addr_opt is marked as not
needed and forced local before ppc*_elf_tls_setup is run.

bfd/
	PR 20060
	* elf64-ppc.c (ppc64_elf_tls_setup): Clear forced_local.
	* elf32-ppc.c (ppc_elf_tls_setup): Likewise.
ld/
	PR 20060
	* testsuite/ld-powerpc/powerpc.exp: Run new tests.
	* testsuite/ld-powerpc/tlsdll.s: New.
	* testsuite/ld-powerpc/tlsdll.ver: New.
	* testsuite/ld-powerpc/tlsdll_32.s: New.
	* testsuite/ld-powerpc/tlsopt5.d: New.
	* testsuite/ld-powerpc/tlsopt5.s: New.
	* testsuite/ld-powerpc/tlsopt5_32.d: New.
	* testsuite/ld-powerpc/tlsopt5_32.s: New.
2016-05-11 22:40:09 +09:30
Jiong Wang 4e7fbb34f0 [AArch64] Remove redundant tls relax in elfNN_aarch64_final_link_relocate
bfd/
  * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Remove redundant
  aarch64_tls_transition check.
2016-05-11 11:55:02 +01:00
Thomas Preud'homme 4f4faa4d43 Allow veneers to claim veneered symbols
2016-05-10  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* elf32-arm.c (enum elf32_arm_stub_type): New max_stub_type
	enumerator.
	(arm_stub_sym_claimed): New function.
	(elf32_arm_create_stub): Use veneered symbol name and section if
	veneer needs to claim its symbol, and keep logic unchanged otherwise.
	(arm_stub_claim_sym): New function.
	(arm_map_one_stub): Call arm_stub_claim_sym if veneer needs to claim
	veneered symbol, otherwise create local symbol as before.
2016-05-10 16:20:19 +01:00
Thomas Preud'homme 39d911fc3c Use getters/setters to access ARM branch type
2016-05-10  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* elf32-arm.c (elf32_arm_size_stubs): Use new macros
	ARM_GET_SYM_BRANCH_TYPE and ARM_SET_SYM_BRANCH_TYPE to respectively get
	and set branch type of a symbol.
	(bfd_elf32_arm_process_before_allocation): Likewise.
	(elf32_arm_relocate_section): Likewise and fix identation along the
	way.
	(allocate_dynrelocs_for_symbol): Likewise.
	(elf32_arm_finish_dynamic_symbol): Likewise.
	(elf32_arm_swap_symbol_in): Likewise.
	(elf32_arm_swap_symbol_out): Likewise.

gas/
	* config/tc-arm.c (arm_adjust_symtab): Use ARM_SET_SYM_BRANCH_TYPE to
	set branch type of a symbol.

gdb/
	* arm-tdep.c (arm_elf_make_msymbol_special): Use
	ARM_GET_SYM_BRANCH_TYPE to get branch type of a symbol.

include/
	* arm.h (enum arm_st_branch_type): Add new ST_BRANCH_ENUM_SIZE
	enumerator.
	(NUM_ENUM_ARM_ST_BRANCH_TYPE_BITS): New macro.
	(ENUM_ARM_ST_BRANCH_TYPE_BITMASK): Likewise.
	(ARM_SYM_BRANCH_TYPE): Replace by ...
	(ARM_GET_SYM_BRANCH_TYPE): This and ...
	(ARM_SET_SYM_BRANCH_TYPE): This in two versions depending on whether
	BFD_ASSERT is defined or not.

ld/
	* emultempl/armelf.em (gld${EMULATION_NAME}_finish): Use
	ARM_GET_SYM_BRANCH_TYPE to get branch type of a symbol.

opcodes/
	* arm-dis.c (get_sym_code_type): Use ARM_GET_SYM_BRANCH_TYPE to get
	branch type of a symbol.
	(print_insn): Likewise.
2016-05-10 16:17:04 +01:00
Thomas Preud'homme 6bde4c52fb Allow stubs without associated input section in ARM backend
2016-05-10  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* bfd-in.h (elf32_arm_size_stubs): Add an output section parameter.
	* bfd-in2.h: Regenerated.
	* elf32-arm.c (struct elf32_arm_link_hash_table): Add an output section
	parameter to add_stub_section callback.
	(elf32_arm_create_or_find_stub_sec): Get output section from link_sec
	and pass it down to add_stub_section.
	(elf32_arm_add_stub): Set section to stub_sec if NULL before using it
	for error message.
	(elf32_arm_size_stubs): Add output section parameter to
	add_stub_section function pointer parameter.

ld/
	* emultempl/armelf.em (elf32_arm_add_stub_section): Add output_section
	parameter and rename input_section parameter to after_input_section.
	Append input stub section to the output section if after_input_section
	is NULL.
2016-05-10 15:45:01 +01:00
Thomas Preud'homme b715f643ef Factor our stub creation in ARM backend
2016-05-10  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* elf32-arm.c (elf32_arm_create_stub): New function.
	(elf32_arm_size_stubs): Use elf32_arm_create_stub for stub creation.
2016-05-10 15:42:20 +01:00
Thomas Preud'homme 8d9d949014 Refactor Cortex-A8 erratum workaround in preparation
2016-05-10  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* elf32-arm.c (enum elf32_arm_stub_type): Delete
	arm_stub_a8_veneer_lwm enumerator.
	(arm_stub_a8_veneer_lwm): New unsigned constant to replace
	aforementioned enumerator.
	(struct elf32_arm_stub_hash_entry): Delete target_addend
	field and add source_value.
	(struct a8_erratum_fix): Delete addend field and add target_offset.
	(stub_hash_newfunc): Initialize source_value field amd remove
	initialization for target_addend.
	(arm_build_one_stub): Stop special casing Thumb relocations: promote
	the else to being always executed, moving the
	arm_stub_a8_veneer_b_cond specific code in it.  Remove
	stub_entry->target_addend from points_to computation.
	(cortex_a8_erratum_scan): Store in a8_erratum_fix structure the offset
	to target symbol from start of section rather than the offset from the
	stub address.
	(elf32_arm_size_stubs): Set stub_entry's source_value and target_value
	fields from struct a8_erratum_fix's offset and target_offset
	respectively.
	(make_branch_to_a8_stub): Rename target variable to loc.  Compute
	veneered_insn_loc and loc using stub_entry's source_value.
2016-05-10 15:28:10 +01:00
Thomas Preud'homme 15afaa63f3 Add support for ARMv8-M Mainline with DSP extension
2016-05-10  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	(elf32_arm_merge_eabi_attributes): Add merging logic for
	Tag_DSP_extension.

binutils/
	* readelf.c (display_arm_attribute): Add output for Tag_DSP_extension.
	(arm_attr_public_tags): Define DSP_extension attribute.

gas/
	* NEWS: Document ARMv8-M and ARMv8-M Security and DSP Extensions.
	* config/tc-arm.c (arm_ext_dsp): New feature for Thumb DSP
	instructions.
	(arm_extensions): Add dsp extension for ARMv8-M Mainline.
	(aeabi_set_public_attributes): Memorize the feature bits of the
	architecture selected for Tag_CPU_arch.  Use it to set
	Tag_DSP_extension to 1 for ARMv8-M Mainline with DSP extension.
	(arm_convert_symbolic_attribute): Define Tag_DSP_extension.
	* testsuite/gas/arm/arch7em-bad.d: Rename to ...
	* testsuite/gas/arm/arch7em-bad-1.d: This.
	* testsuite/gas/arm/arch7em-bad-2.d: New file.
	* testsuite/gas/arm/arch7em-bad-3.d: Likewise.
	* testsuite/gas/arm/archv8m-main-dsp-1.d: Likewise.
	* testsuite/gas/arm/archv8m-main-dsp-2.d: Likewise.
	* testsuite/gas/arm/archv8m-main-dsp-3.d: Likewise.
	* testsuite/gas/arm/archv8m-main-dsp-4.d: Likewise.
	* testsuite/gas/arm/archv8m-main-dsp-5.d: Likewise.
	* testsuite/gas/arm/attr-march-armv8m.main.dsp.d: Likewise.

include/
	* elf/arm.h (Tag_DSP_extension): Define.

ld/
	* testsuite/ld-arm/arm-elf.exp (EABI attribute merging 10 (DSP)): New
	test.
	* testsuite/ld-arm/attr-merge-10b-dsp.s: New file.
	* testsuite/ld-arm/attr-merge-10-dsp.attr: Likewise.
2016-05-10 15:24:10 +01:00
Pip Cet 66a368220c PR 20059 _bfd_elf_copy_link_hash_symbol_type segfault
PR ld/20059
	* elfxx-target.h (bfd_elfNN_bfd_copy_link_hash_symbol_type):
	Define as _bfd_generic_copy_link_hash_symbol_type when using
	generic hash table.
2016-05-10 11:04:55 +09:30
Nick Clifton 315350be65 Fix seg fault objdumping a corrupt binary with an invalid sh_link field.
PR binutils/20063
	* elf.c (bfd_elf_get_elf_syms): Check for out of range sh_link
	field before accessing sections array.

	* readelf.c (get_32bit_section_headers): Warn if an out of range
	sh_link or sh_info field is encountered.
	(get_64bit_section_headers): Likewise.
2016-05-09 17:31:07 +01:00
Christophe Monat 9239bbd3a6 [ARM/STM32L4XX] PR 20030: --fix-stm32l4xx-629360 fails to create vldm/vpop veneers for double-precision registers
bfd/
	PR ld/20030
	* elf32-arm.c (is_thumb2_vldm): Account for T1 (DP) encoding.
	(stm32l4xx_need_create_replacing_stub): Rename ambiguous nb_regs
	to nb_words.
	(create_instruction_vldmia): Add is_dp to disambiguate SP/DP
	encoding.
	(create_instruction_vldmdb): Likewise.
	(stm32l4xx_create_replacing_stub_vldm): is_dp detects DP encoding,
	uses it to re-encode.

ld/
	PR ld/20030
	* testsuite/ld-arm/arm-elf.exp: Run new stm32l4xx-fix-vldm-dp
	tests. Fix misnamed stm32l4xx-fix-all.
	* testsuite/ld-arm/stm32l4xx-fix-vldm-dp.s: New tests for multiple
	loads with DP registers.
	* testsuite/ld-arm/stm32l4xx-fix-vldm-dp.d: New reference file.
	* testsuite/ld-arm/stm32l4xx-fix-vldm.s: Add missing comment.
	* testsuite/ld-arm/stm32l4xx-fix-all.s: Add tests for multiple
	loads with DP registers.
	* testsuite/ld-arm/stm32l4xx-fix-all.d: Update reference.
2016-05-09 15:10:37 +02:00
Nick Clifton 73597c183c Revert accidental commit.
PR 19938
	* elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Revert accidental
	commit.
2016-05-09 12:07:32 +01:00
Alan Modra ae1bb19726 Redundant hash table check
* elf64-ppc.c (ppc64_elf_init_stub_bfd): Remove redundant NULL check.
2016-05-09 17:08:35 +09:30
H.J. Lu 97196564c7 Strip global symbol defined in discarded section
When a global symbol is defined in COMDAT group, we shouldn't leave an
undefined symbol in symbol table when the symbol section is discarded
unless there is a reference to the symbol outside of COMDAT group.

bfd/

	PR ld/17550
	* elf-bfd.h (elf_link_hash_entry): Update comments for indx,
	documenting that indx == -3 if symbol is defined in a discarded
	section.
	* elflink.c (elf_link_add_object_symbols): Set indx to -3 if
	symbol is defined in a discarded section.
	(elf_link_output_extsym): Strip a global symbol defined in a
	discarded section.

ld/

	PR ld/17550
	* testsuite/ld-elf/pr17550-1.s: New file.
	* testsuite/ld-elf/pr17550-2.s: Likewise.
	* testsuite/ld-elf/pr17550-3.s: Likewise.
	* testsuite/ld-elf/pr17550-4.s: Likewise.
	* testsuite/ld-elf/pr17550a.d: Likewise.
	* testsuite/ld-elf/pr17550b.d: Likewise.
	* testsuite/ld-elf/pr17550c.d: Likewise.
	* testsuite/ld-elf/pr17550d.d: Likewise.
2016-05-06 09:46:50 -07:00
H.J. Lu 030e823caf Define elf_backend_add_symbol_hook for Intel MCU
elf_backend_add_symbol_hook is undefined for FreeBSD.  Define it for
Intel MCU to support STB_GNU_UNIQUE for Intel MCU and NaCl.

	* elf32-i386.c (elf_backend_add_symbol_hook): Defined for Intel
	MCU.
2016-05-06 08:28:27 -07:00
H.J. Lu c175a65796 Extract convert_load_reloc from x86 convert_load
* elf32-i386.c (elf_i386_convert_load): Extract the GOT load
	conversion to ...
	(elf_i386_convert_load_reloc): This.  New function.
	* elf64-x86-64.c (elf_x86_64_convert_load): Extract the GOT load
	conversion to ...
	(elf_x86_64_convert_load_reloc): This.  New function.
2016-05-05 04:14:00 -07:00
H.J. Lu bedfd056d4 Cache the section contents in x86 check_relocs
Cache the section contents in x86 check_relocs for sections without
TLS relocations.

	* elf32-i386.c (elf_i386_check_tls_transition): Remove abfd.
	Don't check if contents == NULL.
	(elf_i386_tls_transition): Add from_relocate_section.  Check
	from_relocate_section instead of contents != NULL.  Update
	elf_i386_check_tls_transition call.
	(elf_i386_check_relocs): Cache the section contents if
	keep_memory is FALSE.  Pass FALSE as from_relocate_section to
	elf_i386_tls_transition.
	(elf_i386_relocate_section): Pass TRUE as from_relocate_section
	to elf_i386_tls_transition.
	(elf_backend_caches_rawsize): New.
	* elf64-x86-64.c (elf_x86_64_check_tls_transition): Don't check
	if contents == NULL.
	(elf_x86_64_tls_transition): Add from_relocate_section.  Check
	from_relocate_section instead of contents != NULL.
	(elf_x86_64_check_relocs): Cache the section contents if
	keep_memory is FALSE.  Pass FALSE as from_relocate_section to
	elf_x86_64_tls_transition.
	(elf_x86_64_relocate_section): Pass TRUE as from_relocate_section
	to elf_x86_64_tls_transition.
	(elf_backend_caches_rawsize): New.
2016-05-05 04:12:16 -07:00
Maciej W. Rozycki 6d6a648c07 PR 10549: MIPS/LD: Handle OSABI setting for STB_GNU_UNIQUE
Add missing OSABI handling for MIPS/LD, complementing:

commit f64b2e8d60
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Apr 11 08:13:22 2011 +0000

Adjust test coverage accordingly.

	bfd/
	PR 10549
	* elfxx-mips.c (_bfd_mips_elf_add_symbol_hook): Handle
	STB_GNU_UNIQUE.

	ld/
	PR 10549
	* testsuite/ld-unique/unique.exp: Also run for `mips*-*-*'.
2016-05-03 23:51:33 +01:00
Jiong Wang 1f56df9d0d [AArch64] Also puts value in place for R_AARCH64_RELATIVE
When handling absolute relocations for global symbols bind within the
shared object, AArch64 will generate one dynamic RELATIVE relocation,
but won't apply the value for this absolution relocations at static
linking stage. This is different from AArch64 gold linker and x86-64.

This is not a bug as AArch64 is RELA, there is only guarantee that
relocation addend is placed in the relocation entry.  But some
system softwares originally writen for x86-64 might assume AArch64
bfd linker gets the same behavior as x86-64, then they could take
advantage of this buy skipping those RELATIVE dynamic relocations
if the load address is the same as the static linking address.

This patch makes AArch64 BFD linker applies absolution relocations at
static linking stage for scenario described above.  Meanwhile old AArch64
android loader has a bug (PR19163) which relies on current linker behavior
as a workaround, so the same option --no-apply-dynamic-relocs added.
2016-05-03 11:59:37 +01:00
H.J. Lu 493f652c95 Set interpreter in x86 create_dynamic_sections
Set interpreter in x86 create_dynamic_sections to make this information
available to x86 check_relocs.

	* elf32-i386.c (elf_i386_size_dynamic_sections): Move interp
	setting to ...
	(elf_i386_create_dynamic_sections): Here.
	* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Move
	interp setting to ...
	(elf_x86_64_create_dynamic_sections): Here.
2016-04-29 08:27:29 -07:00
H.J. Lu e62b9723fd Pass GOT_RELOC to UNDEFINED_WEAK_RESOLVED_TO_ZERO
When UNDEFINED_WEAK_RESOLVED_TO_ZERO is checked to convert load via
GOT, has_got_reloc is always TRUE.  This patch adds GOT_RELOC, which
is TRUE in x86 convert_load, to UNDEFINED_WEAK_RESOLVED_TO_ZERO.

	* elf32-i386.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Take GOT_RELOC
	and replace (EH)->has_got_reloc with GOT_RELOC.
	(elf_i386_fixup_symbol): Pass has_got_reloc to
	UNDEFINED_WEAK_RESOLVED_TO_ZERO.
	(elf_i386_allocate_dynrelocs): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_finish_dynamic_symbol): Likewise.
	(elf_i386_convert_load): Pass TRUE to
	UNDEFINED_WEAK_RESOLVED_TO_ZERO.
	* elf64-x86-64.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Take
	GOT_RELOC and replace (EH)->has_got_reloc with GOT_RELOC.
	(elf_x86_64_fixup_symbol): Pass has_got_reloc to
	UNDEFINED_WEAK_RESOLVED_TO_ZERO.
	(elf_x86_64_allocate_dynrelocs): Likewise.
	(elf_x86_64_relocate_section): Likewise.
	(elf_x86_64_finish_dynamic_symbol): Likewise.
	(elf_x86_64_convert_load): Pass TRUE to
	UNDEFINED_WEAK_RESOLVED_TO_ZERO.
2016-04-29 08:21:51 -07:00
H.J. Lu c337a1627c i386: Don't relocate section when check_relocs failed
No need to relocate section when check_relocs failed.

	* elf32-i386.c (check_relocs_failed): New.
	(elf_i386_check_relocs): Set check_relocs_failed on error.
	(elf_i386_relocate_section): Skip if check_relocs failed.
2016-04-29 04:31:54 -07:00
H.J. Lu afd9acee15 X86-64: Set check_relocs_failed on error
When checking relocations, set check_relocs_failed on error.

	* elf64-x86-64.c (elf_x86_64_check_relocs): Set
	check_relocs_failed on error.
2016-04-29 04:29:38 -07:00
Nick Clifton 5522f910cb Enhance support for copying and stripping Solaris and ARM binaries.
PR 19938
bfd	* elf-bfd.h (struct elf_backend_data): Rename
	elf_backend_set_special_section_info_and_link to
	elf_backend_copy_special_section_fields.
	* elfxx-target.h: Likewise.
	* elf.c (section_match): Ignore the SHF_INFO_LINK flag when
	comparing section flags.
	(copy_special_section_fields): New function.
	(_bfd_elf_copy_private_bfd_data): Copy the EI_ABIVERSION field.
	Perform two scans over special sections.  The first one looks for
	a direct mapping between the output section and an input section.
	The second scan looks for a possible match based upon section
	characteristics.
	* elf32-arm.c (elf32_arm_copy_special_section_fields): New
	function.  Handle setting the sh_link field of SHT_ARM_EXIDX
	sections.
	* elf32-i386.c (elf32_i386_set_special_info_link): Rename to
	elf32_i386_copy_solaris_special_section_fields.
	* elf32-sparc.c (elf32_sparc_set_special_section_info_link):
	Rename to elf32_sparc_copy_solaris_special_section_fields.
	* elf64-x86-64.c (elf64_x86_64_set_special_info_link): Rename to
	elf64_x86_64_copy_solaris_special_section_fields.

binutils* readelf.c (get_solaris_segment_type): New function.
	(get_segment_type): Call it.
2016-04-29 09:24:42 +01:00
Nick Clifton 786a118cdf Updated Chinese (simplified) translations for bfd, binutils and gold. 2016-04-28 14:09:49 +01:00
H.J. Lu 91f8bf69a5 Skip debug sections when estimating distances
Skip debug sections when estimating distances between output sections
since compressed_size is used to compress debug sections and debug
sections aren't excluded from distances between output sections.

bfd/

	PR ld/20006
	* elf64-x86-64.c (elf_x86_64_convert_load): Skip debug sections
	when estimating distances between output sections.

ld/

	PR ld/20006
	* testsuite/ld-elfvsb/elfvsb.exp (COMPRESS_LDFLAG): New.
	(visibility_run): Pass COMPRESS_LDFLAG to visibility_test on
	ELF targets.
2016-04-27 09:13:10 -07:00
Alan Modra a6a4679fc0 Cache result of scan for __start_* and __stop_* sections
include/
	* bfdlink.h (struct bfd_link_hash_entry): Add "section" field to
	undef.  Formatting.
bfd/
	* elflink.c (_bfd_elf_is_start_stop): New function.
	(_bfd_elf_gc_mark_rsec): Use it.
	* elf-bfd.h (_bfd_elf_is_start_stop): Declare.
2016-04-27 17:05:26 +09:30
Trevor Saunders 28cc9170c3 add casts to avoid arithmetic on void *
arithmetic on void * is undefined in ISO C, so we should avoid it.  In
GNU C sizeof void * is defined as 1, and that is pretty clearly what
this code wants, so change it to do arithmetic on bfd_byte *.
Unfortunately most of the argument types come from virtual function
interfaces so changing the types to bfd_byte * isn't trivial though it
might make the code clearer.  So for the moment its easiest to leave the
variable types as void * and cast before doing arithmetic.

bfd/ChangeLog:

2016-04-26  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* elf32-rx.c (rx_set_section_contents): Avoid arithmetic on void *.
	* mmo.c (mmo_get_section_contents): Likewise.
	(mmo_set_section_contents): Likewise.
2016-04-26 20:09:57 -04:00