Commit Graph

7079 Commits

Author SHA1 Message Date
Jiong Wang 9a22846790 [AArch64] Remove redundant calculation of plt stub destination for veneer
elfNN_aarch64_size_stubs, the caller of aarch64_type_stub has redirected
the final destination of long branch veneer to plt stub if the call
should go through it.

It's redundant to do the same check and redirect again from scratch
inside aarch64_type_stub.

bfd/
  * elfnn-aarch64. (aarch64_type_of_stub): Remove redundation calcuation
  for destination.  Remove useless function parameters.
  (elfNN_aarch64_size_stubs): Update parameters for aarch64_type_of_stub.
2016-02-22 12:16:06 +00:00
Nick Clifton e517df3dbf Prevent a seg-fault in the linker when accessing a specially crafted, corrupt, aout binary.
PR ld/19629
	* aoutx.h (aout_link_add_symbols): Check for out of range string
	table offsets.
2016-02-19 15:55:06 +00:00
Nick Clifton 737684142b Fix a seg-fault in the linker when it encounters a corrupt binary containing a reloc with no associated symbol.
PR ld/19628
	* reloc.c (bfd_generic_get_relocated_section_contents): Stop
	processing if we encounter a reloc without an associated symbol.
2016-02-19 15:20:30 +00:00
H.J. Lu bf89386a86 Always create dynamic sections for -E/--dynamic-list
In embedded environments, including boot loaders, the non-PIC executable
needs to export its symbols to modules loaded in the future.  We should
always create dynamic sections for -E/--dynamic-list.

bfd/

	PR ld/19617
	* elflink.c (elf_link_add_object_symbols): Always create dynamic
	sections for -E/--dynamic-list.

ld/

	PR ld/19617
	* testsuite/ld-elf/pr19617.s: New file.
	* testsuite/ld-elf/pr19617a.d: Likewise.
	* testsuite/ld-elf/pr19617b.d: Likewise.
	* testsuite/ld-elf/pr19617c.d: Likewise.
2016-02-18 03:13:51 -08:00
H.J. Lu 8f79b794ce [x86-64] Omit dynamic sections symbols
Define elf_backend_omit_section_dynsym to bfd_true for x86-64, similar
to i386, x86-64 doesn't need dynamic sections symbols.

bfd/

	* elf64-x86-64.c (elf_backend_omit_section_dynsym): New.  Defined
	to bfd_true.

ld/

	* testsuite/ld-ifunc/ifunc-1-local-x86.d: Updated.
	* testsuite/ld-ifunc/ifunc-1-x86.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-3a-x86.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-1.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise.
	* testsuite/ld-x86-64/bnd-plt-1.d: Likewise.
	* testsuite/ld-x86-64/ilp32-4-nacl.d: Likewise.
	* testsuite/ld-x86-64/ilp32-4.d: Likewise.
	* testsuite/ld-x86-64/load1c-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1c.d: Likewise.
	* testsuite/ld-x86-64/load1d-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1d.d: Likewise.
	* testsuite/ld-x86-64/pr14207.d: Likewise.
	* testsuite/ld-x86-64/pr19162.d: Likewise.
	* testsuite/ld-x86-64/tlsdesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsdesc.rd: Likewise.
	* testsuite/ld-x86-64/tlsgdesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsgdesc.rd: Likewise.
	* testsuite/ld-x86-64/tlspic-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlspic.rd: Likewise.
2016-02-17 11:19:04 -08:00
Joseph Myers 64bfc2584c Fix BFD format matching for x86_64-w64-mingw32 -m32 LTO.
In <https://sourceware.org/ml/binutils/2015-12/msg00190.html> (commit
4a07dc8135), Kwok fixed a problem with
the template used for a dummy BFD for an IR file for LTO on MinGW,
where the input and output formats are not the same.

A problem, however, remains in the case of linking for
x86_64-w64-mingw32 -m32, where LTO linking reports an ambiguity
between the pe-i386 and pei-i386 formats.  An object (pe-i386) with
plugin data is being tested by the linker to see what formats match.
The default format initially set by the linker when
bfd_check_format_matches is called is pei-i386 (as that's the output
format from the linker script), which does not match, so the function
goes on to the loop over possible BFD vectors.  The pe-i386 vector
matches, as it should.  One other vector matches: the plugin vector.

bfd_check_format_matches tests a vector for matching by temporarily
modifying the BFD object to use that vector then using
_bfd_check_format on it.  So the BFD object is temporarily using
plugin_vec.  _bfd_check_format ends up using bfd_plugin_object_p which
uses plugin_object_p from ld which uses plugin_get_ir_dummy_bfd which
succeeds, having created a BFD based on link_info.output_bfd (because
srctemplate is the BFD temporarily using plugin_vec, even after Kwok's
patch link_info.output_bfd is all that's available to base the dummy
BFD on).  So we end up with a match from the plugin vector which uses
the pei-i386 vector even though the pei-i386 vector itself does not
match the input object.  (In the i686-mingw32 case, as opposed to this
multilib case, pe-i386 is the default BFD target, which would
short-circuit that logic.)

There are two cases of the linker handling inputs with a plugin: they
may be inputs that are also accepted by some non-plugin BFD format, as
here, or they may be a format that would not be recognized at all, as
with some tests in the ld testsuite.  In the former case, there is no
need for BFD to accept the objects using the plugin vector, as the
linker has its own logic to allow plugins to claim objects accepted by
some other BFD vector.  Thus, this patch arranges for the plugin
vector to have the lowest match priority, and for the priority from
that vector to be used in the relevant case (the attempted match to
the plugin vector results in TEMP pointing to the pei-i386 vector).

Tested for GCC and Binutils testsuites for x86_64-pc-linux-gnu, as
well as verifying that it fixes the observed LTO issue for
x86_64-w64-mingw32.

	* plugin.c (plugin_vec): Set match priority to 255.
	* format.c (bfd_check_format_matches) [BFD_SUPPORTS_PLUGINS]: When
	matching against the plugin vector, take priority from there not
	from TEMP.
2016-02-16 00:27:11 +00:00
Nick Clifton 9fb71ee49f Enhance GAS's .section directive so that it can take numeric values for the flags and type fields. (ELF only)
gas	* doc/as.texinfo (.section): Document that numeric values can now
	be used for the flags and type fields of the ELF target's .section
	directive.  Add notes about the restrictions on setting flags and
	types.
	* config/obj-elf.c (obj_elf_change_section): Allow known sections
	to be given processor specific section types.  Allow processor and
	application specific flags of a section to be set after
	definition.
	(obj_elf_parse_section_letters): Handle parsing numeric values.
	(obj_elf_section_type): Handle parsing numeric values.
	(obj_elf_section): Allow numeric type values.
	* config/obj-elf.h (obj_elf_change_section): Update prototype.
	* testsuite/gas/elf/section10.d: New test.
	* testsuite/gas/elf/section10.s: Source file for new test.
	* testsuite/gas/elf/elf.exp: Run the new test.
	* testsuite/gas/i386/ilp32/x86-64-unwind.d: Remove dependency upon
	the description of the flags produced by readelf.
	* testsuite/gas/tic6x/scomm-directive-4.d: Likewise.
	* NEWS: Mention the new feature.

bfd	* elf-bfd.h (struct bfd_elf_special_section): Use unsigned values
	for length and type fields.  Use a signed value for the
	suffix_length field.

binutils* readelf.c (get_section_type_name): Add hex prefix to offsets
	printed for LOPROC and LOOS values.  Ensure that a result is
	always returned for the V850 target, even when an unrecognised
	processor specific value is encountered.
	(process_section_headers): Display key values in the order in
	which they appear to the user.  Add the "C (compressed)" value to
	the list.

ld	* testsuite/ld-i386/pr12718.d: Remove dependency upon the
	description of the flags produced by readelf.
	* testsuite/ld-i386/pr12921.d: Likewise.
	* testsuite/ld-i386/tlsbin-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsbin.rd: Likewise.
	* testsuite/ld-i386/tlsbindesc-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsbindesc.rd: Likewise.
	* testsuite/ld-i386/tlsdesc-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsdesc.rd: Likewise.
	* testsuite/ld-i386/tlsgdesc-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsgdesc.rd: Likewise.
	* testsuite/ld-i386/tlsnopic-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsnopic.rd: Likewise.
	* testsuite/ld-i386/tlspic-nacl.rd: Likewise.
	* testsuite/ld-i386/tlspic.rd: Likewise.
	* testsuite/ld-s390/tlsbin.rd: Likewise.
	* testsuite/ld-s390/tlsbin_64.rd: Likewise.
	* testsuite/ld-s390/tlspic.rd: Likewise.
	* testsuite/ld-s390/tlspic_64.rd: Likewise.
	* testsuite/ld-sh/tlsbin-2.d: Likewise.
	* testsuite/ld-sh/tlspic-2.d: Likewise.
	* testsuite/ld-tic6x/common.d: Likewise.
	* testsuite/ld-tic6x/shlib-1.rd: Likewise.
	* testsuite/ld-tic6x/shlib-1b.rd: Likewise.
	* testsuite/ld-tic6x/shlib-1r.rd: Likewise.
	* testsuite/ld-tic6x/shlib-1rb.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1b.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1r.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise.
	* testsuite/ld-tic6x/shlib-noindex.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1b.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1r.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1rb.rd: Likewise.
	* testsuite/ld-x86-64/ilp32-4-nacl.d: Likewise.
	* testsuite/ld-x86-64/ilp32-4.d: Likewise.
	* testsuite/ld-x86-64/pr12718.d: Likewise.
	* testsuite/ld-x86-64/pr12921.d: Likewise.
	* testsuite/ld-x86-64/split-by-file-nacl.rd: Likewise.
	* testsuite/ld-x86-64/split-by-file.rd: Likewise.
	* testsuite/ld-x86-64/tlsbin-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsbin.rd: Likewise.
	* testsuite/ld-x86-64/tlsbindesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsbindesc.rd: Likewise.
	* testsuite/ld-x86-64/tlsdesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsdesc.rd: Likewise.
	* testsuite/ld-x86-64/tlsgdesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsgdesc.rd: Likewise.
	* testsuite/ld-x86-64/tlspic-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlspic.rd: Likewise.
	* testsuite/ld-xtensa/tlsbin.rd: Likewise.
	* testsuite/ld-xtensa/tlspic.rd: Likewise.
2016-02-15 11:11:46 +00:00
H.J. Lu 32875eb1f3 Mask off the least significant bit in GOT offset
The least significant bit in GOT offset is to record whether we have
initialized the GOT entry in R_386_GOT32 processing.  We need to mask
it off for R_386_GOT32X.

	PR ld/19601
	* elf32-i386.c (elf_i386_relocate_section): Mask off the least
	significant bit in GOT offset for R_386_GOT32X.
2016-02-10 19:33:52 -08:00
Nick Clifton 83da6e748c Correct assertion in NIOS2 linker to allow signed 16-buit immediate values.
PR 19405
	* elf32-nios2.c (nios2_elf32_install_imm16): Allow for signed
	immediate values.
	* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Limit the
	number of messages about FDE encoding preventing .eh_frame_hdr
	generation.
2016-02-10 11:25:59 +00:00
Nick Clifton 609332f15c Fix compile time warnings building the binutils with a gcc6 compiler.
include	* opcode/metag.h (metag_scondtab): Mark as possibly unused.
	* opcode/nds32.h (nds32_r45map): Likewise.
	(nds32_r54map): Likewise.
	* opcode/visium.h (gen_reg_table): Likewise.
	(fp_reg_table, cc_table, opcode_table): Likewise.

bfd	* oasys.c (oasys_archive_p): Fix indentation.
	* elf32-nds32.c (nds32_elf_relax_section): Use an unsigned
	constant for left shifting.
2016-02-09 16:34:24 +00:00
Nick Clifton 027e9c750c Add a more helpful warning message to explain why some AArch64 relocations can overflow.
bfd	* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Add a more
	helpful warning message to explain why certain AArch64 relocs
	might overflow.

ld	* testsuite/ld-aarch64/reloc-overflow-bad.d: New test.
	* testsuite/ld-aarch64/reloc-overflow-1.s: New source file.
	* testsuite/ld-aarch64/reloc-overflow-2.s: New source file.
	* testsuite/ld-aarch64/aarch64-elf.exp: Run the new test.
2016-02-09 10:47:54 +00:00
Walfred Tedeschi 0635c87593 Revert "Add a more helpful warning message to explain why some AArch64 relocations can overflow."
This reverts commit 2ea53e0031.
2016-02-09 11:36:15 +01:00
Nick Clifton 2ea53e0031 Add a more helpful warning message to explain why some AArch64 relocations can overflow.
bfd	* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Add a more
	helpful warning message to explain why certain AArch64 relocs
	might overflow.

ld	* testsuite/ld-aarch64/reloc-overflow-bad.d: New test.
	* testsuite/ld-aarch64/reloc-overflow-1.s: New source file.
	* testsuite/ld-aarch64/reloc-overflow-2.s: New source file.
	* testsuite/ld-aarch64/aarch64-elf.exp: Run the new test.
2016-02-09 09:56:21 +00:00
Simon Marchi 6f57d0469a Fix formatting of pe-mips.c file.
* pe-mips.c (coff_mips_reloc): Fix formatting.
2016-02-05 10:15:26 +00:00
Cupertino Miranda bdbca4e6f8 Change the default architecture value for ARC bfds so that they have the lowest possible value, and hence can be merged with other ARC binaries wihtout changing their architecture value.
bfd	* cpu-arc.c: Change default archure from bfd_mach_arc_arcv2
	to bfd_mach_arc_arc600.

binutils * testsuite/binutils-all/objdump.exp: Update expected default
	architecture value for ARC binaries.
2016-02-05 09:58:01 +00:00
Alan Modra 4f038ee5d2 Fix "PowerPC64 ELFv2 entry code" for big-endian
bfd/
	* elf64-ppc.c (ppc64_elf_relocate_section): Adjust last patch
	for big-endian.
gold/
	* powerpc.cc (relocate): Adjust last patch for big-endian.
2016-02-04 00:31:14 +10:30
H.J. Lu fb06f1c0f2 Fix typos in bfd/ChangeLog and bfd/elf64-x86-64.c 2016-02-02 13:08:58 -08:00
H.J. Lu 4a539596f5 Store estimated istrances in compressed_size
elf_x86_64_convert_load is very time consuming since it is called on
each input section and has a loop over input text sections to estimate
the branch distrance.  We can store the estimated distrances in the
compressed_size field of the output section, which is only used to
decompress the compressed input section.

Before the patch, linking clang 3.9 takes 52 seconds.  After the patch,
it only takes 2.5 seconds.

	PR ld/19542
	* elf64-x86-64.c (elf_x86_64_convert_load): Store the estimated
	distrances in the compressed_size field of the output section.
2016-02-02 08:20:37 -08:00
Alan Modra 85fabe715c PowerPC64 ELFv2 entry code
This tightens the condition under which ld optimizes PIC entry code
to non-PIC.

bfd/
	* elf64-ppc.c (ppc64_elf_relocate_section): Further restrict
	ELFv2 entry optimization.
gold/
	* powerpc.cc (relocate): Further restrict ELFv2 entry optimization.
2016-02-02 23:59:03 +10:30
H.J. Lu 14f2c699dd Clear HAS_RELOC if there are no relocations
The HAS_RELOC bit should be cleared when relocations are removed from
relocatable files.

bfd/

	PR binutils/19547
	* elf.c (assign_section_numbers): Clear HAS_RELOC if there are
	no relocations in relocatable files.

binutils/

	PR binutils/19547
	* testsuite/binutils-all/objcopy.exp
	(objcopy_test_without_global_symbol): New proc.
	Run objcopy_test_without_global_symbol.
	* testsuite/binutils-all/pr19547.c: New file.
2016-02-02 03:30:48 -08:00
H.J. Lu aef2898990 Don't add DT_NEEDED for unmatched symbol
Don't add DT_NEEDED if a symbol from a library loaded via DT_NEEDED
doesn't match the symbol referenced by regular object.

bfd/

	PR ld/19553
	* elflink.c (elf_link_add_object_symbols): Don't add DT_NEEDED
	if a symbol from a library loaded via DT_NEEDED doesn't match
	the symbol referenced by regular object.

ld/testsuite/

	PR ld/19553
	* testsuite/ld-elf/indirect.exp: Run tests for PR ld/19553.
	* testsuite/ld-elf/pr19553.map: New file.
	* testsuite/ld-elf/pr19553.map: Likewise.
	* testsuite/ld-elf/pr19553a.c: Likewise.
	* testsuite/ld-elf/pr19553b.c: Likewise.
	* testsuite/ld-elf/pr19553b.out: Likewise.
	* testsuite/ld-elf/pr19553c.c: Likewise.
	* testsuite/ld-elf/pr19553c.out: Likewise.
	* testsuite/ld-elf/pr19553d.c: Likewise.
	* testsuite/ld-elf/pr19553d.out: Likewise.
2016-02-01 15:49:52 -08:00
Nathaniel Smith 655ed9ea17 Add support for importing data from ILF images.
* peicode.h (pe_ILF_build_a_bfd): Create an import symbol for both
	CODE and DATA.
2016-02-01 13:44:15 +00:00
Alan Modra ec1f73bb0b x86 synthetic plt symbols
Changing "pushq $1" in the following to "pushq $too_big" results in an
abort.  BFD shouldn't abort on (deliberately) bad user input.

 400480:       ff 25 9a 0b 20 00       jmpq   *0x200b9a(%rip)
 400486:       68 01 00 00 00          pushq  $0x1
 40048b:       e9 d0 ff ff ff          jmpq   400460 <_init+0x20>

	* elf64-x86-64.c (elf_x86_64_get_plt_sym_val): Don't abort on
	an out of range reloc_index.
	* elf32-i386.c (elf_i386_get_plt_sym_val): Likewise.
2016-02-01 21:27:02 +10:30
Kamil Rytarowski b6471e6e2c Fix NetBSD build with BSD and GNU make(1).
* Makefile.am (OPTIONAL_BACKENDS): Add netbsd-core.lo.
	(OPTIONAL_BACKENDS_CFILES): Add netbsd-core.c.
	* Makefile.in: Regenerated.
2016-02-01 10:35:38 +00:00
Jan Kratochvil 0bc7245a3a elf64-s390.c: Fix -Werror=misleading-indentation
../../bfd/elf64-s390.c: In function 'elf_s390_reloc_name_lookup':
../../bfd/elf64-s390.c:340:5: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
     if (strcasecmp (elf64_s390_vtinherit_howto.name, r_name) == 0)
     ^~
../../bfd/elf64-s390.c:333:3: note: ...this 'for' clause, but it is not
   for (i = 0;
   ^~~

bfd/
	* elf64-s390.c (elf_s390_reloc_name_lookup): Fix indentation.
2016-02-01 03:47:47 +01:00
John David Anglin 6d4b2867f8 Fix /usr/bin/ld: final link failed: File truncated error on hppa. 2016-01-31 11:52:24 -05:00
H.J. Lu d9e3b59069 Check reloc against IFUNC symbol only with dynamic symbols
There is no need to check relocation IFUNC symbol if there are no
dynamic symbols.

bfd/

	PR ld/19539
	* elf32-i386.c (elf_i386_reloc_type_class): Check relocation
	against STT_GNU_IFUNC symbol only with dynamic symbols.
	* elf64-x86-64.c (elf_x86_64_reloc_type_class): Likewise.

ld/

	PR ld/19539
	* testsuite/ld-elf/pr19539.d: New file.
	* testsuite/ld-elf/pr19539.s: Likewise.
	* testsuite/ld-elf/pr19539.t: Likewise.
2016-01-30 16:08:20 -08:00
H.J. Lu bf150a0bad Set BFD_DECOMPRESS to decompress debug sections
We should set BFD_DECOMPRESS to decompress debug sections when reading in
DWARF debug sections.

bfd/

	PR binutils/19523
	* dwarf2.c (_bfd_dwarf2_slurp_debug_info): Set BFD_DECOMPRESS to
	decompress debug sections.

binutils/

	PR binutils/19523
	* Makefile.am (check-DEJAGNU): Pass CC and CC_FOR_BUILD to
	runtest.
	* Makefile.in: Regenerated.
	* testsuite/binutils-all/compress.exp (test_gnu_debuglink): New
	proc.
	Run test_gnu_debuglink for native ELF build.
2016-01-28 13:29:53 -08:00
Maciej W. Rozycki 840855c5ed ARC/BFD: Fix a build error from `index' shadowing a global declaration
bfd/
	* elf32-arc.c (elf_arc_finish_dynamic_symbol): Rename `index' to
	`dynindx'.
2016-01-25 16:06:46 +00:00
Nick Clifton cf466c2ac5 Fix memory corruption on Mach-O systems by suppressing a memory tidy up.
PR target/19435
	* mach-o.c (bfd_mach_o_close_and_cleanup): Suppress code to free
	dsym filename buffer.
2016-01-25 09:35:33 +00:00
Maciej W. Rozycki eb6b0cf45d MIPS/BFD: Simplify register index calculation in BZ16_REG_FIELD
Just mask higher bits off, which returns the same set of 3-bit register
encodings of { 0, 1, 2, 3, 4, 5, 6, 7 } for the allowed 5-bit encodings
of { 16, 17, 2, 3, 4, 5, 6, 7 }.  Input has already been validated with
OP16_VALID_REG.

	bfd/
	* elfxx-mips.c (BZ16_REG_FIELD): Simplify calculation.
2016-01-24 01:01:15 +00:00
Maciej W. Rozycki e67f83e590 MIPS/BFD: Correct register index calculation in BZ16_REG
For the 3-bit register encodings of { 0, 1, 2, 3, 4, 5, 6, 7 } return
the 5-bit encodings of { 16, 17, 2, 3, 4, 5, 6, 7 } respectively rather
than { 24, 25, 2, 3, 4, 5, 6, 7 }.

	bfd/
	* elfxx-mips.c (BZ16_REG): Correct calculation.
2016-01-24 01:01:14 +00:00
Nick Clifton 23a4208915 Fix compile time errors building ARC target on a 32-bit host.
* elf32-arc.c (ADD_RELA): Fix compile time warning errors by
	changing the type of _loc to be bfd_byte *.
	(elf_arc_finish_dynamic_symbol): Likewise.
2016-01-21 13:54:11 +00:00
Nick Clifton aebf9be708 Fix unexpected failures in the linker testsuite for ARM VxWorks targets.
PR ld/19455
	* elf32-arm.c (elf32_arm_create_dynamic_sections): Set the ELF
	class of the linker stub bfd.
	(elf32_arm_check_relocs): Skip check for pic format after
	processing a vxWorks R_ARM_ABS12 reloc.
	* elflink.c (bfd_elf_final_link): Check for ELFCLASSNONE when
	reporting a class mismatch.

	* testsuite/ld-arm/vxworks1-lib.dd: Update for current
	disassmebler output.
	* testsuite/ld-arm/vxworks1-lib.rd: Likewise.
	* testsuite/ld-arm/vxworks1.dd: Likewise.
	* testsuite/ld-arm/vxworks1.rd: Likewise.
	* testsuite/ld-arm/vxworks1.ld: Set the output format.
2016-01-21 10:51:25 +00:00
Jiong Wang 2f340668a9 [AArch64] Relax long branch veneer insertion for non STT_FUNC symbol
As defined at AArch64 ELF Specification (4.6.7 Call and Jump
  relocations), symbol with type of non STT_FUNC but in different input
  section with relocation place should insert long branch veneer also.

  Meanwhile the current long branch veneer infrastructure havn't considered
  the situation where the branch destination is "sym_value + rela->addend".

  This was OK because we only insert veneer for long call destination is
  STT_FUNC symbol for which the addend is always zero. But as we relax the
  support to other situations by this patch, we need to handle addend be
  non-zero value. For example, for static function, relocation against
  "local symbol" are turned into relocation against "section symbol + offset"
  where there is a valid addend.

  bfd/
	* elfnn-aarch64.c (aarch64_type_of_stub): Allow insert long branch
	veneer for sym_sec != input_sec.
	(elfNN_aarch64_size_stub): Support STT_SECTION symbol.
	(elfNN_aarch64_final_link_relocate): Take rela addend into account when
	calculation destination.

  ld/
	* testsuite/ld-aarch64/farcall-section.d: Delete.
	* testsuite/ld-aarch64/farcall-section.s: Delete.
	* testsuite/ld-aarch64/farcall-b-section.d: New expectation file.
	* testsuite/ld-aarch64/farcall-bl-section.d: Likewise.
	* testsuite/ld-aarch64/farcall-b-section.s: New testcase.
	* testsuite/ld-aarch64/farcall-bl-section.s: Likewise.
	* testsuite/ld-aarch64/aarch64-elf.exp: Likewise.
2016-01-21 09:57:09 +00:00
Alan Modra aeb7056972 Convert macros in elf-linux-core.h to inline functions
Besides changing some macros into inline functions, this removes
redundant memsets and uses bfd_put_* rather than H_PUT_*.

	* elf-linux-core.h (swap_linux_prpsinfo32_out): New function.
	(swap_linux_prpsinfo64_out): New function.
	(LINUX_PRPSINFO32_SWAP_FIELDS): Delete.
	(LINUX_PRPSINFO64_SWAP_FIELDS): Delete.
	* elf.c (elfcore_write_linux_prpsinfo32): Adjust.  Don't memset.
	(elfcore_write_linux_prpsinfo64): Likewise.
	* elf32-ppc.c (swap_ppc_linux_prpsinfo32_out): New function.
	(PPC_LINUX_PRPSINFO32_SWAP_FIELDS): Delete.
	(elfcore_write_ppc_linux_prpsinfo32): Adjust.  Don't memset.
2016-01-21 19:59:33 +10:30
Alan Modra de64ce13a7 Rename elf-linux-psinfo.h to elf-linux-core.h
Since it will sometime have more than just prpsinfo.  Also,
elf32-ppc.c needlessly includes this header.

	* elf-linux-core.h: Rename from elf-linux-psinfo.h.
	* elf.c: Adjust #include.
	* elf32-ppc.c: Don't #include elf-linux-psinfo.h
	* Makefile.am (SOURCE_HFILES): Update.
	* Makefile.in: Regenerate.
	* po/SRC-PORFILES.in: Regenerate.
2016-01-21 19:59:33 +10:30
Alan Modra c603b11bec bfd/configure reorganisation
Corefile code should be moved after running config.bfd, because it
uses want64.

	* configure.ac: Move corefile selection later in file.  Move
	tdefaults code immediately after other target vector code.
	* configure: Regenerate.
2016-01-21 19:59:33 +10:30
Mickael Guene 91f68a68f9 Add support for an ARM specific 'y' section attribute flag to mark the section as NOREAD.
bfd/ChangeLog:
      * elf32-arm.c ((elf32_arm_special_sections): Remove catch of noread
      section using '.text.noread' pattern.

gas/ChangeLog:
      * config/obj-elf.c (obj_elf_change_section) : Allow arm section with
      SHF_ARM_NOREAD section flag.
      * config/tc-arm.h (md_elf_section_letter) : Implement this hook to
      handle letter 'y'.
     (arm_elf_section_letter) : Declare it.
      * config/tc-arm.c (arm_elf_section_letter): Handle letter 'y' to set
      SHF_ARM_NOREAD section flag.
      * doc/c-arm.texi (ARM section attribute 'y'): Document it.

gas/testsuite/ChangeLog:
      * gas/arm/section-execute-only.s: New test case.
      * gas/arm/section-execute-only.d: Expected output.

ld/testsuite/ChangeLog:
      * ld-arm/thumb1-noread-not-present-mixing-two-section.s: Add 'y'
      attribute usage.
      * ld-arm/thumb1-noread-present-one-section.s: Likewise.
      * ld-arm/thumb1-noread-present-two-section.s: Likewise.
      * ld-arm/thumb1-input-section-flag-match.s: Likewise.

binutils/ChangeLog:
      * readelf.c (get_elf_section_flags): Display y letter for section
      with SHF_ARM_NOREAD section flag in readelf section output.
      (process_section_headers): Add y letter in readelf section output
      key mapping for ARM architecture.
2016-01-20 12:53:50 +00:00
John Baldwin 5b2c414df1 Add a pseudosection for the NT_FREEBSD_THRMISC note.
bfd/ChangeLog:

	* elf.c (elfcore_grok_note): Recognize NT_FREEBSD_THRMISC notes.
2016-01-19 08:15:08 -08:00
Miranda Cupertino 34e967a5f3 Add PIC and TLS support to the ARC target.
bfd/ChangeLog:
	* arc-plt.def: New file.
	* arc-plt.h: Likewise.
	* elf32-arc.c (elf_arc_abs_plt0_entry, elf_arc_abs_pltn_entry,
		       elf_arcV2_abs_plt0_entry, elf_arcV2_abs_pltn_entry,
		       elf_arc_pic_plt0_entry, elf_arc_pic_pltn_entry,
		       elf_arcV2_pic_plt0_entry, elf_arcV2_pic_pltn_entry): Remove.
	(name_for_global_symbol): Added.
	(ADD_RELA): Helper to create dynamic relocs.
	(new_got_entry_to_list): Create a new got entry in linked list.
	(symbol_has_entry_of_type): Search for specific type of entry in
	list.
	(is_reloc_for_GOT): return FALSE for any TLS related relocs.
	(is_reloc_for_TLS, arc_elf_set_private_flags)
	(arc_elf_print_private_bfd_data, arc_elf_copy_private_bfd_data)
	(arc_elf_merge_private_bfd_data): New functions.
	(debug_arc_reloc): Cleaned debug info printing.
	(PDATA reloc): Changed not to perform address alignment.
	(reverse_me): Added. Fix for ARC_32 relocs.
	(arc_do_relocation): Return bfd_reloc_of when no relocation should
	occur.
	(arc_get_local_got_ents): Renamed from arc_get_local_got_offsets.
	Changed function to access an array of list of GOT entries instead
	of just an array of offsets.
	(elf_arc_relocate_section): Added support for PIC and TLS related relocations.
	(elf_arc_check_relocs): Likewise.
	(elf_arc_adjust_dynamic_symbol, elf_arc_finish_dynamic_symbol,
	(elf_arc_finish_dynamic_sections): Likewise
	(arc_create_dynamic_sections): Modified conditions to create
	dynamic sections.
	(ADD_SYMBOL_REF_SEC_AND_RELOC): New macro.
	(plt_do_relocs_for_symbol, relocate_plt_for_symbol)
	(relocate_plt_for_entry): Changed to support new way to define PLT
	related code.
	(add_symbol_to_plt): Likewise.
	(arc_elf_link_hash_table_create): New function.

include/ChangeLog:
	* elf/arc-reloc.def (ARC_32, ARC_GOTPC, ARC_TLS_GD_GOT)
	(ARC_TLS_IE_GOT, ARC_TLS_DTPOFF, ARC_TLS_DTPOFF_S9, ARC_TLS_LE_S9)
	(ARC_TLS_LE_32): Fixed formula.
	(ARC_TLS_GD_LD): Use new special function.
	* opcode/arc-func.h: Changed all the replacement
	functions to clear the patching bits before doing an or it with the value
	argument.
2016-01-19 15:25:58 +00:00
Nick Clifton 9ae678af99 Use a 32-bit value to hold the section number in the internal COFF symbol structure.
PR ld/19440
inc	* coff/internal.h (internal_syment): Use int to hold section
	number.
	(N_UNDEF): Cast to int not short.
	(N_ABS): Likewise.
	(N_DEBUG): Likewise.
	(N_TV): Likewise.
	(P_TV): Likewise.

bfd	PR ld/19440
	* coff-rs6000.c (_bfd_xcoff_swap_sym_in): Sign extend external
	section number into internal section number.
	* coff64-rs6000.c (_bfd_xcoff64_swap_sym_in): Likewise.
	* coffswap.h (coff_swap_sym_in): Likewise.
	* peXXigen.c (_bfd_XXi_swap_sym_in): Likewise.
	* coffcode.h (_coff_bigobj_swap_sym_in): Make sure that internal
	section number field is big enough to hold the external value.
2016-01-18 15:58:47 +00:00
Alan Modra 5c14705fb3 Regen configure
Picks up 2016-01-12 libtool.m4 change.

bfd/
	* configure: Regenerate.
binutils/
	* configure: Regenerate.
gas/
	* configure: Regenerate.
gprof/
	* configure: Regenerate.
ld/
	* configure: Regenerate.
opcodes/
	* configure: Regenerate.
2016-01-17 12:28:14 +10:30
Yury Usishchev ac06903dcf Add cantunwind when unwind info does not match start of section.
bfd     * elf32-arm.c (elf32_arm_fix_exidx_coverage): Insert cantunwind when
        address in first unwind entry does not match start of section.

tests   * ld-arm/arm-elf.exp: New test.
        * ld-arm/unwind-mix.d: New file.
        * ld-arm/unwind-mix1.s: New file.
        * ld-arm/unwind-mix2.s: New file.
2016-01-12 16:35:49 +00:00
Jiong Wang 109575d7eb [ARM] PR ld/19368: Add missing relocation type class for R_ARM_IRELATIVE
2016-01-08  Richard Sandiford  <richard.sandiford@arm.com>
	    Jiong Wang  <jiong.wang@arm.com>

	PR ld/19368
	bfd/
	* elf32-arm.c (elf32_arm_reloc_type_class): Map R_ARM_IRELATIVE to
	reloc_class_ifunc.

	ld/
	* testsuite/ld-arm/ifunc-3.rd: Update expected result.
	* testsuite/ld-arm/ifunc-4.rd: Likewise.
	* testsuite/ld-arm/ifunc-9.rd: Likewise.
	* testsuite/ld-arm/ifunc-10.rd: Likewise.
	* testsuite/ld-arm/ifunc-12.rd: Likewise.
	* testsuite/ld-arm/ifunc-13.rd: Likewise.
2016-01-08 09:49:03 +00:00
Andrew Burgess b05a65d0ad bfd/arc: Add R_ prefix to all relocation names
The convention within for relocation names is that they start with the
string "R_", however, this is not so for ARC for the display names of
relocations, however, internally, the names for the relocations types do
have the 'R_' prefix.  I suspect that the missing 'R_' on the output
strings was an oversight, as I can't see any comment to the contrary.

To bring ARC into line with other targets, this commit adds the 'R_'
prefix to the output strings used for relocation names, and updates all
of the assembler tests where this was exposed.

bfd/ChangeLog:

	* elf32-arc.c (reloc_type_to_name): Change ARC_RELOC_HOWTO to
	place 'R_' before the reloc name returned.
	(elf_arc_howto_table): Change ARC_RELOC_HOWTO to place 'R_' before
	the relocation string.

gas/ChangeLog:

	* testsuite/gas/arc/adc.d: Add 'R_' prefix to relocation names.
	* testsuite/gas/arc/add.d: Likewise.
	* testsuite/gas/arc/and.d: Likewise.
	* testsuite/gas/arc/asl.d: Likewise.
	* testsuite/gas/arc/asr.d: Likewise.
	* testsuite/gas/arc/bic.d: Likewise.
	* testsuite/gas/arc/extb.d: Likewise.
	* testsuite/gas/arc/extw.d: Likewise.
	* testsuite/gas/arc/j.d: Likewise.
	* testsuite/gas/arc/jl.d: Likewise.
	* testsuite/gas/arc/ld2.d: Likewise.
	* testsuite/gas/arc/lsr.d: Likewise.
	* testsuite/gas/arc/mov.d: Likewise.
	* testsuite/gas/arc/or.d: Likewise.
	* testsuite/gas/arc/pcl-relocs.d: Likewise.
	* testsuite/gas/arc/pcrel-relocs.d: Likewise.
	* testsuite/gas/arc/pic-relocs.d: Likewise.
	* testsuite/gas/arc/plt-relocs.d: Likewise.
	* testsuite/gas/arc/rlc.d: Likewise.
	* testsuite/gas/arc/ror.d: Likewise.
	* testsuite/gas/arc/rrc.d: Likewise.
	* testsuite/gas/arc/sbc.d: Likewise.
	* testsuite/gas/arc/sda-relocs.d: Likewise.
	* testsuite/gas/arc/sda-relocs2.d: Likewise.
	* testsuite/gas/arc/sexb.d: Likewise.
	* testsuite/gas/arc/sexw.d: Likewise.
	* testsuite/gas/arc/st.d: Likewise.
	* testsuite/gas/arc/sub.d: Likewise.
	* testsuite/gas/arc/tls-relocs.d: Likewise.
	* testsuite/gas/arc/xor.d: Likewise.
2016-01-06 14:15:22 +00:00
Maciej W. Rozycki a3dc0a7f65 MIPS/BFD: Factor out ABI flag merging
Factor out the parts of `_bfd_mips_elf_merge_private_bfd_data'
responsible for ABI flag merging to `mips_elf_merge_obj_abiflags'.  No
functional change.

	bfd/
	* elfxx-mips.c (mips_elf_merge_obj_abiflags): New function,
	factored out from...
	(_bfd_mips_elf_merge_private_bfd_data): ... here.
2016-01-04 23:32:34 +00:00
Maciej W. Rozycki d537eeb527 MIPS/BFD: Move attribute check after ELF file header flag check
We have a problem in that in making compatibility checks while merging
private BFD data on the MIPS target we give priority to the attribute
check, which may fail and cause the function to abort early on.  The
problem with this is the ABI compatibility aspect recorded in the
attributes is relatively minor compared to aspects recorded in the ELF
file header.  However the premature exit causes any more important
compatibility aspect violated to be masked and not reported to the user
once a problem with attributes has been noticed.

So move the attribute check after the ELF file header flag check in
`_bfd_mips_elf_merge_private_bfd_data', and do not return prematurely
there.  Take advantage of the resulting grouping of ELF file header
handling together and remove the premature success return point for the
first input object being handled, letting the code later on figure out
output ABI flags even for this object.

Update LD test cases according to messages from ELF file header checks
now preceding ones from attribute checks.

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Move
	attribute check after ELF file header flag check.

	ld/
	* testsuite/ld-mips-elf/attr-gnu-4-14.d: Update the order of
	messages expected according to MIPS BFD private data merge
	changes.
	* testsuite/ld-mips-elf/attr-gnu-4-24.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-34.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-41.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-42.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-43.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-45.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-46.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-47.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-48.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-49.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-54.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-64.d: Likewise.
	* testsuite/ld-mips-elf/attr-gnu-4-74.d: Likewise.
2016-01-04 23:30:00 +00:00
Maciej W. Rozycki 43d223b543 MIPS/BFD: Propagate the return status in attribute merging
Fix the issue of any failure from `_bfd_elf_merge_object_attributes' not
being propagated by `mips_elf_merge_obj_attributes'.

	bfd/
	* elfxx-mips.c (mips_elf_merge_obj_attributes): Propagate the
	return status from `_bfd_elf_merge_object_attributes'.
2016-01-04 23:16:45 +00:00
Maciej W. Rozycki b2e9744f80 MIPS/BFD: Factor out ELF file header flag checks
Factor out the parts of `_bfd_mips_elf_merge_private_bfd_data'
responsible for ELF file header flag compatibility checks to
`mips_elf_merge_obj_e_flags'.  As a side effect remove a premature
return point from `_bfd_mips_elf_merge_private_bfd_data'.  No functional
change otherwise.

	bfd/
	* elfxx-mips.c (mips_elf_merge_obj_e_flags): New function,
	factored out from...
	(_bfd_mips_elf_merge_private_bfd_data): ... here.
2016-01-04 23:15:03 +00:00