Commit Graph

5261 Commits

Author SHA1 Message Date
Alan Modra 94b41882b0 ld expression section
Changes the result of ld expressions that were previously plain
numbers to be an absolute address, in the same circumstances where
numbers are treated as absolute addresses.

	* ld.texinfo (Expression Section): Update result of arithmetic
	expressions.
	* ldexp.c (arith_result_section): New function.
	(fold_binary): Use it.
2016-10-04 10:43:50 +10:30
Alan Modra 9ad39107ca Fold arithmetic integer expressions
Commit b751e639 regressed arm linux kernel builds, that have an
ASSERT (((__hyp_idmap_text_end - (__hyp_idmap_text_start
       			          & ~ (((0x1 << 0xc) - 0x1))))
         <= (0x1 << 0xc)), HYP init code too big or misaligned)

Due to some insanity in ld expression evaluation, the integer values
0x1 and 0xc above are treated as absolute addresses (ie. they have an
associated section, *ABS*, see exp_fold_tree_1 case etree_value) while
the expression (0x1 << 0xc) has a plain number result.  The left hand
side of the inequality happens to evaluate to a "negative" .text
section relative value.  Comparing a section relative value against an
absolute value works since the section relative value is first
converted to absolute.  Comparing a section relative value against a
number just compares the offsets, which fails since the "negative"
offset is really a very large positive number.

This patch works around the problem by folding integer expressions, so
the assert again becomes
ASSERT (((__hyp_idmap_text_end - (__hyp_idmap_text_start
       			          & 0xfffffffffffff000))
         <= 0x1000), HYP init code too big or misaligned)

	* ldexp.c (exp_value_fold): New function.
	(exp_unop, exp_binop, exp_trinop): Use it.
2016-10-04 10:41:26 +10:30
Alan Modra 76276ff673 v850 linker scripts
This should mean the 2010-10-28 change for ld -r --gc-sections can
be reverted.

	* scripttempl/v850.sc: Don't reference __ctbp, __ep, __gp when
	not relocating.
	* scripttempl/v850_rh850.sc: Likewise.
2016-09-30 17:53:27 +09:30
Alan Modra 80169c8a23 Fix pr20528 testsuite
PR ld/20528
	* testsuite/ld-elf/pr20528a.d: xfail generic elf targets.  Allow
	multiple .text sections for hppa-linux.
	* testsuite/ld-elf/pr20528b.d: Likewise.
2016-09-30 17:51:07 +09:30
Alan Modra 4519d07138 Better ld --fatal-warnings support
* ldmain.c (default_bfd_error_handler): New function pointer.
	(ld_bfd_error_handler): New function.
	(main): Arrange to call it on bfd errors/warnings.
	(ld_bfd_assert_handler): Enable tail call.
2016-09-30 11:38:45 +09:30
Alan Modra 52d45da3f2 Make bfd_error_handler_type like vprintf
It was like printf, which means you can't use bfd_set_error_handler to
hook in a function to do something and then call the original handler.

The patch also deletes some unused functions and makes pointers local.

bfd/
	* bfd-in.h: Include stdarg.h.
	* bfd.c (bfd_error_handler_type): Make like vprintf.
	(_bfd_error_internal): Rename from _bfd_error_handler.  Make static.
	(error_handler_internal): New function, split out from..
	(_bfd_default_error_handler): ..here.  Rename to _bfd_error_handler.
	(bfd_set_error_handler): Update.
	(bfd_get_error_handler, bfd_get_assert_handler): Delete.
	(_bfd_assert_handler): Make static.
	* coffgen.c (null_error_handler): Update params.
	* elf-bfd.h (struct elf_backend_data <link_order_error_handler>):
	Don't use bfd_error_handler_type.
	* elf64-mmix.c (mmix_dump_bpo_gregs): Likewise.
	* elfxx-target.h (elf_backend_link_order_error_handler): Default
	to _bfd_error_handler.
	* libbfd-in.h (_bfd_default_error_handler): Don't declare.
	(bfd_assert_handler_type): Likewise.
	(_bfd_error_handler): Update.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
ld/
	* ldlang.c (ignore_bfd_errors): Update params.
2016-09-30 11:38:39 +09:30
H.J. Lu 93dc595d76 Don't merge 2 sections with different SHF_EXCLUDE
SEC_EXCLUDE is ignored when doing a relocatable link.  But we can't
merge 2 input sections with the same name when only one of them has
SHF_EXCLUDE.

	PR ld/20528
	* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Don't
	merge 2 sections with different SHF_EXCLUDE.
	* testsuite/ld-elf/pr20528a.d: New file.
	* testsuite/ld-elf/pr20528a.s: Likewise.
	* testsuite/ld-elf/pr20528b.d: Likewise.
	* testsuite/ld-elf/pr20528b.s: Likewise.
2016-09-29 12:58:40 -07:00
Christophe Lyon 2df2751d19 [ARM] PR ld/20608 Relocation truncated to fit: R_ARM_THM_JUMP24 for relocation to PLT entry
2016-09-28  Christophe Lyon  <christophe.lyon@linaro.org>

	PR ld/20608
	bfd/
	* elf32-arm.c (arm_type_of_stub): Handle the case when the pre-PLT
	Thumb-ARM stub is too far.

	ld
	* testsuite/ld-arm/arm-elf.exp: Handle new testcase.
	* testsuite/ld-arm/farcall-mixed-app2.d: New file.
	* testsuite/ld-arm/farcall-mixed-app2.r: Likewise.
	* testsuite/ld-arm/farcall-mixed-app2.s: Likewise.
	* testsuite/ld-arm/farcall-mixed-app2.sym: Likewise.
2016-09-28 01:41:00 +02:00
Vlad Zakharov c5da193232 When building target binaries, ensure that the warning flags selected for the command line match the target compiler.
bfd	* warning.m4 (AC_EGREP_CPP_FOR_BUILD): Introduce macro
	to verify CC_FOR_BUILD compiler.
	(AM_BINUTILS_WARNINGS): Introduce ac_cpp_for_build variable
	and add CC_FOR_BUILD compiler checks.
	* Makefile.in: Regenerate.
	* configure: Likewise.
	* doc/Makefile.in: Likewise.

binutils	* Makefile.am: Replace AM_CLFAGS with AM_CFLAGS_FOR_BUILD
	when building with CC_FOR_BUILD compiler.
	* Makefile.in: Regenerate.
	* configure: Likewise.
	* doc/Makefile.in: Likewise.

gas	* Makefile.in: Regenerate.
	* configure: Likewise.
	* doc/Makefile.in: Likewise.

gold	* Makefile.in: Regenerate.
	* configure: Likewise.
	* testsuite/Makefile.in: Likewise.

gprof	* Makefile.in: Regenerate.
	* configure: Likewise.

ld	* Makefile.in: Regenerate.
	* configure: Likewise.

opcodes	* Makefile.in: Regenerate.
	* configure: Likewise.
2016-09-26 16:36:08 +01:00
Alan Modra 005d79fd61 PowerPC .gnu.attributes
This patch extends Tag_GNU_Power_ABI_FP to cover long double ABIs,
makes the assembler warn about undefined tag values, and removes
similar warnings from the linker.  I think it is better to not
warn in the linker about undefined tag values as future extensions to
the tags then won't result in likely bogus warnings.  This is
consistent with the fact that an older linker won't warn on an
entirely new tag.

include/
	* elf/ppc.h (Tag_GNU_Power_ABI_FP): Comment.
bfd/
	* elf-bfd.h (_bfd_elf_ppc_merge_fp_attributes): Declare.
	* elf32-ppc.c (_bfd_elf_ppc_merge_fp_attributes): New function.
	(ppc_elf_merge_obj_attributes): Use it.  Don't copy first file
	attributes, merge them.  Don't warn about undefined tag bits,
	or copy unknown values to output.
	* elf64-ppc.c (ppc64_elf_merge_private_bfd_data): Call
	_bfd_elf_ppc_merge_fp_attributes.
binutils/
	* readelf.c (display_power_gnu_attribute): Catch truncated section
	for all powerpc attributes.  Display long double ABI.  Don't
	capitalize words, except for names.  Show known bits of tag values
	when some unknown bits are present.  Whitespace fixes.
gas/
	* config/tc-ppc.c (ppc_elf_gnu_attribute): New function.
	(md_pseudo_table <ELF>): Handle "gnu_attribute".
ld/
	* testsuite/ld-powerpc/attr-gnu-4-4.s: Delete.
	* testsuite/ld-powerpc/attr-gnu-4-14.d: Delete.
	* testsuite/ld-powerpc/attr-gnu-4-24.d: Delete.
	* testsuite/ld-powerpc/attr-gnu-4-34.d: Delete.
	* testsuite/ld-powerpc/attr-gnu-4-41.d: Delete.
	* testsuite/ld-powerpc/attr-gnu-4-32.d: Adjust expected warning.
	* testsuite/ld-powerpc/attr-gnu-8-23.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-01.d: Adjust expected output.
	* testsuite/ld-powerpc/attr-gnu-4-02.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-03.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-10.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-11.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-20.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-22.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-33.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-8-11.d: Likewise.
	* testsuite/ld-powerpc/powerpc.exp: Don't run deleted tests.
2016-09-26 18:04:57 +09:30
Akihiko Odaki 5025eb7c0d Delete relocations associatesd with deleted exidx entries.
PR ld/20595
ld	* testsuite/ld-arm/unwind-4.d: Add -q option to linker command
	line and -r option to objdump command line.  Match emitted relocs
	to make sure that superflous relocs are not generated.

bfd	* elf-bfd.h (struct elf_backend_data): Add
	elf_backend_count_output_relocs callback to count relocations in
	the final output.
	* elf-arm.c (elf32_arm_add_relocation): Deleted.
	(elf32_arm_write_section): Move additional relocation to emit_relocs.
	(elf32_arm_count_output_relocs): New function.
	(emit_relocs): New function.
	(elf32_arm_emit_relocs): New function.
	(elf32_arm_vxworks_emit_relocs): New function.
	(elf_backend_emit_relocs): Updated to use the new functions.
	(elf_backend_count_output_relocs): New define.
	* bfd/elflink.c (bfd_elf_final_link): Do not add additional_reloc_count
	to the relocation count.
	(_bfd_elf_link_size_reloc_section): Use callback to count the
	relocations which will be in output.
	(_bfd_elf_default_count_output_relocs): New function.
	* bfd/elfxx-target.h (elf_backend_count_output_relocs): New define.
2016-09-23 16:32:04 +01:00
Andreas Krebbel 7c4236c350 S/390: Move start of 64 bit binaries from 2GB to 256MB.
ld/ChangeLog:

2016-09-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

	* emulparams/elf64_s390.sh: Change TEXT_START_ADDR to 256MB.
	* testsuite/ld-s390/tlsbin_64.dd: Adjust testcase accordingly.
	* testsuite/ld-s390/tlsbin_64.rd: Likewise.
2016-09-23 11:26:05 +02:00
Nick Clifton 0ec22c2c9f Report failed attempts to locate DT_NEEDED files when --verbose is in effect.
* emultempl/elf32.em (_try_needed): In verbose mode, report failed
	attempts to find a needed library.
2016-09-22 14:29:49 +01:00
Richard Sandiford ad43e107eb [AArch64] Print spaces after commas in addresses
I got an off-list request to make the AArch64 disassembler print
spaces after commas in addresses.  This patch does that.

The same code is used to print operands in "did you mean" errors,
so to keep things consistent, the patch also prints spaces between
operands in those messages.

opcodes/
	* aarch64-opc.c (print_immediate_offset_address): Print spaces
	after commas in addresses.
	(aarch64_print_operand): Likewise.

gas/
	* config/tc-aarch64.c (print_operands): Print spaces between
	operands.
	* testsuite/gas/aarch64/ilp32-basic.d: Expect spaces after ","
	in addresses.
	* testsuite/gas/aarch64/ldst-reg-imm-post-ind.d: Likewise.
	* testsuite/gas/aarch64/ldst-reg-imm-pre-ind.d: Likewise.
	* testsuite/gas/aarch64/ldst-reg-pair.d: Likewise.
	* testsuite/gas/aarch64/ldst-reg-reg-offset.d: Likewise.
	* testsuite/gas/aarch64/ldst-reg-uns-imm.d: Likewise.
	* testsuite/gas/aarch64/ldst-reg-unscaled-imm.d: Likewise.
	* testsuite/gas/aarch64/reloc-insn.d: Likewise.
	* testsuite/gas/aarch64/sve.d: Likewise.
	* testsuite/gas/aarch64/symbol.d: Likewise.
	* testsuite/gas/aarch64/system.d: Likewise.
	* testsuite/gas/aarch64/tls-desc.d: Likewise.
	* testsuite/gas/aarch64/sve-invalid.l: Expect spaces after ","
	in suggested alternatives.
	* testsuite/gas/aarch64/verbose-error.l: Likewise.

ld/
	* testsuite/ld-aarch64/emit-relocs-28.d: Expect spaces after ","
	in addresses.
	* testsuite/ld-aarch64/emit-relocs-301-be.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-301.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-302-be.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-302.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-310-be.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-310.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-313.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-515-be.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-515.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-516-be.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-516.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-531.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-532.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-533.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-534.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-535.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-536.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-537.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-538.d: Likewise.
	* testsuite/ld-aarch64/erratum835769.d: Likewise.
	* testsuite/ld-aarch64/erratum843419.d: Likewise.
	* testsuite/ld-aarch64/farcall-b-plt.d: Likewise.
	* testsuite/ld-aarch64/farcall-bl-plt.d: Likewise.
	* testsuite/ld-aarch64/gc-plt-relocs.d: Likewise.
	* testsuite/ld-aarch64/ifunc-21.d: Likewise.
	* testsuite/ld-aarch64/ifunc-7c.d: Likewise.
	* testsuite/ld-aarch64/tls-desc-ie.d: Likewise.
	* testsuite/ld-aarch64/tls-large-desc-be.d: Likewise.
	* testsuite/ld-aarch64/tls-large-desc.d: Likewise.
	* testsuite/ld-aarch64/tls-large-ie-be.d: Likewise.
	* testsuite/ld-aarch64/tls-large-ie.d: Likewise.
	* testsuite/ld-aarch64/tls-relax-all.d: Likewise.
	* testsuite/ld-aarch64/tls-relax-gd-ie.d: Likewise.
	* testsuite/ld-aarch64/tls-relax-gdesc-ie-2.d: Likewise.
	* testsuite/ld-aarch64/tls-relax-gdesc-ie.d: Likewise.
	* testsuite/ld-aarch64/tls-relax-large-desc-ie-be.d: Likewise.
	* testsuite/ld-aarch64/tls-relax-large-desc-ie.d: Likewise.
	* testsuite/ld-aarch64/tls-tiny-desc.d: Likewise.
	* testsuite/ld-aarch64/tls-tiny-gd.d: Likewise.
2016-09-21 17:11:52 +01:00
Richard Sandiford bb7eff5206 [AArch64] Add SVE condition codes
SVE defines new names for existing NZCV conditions, to reflect the
result of instructions like PTEST.  This patch adds support for these
names.

The patch also adds comments to the disassembly output to show the
alternative names of a condition code.  For example:

	cinv	x0, x1, cc

becomes:

     	cinv	x0, x1, cc  // cc = lo, ul, last

and:

	b.cc	f0 <...>

becomes:

     	b.cc	f0 <...>  // b.lo, b.ul, b.last

Doing this for the SVE names follows the practice recommended by the
SVE specification and is definitely useful when reading SVE code.
If the feeling is that it's too distracting elsewhere, we could add
an option to turn it off.

include/
	* opcode/aarch64.h (aarch64_cond): Bump array size to 4.

opcodes/
	* aarch64-dis.c (remove_dot_suffix): New function, split out from...
	(print_mnemonic_name): ...here.
	(print_comment): New function.
	(print_aarch64_insn): Call it.
	* aarch64-opc.c (aarch64_conds): Add SVE names.
	(aarch64_print_operand): Print alternative condition names in
	a comment.

gas/
	* config/tc-aarch64.c (opcode_lookup): Search for the end of
	a condition name, rather than assuming that it will have exactly
	2 characters.
	(parse_operands): Likewise.
	* testsuite/gas/aarch64/alias.d: Add new condition-code comments
	to the expected output.
	* testsuite/gas/aarch64/beq_1.d: Likewise.
	* testsuite/gas/aarch64/float-fp16.d: Likewise.
	* testsuite/gas/aarch64/int-insns.d: Likewise.
	* testsuite/gas/aarch64/no-aliases.d: Likewise.
	* testsuite/gas/aarch64/programmer-friendly.d: Likewise.
	* testsuite/gas/aarch64/reloc-insn.d: Likewise.
	* testsuite/gas/aarch64/b_c_1.d, testsuite/gas/aarch64/b_c_1.s:
	New test.

ld/
	* testsuite/ld-aarch64/emit-relocs-280.d: Match branch comments.
	* testsuite/ld-aarch64/weak-undefined.d: Likewise.
2016-09-21 17:09:59 +01:00
Andrew Burgess d4ed4da3f5 ld: Fix mistake in ChangeLog
The previous commit contained a small mistake in the ChangeLog, fixed in
this commit.
2016-09-20 15:34:20 +01:00
Andrew Burgess a5bf7d4fe7 ld: Extend documentation for EXCLUDE_FILE
There was a gap in the documentation of EXCLUDE_FILE that could cause
confusion to a user.  When writing an input section specifier like this:

    *(EXCLUDE_FILE (somefile.o) .text .text.*)

this could mean one of the following:

   1. All '.text' and '.text.*' from all files except for 'somefile.o',
   or
   2. All '.text' from all files except 'somefile.o', and all '.text.*'
   sections from all files.

It turns out that the second interpretation is correct, but the manual
does not make this clear (to me at least).  Hopefully this patch makes
things clearer.

ld/ChangeLog:

	* ld/ld.texinfo (Input Section Basics): Expand the description of
	EXCLUDE_FILE.
2016-09-20 14:22:34 +01:00
Thomas Preud'homme 4f90d84b2f Fix ld --gc-section segfault with ARMv8-M entry function in absolute section
bfd/
2016-09-14  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* elf32-arm.c (elf32_arm_gc_mark_extra_sections): Only mark section
	not already marked.

ld/
2016-09-14  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* testsuite/ld-arm/cmse-veneers.s: Add a test for ARMv8-M Security
	Extensions entry functions in absolute section.
	* testsuite/ld-arm/cmse-veneers.rd: Adapt expected output accordingly.
2016-09-14 16:03:43 +01:00
Claudiu Zissulescu 32348c581b [ARC] Fix parsing dtpoff relocation expression.
The assembler accepts dtpoff complex relocation expression like
identifier@dtpoff + const. However, it doesn't accept an expression such
as identifier@dtpoff@base + const. This patch solves this issue, and adds
a number of tests.

ld/
2016-09-14  Claudiu Zissulescu  <claziss@synopsys.com>

	* testsuite/ld-arc/tls-dtpoff.dd: New file.
	* testsuite/ld-arc/tls-dtpoff.rd: Likewise.
	* testsuite/ld-arc/tls-dtpoff.s: Likewise.
	* testsuite/ld-arc/tls-relocs.ld: Likewise.
	* testsuite/ld-arc/arc.exp: Add new tdpoff test.

gas/
2016-09-14  Claudiu Zissulescu  <claziss@synopsys.com>

	* testsuite/gas/arc/tls-relocs2.d: New file.
	* testsuite/gas/arc/tls-relocs2.s: Likewise.
	* config/tc-arc.c (tokenize_arguments): Accept offsets when base
	is used.
2016-09-14 14:04:34 +02:00
Nick Clifton 29063f8bfb Add support for disabling automatic generation of .eh_frame_hdr sections in ELF based linkers.
PR ld/20537
	* emultempl/elf32.em: More OPTION_xxx values into an enum.  Add
	OPTION_NO_EH_FRAME_HDR.
	(_add_options): Add support for --no-eh-frame-hdr.
	* ld.texinfo: Document new option.
	* lexsup.c (elf_shlib_list_options): List new option.
	* NEWS: Mention the new option.
2016-09-14 10:42:10 +01:00
H.J. Lu d8457a04b7 Resolve size relocation with copy relocation
We can resolve size relocation against symbol which needs copy relocation
when building executable.

bfd/

	PR ld/20550
	* elf64-x86-64.c (elf_x86_64_relocate_section): Resolve size
	relocation with copy relocation when building executable.

ld/

	PR ld/20550
	* testsuite/ld-x86-64/pr20550a.s: New file.
	* testsuite/ld-x86-64/pr20550b.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp (x86_64tests): Add tests for
	PR ld/20550.
2016-09-06 13:34:44 -07:00
Nick Clifton 22d6c51be8 Do not pass host compiler sanitization flags on to linker testsuite.
* Makefile.am (CFLAGS_FOR_TARGET): Define as a copy of CFLAGS but
	without any sanitization options.
	(CXXFLAGS_FOR_TARGET): Define as a copy of CXXFLAGS but	without
	any sanitization options.
	(check-DEJAGNU): Pass CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET
	as CFLAGS and CXXFLAGS respectively.
2016-09-06 17:35:35 +01:00
Senthil Kumar Selvaraj bf1865065f Fix PR ld/20545 - relaxation bugs in avr backend
Prior to the patch, addends for relocs were being adjusted even if
they went beyond an alignment boundary. This is wrong - to
preserve alignment constraints, the relaxation logic adds as many padding
bytes at the alignment boundary as was deleted, so addends beyond the
boundary should not be adjusted. avr-prop-7.s reproduces this
scenario.

Also, prior to this patch, the relaxation logic assumed that the addr
parameter pointed to the middle of the instruction to be deleted, and
that addr - count would therefore be the shrinked instruction's
address. This is true when actually shrinking instructions.

The alignment constraints handling logic also invokes the same logic
though, with addr as the starting offset of padding bytes and
with count as the number of bytes to be deleted. Calculating the
shrinked insn's address as addr - count is obviously wrong in this
case - that offset would point to count bytes before the last
non-padded byte. avr-prop-8.s reproduces this scenario.

To fix scenario 1, the patch adds an additional check to ensure reloc addends
aren't adjusted if they cross a shrink boundary. The shrink boundary
is either the section size or an alignment boundary. Addends pointing
at an alignment boundary don't need to be adjusted, as padding would
occur and keep the boundary the same. Addends pointing at section size
need to be adjusted though, as no padding occurs and the section size
itself would get decremented. The patch records whether padding
occured (did_pad) and uses that to detect and handle this condition.

To fix scenario 2, the patch adds an additional parameter
(delete_shrinks_insn) to elf32_avr_relax_delete_bytes to distinguish
instruction bytes deletion from padding bytes deletion. It then uses that to
correctly set shrinked_insn_address.

bfd/ChangeLog:

2016-09-02  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>

	PR ld/20545
	* elf32-avr.c (elf32_avr_relax_delete_bytes): Add parameter
	delete_shrinks_insn. Modify computation of shrinked_insn_address.
	Compute shrink_boundary and adjust addend only if
	addend_within_shrink_boundary.
	(elf32_avr_relax_section): Modify calls to
	elf32_avr_relax_delete_bytes to pass extra parameter.

ld/ChangeLog:

2016-09-02  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>

	PR ld/20545
	* testsuite/ld-avr/avr-prop-7.d: New test.
	* testsuite/ld-avr/avr-prop-7.s: New test.
	* testsuite/ld-avr/avr-prop-8.d: New test.
	* testsuite/ld-avr/avr-prop-8.s: New test.
2016-09-06 12:28:37 +05:30
H.J. Lu 1b2d85b255 Limit pr20513c/pr20513d to Linux and GNU targets
* testsuite/ld-elf/pr20513c.d: Limit to *-*-linux* and *-*-gnu*
	targets.
	* testsuite/ld-elf/pr20513d.d: Likewise.
2016-09-02 07:58:24 -07:00
H.J. Lu 652a8f4f57 Add tests for PR ld/20513
PR ld/20513
	* testsuite/ld-elf/pr20513a.d: New file.
	* testsuite/ld-elf/pr20513a.s: Likewise.
	* testsuite/ld-elf/pr20513b.d: Likewise.
	* testsuite/ld-elf/pr20513b.s: Likewise.
	* testsuite/ld-elf/pr20513c.d: Likewise.
	* testsuite/ld-elf/pr20513d.d: Likewise.
	* testsuite/ld-elf/pr20513e.d: Likewise.
	* testsuite/ld-elf/pr20513f.d: Likewise.
2016-09-01 12:01:11 -07:00
Alan Modra 2e84f9c1b5 Ignore symbols defined in SHF_EXCLUDE sections
PR 20513
	* ldlang.c (section_already_linked): Deal with SHF_EXCLUDE sections.
2016-08-31 19:22:43 +09:30
Alan Modra 3e8c34ea9d Adjust VLE testsuite
To suit f7d69005.

	* testsuite/ld-powerpc/vle-multiseg-1.d: Adjust to suit segment change.
	* testsuite/ld-powerpc/vle-multiseg-2.d: Likewise.
	* testsuite/ld-powerpc/vle-multiseg-3.d: Likewise.
	* testsuite/ld-powerpc/vle-multiseg-6.d: Likewise.
	* testsuite/ld-powerpc/vle-reloc-2.d: Likewise.
2016-08-31 14:05:44 +09:30
Cupertino Miranda b2b383620e Made tests to XFAIL for arc*-*-elf*.
ld/ChangeLog:
    Cupertino Miranda  <cmiranda@synopsys.com>

	* testsuite/ld-arc/tls_gs-01.d: Set to XFAIL on arc*-*-elf*.
	* testsuite/ld-arc/tls_ie-01.d: Likewise.
2016-08-30 16:02:25 +02:00
H.J. Lu 3c4f32287f Run PR ld/19784 tests only if ifunc attribute works
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/19784 tests only
	if ifunc attribute works.
2016-08-29 09:09:14 -07:00
H.J. Lu 74437ea28f i386: Issue an error on non-PIC call to IFUNC in PIC object
On i386, IFUNC function must be called via PLT.  Since PLT in PIC
object uses EBX register, R_386_PLT32 relocation must be used to
call IFUNC function even when IFUNC function is defined locally.
Linker should issue an error when R_386_PC32 relocation is used
to call IFUNC function.

Since PR ld/19784 tests doesn't use PLT relocation to local IFUNC
function, they are moved to the x86-64 test directory.

bfd/

	PR ld/14961
	PR ld/20515
	* elf32-i386.c (elf_i386_check_relocs): Issue an error when
	R_386_PC32 relocation is used to call IFUNC function in PIC
	object.

ld/

	PR ld/14961
	PR ld/20515
	* testsuite/ld-i386/i386.exp: Run pr20515.
	* testsuite/ld-i386/pr20515.d: New file.
	* testsuite/ld-i386/pr20515.s: Likewise.
	* testsuite/ld-ifunc/ifunc-14a.s: Use R_386_PLT32 to call IFUNC
	function.
	* testsuite/ld-ifunc/ifunc-14c.s: Likewise.
	* testsuite/ld-ifunc/ifunc-2-i386.s: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-i386.s: Likewise.
	* testsuite/ld-ifunc/ifunc.exp: Move PR ld/19784 tests to ...
	* testsuite/ld-x86-64/x86-64.exp: Here.
	* testsuite/ld-ifunc/pr19784a.c: Moved to ...
	* testsuite/ld-x86-64/pr19784a.c: Here.
	* testsuite/ld-ifunc/pr19784b.c: Moved to ...
	* testsuite/ld-x86-64/pr19784b.c: Here.
	* testsuite/ld-ifunc/pr19784c.c: Moved to ...
	* testsuite/ld-x86-64/pr19784c.c: Here.
2016-08-29 08:14:45 -07:00
Thomas Preud'homme 68c3989217 Reduce parameter list in bfd_elf32_arm_target_relocs
2016-08-26  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* bfd-in.h (struct elf32_arm_params): Define.
	(bfd_elf32_arm_set_target_relocs): Rename into ...
	(bfd_elf32_arm_set_target_params): This.  Use a struct
	elf32_arm_params to pass all parameters but the bfd and bfd_link_info.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (bfd_elf32_arm_set_target_relocs): Rename into ...
	(bfd_elf32_arm_set_target_params): This.  Pass all values via a struct
	elf32_arm_params rather than as individual parameters.

ld/
	* emultempl/armelf.em (params): New static variable.
	(thumb_entry_symbol, byteswap_code, target1_is_rel, target2_type,
	fix_v4bx, use_blx, vfp11_denorm_fix, stm32l4xx_fix, fix_cortex_a8,
	no_enum_size_warning, no_wchar_size_warning, pic_veneer,
	merge_exidx_entries, fix_arm1176, cmse_implib): move as part of the
	above new structure.
	(arm_elf_before_allocation): Access static variable from the params
	structure.
	(gld${EMULATION_NAME}_finish): Likewise.
	(arm_elf_create_output_section_statements): Likewise and pass the
	address of that structure to bfd_elf32_arm_set_target_relocs instead
	of the static variables.
	(PARSE_AND_LIST_ARGS_CASES): Access static variable from the params
	structure.
2016-08-26 14:00:39 +01:00
Cupertino Miranda 980aa3e6df Dynamic TLS GOT entries would not be relocated.
Forgot to set should_relocate to TRUE in case of GOT and TLS relocations of
undefined symbols for shared libraries.
In dynamic libraries if symbol is not known the instruction relocation would
not be resolved to point to the respective .got entry.
A test was created to detect similar future mistakes.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* elf32-arc.c (elf_arc_relocate_section): Changed. Set should_relocate
	to TRUE for GOT and TLS relocs.

ld/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* ld/testsuite/ld-arc/tls_gd-01.s: Added a testcase for this patch.
	* ld/testsuite/ld-arc/tls_gd-01.d: Likewise.
2016-08-26 12:09:17 +02:00
Cupertino Miranda 4dd72ffdfe Content for TLS_IE_GOT not written to .got.
When no dynamic relocation was generated the .got content would not be
updated for the TLS_IE_GOT relocation addresses.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* arc-got.h (relocate_fix_got_relocs_for_got_info): Fixed addresses in
	debug comments. Fixed address in .got related to TLS_IE_GOT dynamic
	relocation.

ld/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* testsuite/ld-arc/tls_ie-01.s: Added to verify associated fix.
	* testsuite/ld-arc/tls_ie-01.d: Likewise
2016-08-26 12:09:17 +02:00
Thomas Preud'homme 0955507f6e Add support for stable secure gateway veneers addresses
2016-08-26  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* bfd-in.h (bfd_elf32_arm_set_target_relocs): Add a new parameter for
	the input import library bfd.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (struct elf32_arm_link_hash_table): New in_implib_bfd
	and new_cmse_stub_offset fields.
	(stub_hash_newfunc): Initialize stub_offset and stub_template_size to
	-1.
	(elf32_arm_add_stub): Likewise for stub_offset.
	(arm_new_stubs_start_offset_ptr): New function.
	(arm_build_one_stub): Only allocate a stub_offset if it is -1.  Allow
	empty SG veneers to have zero relocations.
	(arm_size_one_stub): Only initialize stub size and template
	information for non empty veneers.  Do not update veneer section size
	if veneer already has an offset.
	(elf32_arm_create_stub): Return the stub entry pointer or NULL instead
	of a boolean indicating success or failure.
	(cmse_scan): Change stub_changed parameter into an integer pointer
	parameter cmse_stub_created to count the number of stub created and
	adapt to change of return value in elf32_arm_create_stub.
	(cmse_entry_fct_p): New function.
	(arm_list_new_cmse_stub): Likewise.
	(set_cmse_veneer_addr_from_implib): Likewise.
	(elf32_arm_size_stubs): Define cmse_stub_created, pass its address to
	cmse_scan instead of that of cmse_stub_changed to compute the number
	of stub created and use it to initialize stub_changed.  Call
	set_cmse_veneer_addr_from_implib after all cmse_scan.  Adapt to change
	of return value in elf32_arm_create_stub.  Use
	arm_stub_section_start_offset () if not NULL to initialize size of
	secure gateway veneers section.  Initialize stub_offset of Cortex-A8
	erratum fix to -1.  Use ret to hold return value.
	(elf32_arm_build_stubs): Use arm_stub_section_start_offset () if not
	NULL to initialize size of secure gateway veneers section.  Adapt
	comment to stress the importance of zeroing veneer section content.
	(bfd_elf32_arm_set_target_relocs): Add new in_implib_bfd parameter to
	initialize eponymous field in struct elf32_arm_link_hash_table.

ld/
	* emultempl/armelf.em (in_implib_filename): Declare and initialize new
	variable.
	(arm_elf_create_output_section_statements): Open import input library
	file for writing and pass resulting in_implib_bfd to
	bfd_elf32_arm_set_target_relocs.
	(PARSE_AND_LIST_PROLOGUE): Define OPTION_IN_IMPLIB option.
	(PARSE_AND_LIST_LONGOPTS): Define --in-implib option.
	(PARSE_AND_LIST_OPTIONS): Add help message for --in-implib option.
	(PARSE_AND_LIST_ARGS_CASES): Handle new OPTION_IN_IMPLIB case.
	* ld.texinfo (--cmse-implib): Update to mention --in-implib.
	(--in-implib): Document new option.
	* NEWS: Likewise.
	* testsuite/ld-arm/arm-elf.exp
	(Secure gateway import library generation): add --defsym VER=1 to gas
	CLI.
	(Secure gateway import library generation: errors): Likewise.
	(Input secure gateway import library): New test.
	(Input secure gateway import library: no output import library):
	Likewise.
	(Input secure gateway import library: not an SG input import library):
	Likewise.
	(Input secure gateway import library: earlier stub section base):
	Likewise.
	(Input secure gateway import library: later stub section base):
	Likewise.
	(Input secure gateway import library: veneer comeback): Likewise.
	(Input secure gateway import library: entry function change):
	Likewise.
	* testsuite/ld-arm/cmse-implib.s: Add input import library testing.
	* testsuite/ld-arm/cmse-implib.rd: Update accordingly.
	* testsuite/ld-arm/cmse-new-implib.out: New file.
	* testsuite/ld-arm/cmse-new-implib.rd: Likewise.
	* testsuite/ld-arm/cmse-new-implib-no-output.out: Likewise.
	* testsuite/ld-arm/cmse-new-implib-not-sg-in-implib.out: Likewise.
	* testsuite/ld-arm/cmse-new-earlier-later-implib.out: Likewise.
	* testsuite/ld-arm/cmse-new-comeback-implib.rd: Likewise.
	* testsuite/ld-arm/cmse-new-wrong-implib.out: Likewise.
2016-08-26 11:00:36 +01:00
Alan Modra 4811ccb48f powerpc ld configure
This fixes a few problems in the powerpc ld configury.
1) Using powerpc*le-* to test for powerpcle and powerpc64le would
   incorrectly match a target triple like powerpc-apple-elf.
2) In the same vein, *64* could match 64 in the user supplied MANUF-OS
   part of the target triple.
3) tooldir vars were missing, and some target aliases would result in
   ridiculous values for those tdir_* vars given.
4) Since 2016-04-25, BE support was added automatically when asking
   for an LE target.  If that is a good idea, then so is adding LE
   support when asking for BE.

	* configure.tgt (powerpc*-*-linux* et al): Rewrite, adding LE
	support for BE.  First output all target endian configury
	values, then opposite endian.  Handle more tooldirs.  Fix
	bogus matches with strings in MANUF-OS part of target triple.
2016-08-25 23:41:11 +09:30
Alan Modra d44ea5d05b Fix duplicate FAILs from ld testsuite
* testsuite/lib/ld-lib.exp (run_cc_link_tests): Don't fail tests
	twice.
2016-08-23 12:23:05 +09:30
Nick Clifton 576438f0fa Enable relro by default for AArch64, ARM and SCORE.
ld	* emultempl/aarch64elf.em (before_parse): Initialise the relro
	field in the link_info structure.
	* emultempl/armelf.em (before_parse): Likewise.
	* emultempl/linux.em (before_parse): Likewise.
	* emultempl/scoreelf.em (before_parse): Likewise.
2016-08-19 09:27:52 +01:00
Nick Clifton dd90581873 Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets.
bfd
  * elf.c (assign_section_numbers): Assign number for the .shstrtab
  section after the symbol table and string table sections.

binutils
  * testsuite/binutils-all/readelf.s: Adjust expected ordering of
  sections.
  * testsuite/binutils-all/readelf.s-64: Likewise.

gas
  * testsuite/gas/i386/ilp32/x86-64-unwind.d: Adjust expected ordering
  of sections.
  * testsuite/gas/i386/x86-64-unwind.d: Likewise.
  * testsuite/gas/ia64/alias-ilp32.d: Likewise.
  * testsuite/gas/ia64/alias.d: Likewise.
  * testsuite/gas/ia64/group-1.d: Likewise.
  * testsuite/gas/ia64/group-2.d: Likewise.
  * testsuite/gas/ia64/secname-ilp32.d: Likewise.
  * testsuite/gas/ia64/secname.d: Likewise.
  * testsuite/gas/ia64/unwind-ilp32.d: Likewise.
  * testsuite/gas/ia64/unwind.d: Likewise.
  * testsuite/gas/ia64/xdata-ilp32.d: Likewise.
  * testsuite/gas/ia64/xdata.d: Likewise.
  * testsuite/gas/mmix/bspec-1.d: Likewise.
  * testsuite/gas/mmix/bspec-2.d: Likewise.
  * testsuite/gas/mmix/byte-1.d: Likewise.
  * testsuite/gas/mmix/loc-1.d: Likewise.
  * testsuite/gas/mmix/loc-2.d: Likewise.
  * testsuite/gas/mmix/loc-3.d: Likewise.
  * testsuite/gas/mmix/loc-4.d: Likewise.
  * testsuite/gas/mmix/loc-5.d: Likewise.
  * testsuite/gas/tic6x/scomm-directive-4.d: Likewise.

ld
  * testsuite/ld-alpha/tlsbin.rd: Adjust expected ordering of sections.
  * testsuite/ld-alpha/tlsbinr.rd: Likewise.
  * testsuite/ld-alpha/tlspic.rd: Likewise.
  * testsuite/ld-cris/libdso-2.d: Likewise.
  * testsuite/ld-i386/nogot1.d: Likewise.
  * testsuite/ld-i386/pr12718.d: Likewise.
  * testsuite/ld-i386/pr12921.d: Likewise.
  * testsuite/ld-i386/tlsbin-nacl.rd: Likewise.
  * testsuite/ld-i386/tlsbin.rd: Likewise.
  * testsuite/ld-i386/tlsbin2-nacl.rd: Likewise.
  * testsuite/ld-i386/tlsbin2.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-i386/tlspic2-nacl.rd: Likewise.
  * testsuite/ld-i386/tlspic2.rd: Likewise.
  * testsuite/ld-ia64/tlsbin.rd: Likewise.
  * testsuite/ld-ia64/tlspic.rd: Likewise.
  * testsuite/ld-mips-elf/attr-gnu-4-10.d: Likewise.
  * testsuite/ld-mips-elf/attr-gnu-4-50.d: Likewise.
  * testsuite/ld-mips-elf/attr-gnu-4-60.d: Likewise.
  * testsuite/ld-mips-elf/attr-gnu-4-70.d: Likewise.
  * testsuite/ld-mmix/bspec1.d: Likewise.
  * testsuite/ld-mmix/bspec2.d: Likewise.
  * testsuite/ld-mmix/local1.d: Likewise.
  * testsuite/ld-mmix/local3.d: Likewise.
  * testsuite/ld-mmix/local5.d: Likewise.
  * testsuite/ld-mmix/local7.d: Likewise.
  * testsuite/ld-mmix/undef-3.d: Likewise.
  * testsuite/ld-powerpc/tlsexe.r: Likewise.
  * testsuite/ld-powerpc/tlsexe32.r: Likewise.
  * testsuite/ld-powerpc/tlsexetoc.r: Likewise.
  * testsuite/ld-powerpc/tlsso.r: Likewise.
  * testsuite/ld-powerpc/tlsso32.r: Likewise.
  * testsuite/ld-powerpc/tlstocso.r: 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/sh64/crange1.rd: Likewise.
  * testsuite/ld-sh/sh64/crange2.rd: Likewise.
  * testsuite/ld-sh/sh64/crange3-cmpct.rd: Likewise.
  * testsuite/ld-sh/sh64/crange3-media.rd: Likewise.
  * testsuite/ld-sh/sh64/crange3.rd: Likewise.
  * testsuite/ld-sh/sh64/crangerel1.rd: Likewise.
  * testsuite/ld-sh/sh64/crangerel2.rd: Likewise.
  * testsuite/ld-sh/tlsbin-2.d: Likewise.
  * testsuite/ld-sh/tlspic-2.d: Likewise.
  * testsuite/ld-sparc/gotop32.rd: Likewise.
  * testsuite/ld-sparc/gotop64.rd: Likewise.
  * testsuite/ld-sparc/tlssunbin32.rd: Likewise.
  * testsuite/ld-sparc/tlssunbin64.rd: Likewise.
  * testsuite/ld-sparc/tlssunnopic32.rd: Likewise.
  * testsuite/ld-sparc/tlssunnopic64.rd: Likewise.
  * testsuite/ld-sparc/tlssunpic32.rd: Likewise.
  * testsuite/ld-sparc/tlssunpic64.rd: 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/nogot1.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/tlsbin2-nacl.rd: Likewise.
  * testsuite/ld-x86-64/tlsbin2.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-x86-64/tlspic2-nacl.rd: Likewise.
  * testsuite/ld-x86-64/tlspic2.rd: Likewise.
  * testsuite/ld-xtensa/tlsbin.rd: Likewise.
  * testsuite/ld-xtensa/tlspic.rd: Likewise.
2016-08-19 09:16:30 +01:00
Alan Modra 626c539f2e Fix thinko in new weak undefined function test
* testsuite/ld-undefined/weak-undef.exp: Use unsupported not
	unresolved.
2016-08-18 20:28:29 +09:30
Alan Modra 90ac242072 Correct .dynsym sh_info
bfd/
	* elf-bfd.h (struct elf_link_hash_table): Add local_dynsymcount.
	* elflink.c (_bfd_elf_link_renumber_dynsyms): Set local_dynsymcount.
	(bfd_elf_final_link): Set .dynsym sh_info from local_dynsymcount.
ld/
	* testsuite/ld-tic6x/shlib-1.rd: Correct expected .dynsym sh_info.
	* 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.
2016-08-13 00:07:20 +09:30
Alan Modra bf174910c8 Add undefined weak function tests
* testsuite/ld-undefined/weak-fundef.s: New.
	* testsuite/ld-undefined/weak-undef.t: Don't specify filename.
	* testsuite/ld-undefined/weak-undef.exp: Run new tests.  Rearrange
	much of old code.  Use is_elf_format to select targets.
2016-08-12 14:34:49 +09:30
Alan Modra 8be1e36919 Fix ERROR: target-cc does not exist
PR ld/20436
	* testsuite/lib/ld-lib.exp (at_least_gcc_version): Don't ignore
	remote_exec status.
	(check_gcc_plugin_enabled): Likewise.
2016-08-11 23:53:18 +09:30
Nick Clifton 7f6bf02d58 Avoid testsuite errors about missing compilers.
PR ld/20436
	* testsuite/lib/ld-lib.exp (check_gcc_plugin_enabled): When not
	testing remotely, check to see if target compiler is installed
	before trying to run it.
2016-08-11 10:22:41 +01:00
Maciej W. Rozycki 3807734dbe PR ld/15428: MIPS/LD/testsuite: Un-KFAIL `__ehdr_start' test 2
Complement commit b75d42bce5 ("Fix mips segfault on GOT access of
absolute symbol") and unmark the `__ehdr_start' test 2 as known to fail
for the n32 and n64 ABIs, as with the change referred in place the
causing issue has been properly addressed and consequently the tests do
not fail anymore and neither are supposed to.

	ld/
	PR ld/15428
	* testsuite/ld-mips-elf/mips-elf.exp: Un-KFAIL `__ehdr_start'
	test 2.
2016-08-11 00:54:41 +01:00
Maciej W. Rozycki 0375b0a537 MIPS/LD/testsuite: Verify microMIPS LA25 stub generation
Repeat `PIC and non-PIC test 1' checks for microMIPS LA25 stubs,
covering code generation and stub symbol annotation.

	ld/
	* testsuite/ld-mips-elf/pic-and-nonpic-1-micromips-rel.dd: New
	test.
	* testsuite/ld-mips-elf/pic-and-nonpic-1-micromips-rel.nd: New
	test.
	* testsuite/ld-mips-elf/pic-and-nonpic-1-micromips.dd: New test.
	* testsuite/ld-mips-elf/pic-and-nonpic-1-micromips.nd: New test.
	* testsuite/ld-mips-elf/pic-and-nonpic-1a-micromips.s: New test
	source.
	* testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s: New test
	source.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2016-08-10 22:24:43 +01:00
H.J. Lu 5ff559107a Skip LTO tests for --disable-plugin
Don't run LTO tests if compiler is configured with --disable-plugin.

	PR ld/20436
	* testsuite/lib/ld-lib.exp (check_gcc_plugin_enabled): New
	proc.
	(check_lto_available): Return 0 if check_gcc_plugin_enabled
	returns 0.
	(check_lto_fat_available): Likewise.
	(check_lto_shared_available): Likewise.
2016-08-09 16:41:29 -07:00
Roland McGrath 7cfee229f1 Support -pie for arm*-eabi targets.
ld/
	* emulparams/armelf.sh (GENERATE_PIE_SCRIPT): Set to yes.
2016-08-09 12:09:17 -07:00
H.J. Lu ed1b027aa0 Add missing ChangLog enrtry 2016-08-05 13:15:16 -07:00
Thomas Preud'homme 54ddd295b5 2016-08-04 Thomas Preud'homme <thomas.preudhomme@arm.com>
bfd/
	* bfd-in.h (bfd_elf32_arm_set_target_relocs): Add one parameter.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (struct elf32_arm_link_hash_table): Declare new
	cmse_implib field.
	(bfd_elf32_arm_set_target_relocs): Add new parameter to initialize
	cmse_implib field in struct elf32_arm_link_hash_table.
	(elf32_arm_filter_cmse_symbols): New function.
	(elf32_arm_filter_implib_symbols): Likewise.
	(elf_backend_filter_implib_symbols): Define to
	elf32_arm_filter_implib_symbols.

ld/
	* emultempl/armelf.em (cmse_implib): Declare and define this new
	static variable.
	(arm_elf_create_output_section_statements): Add new cmse_implib
	parameter.
	(OPTION_CMSE_IMPLIB): Define macro.
	(PARSE_AND_LIST_LONGOPTS): Add entry for new --cmse-implib switch.
	(PARSE_AND_LIST_OPTIONS): Likewise.
	(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_CMSE_IMPLIB case.
	* ld.texinfo (--cmse-implib): Document new option.
	* testsuite/ld-arm/arm-elf.exp
	(Secure gateway import library generation): New test.
	(Secure gateway import library generation: errors): Likewise.
	* testsuite/ld-arm/cmse-implib.s: New file.
	* testsuite/ld-arm/cmse-implib-errors.out: Likewise.
	* testsuite/ld-arm/cmse-implib.rd: Likewise.
2016-08-04 15:54:57 +01:00
Thomas Preud'homme 4ba2ef8fbe 2016-08-04 Thomas Preud'homme <thomas.preudhomme@arm.com>
bfd/
	* elf32-arm.c (CMSE_PREFIX): Define macro.
	(elf32_arm_stub_cmse_branch_thumb_only): Define stub sequence.
	(cmse_branch_thumb_only): Declare stub.
	(struct elf32_arm_link_hash_table): Define cmse_stub_sec field.
	(elf32_arm_get_plt_info): Add globals parameter.  Use it to return
	FALSE if there is no PLT.
	(arm_type_of_stub): Adapt to new elf32_arm_get_plt_info signature.
	(elf32_arm_final_link_relocate): Likewise.
	(elf32_arm_gc_sweep_hook): Likewise.
	(elf32_arm_gc_mark_extra_sections): Mark sections holding ARMv8-M
	secure entry functions.
	(arm_stub_is_thumb): Add case for arm_stub_cmse_branch_thumb_only.
	(arm_dedicated_stub_output_section_required): Change to a switch case
	and add a case for arm_stub_cmse_branch_thumb_only.
	(arm_dedicated_stub_output_section_required_alignment): Likewise.
	(arm_stub_dedicated_output_section_name): Likewise.
	(arm_stub_dedicated_input_section_ptr): Likewise and remove
	ATTRIBUTE_UNUSED for htab parameter.
	(arm_stub_required_alignment): Likewise.
	(arm_stub_sym_claimed): Likewise.
	(arm_dedicated_stub_section_padding): Likewise.
	(cmse_scan): New function.
	(elf32_arm_size_stubs): Call cmse_scan for ARM M profile targets.
	Set stub_changed to TRUE if such veneers were created.
	(elf32_arm_swap_symbol_in): Add detection code for CMSE special
	symbols.

include/
	* arm.h (ARM_GET_SYM_CMSE_SPCL): Define macro.
	(ARM_SET_SYM_CMSE_SPCL): Likewise.

ld/
	* ld.texinfo (Placement of SG veneers): New concept entry.
	* testsuite/ld-arm/arm-elf.exp
	(Secure gateway veneers: no .gnu.sgstubs section): New test.
	(Secure gateway veneers: wrong entry functions): Likewise.
	(Secure gateway veneers (ARMv8-M Baseline)): Likewise.
	(Secure gateway veneers (ARMv8-M Mainline)): Likewise.
	* testsuite/ld-arm/cmse-veneers.s: New file.
	* testsuite/ld-arm/cmse-veneers.d: Likewise.
	* testsuite/ld-arm/cmse-veneers.rd: Likewise.
	* testsuite/ld-arm/cmse-veneers.sd: Likewise.
	* testsuite/ld-arm/cmse-veneers-no-gnu_sgstubs.out: Likewise.
	* testsuite/ld-arm/cmse-veneers-wrong-entryfct.out: Likewise.
2016-08-04 15:36:52 +01:00