Commit Graph

2056 Commits

Author SHA1 Message Date
Jan Beulich 61b86cb194 ld: don't use ia64 register name in expression of pr16322 test
"f1" is a register name on ia64, and hence gets warned upon when used
as expression value:

.../binutils/2.25/ld/testsuite/ld-elf/pr16322.s: Assembler messages:
.../binutils/2.25/ld/testsuite/ld-elf/pr16322.s:6: Warning: register value used as expression

Change the name (and "p1" at once, which is a register name too, albeit
not currently causing any immediate problem).

ld/testsuite/
2015-01-28  Jan Beulich  <jbeulich@suse.com>

	* ld-elf/pr16322.s (p1): Rename to px1.
	(f1): Rename to fx1.
2015-01-28 10:04:51 +01:00
Alan Modra dbd1e97e32 PowerPC64 changes for xlc
The changes to reorder sections for better relro protection on powerpc64,
3e2b0f31, 23283c1b, and 5ad18f16, run into a problem with xlc.
xlc -qdatalocal puts global variables into .toc, which means that .toc
must be writable.  The simplest way to accomplish this is to edit the
linker script to remove .toc sections from .got on detecting xlc object
files.

bfd/
	* elf64-ppc.h (struct ppc64_elf_params): Add "object_in_toc".
	* elf64-ppc.c (ppc64_elf_add_symbol_hook): Assume that global symbols
	in .toc indicate xlc compiled code that might require a rw .toc.
ld/
	* emulparams/elf64ppc.sh (INITIAL_READWRITE_SECTIONS): Define.
	* emultempl/ppc64elf.em (params): Init new field.
	(ppc_after_open): New function.
	(LDEMUL_AFTER_OPEN): Define.
	* ldlang.c (lang_final): Whitespace fix.
ld/testsuite/
	* ld-powerpc/tocvar.d, * ld-powerpc/tocvar.s: New test.
	* ld-powerpc/tocnovar.d, * ld-powerpc/tocnovar.s: New test.
	* ld-powerpc/powerpc.exp: Run tocvar and tocnovar.
2015-01-28 18:30:54 +10:30
Senthil Kumar Selvaraj cc9ad334a7 Allow symbols in MEMORY region specification
This patch fixes PR 4643 by allowing symbols in the LENGTH and ORIGIN
fields of MEMORY regions.  Previously, only constants and constant
expressions are allowed.

For the AVR target, this helps define memory constraints more
accurately (per device), without having to create a ton of device
specific linker scripts.

ld/
	PR 4643
	* ldexp.c (fold_name): Fold LENGTH only after
	lang_first_phase_enum.
	* ldgram.y (memory_spec): Don't evaluate ORIGIN and LENGTH
	rightaway.
	* ldlang.h (struct memory_region_struct): Add origin_exp and
	length_exp fields.
	* ldlang.c (lang_do_memory_regions): New.
	(lang_memory_region_lookup): Initialize origin_exp and
	length_exp fields.
	(lang_process): Call lang_do_memory_regions.
ld/testsuite/
	* ld-scripts/memory.t: Define new symbol tred.
	* ld-scripts/memory_sym.t: New.
	* ld-scripts/script.exp: Perform MEMORY with symbols test, and
	conditionally check values of linker symbols.
2015-01-28 15:06:48 +10:30
Andrew Burgess 481765cde0 ld: Update expected test results for 32-bit hosts.
Tests that I added in commit c05b575a8d
fails on 32-bit hosts due to differences in whitespace.

This patch updates the expected output patterns to be more accepting of
differences in whitespace, the tests should now pass.

ld/testsuite/ChangeLog:

	* ld-scripts/provide-4-map.d: Update expected output.
	* ld-scripts/provide-5-map.d: Likewise.
2015-01-20 16:03:32 +00:00
Andrew Burgess c05b575a8d ld: Don't evaluate unneeded PROVIDE expressions.
When creating a linker mapfile (using -Map=MAPFILE), we previously would
always try to evaluate the expression from a PROVIDE statement.

However, this is not always safe, consider:

  PROVIDE (foo = 0x10);
  PROVIDE (bar = foo);

In this example, if neither 'foo' or 'bar' is needed, then while
generating the linker mapfile evaluating the expression for 'foo' is
harmless (just the value 0x10).  However, evaluating the expression for
'bar' requires the symbol 'foo', which is undefined.  This used to cause
a fatal error.

This patch changes the behaviour, so that when the destination of the
PROVIDE is not defined (that is the PROVIDE is not going to provide
anything) the expression is not evaluated, and instead a special string
is displayed to indicate that the linker is discarding the PROVIDE
statement.

This change not only fixes the spurious undefined symbol error, but also
means that a user can now tell if a PROVIDE statement has provided
anything by inspecting the linker mapfile, something that could not be
done before.

ld/ChangeLog:

	* ldlang.c (print_assignment): Only evaluate the expression for a
	PROVIDE'd assignment when the destination is being defined.
	Display a special message for PROVIDE'd symbols that are not being
	provided.

ld/testsuite/ChangeLog:

	* ld-scripts/provide-4.d: New file.
	* ld-scripts/provide-4-map.d: New file.
	* ld-scripts/provide-4.t: New file.
	* ld-scripts/provide-5.d: New file.
	* ld-scripts/provide-5.s: New file.
	* ld-scripts/provide-5-map.d: New file.
	* ld-scripts/provide-5.t: New file.
	* ld-scripts/provide.exp: Run the provide-4.d and provide-5.d
	tests.
2015-01-20 09:49:27 +00:00
Andrew Burgess 43d66c95c8 ld/testing: run_dump_test can now check linker mapfiles.
Add a new option 'map' to the ld run_dump_test mechanism.  When the
'map' option is given run_dump_test will ensure that there is a
-Map=MAPFILE present in the linker command line, adding one if needed.

The MAPFILE is then compared with the file passed to the new 'map'
option using the regexp_diff function.  This should make it slightly
easier to write tests that check the linker mapfile output.

The only test I found that already compares mapfile content is updated
to use the new mechanism.

ld/testsuite/ChangeLog:

	* ld-scripts/overlay-size.d: Add 'map' option.
	* ld-scripts/overlay-size.exp: Remove manual check of mapfile.
	* lib/ld-lib.exp (run_dump_test): Add support for new 'map'
	option, checking linker mapfile output.
2015-01-20 09:47:37 +00:00
Alan Modra 23283c1be0 Reorder more powerpc64 sections for -z relro
This moves .got too, which requires .sdata and .sbss to move with it,
because these sections share addressing via the toc pointer and with
small-model code must be within a 16-bit signed offset.  .plt, .iplt
and .branch_lt must also be moved since they are addressed via a
32-bit offset from the toc pointer, and we might have a very large
.data section.

This change means we may have some bss style sections before the data
segment, necessitating another PT_LOAD header.  Also, since _edata is
defined at the end of the data segment it's possible with an empty
.data to have _edata at the end of .plt which looks a little unusual
since .plt is a bss style section.  That should only happen rarely in
real world binaries, but does occur in the ld testsuite.

ld/
	* emulparams/elf64ppc.sh (BSS_PLT): Don't define.
	(OTHER_READWRITE_SECTIONS): Move .branch_lt to..
	(OTHER_RELRO_SECTIONS_2): ..here.
	(DATA_GOT, SEPARATE_GOTPLT, DATA_SDATA, DATA_PLT,
	PLT_BEFORE_GOT): Define.
	* scripttempl/elf.sc: Handle DATA_SDATA and DATA_GOT/DATA_PLT/
	PLT_BEFORE_GOT combination.
	(DATA_GOT, SDATA_GOT): Don't define if either is already defined.
ld/testsuite/
	* ld-powerpc/ambiguousv1.d,
	* ld-powerpc/ambiguousv1b.d,
	* ld-powerpc/ambiguousv2.d,
	* ld-powerpc/ambiguousv2b.d,
	* ld-powerpc/elfv2exe.d,
	* ld-powerpc/elfv2so.d,
	* ld-powerpc/tlsexe.r,
	* ld-powerpc/tlsexetoc.r,
	* ld-powerpc/tlsso.r,
	* ld-powerpc/tlstocso.r: Update.
2015-01-20 19:52:42 +10:30
Alan Modra 10ab94ebf8 Fix pr17615 testcase
PR ld/17615
	* ld-elf/pr17615.d: Match .sbss too.
2015-01-20 11:12:35 +10:30
H.J. Lu 3e2aa5bbd3 Add a testcase for PR ld/17615
PR ld/17615
	* ld-elf/pr17615.d: New file.
	* ld-elf/pr17615.s: Likewise.
2015-01-19 09:23:29 -08:00
Alan Modra c4621b339e Fix garbage collection of common symbols
Running lang_common before garbage collection means slightly less work
in garbage collection code, since common symbols should no longer
appear there.  It does have the side effect of keeping linker script
symbols (at least those defined outside of sections) global too,
hence some testsuite churn.

bfd/
	PR 17165
	* elf-bfd.h (ELF_COMMON_DEF): Note that this might be true for
	linker script assignments too.
	* elflink.c (elf_gc_sweep_symbol): Don't drop ELF_COMMON_DEF syms.
	(bfd_elf_gc_mark_dynamic_ref_symbol): Similarly.
ld/
	PR 17165
	* ldlang.c (lang_process): Run lang_common before lang_gc_sections.
ld/testsuite/
	* ld-gc/pr14265.d,
	* ld-cris/tls-gc-68.d,
	* ld-cris/tls-gc-69.d,
	* ld-cris/tls-gc-70.d,
	* ld-cris/tls-gc-71.d,
	* ld-cris/tls-gc-75.d,
	* ld-cris/tls-gc-76.d,
	* ld-cris/tls-gc-79.d,
	* ld-mmix/bpo-10.d,
	* ld-mmix/bpo-11.d: Update.
2015-01-19 21:26:30 +10:30
Andreas Krebbel 1e2e8c529c S/390: Add support for IBM z13.
- 32 128 bit vector registers (overlapping with the existing 16 64 bit
  floating point registers)
- vector double instructions
- vector integer instructions
- scalar vector instructions (allowing to have more floating point
  registers for scalar operations)
- vector string instructions

gas/ChangeLog:

	* config/tc-s390.c (struct pd_reg): Remove.
	(pre_defined_registers): Remove.
	(REG_NAME_CNT): Remove.
	(reg_name_search): Calculate the register number instead of doing
	a lookup.
	(register_name, tc_s390_regname_to_dw2regnum): Adopt to the new
	reg_name_search signature.
	(s390_parse_cpu): Support the new arch string z13.
	(s390_insert_operand): Support for vector registers with the extra
	field for the fifth bit of each vector register operand.
	(md_gather_operand): Adjust to the new handling of optional
	parameters.

	* doc/as.texinfo: Document the z13 cpu string.

gas/testsuite/ChangeLog:

	* gas/s390/esa-g5.d: Add a variant without the optional operand.
	* gas/s390/esa-g5.s: Likewise.
	* gas/s390/esa-z9-109.d: Likewise.
	* gas/s390/esa-z9-109.s: Likewise.
	* gas/s390/zarch-z9-109.d: Likewise.
	* gas/s390/zarch-z9-109.s: Likewise.
	* gas/s390/zarch-z10.d: For variants with a zero optional argument
	it is not dumped by objdump anymore.
	* gas/s390/zarch-zEC12.d: Likewise.

	* gas/s390/zarch-z13.d: New file.
	* gas/s390/zarch-z13.s: New file.
	* gas/s390/s390.exp: Run the test for the z13 files.

include/opcode/ChangeLog:

	* s390.h (s390_opcode_cpu_val): Add S390_OPCODE_Z13.

ld/testsuite/ChangeLog:

	* ld-s390/tlsbin.dd: The nopr register operand is optional and not
	printed if 0 anymore.

opcodes/ChangeLog:

	* s390-dis.c (s390_extract_operand): Support vector register
	operands.
	(s390_print_insn_with_opcode): Support new operands types and add
	new handling of optional operands.
	* s390-mkopc.c (s390_opcode_mode_val, s390_opcode_cpu_val): Remove
	and include opcode/s390.h instead.
	(struct op_struct): New field `flags'.
	(insertOpcode, insertExpandedMnemonic): New parameter `flags'.
	(dumpTable): Dump flags.
	(main): Parse flags from the s390-opc.txt file.  Add z13 as cpu
	string.
	* s390-opc.c: Add new operands types, instruction formats, and
	instruction masks.
	(s390_opformats): Add new formats for .insn.
	* s390-opc.txt: Add new instructions.
2015-01-16 12:28:58 +01:00
H.J. Lu 6333bc0dd6 Don't complain about -fPIC for undefined symbol
When building executable, undefined symbol is a fatal error.  We don't
complain about -fPIC if the symbol is undefined.

bfd/

	PR ld/17847
	* elf64-x86-64.c (elf_x86_64_relocate_section): Don't complain
	about -fPIC if the symbol is undefined when building executable.

ld/testsuite/

	PR ld/17847
	* ld-x86-64/pie1.d: New file.
	* ld-x86-64/pie1.s: Likwise.
	* ld-x86-64/x86-64.exp: Run pie1.
2015-01-15 11:08:59 -08:00
Jiong Wang 0941db698e [AArch64] Fix function pointer variable with -Bsymbolic-functions
bfd/ChangeLog

2015-01-13 Thomas Preud'homme <thomas.preudhomme@arm.com>

    * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Use
    SYMBOLIC_BIND to check if a symbol should be bound symbolically.

ld/testsuite/ChangeLog

2015-01-13 Thomas Preud'homme <thomas.preudhomme@arm.com>

    * ld-aarch64/aarch64-elf.exp: Added relocs-257-symbolic-func test.
    * ld-aarch64/relocs-257-symbolic-func.d: New file.
    * ld-aarch64/relocs-257-symbolic-func.s: Likewise.
2015-01-13 11:36:54 +00:00
Jiong Wang 0172429c3b [AArch64] Enable overflow check for TLSLE_MOVW_TPREL_G2
bfd/
    * elfnn-aarch64.c: (elfNN_aarch64_howto_table): Enable overflow check for
    TLSLE_MOVW_TPREL_G2.

  ld/testsuite/
    * ld-aarch64/tprel_g2_overflow.s: New testcase.
    * ld-aarch64/tprel_g2_overflow.d: New expectation file.
    * ld-aarch64/aarch64-elf.exp: Run new testcase.
2015-01-13 11:21:43 +00:00
Jiong Wang bab91cce20 [AArch64] Enable overflow check for R_AARCH64_TLSLE_ADD_TPREL_HI12
bfd/
    PR ld/17415
    * elfnn-aarch64.c (elfNN_aarch64_howto_table): Mark
    R_AARCH64_TLSLE_ADD_TPREL_HI12 as complain_overflow_unsigned.
    * elfxx-aarch64.c (_bfd_aarch64_elf_resolve_relocation): Correct the bit
    mask.

  ld/testsuite/
    PR ld/17415
    * ld-aarch64/pr17415.s: Source file for new test.
    * ld-aarch64/pr17415.d: Expect file for new test.
    * ld-aarch64/aarch64-elf.exp: Run the new test.
2015-01-13 11:18:10 +00:00
H.J. Lu 9d1d54d5a7 Only discard space for pc-relative relocs symbols
When building PIE, we should only discard space for pc-relative relocs
symbols which turn out to need copy relocs.

bfd/

	PR ld/17827
	* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): For PIE,
	only discard space for pc-relative relocs symbols which turn
	out to need copy relocs.

ld/testsuite/

	PR ld/17827
	* ld-x86-64/pr17689.out: Updated.
	* ld-x86-64/pr17689b.S: Likewise.

	* ld-x86-64/pr17827.rd: New file.

	* ld-x86-64/x86-64.exp: Run PR ld/17827 test.
2015-01-11 08:04:27 -08:00
Jan Beulich 2279a12a44 ld/x86-64: adjust pr14207 test expectations
The original test output expectations cause it to fail when configure
determines enable_initfini_array=no (which was observed on a cross
build on an old 32-bit host, pointing out that taking into account host
properties in such a case is bogus anyway).

ld/testsuite/
2015-01-08  Jan Beulich  <jbeulich@suse.com>

	* ld-x86-64/pr14207.d: Adjust expecations to cover the
	enable_initfini_array=no case.
2015-01-08 14:10:36 +01:00
Andrew Burgess 8d983e3645 ld/testing: Extend comment on run_dump_test
Mention that readelf can be used as a test program in the comment of
run_dump_test.

ld/testsuite/ChangeLog:

	* lib/ld-lib.exp (run_dump_test): Extend comment to mention
	readelf.
2015-01-07 10:53:04 +00:00
Alan Modra b90efa5b79 ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
H.J. Lu ee3b52e917 Assign file position for .strtab only if needed
bfd/

	PR ld/17773
	* elflink.c (bfd_elf_final_link): Assign the file position for
	the symbol string table only there are symbols to be emitted.

ld/testsuite/

	PR ld/17773
	* ld-elf/binutils.exp (binutils_test): Add an optional
	readelf_options.  Replace -l with $readelf_options.  Add a
	gap test.
	* ld/testsuite/ld-elf/gap.s: New file.
2014-12-30 19:09:11 -08:00
Alan Modra bd47fe1c2e Update two sh64 ld test's expected output
At some stage someone fixed a bug in ld -r output, preserving
SHF_INFO_LINK from input objects.  These two tests expected the old
wrong output.

	* ld-sh/sh64/crangerel1.rd: Update.
	* ld-sh/sh64/crangerel2.rd: Update.
2014-12-26 22:19:30 +10:30
Terry Guo 5c294fee9a ARM: Add support for value 3 of Tag_ABI_VFP_args attribute
*** bfd/ChangeLog ***

2014-12-25  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* elf32-arm.c (elf32_arm_merge_eabi_attributes): Handle new
	Tag_ABI_VFP_args value and replace hardcoded values by enum
	values.
	(elf32_arm_post_process_headers): Set e_flags in ELF header
	as hard float only when Tag_ABI_VFP_args is 1, using new enum
	value AEABI_VFP_args_vfp to check that.

*** binutils/ChangeLog ***

2014-12-25  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* readelf.c (arm_attr_tag_ABI_VFP_args): Add "compatible".

*** gdb/ChangeLog ***

2014-12-25  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* arm-tdep.c (arm_gdbarch_init): Explicitely handle value 3 of
	Tag_ABI_VFP_args. Also replace hardcoded values by enum values
	in the switch handling the different values of Tag_ABI_VFP_args.

*** gold/ChangeLog ***

2014-12-25  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* arm.cc (Target_arm::do_adjust_elf_header): Set e_flags in ELF
	header as hard float only when Tag_ABI_VFP_args is 1, using new
	enum value AEABI_VFP_args_vfp to check that.
	(Target_arm::merge_object_attributes): Handle new Tag_ABI_VFP_args
	value and replace hardcoded values by enum values.

*** include/elf/ChangeLog ***

2014-12-25  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* arm.h: New AEABI_FP_number_model_* and AEABI_VFP_args_* enum
	values.

*** ld/testsuite/ChangeLog ***

2014-12-25  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* ld-arm/attr-merge-2a.s: Add Tag_ABI_VFP_args.
	* ld-arm/attr-merge-2b.s: Likewise.
	* ld-arm/attr-merge-2.attr: Likewise.
	* ld-arm/attr-merge-4a.s: Add Tag_ABI_FP_number_model and
	Tag_ABI_VFP_args.
	* ld-arm/attr-merge-4b.s: Likewise.
	* ld-arm/attr-merge-4.attr: Likewise.
	* ld-arm/attr-merge-6a.s: Likewise.
	* ld-arm/attr-merge-6b.s: Likewise.
	* ld-arm/attr-merge-6.attr: Add Tag_ABI_FP_number_model.
2014-12-25 09:55:03 +08:00
Andrew Burgess edc9e9a62f AVR: Assembler now prepares for linker relaxation by default.
Have the assembler prepare for linker relaxation by default.  This
means that users will be able to make use of linker relaxation without
having to adjust the assembler flags, this can make life easier when
compiling libraries.

Having this on by default in the assembler should make no difference to
the assembler code produced, however, some of the debug information will
be slightly less compressed.

A few tests needed to be updated as a result of this change as they
relied on linker relaxation support being off by default.

I've tightened up the definition of which sections can be relaxed on AVR
as part of this commit, the assembler used to think that all
non-debugging sections could be relaxed, when in reality only code
sections can be relaxed for AVR.  The previous definition was not
dangerous, just over cautious.  The new tighter definition allows an
extra test (gas/testsuite/gas/all/forward.d) to continue to pass.

gas/ChangeLog:

	* config/tc-avr.c (struct avr_opt_s): Change link_relax to
	no_link_relax, extend comment.
	(enum options): Add new OPTION_NO_LINK_RELAX.
	(md_longopts): Add entry for -mno-link-relax.
	(md_parse_option): Handle OPTION_NO_LINK_RELAX, and update
	OPTION_LINK_RELAX.
	(md_begin): Initialise linkrelax from no_link_relax.
	(md_show_usage): Include -mno-link-relax option.
	(relaxable_section): Only allocatable code sections can be
	relaxed.
	* config/tc-avr.h (TC_LINKRELAX_FIXUP): Define.

gas/testsuite/ChangeLog:

	* gas/all/gas.exp: Test will not pass on AVR due to linker
	relaxation support.
	* gas/avr/noreloc_withoutrelax.d: Add -mno-link-relax option.
	* gas/avr/link-relax-elf-flag-clear.d: Likewise.

ld/testsuite/ChangeLog:

	* ld/testsuite/ld-avr/relax-elf-flags-02.d: Add -mno-link-relax
	option.
	* ld/testsuite/ld-avr/relax-elf-flags-03.d: Likewise.
	* ld/testsuite/ld-avr/relax-elf-flags-04.d: Likewise.
	* ld/testsuite/ld-avr/relax-elf-flags-05.d: Likewise.
	* ld/testsuite/ld-avr/relax-elf-flags-06.d: Likewise.
2014-12-24 21:27:43 +00:00
Alan Modra 931804de6c Yet another DEFINED testcase
* ld-scripts/defined6.s,
	* ld-scripts/defined6.t,
	* ld-scripts/defined6.d: New test.
	* ld-scripts/defined.exp: Run it.
2014-12-24 11:56:51 +10:30
Andrew Burgess 9d7b48dc6e AVR/ld: Propagate link-relax elf header flag correctly.
The AVR target has an elf header flag to indicate if an object was
assembler ready for linker relaxation.  If a partial link is performed
then it is important that the link-relax flag in the output object is
set correctly, otherwise, during the final link, we might try to perform
linker relaxation on code that was not assembled suitably.

As the link-relax elf header covers the entire object file we must be
conservative when setting the flag in the output object, so, for a
partial link, any input object that does not have the link-relax flag
set will cause the output object to also not have the link-relax flag
set.

This conservative approach could be softened in future, we only need to
disable the link relax flag if an input file is not marked link-relax
ready, and the input file contains a relaxable section.  However, I've
left this optimisation for a later day.

For the final link I've overloaded the use of the link-relax elf header
flag, in a final executable, the flag now indicates if the executable
was built with linker relaxation on or not.

ld/ChangeLog:

	* emultempl/avrelf.em: Add include of elf/avr.h.
	(avr_finish): New function.
	(LDEMUL_FINISH): Added.

ld/testsuite/ChangeLog:

	* ld-avr/relax-elf-flags-01.d: New file.
	* ld-avr/relax-elf-flags-02.d: New file.
	* ld-avr/relax-elf-flags-03.d: New file.
	* ld-avr/relax-elf-flags-04.d: New file.
	* ld-avr/relax-elf-flags-05.d: New file.
	* ld-avr/relax-elf-flags-06.d: New file.
	* ld-avr/relax-elf-flags-07.d: New file.
	* ld-avr/relax-elf-flags-08.d: New file.
	* ld-avr/relax-elf-flags-a.s: New file.
	* ld-avr/relax-elf-flags-b.s: New file.
2014-12-23 15:45:11 +00:00
Alan Modra 12b2843a6b Use a symbol flag bit to mark linker defined symbols
Trying to use the SEC_LINKER_CREATED section flag to determine whether
a symbol is linker defined fails to work on targets like alpha that
define special SEC_COMMON sections.  These might contain symbols that
originated in an object file.

include/
	* bfdlink.h (struct bfd_link_hash_entry): Comment non_ir_ref.  Add
	linker_def.
bfd/
	* elflink.c (_bfd_elf_define_linkage_sym): Set linker_def.
	* linker.c (_bfd_generic_link_add_one_symbol): Clear linker_def
	for CDEF, DEF, DEFW, COM.
ld/
	* ldexp.c (exp_fold_tree_1 <etree_provide>): Test linker_def.
ld/testsuite/
	* ld-powerpc/sdabase.s,
	* ld-powerpc/sdabase.t,
	* ld-powerpc/sdabase.d: New test.
	* ld-powerpc/sdabase2.t,
	* ld-powerpc/sdabase2.d: New test.
	* ld-powerpc/powerpc.exp: Run them.
2014-12-23 23:36:50 +10:30
Alan Modra 4cc2bf08a4 Don't PROVIDE over top of common symbols
This:
  int end[100000];
  int main(void) { end[99999] = 0; return 0; }
should not segfault.

ld/
	* ldexp.c (exp_fold_tree_1 <etree_provide>): Leave bfd_link_hash_common
	symbols alone.
ld/testsuite/
	* ld-elf/endsym.s, *ld-elf/endsym.d: New test.
2014-12-23 23:36:50 +10:30
Matthew Fortune d340a82588 Fix all failing FPXX tests for tx39-elf.
ld/testsuite/

	* ld-mips-elf/attr-gnu-4-00.d: Relax check for ISA extension.
	* ld-mips-elf/attr-gnu-4-01.d: Likewise.
	* ld-mips-elf/attr-gnu-4-02.d: Likewise.
	* ld-mips-elf/attr-gnu-4-03.d: Likewise.
	* ld-mips-elf/attr-gnu-4-08.d: Likewise.
	* ld-mips-elf/attr-gnu-4-10.d: Likewise.
	* ld-mips-elf/attr-gnu-4-11.d: Likewise.
	* ld-mips-elf/attr-gnu-4-18.d: Likewise.
	* ld-mips-elf/attr-gnu-4-20.d: Likewise.
	* ld-mips-elf/attr-gnu-4-22.d: Likewise.
	* ld-mips-elf/attr-gnu-4-28.d: Likewise.
	* ld-mips-elf/attr-gnu-4-30.d: Likewise.
	* ld-mips-elf/attr-gnu-4-33.d: Likewise.
	* ld-mips-elf/attr-gnu-4-38.d: Likewise.
	* ld-mips-elf/attr-gnu-4-44.d: Likewise.
2014-12-19 14:20:17 +00:00
Matthew Fortune 6e8ec71244 Fix undefined weak symbol reloc tests
ld/testsuite/

	* ld-mips-elf/mips-elf.exp: Update undefweak-overflow tests.
	* ld-mips-elf/undefweak-overflow-n32.d: Remove.
	* ld-mips-elf/undefweak-overflow-n64.d: Likewise.
	* ld-mips-elf/undefweak-overflow.s: Set mips64r6, noreorder and
	add a label to mark the micromips region.
	* ld-mips-elf/undefweak-overflow.d: Update expected output.
2014-12-19 14:19:42 +00:00
H.J. Lu bc696fd5af Handle weak alias for PIE with copy reloc
When there is a weak symbol with a real definition, the processor
independent code will have arranged for us to see the real definition
first.  We need to copy the needs_copy bit from the real definition and
check it when allowing copy reloc in PIE.

bfd/

	PR ld/17689
	* elf64-x86-64.c (elf_x86_64_link_hash_entry): Add needs_copy.
	Change has_bnd_reloc to bit field.
	(elf_x86_64_link_hash_newfunc): Initialize needs_copy and
	has_bnd_reloc to 0.
	(elf_x86_64_check_relocs): Set has_bnd_reloc to 1 instead
	of TRUE.
	(elf_x86_64_adjust_dynamic_symbol): Copy needs_copy from the
	real definition to a weak symbol.
	(elf_x86_64_allocate_dynrelocs): Also check needs_copy of a
	weak symbol for PIE when discarding space for relocs against
	symbols which turn out to need copy relocs.
	(elf_x86_64_relocate_section): Also check needs_copy of a
	weak symbol for PIE with copy reloc.

ld/testsuite/

	PR ld/17689
	* ld-x86-64/pr17689.out: New file.
	* ld-x86-64/pr17689.rd: Likewise.
	* ld-x86-64/pr17689a.c: Likewise.
	* ld-x86-64/pr17689b.S: Likewise.

	* ld-x86-64/x86-64.exp: Run PR ld/17689 tests.
2014-12-13 23:39:56 -08:00
Eric Botcazou c18392d87d Add Visium support to ld
ld/
	* configure.tgt: Add Visium support.
	* Makefile.am (ALL_EMULATION_SOURCES): Add eelf32visium.c.
	(eelf32visium.c): New rule.
	* Makefile.in: Regenerate.
	* emulparams/elf32visium.sh: New file.
	* scripttempl/visium.sc: Likewise.
ld/testsuite/
	* lib/ld-lib.exp (check_shared_lib_support): Return 0 for Visium.
	* ld-visium/: New directory.
2014-12-06 16:45:22 +01:00
Alan Modra 53df40a43c Sort relocs output by ld -r
bfd/
	PR 17666
	* elflink.c: Include bfd_stdint.h.
	(cmp_ext32l_r_offset, cmp_ext32b_r_offset,
	cmp_ext64l_r_offset, cmp_ext64b_r_offset): New functions.
	(elf_link_adjust_relocs): Sort relocs.  Free reloc hashes after
	sorting invalidates.
ld/testsuite/
	* ld-powerpc/vxworks-relax.rd: Update for reloc sorting.
	* ld-powerpc/vxworks-relax-2.rd: Likewise.
	* ld-sh/sh64/reldl32.rd: Likewise.
	* ld-sh/sh64/reldl64.rd: Likewise.
2014-12-04 17:37:58 +10:30
H.J. Lu 01bbed2a55 Replace copyreloc-main.c with copyreloc-main.S
* ld-x86-64/copyreloc-main.c: Removed.
	* ld-x86-64/copyreloc-main.S: New.
	* ld-x86-64/x86-64.exp: Replace copyreloc-main.c with
	copyreloc-main.S.
2014-12-03 08:52:00 -08:00
H.J. Lu 9a926d55ab X86-64: Allow copy relocs for building PIE
This patch allows copy relocs for non-GOT pc-relative relocation in PIE.

bfd/

	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Always
	allow copy relocs for building executables.
	(elf_x86_64_check_relocs): Allow copy relocs for non-GOT
	pc-relative relocation in shared object.
	(elf_x86_64_adjust_dynamic_symbol): Allocate copy relocs for
	PIE.
	(elf_x86_64_relocate_section): Don't copy a pc-relative
	relocation into the output file if the symbol needs copy reloc.

ld/testsuite/

	* ld-x86-64/copyreloc-lib.c: New file.
	* ld-x86-64/copyreloc-main.c: Likewise.
	* ld-x86-64/copyreloc-main.out: Likewise.
	* ld-x86-64/copyreloc-main1.rd: Likewise.
	* ld-x86-64/copyreloc-main2.rd: Likewise.

	* ld-x86-64/x86-64.exp: Run copyreloc tests.
2014-12-02 15:19:25 -08:00
Andrew Bennett 538baf8b7e [MIPS] When calculating a relocation using an undefined weak symbol don't check for overflow.
In MIPS the relocation calculation only ignores the overflow checks for undefined
weak symbols on relocations associated with j/jal.   This patch extends this to
the relocations used by the: b* instructions; pc/gp relative symbol offsets; and the
lwpc/ldpc MIPS r6 instructions.

bfd/
	* elfxx-mips.c (mips_elf_calculate_relocation): Only check for overflow
	on non-weak undefined symbols.

ld/testsuite/
	* ld-mips-elf/mips-elf.exp: Add in undefined weak overflow tests for
	o32, n32 and n64.
	* ld-mips-elf/undefweak-overflow.s: New test.
	* ld-mips-elf/undefweak-overflow.d: New test.
	* ld-mips-elf/undefweak-overflow-n32.d: New test.
	* ld-mips-elf/undefweak-overflow-n64.d: New test.
2014-12-02 13:27:36 +00:00
H.J. Lu fb389763e0 Add tests for PR ld/16452 and PR ld/16457
PR ld/16452
	PR ld/16457
	* ld-elf/pr16452.map: New file.
	* ld-elf/pr16452.od: Likewise.
	* ld-elf/pr16452a.c: Likewise.
	* ld-elf/pr16452b.c: Likewise.
	* ld-elf/pr16457.od: Likewise.

	* ld-elf/shared.exp (build_tests): Add tests for PR ld/16452 and
	PR ld/16457.
2014-12-01 06:06:21 -08:00
H.J. Lu 3a1cfc456f Update mips tests with symbol version string
* ld-mips-elf/got-vers-1.rd: Add symbol version string to
	versioned symbol names in dynamic relocation.
	* ld-mips-elf/reloc-estimate-1.d: Likewise.
	* ld-mips-elf/tlsdyn-o32-1.got: Likewise.
	* ld-mips-elf/tlsdyn-o32-2.got: Likewise.
	* ld-mips-elf/tlsdyn-o32-3.got: Likewise.
	* ld-mips-elf/tlslib-o32-ver.got: Likewise.
2014-11-27 06:44:29 -08:00
H.J. Lu 61e6682207 Update ld-alpha tests for secureplt
* ld-alpha/tlsbin.dd: Updated for secureplt.
	* ld-alpha/tlsbin.rd: Likewise.
	* ld-alpha/tlsbin.sd: Likewise.
	* ld-alpha/tlsbinr.dd: Likewise.
	* ld-alpha/tlsbinr.rd: Likewise.
	* ld-alpha/tlspic.dd: Likewise.
	* ld-alpha/tlspic.rd: Likewise.
	* ld-alpha/tlspic.sd: Likewise.
2014-11-25 13:41:30 -08:00
H.J. Lu bb4d2ac2cc Display symbol version when dumping dynrelocs
Both readelf/objdump know how to get symbol version string for dynamic
symbols.  This patch extracts this functionality into a separate
function and uses it to add symbol version string to versioned symbol
names when dumping dynamic relocations.

bfd/

	PR binutils/16496
	* elf-bfd.h (bfd_elf_get_symbol_version_string): New.
	* elf.c (bfd_elf_get_symbol_version_string): New.  Extracted
	from bfd_elf_print_symbol.
	(bfd_elf_print_symbol): Use it.

binutils/

	PR binutils/16496
	* objdump.c (objdump_print_symname): Call
	bfd_elf_get_symbol_version_string to get ELF symbol version
	string.  Append version string if needed.

	* readelf.c (versioned_symbol_info): New enum.
	(get_symbol_version_string): New.  Extracted from
	process_symbol_table.
	(dump_relocations): Add a new argument to indicate if dynamic
	symbol table is used.  Use get_symbol_version_string to get
	symbol version string for dynamic symbol.  Append version string
	if needed.
	(process_relocs): Updated dump_relocations call.
	(process_symbol_table): Use get_symbol_version_string.

ld/testsuite/

	PR binutils/16496
	* ld-cris/weakref3.d: Add symbol version string to versioned
	symbol names in dynamic relocation.
	* ld-cris/weakref4.d: Likewise.
	* ld-elfvers/vers24.rd: Likewise.

	* ld-elf/pr16496a.c: New file.
	* ld-elf/pr16496a.map: Likewise.
	* ld-elf/pr16496b.c: Likewise.
	* ld-elf/pr16496b.od: Likewise.

	* ld-elf/shared.exp (build_tests): Add libpr16496a.so and
	libpr16496b.so tests.
2014-11-25 06:47:44 -08:00
H.J. Lu dd7e64d45b Optimize out i386/x86-64 JUMP_SLOT relocation
When there are both PLT and GOT references to the same function symbol,
linker will create a GOTPLT slot for PLT entry and a GOT slot for GOT
reference.  A run-time JUMP_SLOT relocation is created to update the
GOTPLT slot and a run-time GLOB_DAT relocation is created to update the
GOT slot.  Both JUMP_SLOT and GLOB_DAT relocations will apply the same
symbol value to GOTPLT and GOT slots, respectively, at run-time.

This optimization combines GOTPLT and GOT slots into a single GOT slot
and removes the run-time JUMP_SLOT relocation.  It replaces the regular
PLT entry:

	indirect jump	[GOTPLT slot]
	push		relocation index
	jump		PLT0

with an GOT PLT entry with an indirect jump via the GOT slot:

	indirect jump	[GOT slot]
	nop

and resolves PLT reference to the GOT PLT entry.

We must avoid this optimization if pointer equality is needed since
we don't clear symbol value in this case and the dynamic linker won't
update the GOT slot.  Otherwise, the resulting binary will get into an
infinite loop at run-time.

bfd/

	* elf32-i386.c (elf_i386_got_plt_entry): New.
	(elf_i386_pic_got_plt_entry): Likewise.
	(elf_i386_link_hash_entry): Add plt_got.
	(elf_i386_link_hash_table): Likewise.
	(elf_i386_link_hash_newfunc): Initialize plt_got.offset to -1.
	(elf_i386_get_local_sym_hash): Likewise.
	(elf_i386_check_relocs): Create the GOT PLT if there are both
	PLT and GOT references when the regular PLT is used.
	(elf_i386_allocate_dynrelocs): Use the GOT PLT if there are
	both PLT and GOT references unless pointer equality is needed.
	(elf_i386_relocate_section): Also check the GOT PLT when
	resolving R_386_PLT32.
	(elf_i386_finish_dynamic_symbol): Use the GOT PLT if it is
	available.

	* elf64-x86-64.c (elf_x86_64_link_hash_entry): Add plt_got.
	(elf_x86_64_link_hash_table): Likewise.
	(elf_x86_64_link_hash_newfunc): Initialize plt_got.offset to -1.
	(elf_x86_64_get_local_sym_hash): Likewise.
	(elf_x86_64_check_relocs): Create the GOT PLT if there are both
	PLT and GOT references when the regular PLT is used.
	(elf_x86_64_allocate_dynrelocs): Use the GOT PLT if there are
	both PLT and GOT references unless pointer equality is needed.
	(elf_x86_64_relocate_section): Also check the GOT PLT when
	resolving R_X86_64_PLT32.
	(elf_x86_64_finish_dynamic_symbol): Use the GOT PLT if it is
	available.

ld/

	* emulparams/elf_i386.sh (TINY_READONLY_SECTION): New.
	* emulparams/elf_x86_64.sh (TINY_READONLY_SECTION): Add .plt.got.

ld/testsuite/

	* ld-i386/i386.exp: Add run-time relocation tests for plt-main.
	* ld-i386/plt-main.rd: New file.
	* ld-x86-64/plt-main-bnd.dd: Likewise.
	* ld-x86-64/plt-main.rd: Likewise.
	* ld-x86-64/x86-64.exp: Add run-time relocation tests for
	plt-main.
2014-11-25 05:05:39 -08:00
H.J. Lu 4a7a792388 Add function and function pointer tests for i386
This patch adds tests for function and function pointer for i386.

	* ld-i386/plt-lib.c: New file.
	* ld-i386/plt-main.out: Likewise.
	* ld-i386/plt-main1.c: Likewise.
	* ld-i386/plt-main1.rd: Likewise.
	* ld-i386/plt-main2.c: Likewise.
	* ld-i386/plt-main2.rd: Likewise.
	* ld-i386/plt-main3.c: Likewise.
	* ld-i386/plt-main3.rd: Likewise.
	* ld-i386/plt-main4.c: Likewise.
	* ld-i386/plt-main4.rd: Likewise.
	* ld-i386/plt-main5.c: Likewise.

	* ld-i386/i386.exp: Run plt-main tests.
2014-11-21 08:45:02 -08:00
H.J. Lu ce641d0b6b Run plt-main test with -pie
* ld-x86-64/x86-64.exp: Run plt-main test with -pie.
2014-11-21 07:57:38 -08:00
Terry Guo 3cfdb7812c Calculate ARM arch attribute after relaxation
gas/
2014-11-21  Terry Guo  <terry.guo@arm.com>

	* config/tc-arm.c (md_assemble): Do not consider relaxation.
	(md_convert_frag): Test and set target arch attribute accordingly.
	(aeabi_set_attribute_string): Turn it into a global function.
	* config/tc-arm.h (md_post_relax_hook): Enable it for ARM target.
	(aeabi_set_public_attributes): Declare it.

gas/testsuite/
2014-11-21  Terry Guo  <terry.guo@arm.com>

	* gas/arm/attr-arch-assumption.d: New file.
	* gas/arm/attr-arch-assumption.s: Likewise.

ld/testsuite/
2014-11-21  Terry Guo  <terry.guo@arm.com>

	* ld-arm/tls-longplt-lib.s: Require ARMv6T2.
	* ld-arm/tls-longplt.s: Likewise.
	* ld-arm/tls-longplt-lib.d: Updated.
	* ld-arm/tls-longplt.d: Likewise.
2014-11-21 11:54:39 +08:00
Terry Guo a715796ba1 Support ARM Cortex-M7
include/ChangeLog:
2014-11-21  Terry Guo  <terry.guo@arm.com>

	* opcode/arm.h (FPU_VFP_EXT_ARMV8xD): New macro.
	(FPU_VFP_V5D16): Likewise.
	(FPU_VFP_V5_SP_D16): Likewise.
	(FPU_ARCH_VFP_V5D16): Likewise.
	(FPU_ARCH_VFP_V5_SP_D16): Likewise.

bfd/ChangeLog:
2014-11-21  Terry Guo  <terry.guo@arm.com>

	* elf32-arm.c (elf32_arm_merge_eabi_attributes): Support FPv5.

binutils/ChangeLog:
2014-11-21  Terry Guo  <terry.guo@arm.com>

	* readelf.c (arm_attr_tag_FP_arch): Extended to support FPv5.

gas/ChangeLog:
2014-11-21  Terry Guo  <terry.guo@arm.com>

	* config/tc-arm.c (fpu_vfp_ext_armv8xd): New.
	(arm_cpus): Support cortex-m7.
	(arm_fpus): Support fpv5-sp-d16 and fpv5-d16.
	(do_vfp_nsyn_cvt_fpv8): Generate error when use D register for S
	register only target like FPv5-SP-D16.
	(do_neon_cvttb_1): Likewise.
	(do_vfp_nsyn_fpv8): Likewise.
	(do_vrint_1): Likewise.
	(aeabi_set_public_attributes): Set proper FP arch for FPv5.
	* doc/c-arm.texi: Document new cpu and fpu names for cortex-m7.

gas/testsuite/ChangeLog:
2014-11-21  Terry Guo  <terry.guo@arm.com>

	* gas/arm/armv7e-m+fpv5-d16.s: New.
	* gas/arm/armv7e-m+fpv5-d16.d: Likewise.
	* gas/arm/armv7e-m+fpv5-sp-d16.s: Likewise.
	* gas/arm/armv7e-m+fpv5-sp-d16.d: Likewise.

ld/testsuite/ChangeLog:
2014-11-21  Terry Guo  <terry.guo@arm.com>

	* ld-arm/attr-merge-vfp-4-sp.s: New test source file.
	* ld-arm/attr-merge-vfp-5-sp.s: Likewise.
	* ld-arm/attr-merge-vfp-5.s: Likewise.
	* ld-arm/attr-merge-vfp-8.d: New test.
	* ld-arm/attr-merge-vfp-8r.d: Likewise.
	* ld-arm/attr-merge-vfp-9.d: Likewise.
	* ld-arm/attr-merge-vfp-9r.d: Likewise.
	* ld-arm/attr-merge-vfp-10.d: Likewise.
	* ld-arm/attr-merge-vfp-10r.d: Likewise.
	* ld-arm/attr-merge-vfp-11.d: Likewise.
	* ld-arm/attr-merge-vfp-11r.d: Likewise.
	* ld-arm/attr-merge-vfp-12.d: Likewise.
	* ld-arm/attr-merge-vfp-12r.d: Likewise.
	* ld-arm/attr-merge-vfp-13.d: Likewise.
	* ld-arm/attr-merge-vfp-13r.d: Likewise.
	* ld-arm/attr-merge-vfp-14.d: Likewise.
	* ld-arm/attr-merge-vfp-14r.d: Likewise.
	* ld-arm/arm-elf.exp: Run the new tests.
2014-11-21 11:36:06 +08:00
H.J. Lu 344d1e9ca8 Don't run pr17618 test on x32
* ld-x86-64/pr17618.d: Don't run on x32.
2014-11-20 13:38:31 -08:00
H.J. Lu 4cd4358388 Update plt-main tests for x32
* ld-x86-64/plt-main1.rd: Updated for x32.
	* ld-x86-64/plt-main2.rd: Likewise.
	* ld-x86-64/plt-main3.rd: Likewise.
	* ld-x86-64/plt-main4.rd: Likewise.
2014-11-20 13:29:41 -08:00
H.J. Lu 76e7af5ffa Add function and function pointer tests
This patch adds tests for function and function pointer.

	* ld-x86-64/plt-lib.c: New file.
	* ld-x86-64/plt-main.out: Likewise.
	* ld-x86-64/plt-main1.c: Likewise.
	* ld-x86-64/plt-main1.rd: Likewise.
	* ld-x86-64/plt-main2.c: Likewise.
	* ld-x86-64/plt-main2.rd: Likewise.
	* ld-x86-64/plt-main3.c: Likewise.
	* ld-x86-64/plt-main3.rd: Likewise.
	* ld-x86-64/plt-main4.c: Likewise.
	* ld-x86-64/plt-main4.rd: Likewise.
	* ld-x86-64/plt-main5.c: Likewise.

	* ld-x86-64/x86-64.exp: Run plt-main tests.
2014-11-20 12:41:11 -08:00
H.J. Lu 731885c1ad Always load function pointer into a stack variable
This patch makes sure that compiler won't optimize out loading function
into a stack variable.

	* ld-ifunc/ifunc-main.c (get_bar): New function.
	(main): Use it.
2014-11-20 11:29:45 -08:00
H.J. Lu 5f7cbeec7d Add ifunc-main IFUNC tests
* ld-ifunc/ifunc.exp: Run ifunc-main.
	* ld-ifunc/ifunc-lib.c: New file.
	* ld-ifunc/ifunc-main.c: Likewise.
	* ld-ifunc/ifunc-main.out: Likewise.
2014-11-20 10:49:46 -08:00
H.J. Lu c22ee0ad9d Run IFUNC run-time tests only if IFUNC is supported
* lib/ld-lib.exp (check_ifunc_available): New.
	* ld-ifunc/ifunc.exp: Run IFUNC run-time tests only if IFUNC
	is supported.
2014-11-20 08:59:42 -08:00
Terry Guo 9274e9de16 Enable to link ARM object file that hasn't attribute section.
bfd/ChangeLog

2014-11-20  Terry Guo  <terry.guo@arm.com>

	* elf32-arm.c (elf32_arm_merge_eabi_attributes): Skip if input bfd
	hasn't attribute section.

ld/testsuite/ChangeLog:

2014-11-20  Terry Guo  <terry.guo@arm.com>

	* ld-arm/attr-merge-nosection-1.d: New file.
	* ld-arm/attr-merge-nosection-1a.s: Likewise.
	* ld-arm/attr-merge-nosection-1b.s: Likewise.
	* ld-arm/arm-elf.exp: Include the new test.
2014-11-20 13:54:27 +08:00
H.J. Lu ab7fede88e Check PC-relative offset overflow in PLT entry
This patch checks PC-relative offset overflow in pushq instruction in
x86-64 PLT entry.

bfd/

	PR ld/17618
	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Check
	PC-relative offset overflow in PLT entry.

ld/testsuite/

	PR ld/17618
	* ld-x86-64/x86-64.exp: Run pr17618 for Linux target.

	* ld-x86-64/pr17618.d: New file.
	* ld-x86-64/pr17618.s: Likewise.
2014-11-18 11:04:46 -08:00
H.J. Lu de84aee38c Always run mpx3 and mpx4 tests in 64-bit
* ld-x86-64/mpx.exp: Always run mpx3 and mpx4 tests in 64-bit.
2014-11-18 05:55:32 -08:00
Igor Zamyatin d258b82828 Add -z bndplt to generate BND prefix in PLT entries
This patch adds "-z bndplt" option Linux/x86-64 linker to generate BND
prefix in PLT entries.  It also updated Linux/x86-64 assembler not to
generate R_X86_64_PLT32_BND nor R_X86_64_PC32_BND relocations.

bfd/

2014-11-18  Igor Zamyatin  <igor.zamyatin@intel.com>

	* elf64-x86-64.c (elf_x86_64_check_relocs): Enable MPX PLT only
	for -z bndplt.

gas/

2014-11-18  Igor Zamyatin  <igor.zamyatin@intel.com>

	* config/tc-i386-intel.c (i386_operator): Remove last argument
	from lex_got call.
	* config/tc-i386.c (reloc): Remove bnd_prefix from parameters'
	list.  Return always BFD_RELOC_32_PCREL.
	* (output_branch): Remove condition for BFD_RELOC_X86_64_PC32_BND.
	* (output_jump): Update call to reloc accordingly.
	* (output_interseg_jump): Likewise.
	* (output_disp): Likewise.
	* (output_imm): Likewise.
	* (x86_cons_fix_new): Likewise.
	* (lex_got): Remove bnd_prefix from parameters' list in macro and
	declarations. Don't use BFD_RELOC_X86_64_PLT32_BND.
	* (x86_cons): Update call to lex_got accordingly.
	* (i386_immediate): Likewise.
	* (i386_displacement): Likewise.
	* (md_apply_fix): Don't use BFD_RELOC_X86_64_PLT32_BND nor
	BFD_RELOC_X86_64_PC32_BND.
	* (tc_gen_reloc): Likewise.

include/

2014-11-18  Igor Zamyatin  <igor.zamyatin@intel.com>

	* bfdlink.h (struct bfd_link_info): Add bndplt.

ld/

2014-11-18  Igor Zamyatin  <igor.zamyatin@intel.com>

	* emulparams/elf_x86_64.sh (BNDPLT): Set to yes for x86_64.
	* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Handle
	"-z bndplt" if BNDPLT is yes.
	(gld${EMULATION_NAME}_list_options): Add "-z bndplt" entry.
	* ld.texinfo: Add description for bndplt.

ld/testsuite/

2014-11-18  Igor Zamyatin  <igor.zamyatin@intel.com>

	* testsuite/ld-x86-64/bnd-ifunc-1.d: Add bndplt option.
	* testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise.
	* testsuite/ld-x86-64/bnd-plt-1.d: Likewise.  Update dissassembly
	sections.
	* testsuite/ld-x86-64/mpx.exp: Handle mpx3 and mpx4 tests.
	* testsuite/ld-x86-64/mpx1a.rd: Remove _BND from relocation name.
	* testsuite/ld-x86-64/mpx1c.rd: Likewise.
	* testsuite/ld-x86-64/mpx2a.rd: Likewise.
	* testsuite/ld-x86-64/mpx2c.rd: Likewise.
	* testsuite/ld-x86-64/mpx3.dd: New file.
	* testsuite/ld-x86-64/mpx3a.s: Likewise.
	* testsuite/ld-x86-64/mpx3b.s: Likewise.
	* testsuite/ld-x86-64/mpx4.dd: Likewise.
	* testsuite/ld-x86-64/mpx4a.s: Likewise.
	* testsuite/ld-x86-64/mpx4b.s: Likewise.
2014-11-18 05:40:17 -08:00
H.J. Lu 553d1284b7 Add assembler support for @gotplt
Obsolete R_X86_64_GOTPLT64 and treat it the same as R_X86_64_GOT64.

bfd/

	PR gas/17598
	* elf64-x86-64.c (elf_x86_64_check_relocs): Treat
	R_X86_64_GOTPLT64 the same as R_X86_64_GOT64.
	(elf_x86_64_relocate_section): Likewise.

gas/

	PR gas/17598
	* config/tc-i386.c (reloc): Support BFD_RELOC_X86_64_GOTPLT64.

gas/testsuite/

	PR gas/17598
	* gas/i386/reloc64.s: Add @gotplt check.

	* gas/i386/reloc64.d: Updated.
	* gas/i386/reloc64.l: Likewise.

ld/testsuite/

	PR gas/17598
	* ld-x86-64/x86-64.exp: Run gotplt1.

	* ld-x86-64/gotplt1.d: New file.
	* ld-x86-64/gotplt1.s: Likewise.
2014-11-13 11:09:40 -08:00
Jiong Wang 603c43995f [PATCH] treate -specs as both cflags & ldflags
ld/testsuite/
    * lib/ld-lib.exp (run_ld_link_exec_tests): Append board_cflags if gcc driver
    used as link tool.
    (run_cc_link_exec_tests): Likewise.
2014-11-11 16:41:37 +00:00
H.J. Lu cf61b7473a X32: Add REX prefix to encode R_X86_64_GOTTPOFF
Structions with R_X86_64_GOTTPOFF relocation must be encoded with REX
prefix even if it isn't required by destination register.  Otherwise
linker can't safely perform IE -> LE optimization.

bfd/

	PR ld/17482
	* elf64-x86-64.c (elf_x86_64_relocate_section): Update comments
	for IE->LE transition.

gas/

	PR ld/17482
	* config/tc-i386.c (output_insn): Add a dummy REX_OPCODE prefix
	for structions with R_X86_64_GOTTPOFF relocation for x32 if needed.

gas/testsuite/

	PR ld/17482
	* gas/i386/ilp32/x32-tls.d: New file.
	* gas/i386/ilp32/x32-tls.s: Likewise.

ld/testsuite/

	PR ld/17482
	* ld-x86-64/tlsie4.dd: Updated.
2014-11-07 12:22:53 -08:00
Matthew Fortune 09c14161c5 Update .MIPS.abiflags to support MIPS R6
bfd/

	* elfxx-mips.c (update_mips_abiflags_isa): Add E_MIPS_ARCH_32R6
	and E_MIPS_ARCH_64R6 support.

ld/testsuite/

	* ld-mips-elf/abiflags-strip10-ph.d: New file.
	* ld-mips-elf/mips-eld.exp: Run the new test.

gas/

	* config/tc-mips.c (mips_elf_final_processing): Add INSN_ISA32R6
	and INSN_ISA64R6 support.

gas/testsuite/

	* gas/mips/elf_arch_mips32r6.d: New file.
	* gas/mips/elf_arch_mips64r6.d: New file.
	* gas/mips/mips.exp: Run the new tests.
2014-11-05 10:48:38 +00:00
Will Newton 62cf91a31e ld/testsuite/ld-unique: Fix running unique tests on ARM
The @ character is a comment character on ARM, so use % instead. Also
use a wider glob for matching ARM targets to make sure the test gets
run.

ld/testsuite/ChangeLog:

2014-10-30  Will Newton  <will.newton@linaro.org>

	* ld-unique/unique.exp: Use a wider glob for matching ARM
	targets.
	* ld-unique/unique.s: Use % instead of @ in .type directive.
	* ld-unique/unique_shared.s: Likewise.
2014-10-30 11:06:43 +00:00
Jiong Wang 68fcca92b7 [AArch64] Cortex-A53 erratum 835769 linker workaround
2014-10-22  Tejas Belagod  <tejas.belagod@arm.com>

bfd/
	* bfd-in.h (bfd_elf64_aarch64_set_options): Add a parameter.
	* bfd-in2.h (bfd_elf64_aarch64_set_options): Likewise.
	* elfnn-aarch64.c (aarch64_erratum_835769_stub): New.
	(elf_aarch64_stub_type): Add new type
	aarch64_stub_erratum_835769_veneer.
	(elf_aarch64_stub_hash_entry): New fields for erratum 835769.
	(aarch64_erratum_835769_fix): New data struct to record erratum
	835769.
	(elf_aarch64_link_hash_table: Global flags for 835769.
	(aarch64_build_one_stub): Add case for 835769.
	(aarch64_size_one_stub): Likewise.
	(aarch64_mem_op_p, aarch64_mlxl_p,
	aarch64_erratum_sequence,erratum_835769_scan):
	New. Decode and scan functions for erratum 835769.
	(elf_aarch64_create_or_find_stub_sec): New.
	(elfNN_aarch64_size_stubs): Look for erratum 835769 and record
	them.
	(bfd_elfNN_aarch64_set_options: Set global flag for 835769.
	(erratum_835769_branch_to_stub_data,
	make_branch_to_erratum_835769_stub):New. Connect up all the
	erratum stubs to occurances by branches.
	(elfNN_aarch64_write_section): New hook.
	(aarch64_map_one_stub): Output erratum stub symbol.
	(elfNN_aarch64_size_dynamic_sections): Init mapping symbol
	information for erratum 835769.
	(elf_backend_write_section): Define.

ld/
	* emultempl/aarch64elf.em: Add command-line option for erratum
	835769.

ld/testsuite/

	* ld-aarch64/aarch64-elf.exp (aarch64elftests): Drive erratum
	835769 tests.
	* ld-aarch64/erratum835769.d: New.
	* ld-aarch64/erratum835769.s: New.
2014-10-24 11:39:35 +01:00
Hans-Peter Nilsson 3f7308212c Fix ld tests with sysroot=/ and --enable-targets=all and test --print-sysroot
* ld-scripts/sysroot-prefix.exp: Log $ld_sysroot.  Handle sysroot
	== "/" as a separate sysroot-configuration with separable
	test-types.
	(sysroot_prefix_tests): Include all existing sysroot tests in
	sysroot == "/" tests except exclude those where a --sysroot option
	is not specified.
	* lib/ld-lib.exp (check_sysroot_available): Rewrite to use
	--print-sysroot instead of relying on error code from using
	--sysroot=...  Also, set $ld_sysroot.

The reason we exclude not just the failing "full-path =-prefixed
without" but also the passing "plain =-prefixed without but -Lpath"
for sysroot == "/" is that for the latter to succeed, we have to make
assumptions about the system not having a /sysroot directory or
assumptions about its contents etc.

When passing --enable-targets=all --enable-64-bit-bfd (the
latter not required for a "64-bit-host" of course) the ld --help
output got too much to handle for poor tcl (or maybe dejagnu is
to blame) and remote_exec exited with an error, so the
configuration being tested was mishandled as being a
sysroot-less configuration.  Using --version instead of --help
would work too, but the new --print-sysroot option calls for
nominal coverage, so why not use that instead.
2014-10-17 13:11:42 +02:00
Hans-Peter Nilsson ef1ab8e216 Add sysroot-prefix ld linker tests.
* ld-scripts/sysroot-prefix.exp, ld-scripts/sysroot-prefix-x.s,
	ld-scripts/sysroot-prefix-y.s: New files.

N.B: full coverage is only possible with complementary use of
--with-sysroot when configuring.
2014-10-15 02:59:41 +02:00
Hans-Peter Nilsson bdd65db9b9 lib/ld-lib.exp (check_sysroot_available): New proc. 2014-10-15 02:54:56 +02:00
Alan Modra c2aaac080c Discard zero address range eh_frame FDEs
These are useless because they can't match any address.  In fact,
worse than useless because the .eh_frame_hdr lookup table matching
addresses to FDEs does not contain information about the FDE range.
The table is sorted by address;  Range is inferred by the address
delta from one entry to the next.  So if a zero address range FDE is
followed by a normal non-zero range FDE for the same address,
everything is good.  However, the qsort could just as easily sort the
FDEs in the other order, in which case the normal FDE would
effectively be seen to have a zero range.

bfd/
	PR 17447
	* elf-bfd.h (struct eh_cie_fde): Comment re NULL u.fde.cie_inf.
	* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Mark zero address
	range FDEs for discarding.
	(vma_compare): Sort on range after address.
	(_bfd_elf_gc_mark_fdes): Test for NULL u.fde.cie_inf.
	(_bfd_elf_discard_section_eh_frame): Likewise.  Write "FDE" in
	error message rather than "fde".
	(_bfd_elf_write_section_eh_frame_hdr): Write "PC" and "FDE" in
	error message.
ld/testsuite/
	* ld-elf/eh1.s: Don't create FDEs with zero address ranges.
	* ld-elf/eh3.s: Likewise.
	* ld-elf/eh1.d, * ld-elf/eh2.d, * ld-elf/eh3.d: Adjust.
	* ld-mips-elf/eh-frame1-n32.d: Warning match update.
	* ld-mips-elf/eh-frame1-n64.d: Likewise.
	* ld-mips-elf/eh-frame2-n32.d: Likewise.
	* ld-mips-elf/eh-frame2-n64.d: Likewise.
2014-10-04 22:49:32 +09:30
Alan Modra 4dea914eb1 Find lto plugin when using gcc-5.0
I originally had this as --print-prog-name and changed back to
--print-file-name to suit older gcc, neglecting to check whether
gcc-5.0 --print-file-name finds the lto plugin.  It doesn't.

	* ld-plugin/lto.exp: Use both --print-file-name and --print-prog-name
	when looking for lto plugin.
2014-09-22 19:04:48 +09:30
Terry Guo 70e99720f9 Make the linker return an error status if it fails to merge ARM binaries with
different architecture tags.  Add a test case to make sure that this works,
and update readelf so that it will not seg-fault when trying to display the
attributes of binaries with invalid architecture tags.

	* elf32-arm.c (elf32_arm_merge_eabi_attributes): Return false if
	failed to merge.

	* ld-arm/attr-merge-arch-2.d: New test case.
	* ld-arm/attr-merge-arch-2a.s: New test case source file.
	* ld-arm/attr-merge-arch-2b.s: Likewise.
	* ld-arm/arm-elf.exp: Run new test case.

	* readelf.c (display_arm_attribute): Use unsigned int type for
	tag, val and type variables.
2014-09-16 13:08:22 +01:00
Andrew Bennett a9d58c068c Add mips*-img-elf* target triple.
/
	* configure.ac: Add mips*-img-elf* target triple.
	* configure: Regenerate.

bfd/
	* config.bfd: Add mips*-img-elf* target triple.

gas/
	* configure.tgt: Add mips*-img-elf* target triple.

gas/testsuite/
	* gas/mips/mips.exp: Add mips*-img-elf* target triple.

binutils/testsuite/
	* binutils-all/objcopy.exp: Add mips*-img-elf* target triple.
	* binutils-all/readelf.exp: Likewise.

ld/
	* configure.tgt: Add mips*-img-elf* target triple.

ld/testsuite/
	* ld-mips-elf/mips-elf.exp: Add support for mips*-img-elf* target
	triple.
2014-09-12 14:25:15 +01:00
Alan Modra a485e98ea0 Move ELF section headers to end of object file
Currently, section ordering differs a little for non-loaded reloc
sections output by ld -emit-relocs or ld -r and that after passing
such objects through objcopy.  Not that it really matters, but it
would be better for a simple objcopy to produce an unchanged output
object file.  Also, section headers are put somewhere in the middle of
the non-loaded sections, again slightly differently for ld and
objcopy.  This patch fixes these discrepancies and puts section
headers last, which is where gold puts them, and is where
bfd_from_remote_memory wrongly assumed they will be found.

bfd/
	* elf.c (assign_file_positions_except_relocs): Move section header
	placement to..
	(_bfd_elf_assign_file_positions_for_relocs): ..here.  Make static.
	* elf-bfd.h (_bfd_elf_assign_file_positions_for_relocs): Delete.
	* elflink.c (bfd_elf_final_link): Don't call above function.
gas/testsuite/
	* gas/arm/got_prel.d: Adjust for changed section header placement.
	* gas/i386/ilp32/x86-64-size-1.d: Likewise.
	* gas/i386/ilp32/x86-64-size-3.d: Likewise.
	* gas/i386/ilp32/x86-64-size-5.d: Likewise.
	* gas/i386/ilp32/x86-64-unwind.d: Likewise.
	* gas/i386/size-1.d: Likewise.
	* gas/i386/size-3.d: Likewise.
	* gas/i386/x86-64-size-1.d: Likewise.
	* gas/i386/x86-64-size-3.d: Likewise.
	* gas/i386/x86-64-size-5.d: Likewise.
	* gas/i386/x86-64-unwind.d: Likewise.
	* gas/ia64/alias-ilp32.d: Likewise.
	* gas/ia64/alias.d: Likewise.
	* gas/ia64/group-1.d: Likewise.
	* gas/ia64/group-2.d: Likewise.
	* gas/ia64/secname-ilp32.d: Likewise.
	* gas/ia64/secname.d: Likewise.
	* gas/ia64/unwind-ilp32.d: Likewise.
	* gas/ia64/unwind.d: Likewise.
	* gas/mmix/bspec-1.d: Likewise.
	* gas/mmix/bspec-2.d: Likewise.
	* gas/mmix/byte-1.d: Likewise.
	* gas/mmix/loc-1.d: Likewise.
	* gas/mmix/loc-2.d: Likewise.
	* gas/mmix/loc-3.d: Likewise.
	* gas/mmix/loc-4.d: Likewise.
	* gas/mmix/loc-5.d: Likewise.
	* gas/tic6x/scomm-directive-4.d: Likewise.
ld/testsuite/
	* ld-aarch64/emit-relocs-local-addend.d: Adjust for changed
	section header placement.
	* ld-aarch64/local-addend-r.d: Likewise.
	* ld-mmix/bspec1.d: Likewise.
	* ld-mmix/bspec2.d: Likewise.
	* ld-mmix/local1.d: Likewise.
	* ld-mmix/local3.d: Likewise.
	* ld-mmix/local5.d: Likewise.
	* ld-mmix/local7.d: Likewise.
	* ld-mmix/undef-3.d: Likewise.
	* ld-sh/sh64/crange3-cmpct.rd: Likewise.
	* ld-sh/sh64/crange3-media.rd: Likewise.
	* ld-sh/sh64/crangerel1.rd: Likewise.
	* ld-sh/sh64/crangerel2.rd: Likewise.
	* ld-tic6x/common.d: Likewise.
	* ld-tic6x/shlib-1.rd: Likewise.
	* ld-tic6x/shlib-1b.rd: Likewise.
	* ld-tic6x/shlib-1r.rd: Likewise.
	* ld-tic6x/shlib-1rb.rd: Likewise.
	* ld-tic6x/shlib-app-1.rd: Likewise.
	* ld-tic6x/shlib-app-1b.rd: Likewise.
	* ld-tic6x/shlib-app-1r.rd: Likewise.
	* ld-tic6x/shlib-app-1rb.rd: Likewise.
	* ld-tic6x/shlib-noindex.rd: Likewise.
	* ld-tic6x/static-app-1.rd: Likewise.
	* ld-tic6x/static-app-1b.rd: Likewise.
	* ld-tic6x/static-app-1r.rd: Likewise.
	* ld-tic6x/static-app-1rb.rd: Likewise.
	* ld-x86-64/ilp32-4.d: Likewise.
	* ld-x86-64/split-by-file-nacl.rd: Likewise.
	* ld-x86-64/split-by-file.rd: Likewise.
2014-09-11 00:15:51 +09:30
Matthew Fortune e319abb47d MIPS testsuite cleanup - part 4
ld/testsuite/

	* ld-mips-elf/abiflags-strip1-ph.d: Ignore big/little endian
	differences. Ignore program headers other than PT_MIPS_ABIFLAGS.
	Do not force -32, -EB and ld emulation but instead rely on the
	test driver to build for some form of O32.
	* ld-mips-elf/abiflags-strip2-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip3-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip4-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip5-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip6-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip7-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip8-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip9-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-0-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-05.d: Likewise.
	* ld-mips-elf/attr-gnu-4-06.d: Likewise.
	* ld-mips-elf/attr-gnu-4-07.d: Likewise.
	* ld-mips-elf/attr-gnu-4-1-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-10.d: Likewise.
	* ld-mips-elf/attr-gnu-4-15.d: Likewise.
	* ld-mips-elf/attr-gnu-4-16.d: Likewise.
	* ld-mips-elf/attr-gnu-4-17.d: Likewise.
	* ld-mips-elf/attr-gnu-4-2-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-25.d: Likewise.
	* ld-mips-elf/attr-gnu-4-26.d: Likewise.
	* ld-mips-elf/attr-gnu-4-27.d: Likewise.
	* ld-mips-elf/attr-gnu-4-3-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-35.d: Likewise.
	* ld-mips-elf/attr-gnu-4-36.d: Likewise.
	* ld-mips-elf/attr-gnu-4-37.d: Likewise.
	* ld-mips-elf/attr-gnu-4-4-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-45.d: Likewise.
	* ld-mips-elf/attr-gnu-4-46.d: Likewise.
	* ld-mips-elf/attr-gnu-4-47.d: Likewise.
	* ld-mips-elf/attr-gnu-4-5-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-50.d: Likewise.
	* ld-mips-elf/attr-gnu-4-51.d: Likewise.
	* ld-mips-elf/attr-gnu-4-52.d: Likewise.
	* ld-mips-elf/attr-gnu-4-53.d: Likewise.
	* ld-mips-elf/attr-gnu-4-54.d: Likewise.
	* ld-mips-elf/attr-gnu-4-55.d: Likewise.
	* ld-mips-elf/attr-gnu-4-56.d: Likewise.
	* ld-mips-elf/attr-gnu-4-57.d: Likewise.
	* ld-mips-elf/attr-gnu-4-58.d: Likewise.
	* ld-mips-elf/attr-gnu-4-6-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-60.d: Likewise.
	* ld-mips-elf/attr-gnu-4-61.d: Likewise.
	* ld-mips-elf/attr-gnu-4-62.d: Likewise.
	* ld-mips-elf/attr-gnu-4-63.d: Likewise.
	* ld-mips-elf/attr-gnu-4-64.d: Likewise.
	* ld-mips-elf/attr-gnu-4-65.d: Likewise.
	* ld-mips-elf/attr-gnu-4-66.d: Likewise.
	* ld-mips-elf/attr-gnu-4-67.d: Likewise.
	* ld-mips-elf/attr-gnu-4-68.d: Likewise.
	* ld-mips-elf/attr-gnu-4-7-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-70.d: Likewise.
	* ld-mips-elf/attr-gnu-4-71.d: Likewise.
	* ld-mips-elf/attr-gnu-4-72.d: Likewise.
	* ld-mips-elf/attr-gnu-4-73.d: Likewise.
	* ld-mips-elf/attr-gnu-4-74.d: Likewise.
	* ld-mips-elf/attr-gnu-4-75.d: Likewise.
	* ld-mips-elf/attr-gnu-4-76.d: Likewise.
	* ld-mips-elf/attr-gnu-4-77.d: Likewise.
	* ld-mips-elf/attr-gnu-4-78.d: Likewise.
	* ld-mips-elf/mips-elf.exp: Update default abi_asflags(o32) to explicitly
	pass -32 for the 'no abi' configurations.  Modify the way attr-gnu* tests
	are run to use O32 flags appropriate for the current target.
2014-09-06 18:02:50 +01:00
Alan Modra 5a1431e66e Fix testsuite ld_simple_link_defsyms for windows targets
* lib/ld-lib.exp (ld_simple_link_defsyms): Provide both __main
	and ___main for windows targets.
2014-08-29 10:34:18 +09:30
H.J. Lu c8831961f9 Use bfd_is_abs_section to check discarded input section
bfd/

	PR ld/17306
	* elf32-i386.c (elf_i386_convert_mov_to_lea): Use bfd_is_abs_section
	to check discarded input section.
	* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise.

ld/testsuite/

	PR ld/17306
	* ld-i386/i386.exp (i386tests): Add tests for PR ld/17306.
	* ld-x86-64/x86-64.exp (x86_64tests): Likewise.

	* ld-i386/pr17306a.s: New file.
	* ld-i386/pr17306b.s: Likewise.
	* ld-x86-64/pr17306a.s: Likewise.
	* ld-x86-64/pr17306b.s: Likewise.
2014-08-27 07:59:48 -07:00
H.J. Lu 29a9f53e85 Don't attach dynamic sections to input from ld --just-symbols
bfd/

	PR ld/17313
	* elflink.c (elf_link_add_object_symbols): Don't attach dynamic
	sections to input from ld --just-symbols.

2014-08-27  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/17313
	* ld-i386/i386.exp (i386tests): Add tests for PR ld/17313.
	* ld-x86-64/x86-64.exp (x86_64tests): Likewise.
2014-08-27 07:39:48 -07:00
Jiong Wang 614b09cefb [AArch64] Improve copy relocation support on four absolute relocation types
2014-08-26  Jiong Wang  <jiong.wang@arm.com>

  bfd/
	* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Initialize non_got_ref
	properly for MOVW_G0/1/2_NC and MOVW_G3.  Reject them when linking
	shared library.
	(elfNN_aarch64_gc_sweep_hook): Add check on these relocs.

  ld/testsuite/
	* ld-aarch64/copy-relocs-so.s: New test file.
	* ld-aarch64/copy-relocs-exe.s: Likewise.
	* ld-aarch64/copy-relocs.d: New expectation file.
	* ld-aarch64/emit-relocs-264-bad.d: New test file.
	* ld-aarch64/emit-relocs-266-bad.d: Likewise.
	* ld-aarch64/emit-relocs-268-bad.d: Likewise.
	* ld-aarch64/emit-relocs-269-bad.d: Likewise.
	* ld-aarch64/aarch64-elf.exp: Run new added test.
2014-08-26 15:48:47 +01:00
Nick Clifton 2836a869c4 Fix linker testsuite failures for Aarch64.
Resolves PR 17312

	* ld-aarch64/eh-frame-foo.s: Use 8-byte offset for X30.
	* ld-aarch64/eh-frame-bar.s: Likewise.
	* ld-aarch64/eh-frame.d: Updated to match current readelf output.
	* ld-elf/eh5.d: Allow any register names.
2014-08-26 15:06:49 +01:00
Maciej W. Rozycki fbd940576f Power/GAS: Don't set VLE annotation for non-VLE processors/instructions
Only set the VLE flag if the instruction has been pulled via the VLE
instruction set.  This way the flag is guaranteed to be set for VLE-only
instructions or for VLE-only processors, however it'll remain clear for
dual-mode instructions on dual-mode and, more importantly, standard-mode
processors.

	gas/
	* config/tc-ppc.c (md_assemble): Only set the PPC_APUINFO_VLE
	flag if both the processor and opcode flags match.

	ld/testsuite/
	* ld-powerpc/apuinfo-vle.rd: New test.
	* ld-powerpc/apuinfo-vle.s: New test source.
	* ld-powerpc/apuinfo.rd: Adjust according to GAS PPC_APUINFO_VLE
	handling change.
	* ld-powerpc/powerpc.exp: Run the new test.
2014-08-22 16:52:20 +01:00
Terry Guo c542398150 bfd/ChangeLog
2014-08-21  Tony Wang  <tony.wang@arm.com>

	* elf32-arm.c (elf32_arm_final_link_relocate): Implement
	the veneer routine for R_ARM_THM_JUMP19.
	(arm_type_of_stub): Add conditional clause for R_ARM_THM_JUMP19
	(elf32_arm_size_stub): Ditto.

ld/testsuite/ChangeLog
2014-08-21  Tony Wang  <tony.wang@arm.com>

	* ld-arm/jump-reloc-veneers-cond.s: New test.
	* ld-arm/farcall-cond-thumb-arm.s: Ditto.
	* ld-arm/jump-reloc-veneers-cond-short.d: Expected output
	for target without a veneer generation.
	* ld-arm/jump-reloc-veneers-cond-long.d: Expected output
	for target with a veneer generation.
	* ld-arm/farcall-cond-thumb-arm.d: Expected output for
	inter working veneer generation.
	* ld-arm/arm-elf.exp: Add tests for conditional branch veneer.
2014-08-21 18:00:35 +08:00
Roland McGrath 469a34932a Fix PR ld/17277: bogus dynamic relocs and TEXTREL for ARM PC-relative relocs
bfd/
	PR ld/17277
	* elf32-arm.c (elf32_arm_check_relocs): Increment P->pc_count for
	all reloc types with pc_relative set in the howto, not just for
	R_ARM_REL32 and R_ARM_REL32_NOI.
	(allocate_dynrelocs_for_symbol): Update comment.
	(elf32_arm_gc_sweep_hook): For all reloc types with pc_relative
	set in the howto, set call_reloc_p and may_need_local_target_p but
	not may_become_dynamic_p; not only for R_ARM_REL32 and R_ARM_REL32_NOI.
	(elf32_arm_check_relocs): Likewise.

ld/testsuite/
	PR ld/17277
	* ld-arm/pcrel-shared.s: New file.
	* ld-arm/pcrel-shared.rd: New file.
	* ld-arm/arm-elf.exp (armelftests_common): Add it.
2014-08-20 10:12:57 -07:00
Alan Modra cb8e01c6bb LTO plugin with older gcc
* ld-plugin/lto.exp: Use gcc -print-file-name to find lto plugin.
2014-08-18 21:01:26 +09:30
Alan Modra 1240be6b7d PR 17287, DT_NEEDED of unneeded libraries affects --as-needed
PR 17287
bfd/
	* elflink.c (on_needed_list): Only consider libraries that have
	been loaded.
ld/
	* ld.texinfo (--as-needed): Clarify that references from libraries
	must be from needed libraries.
ld/testsuite/
	* ld-plugin/needed3.c: New file.
	* ld-elf/shared.exp: Add needed3 test.
2014-08-18 18:45:01 +09:30
Alan Modra 2d03dd2f8d Tighten test for ld plugin support
To not match spu --plugin option.

	* lib/ld-lib.exp (check_plugin_api_available): Match "-plugin PLUGIN".
2014-08-12 20:51:11 +09:30
H.J. Lu db7129469b Don't issue a warning for references in LTO IR to warning symbols
bfd/
	PR ld/16746
	* linker.c (_bfd_generic_link_add_one_symbol): Don't issue a
	warning for references in LTO IR to warning symbols.

ld/testsuite/
	PR ld/16746
	* ld-plugin/lto.exp: Add 4 tests for PR ld/16746.
	* ld-plugin/pr16746a.c: New file.
	* ld-plugin/pr16746b.c: Likewise.
	* ld-plugin/pr16746c.c: Likewise.
	* ld-plugin/pr16746d.c: Likewise.
2014-08-07 10:28:48 +09:30
Alan Modra c3e11cbe51 Allow lto tests to run with older compilers
* lib/ld-lib.exp (check_lto_fat_available): New.
	(check_lto_available): Remove -ffat-lto-objects test.
	* ld-plugin/lto.exp: Use [list ] rather than { } to set up list
	variables, allowing substition of vars.  Set lto_fat and plug_opt
	and add to various tests.
2014-08-06 13:26:18 +09:30
Kaz Kojima 8c78401680 Fix PR10373 which is SH relax bug. 2014-08-01 19:17:47 +09:00
Kaz Kojima b131d1fcfa Fix PR10378 which is SH relax bug. 2014-08-01 19:13:39 +09:00
Matthew Fortune 351cdf24d2 [MIPS] Implement O32 FPXX, FP64 and FP64A ABI extensions
Specification:
https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking

include/

	* elf/mips.h (PT_MIPS_ABIFLAGS, SHT_MIPS_ABIFLAGS): Define.
	(Val_GNU_MIPS_ABI_FP_OLD_64): Rename from Val_GNU_MIPS_ABI_FP_64.
	(Val_GNU_MIPS_ABI_FP_64): Redefine.
	(Val_GNU_MIPS_ABI_FP_XX): Define.
	(Elf_External_ABIFlags_v0, Elf_Internal_ABIFlags_v0): New structures.
	(AFL_REG_NONE, AFL_REG_32, AFL_REG_64, AFL_REG_128): Define.
	(AFL_ASE_DSP, AFL_ASE_DSPR2, AFL_ASE_EVA, AFL_ASE_MCU): Likewise.
	(AFL_ASE_MDMX, AFL_ASE_MIPS3D, AFL_ASE_MT, AFL_ASE_SMARTMIPS): Likewise.
	(AFL_ASE_VIRT, AFL_ASE_MSA, AFL_ASE_MIPS16): Likewise.
	(AFL_ASE_MICROMIPS, AFL_ASE_XPA): Likewise.
	(AFL_EXT_XLR, AFL_EXT_OCTEON2, AFL_EXT_OCTEONP): Likewise.
	(AFL_EXT_LOONGSON_3A, AFL_EXT_OCTEON, AFL_EXT_5900): Likewise.
	(AFL_EXT_4650, AFL_EXT_4010, AFL_EXT_4100, AFL_EXT_3900): Likewise.
	(AFL_EXT_10000, AFL_EXT_SB1, AFL_EXT_4111, AFL_EXT_4120): Likewise.
	(AFL_EXT_5400, AFL_EXT_5500, AFL_EXT_LOONGSON_2E): Likewise.
	(AFL_EXT_LOONGSON_2F): Likewise.
	(bfd_mips_elf_swap_abiflags_v0_in): Prototype.
	(bfd_mips_elf_swap_abiflags_v0_out): Likewise.
	(bfd_mips_isa_ext): Likewise.

bfd/

	* elfxx-mips.c (ABI_O32_P, MIPS_ELF_ABIFLAGS_SECTION_NAME_P): New macro.
	(mips_elf_obj_tdata): Add abiflags and abiflags_valid fields.
	(bfd_mips_elf_swap_abiflags_v0_in): New function.
	(bfd_mips_elf_swap_abiflags_v0_out): Likewise.
	(_bfd_mips_elf_section_from_shdr): Handle SHT_MIPS_ABIFLAGS.
	(_bfd_mips_elf_fake_sections): Likewise.
	(_bfd_mips_elf_always_size_sections): Handle .MIPS.abiflags.
	(_bfd_mips_elf_additional_program_headers): Account for new
	PT_MIPS_ABIFLAGS program header.
	(_bfd_mips_elf_modify_segment_map): Create PT_MIPS_ABIFLAGS segment and
	associate with .MIPS.abiflags.
	(_bfd_mips_elf_gc_mark_extra_sections): New function.
	(bfd_mips_isa_ext, update_mips_abiflags_isa): New static function.
	(infer_mips_abiflags): Likewise.
	(_bfd_mips_elf_final_link): Handle .MIPS.abiflags.
	(mips_32bit_flags_p): Moved higher.
	(mips_elf_merge_obj_attributes, _bfd_mips_fp_abi_string): Error
	checking for FP ABIs.
	(_bfd_mips_elf_merge_private_bfd_data): Restructure and add abiflags
	checks.  Check EF_MIPS_FP64 flag consistency.
	(print_mips_ases, print_mips_isa_ext): New static function.
	(print_mips_fp_abi_value, get_mips_reg_size): Likewise.
	(_bfd_mips_elf_print_private_bfd_data): Display abiflags data.
	(_bfd_mips_post_process_headers): Set EI_ABIVERSION = 3 for
	Val_GNU_MIPS_ABI_FP_64 or Val_GNU_MIPS_ABI_FP_64A.
	* elfxx-mips.h (_bfd_mips_elf_gc_mark_extra_sections): New prototype.
	* elf32-mips.c (elf_backend_gc_mark_extra_sections): Implement.
	* elfn32-mips.c (elf_backend_gc_mark_extra_sections): Implement.
	* elf64-mips.c (elf_backend_gc_mark_extra_sections): Implement.

binutils/

	* readelf.c (get_mips_segment_type): Display name for PT_MIPS_ABIFLAGS.
	(get_mips_section_type_name): Display name for SHT_MIPS_ABIFLAGS.
	(display_mips_gnu_attribute): Abstracted fp abi printing to...
	(print_mips_fp_abi_value): New static function. Handle new FP ABIs.
	(print_mips_ases, print_mips_isa_ext): New static functions.
	(get_mips_reg_size): Likewise.
	(process_mips_specific): Display abiflags data.

elfcpp/

	* elfcpp.h (PT_MIPS_ABIFLAGS): New program header type.

gas/

	* config/tc-mips.c (mips_flags_frag): New static global.
	(struct mips_set_options): Add oddspreg field.
	(file_mips_opts, mips_opts): Initialize oddspreg.
	(ISA_HAS_ODD_SINGLE_FPR): Add CPU argument and update for R5900 and
	Loongson-3a.
	(enum options, md_longopts, md_parse_option): Add -mfpxx, -modd-spreg
	and -mno-odd-spreg options.
	(md_begin): Create .MIPS.abiflags section.
	(fpabi_incompatible_with, fpabi_requires): New static function.
	(check_fpabi): Likewise.
	(mips_check_options): Handle fp=xx and oddspreg restrictions.
	(file_mips_check_options): Set oddspreg by default for fp=xx.
	(mips_oddfpreg_ok): Re-write function.
	(check_regno): Check odd numbered registers regardless of FPR size.
	For fp != 32 use as_bad instead of as_warn.
	(match_float_constant): Rewrite check regarding FP register width.  Add
	support for generating constants when MXHC1 is present.  Handle fp=xx
	to comply with the ABI.
	(macro): Update M_LI_DD similarly to match_float_constant.  Generate
	MTHC1 when available.  Check that correct code can be generated for
	fp=xx and fp=64 ABIs.
	(parse_code_option, s_mipsset): Add fp=xx, oddspreg and nooddspreg
	options.
	(mips_convert_ase_flags): New static function.
	(mips_elf_final_processing): Use fpabi == Val_GNU_MIPS_ABI_FP_OLD_64
	to determine when to add the EF_MIPS_FP64 flag.  Populate the
	.MIPS.abiflags section.
	(md_mips_end): Update .gnu_attribute based on command line and .module
	as applicable.  Use check_fpabi to ensure .gnu.attribute and command
	line/.module options are consistent.
	* doc/as.texinfo: Add missing -mgp64/-mfp64 options and document new
	-mfpxx, -modd-spreg and -mno-odd-spreg options.
	* doc/c-mips.texi: Document -mfpxx, -modd-spreg, -mno-odd-spreg,
	gnu_attribute values and FP ABIs.

ld/

	* emulparams/elf32bmip.sh: Add .MIPS.abiflags.
	* emulparams/elf32bmipn32-defs.sh: Likewise.
	* emulparams/elf64bmip-defs.sh: Likewise.

opcodes/

	* micromips-opc.c (COD, LCD) New macros.
	(cfc1, ctc1): Remove FP_S attribute.
	(dmfc1, mfc1, mfhc1): Add LCD attribute.
	(dmtc1, mtc1, mthc1): Add COD attribute.
	* mips-opc.c (cfc1, cftc1, ctc, cttc1): Remove FP_S attribute.

binutils/testsuite/

	* binutils-all/readelf.s: Account for .MIPS.abiflags and
	.gnu.attributes.
	* binutils-all/readelf.ss-tmips: Likewise.
	* binutils-all/strip-3.d: Likewise.

gas/testsuite/

	* gas/mips/attr-gnu-4-0.d: New.
	* gas/mips/attr-gnu-4-0.s: Likewise.
	* gas/mips/attr-gnu-4-1-mfp32.l: Likewise.
	* gas/mips/attr-gnu-4-1-mfp32.s: Likewise.
	* gas/mips/attr-gnu-4-1-mfp64.l: Likewise.
	* gas/mips/attr-gnu-4-1-mfp64.s: Likewise.
	* gas/mips/attr-gnu-4-1-mfpxx.s: Likewise.
	* gas/mips/attr-gnu-4-1-msingle-float.l: Likewise.
	* gas/mips/attr-gnu-4-1-msingle-float.s: Likewise.
	* gas/mips/attr-gnu-4-1-msoft-float.l: Likewise.
	* gas/mips/attr-gnu-4-1-msoft-float.s: Likewise.
	* gas/mips/attr-gnu-4-1.d: Likewise.
	* gas/mips/attr-gnu-4-1.s: Likewise.
	* gas/mips/attr-gnu-4-2-mdouble-float.l: Likewise.
	* gas/mips/attr-gnu-4-2-mdouble-float.s: Likewise.
	* gas/mips/attr-gnu-4-2-msoft-float.l: Likewise.
	* gas/mips/attr-gnu-4-2-msoft-float.s: Likewise.
	* gas/mips/attr-gnu-4-2.d: Likewise.
	* gas/mips/attr-gnu-4-2.s: Likewise.
	* gas/mips/attr-gnu-4-3-mhard-float.l: Likewise.
	* gas/mips/attr-gnu-4-3-mhard-float.s: Likewise.
	* gas/mips/attr-gnu-4-3.d: Likewise.
	* gas/mips/attr-gnu-4-3.s: Likewise.
	* gas/mips/attr-gnu-4-4.l: Likewise.
	* gas/mips/attr-gnu-4-4.s: Likewise.
	* gas/mips/attr-gnu-4-5-64.l: Likewise.
	* gas/mips/attr-gnu-4-5-64.s: Likewise.
	* gas/mips/attr-gnu-4-5.d: Likewise.
	* gas/mips/attr-gnu-4-5.l: Likewise.
	* gas/mips/attr-gnu-4-5.s: Likewise.
	* gas/mips/attr-gnu-4-6-64.l: Likewise.
	* gas/mips/attr-gnu-4-6-64.s: Likewise.
	* gas/mips/attr-gnu-4-6.d: Likewise.
	* gas/mips/attr-gnu-4-6.l: Likewise.
	* gas/mips/attr-gnu-4-6.s: Likewise.
	* gas/mips/attr-gnu-4-6-msingle-float.l: Likewise.
	* gas/mips/attr-gnu-4-6-msingle-float.s: Likewise.
	* gas/mips/attr-gnu-4-6-msoft-float.l: Likewise.
	* gas/mips/attr-gnu-4-6-msoft-float.s: Likewise.
	* gas/mips/attr-gnu-4-6-noodd.l: Likewise.
	* gas/mips/attr-gnu-4-6-noodd.s: Likewise.
	* gas/mips/attr-gnu-4-7-64.l: Likewise.
	* gas/mips/attr-gnu-4-7-64.s: Likewise.
	* gas/mips/attr-gnu-4-7-msingle-float.l: Likewise.
	* gas/mips/attr-gnu-4-7-msingle-float.s: Likewise.
	* gas/mips/attr-gnu-4-7-msoft-float.l: Likewise.
	* gas/mips/attr-gnu-4-7-msoft-float.s: Likewise.
	* gas/mips/attr-gnu-4-7-odd.l: Likewise.
	* gas/mips/attr-gnu-4-7-odd.s: Likewise.
	* gas/mips/attr-gnu-4-7.d: Likewise.
	* gas/mips/attr-gnu-4-7.l: Likewise.
	* gas/mips/attr-gnu-4-7.s: Likewise.
	* gas/mips/attr-none-double.d: Likewise.
	* gas/mips/attr-none-o32-fp64.d: Likewise.
	* gas/mips/attr-none-o32-fp64-nooddspreg.d
	* gas/mips/attr-none-o32-fpxx.d: Likewise.
	* gas/mips/attr-none-single-float.d: Likewise.
	* gas/mips/attr-none-soft-float.d: Likewise.
	* gas/mips/elf_arch_mips32r3.d: Likewise.
	* gas/mips/elf_arch_mips32r5.d: Likewise.
	* gas/mips/elf_arch_mips64r3.d: Likewise.
	* gas/mips/elf_arch_mips64r5.d: Likewise.
	* gas/mips/li-d.d: Likewise.
	* gas/mips/li-d.s: Likewise.
	* gas/mips/module-check-warn.l: Likewise.
	* gas/mips/module-check-warn.s: Likewise.
	* gas/mips/module-check.d: Likewise.
	* gas/mips/module-check.s: Likewise.
	* gas/mips/module-mfp32.d: Likewise.
	* gas/mips/module-mfp32.s: Likewise.
	* gas/mips/module-mfp64.d: Likewise.
	* gas/mips/module-mfp64.s: Likewise.
	* gas/mips/module-mfp64-noodd.d: Likewise.
	* gas/mips/module-mfp64-noodd.s: Likewise.
	* gas/mips/module-mfpxx.d: Likewise.
	* gas/mips/module-mfpxx.s: Likewise.
	* gas/mips/module-msingle-float.d: Likewise.
	* gas/mips/module-msingle-float.s: Likewise.
	* gas/mips/module-msoft-float.d: Likewise.
	* gas/mips/module-msoft-float.s: Likewise.
	* gas/mips/module-set-mfpxx.d: Likewise.
	* gas/mips/module-set-mfpxx.s: Likewise.
	* gas/mips/fpxx-oddfpreg.d: Likewise.
	* gas/mips/fpxx-oddfpreg.l: Likewise.
	* gas/mips/fpxx-oddfpreg.s: Likewise.
	* gas/mips/no-odd-spreg.d: Likewise.
	* gas/mips/odd-spreg.d: Likewise.
	* gas/elf/section2.e-mips: Adjust expected output.
	* gas/mips/attr-gnu-abi-fp-1.d: Likewise.
	* gas/mips/attr-gnu-abi-msa-1.d: Likewise.
	* gas/mips/call-nonpic-1.d: Likewise.
	* gas/mips/elf_arch_mips1.d: Likewise.
	* gas/mips/elf_arch_mips2.d: Likewise.
	* gas/mips/elf_arch_mips3.d: Likewise.
	* gas/mips/elf_arch_mips32.d: Likewise.
	* gas/mips/elf_arch_mips32r2.d: Likewise.
	* gas/mips/elf_arch_mips4.d: Likewise.
	* gas/mips/elf_arch_mips5.d: Likewise.
	* gas/mips/elf_arch_mips64.d: Likewise.
	* gas/mips/elf_arch_mips64r2.d: Likewise.
	* gas/mips/elf_ase_micromips-2.d: Likewise.
	* gas/mips/elf_ase_micromips.d: Likewise.
	* gas/mips/elf_ase_mips16-2.d: Likewise.
	* gas/mips/elf_ase_mips16.d: Likewise.
	* gas/mips/module-defer-warn1.d: Likewise.
	* gas/mips/module-override.d: Likewise.
	* gas/mips/n32-consec.d: Likewise.
	* gas/mips/nan-2008-1.d: Likewise.
	* gas/mips/nan-2008-2.d: Likewise.
	* gas/mips/nan-2008-3.d: Likewise.
	* gas/mips/nan-2008-4.d: Likewise.
	* gas/mips/nan-legacy-1.d: Likewise.
	* gas/mips/nan-legacy-2.d: Likewise.
	* gas/mips/nan-legacy-3.d: Likewise.
	* gas/mips/nan-legacy-4.d: Likewise.
	* gas/mips/nan-legacy-5.d: Likewise.
	* gas/mips/tmips16-e.d: Likewise.
	* gas/mips/tmips16-f.d: Likewise.
	* gas/mips/tmipsel16-e.d: Likewise.
	* gas/mips/tmipsel16-f.d: Likewise.
	* gas/testsuite/gas/mips/mips.exp: Add new tests.

ld/testsuite/

	* ld-mips-elf/abiflags-strip1-ph.d: New.
	* ld-mips-elf/abiflags-strip2-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip3-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip4-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip5-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip6-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip7-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip8-ph.d: Likewise.
	* ld-mips-elf/abiflags-strip9-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-0-n32-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-0-n64-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-0-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-06.d: Likewise.
	* ld-mips-elf/attr-gnu-4-07.d: Likewise.
	* ld-mips-elf/attr-gnu-4-08.d: Likewise.
	* ld-mips-elf/attr-gnu-4-1-n32-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-1-n64-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-1-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-16.d: Likewise.
	* ld-mips-elf/attr-gnu-4-17.d: Likewise.
	* ld-mips-elf/attr-gnu-4-18.d: Likewise.
	* ld-mips-elf/attr-gnu-4-2-n32-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-2-n64-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-2-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-26.d: Likewise.
	* ld-mips-elf/attr-gnu-4-27.d: Likewise.
	* ld-mips-elf/attr-gnu-4-28.d: Likewise.
	* ld-mips-elf/attr-gnu-4-3-n32-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-3-n64-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-3-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-36.d: Likewise.
	* ld-mips-elf/attr-gnu-4-37.d: Likewise.
	* ld-mips-elf/attr-gnu-4-38.d: Likewise.
	* ld-mips-elf/attr-gnu-4-4-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-46.d: Likewise.
	* ld-mips-elf/attr-gnu-4-47.d: Likewise.
	* ld-mips-elf/attr-gnu-4-48.d: Likewise.
	* ld-mips-elf/attr-gnu-4-5-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-50.d: Likewise.
	* ld-mips-elf/attr-gnu-4-52.d: Likewise.
	* ld-mips-elf/attr-gnu-4-53.d: Likewise.
	* ld-mips-elf/attr-gnu-4-54.d: Likewise.
	* ld-mips-elf/attr-gnu-4-55.d: Likewise.
	* ld-mips-elf/attr-gnu-4-56.d: Likewise.
	* ld-mips-elf/attr-gnu-4-57.d: Likewise.
	* ld-mips-elf/attr-gnu-4-58.d: Likewise.
	* ld-mips-elf/attr-gnu-4-6-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-6.s: Likewise.
	* ld-mips-elf/attr-gnu-4-60.d: Likewise.
	* ld-mips-elf/attr-gnu-4-61.d: Likewise.
	* ld-mips-elf/attr-gnu-4-62.d: Likewise.
	* ld-mips-elf/attr-gnu-4-63.d: Likewise.
	* ld-mips-elf/attr-gnu-4-64.d: Likewise.
	* ld-mips-elf/attr-gnu-4-65.d: Likewise.
	* ld-mips-elf/attr-gnu-4-66.d: Likewise.
	* ld-mips-elf/attr-gnu-4-67.d: Likewise.
	* ld-mips-elf/attr-gnu-4-68.d: Likewise.
	* ld-mips-elf/attr-gnu-4-7-ph.d: Likewise.
	* ld-mips-elf/attr-gnu-4-7.s: Likewise.
	* ld-mips-elf/attr-gnu-4-70.d: Likewise.
	* ld-mips-elf/attr-gnu-4-71.d: Likewise.
	* ld-mips-elf/attr-gnu-4-72.d: Likewise.
	* ld-mips-elf/attr-gnu-4-73.d: Likewise.
	* ld-mips-elf/attr-gnu-4-74.d: Likewise.
	* ld-mips-elf/attr-gnu-4-75.d: Likewise.
	* ld-mips-elf/attr-gnu-4-76.d: Likewise.
	* ld-mips-elf/attr-gnu-4-77.d: Likewise.
	* ld-mips-elf/attr-gnu-4-78.d: Likewise.
	* ld-mips-elf/attr-gnu-4-8.s: Likewise.
	* ld-mips-elf/attr-gnu-4-81.d: Likewise.
	* ld-mips-elf/empty.s: Likewise.
	* ld-mips-elf/attr-gnu-4-00.d: Adjust expected output.
	* ld-mips-elf/attr-gnu-4-01.d: Likewise.
	* ld-mips-elf/attr-gnu-4-02.d: Likewise.
	* ld-mips-elf/attr-gnu-4-03.d: Likewise.
	* ld-mips-elf/attr-gnu-4-04.d: Likewise.
	* ld-mips-elf/attr-gnu-4-05.d: Likewise.
	* ld-mips-elf/attr-gnu-4-10.d: Likewise.
	* ld-mips-elf/attr-gnu-4-11.d: Likewise.
	* ld-mips-elf/attr-gnu-4-14.d: Likewise.
	* ld-mips-elf/attr-gnu-4-15.d: Likewise.
	* ld-mips-elf/attr-gnu-4-2.s: Likewise.
	* ld-mips-elf/attr-gnu-4-20.d: Likewise.
	* ld-mips-elf/attr-gnu-4-22.d: Likewise.
	* ld-mips-elf/attr-gnu-4-24.d: Likewise.
	* ld-mips-elf/attr-gnu-4-25.d: Likewise.
	* ld-mips-elf/attr-gnu-4-3.s: Likewise.
	* ld-mips-elf/attr-gnu-4-30.d: Likewise.
	* ld-mips-elf/attr-gnu-4-33.d: Likewise.
	* ld-mips-elf/attr-gnu-4-34.d: Likewise.
	* ld-mips-elf/attr-gnu-4-35.d: Likewise.
	* ld-mips-elf/attr-gnu-4-40.d: Likewise.
	* ld-mips-elf/attr-gnu-4-41.d: Likewise.
	* ld-mips-elf/attr-gnu-4-42.d: Likewise.
	* ld-mips-elf/attr-gnu-4-43.d: Likewise.
	* ld-mips-elf/attr-gnu-4-44.d: Likewise.
	* ld-mips-elf/attr-gnu-4-45.d: Likewise.
	* ld-mips-elf/attr-gnu-4-5.s: Likewise.
	* ld-mips-elf/attr-gnu-4-51.d: Likewise.
	* ld-mips-elf/attr-gnu-8-00.d: Likewise.
	* ld-mips-elf/attr-gnu-8-01.d: Likewise.
	* ld-mips-elf/attr-gnu-8-02.d: Likewise.
	* ld-mips-elf/attr-gnu-8-10.d: Likewise.
	* ld-mips-elf/attr-gnu-8-11.d: Likewise.
	* ld-mips-elf/attr-gnu-8-20.d: Likewise.
	* ld-mips-elf/attr-gnu-8-22.d: Likewise.
	* ld-mips-elf/jalx-2.dd: Likewise.
	* ld-mips-elf/mips16-pic-1.gd: Likewise.
	* ld-mips-elf/mips16-pic-2.gd: Likewise.
	* ld-mips-elf/mips16-pic-3.gd: Likewise.
	* ld-mips-elf/mips16-pic-4a.gd: Likewise.
	* ld-mips-elf/multi-got-no-shared.d: Likewise.
	* ld-mips-elf/nan-2008.d: Likewise.
	* ld-mips-elf/nan-legacy.d: Rework test.
	* ld-mips-elf/pic-and-nonpic-3a.gd: Likewise.
	* ld-mips-elf/pic-and-nonpic-3b.gd: Likewise.
	* ld-mips-elf/pic-and-nonpic-5b.gd: Likewise.
	* ld-mips-elf/pic-and-nonpic-6.ld: Likewise.
	* ld-mips-elf/rel32-n32.d: Likewise.
	* ld-mips-elf/rel32-o32.d: Likewise.
	* ld-mips-elf/rel64.d: Likewise.
	* ld-mips-elf/tls-multi-got-1.r: Likewise.
	* ld-elf/group.ld: Discard .MIPS.abiflags and .gnu.attributes.
	* ld-elf/orphan-region.ld: Likewise.
	* ld-elf/orphan.ld: Likewise.
	* ld-mips-elf/compressed-plt-1.ld: Likewise.
	* ld-mips-elf/dyn-sec64.ld: Likewise.
	* ld-mips-elf/got-dump-1.ld: Likewise.
	* ld-mips-elf/got-dump-2.ld: Likewise.
	* ld-mips-elf/got-page-1.ld: Likewise.
	* ld-mips-elf/mips-dyn.ld: Likewise.
	* ld-mips-elf/mips-lib.ld: Likewise.
	* ld-mips-elf/pic-and-nonpic-3a.ld: Likewise.
	* ld-mips-elf/pic-and-nonpic-3b.ld: Likewise.
	* ld-mips-elf/pic-and-nonpic-4b.ld: Likewise.
	* ld-mips-elf/pic-and-nonpic-5b.ld: Likewise.
	* ld-mips-elf/region1.t: Likewise.
	* ld-mips-elf/stub-dynsym-1.ld: Likewise.
	* ld-mips-elf/tls-hidden3.ld: Likewise.
	* ld-mips-elf/vxworks1.ld: Likewise.
	* ld-scripts/overlay-size.t: Likewise.
	* ld-mips-elf/elf-rel-got-n32-embed.d: Remove .MIPS.abiflags from
	objects.
	* ld-mips-elf/elf-rel-got-n32.d: Likewise.
	* ld-mips-elf/elf-rel-got-n64-embed.d: Likewise.
	* ld-mips-elf/elf-rel-got-n64-linux.d: Likewise.
	* ld-mips-elf/elf-rel-got-n64.d: Likewise.
	* ld-mips-elf/elf-rel-xgot-n32.d: Likewise.
	* ld-mips-elf/elf-rel-xgot-n32-embed.d: Likewise.
	* ld-mips-elf/elf-rel-xgot-n64.d: Likewise.
	* ld-mips-elf/elf-rel-xgot-n64-linux.d: Likewise.
	* ld-mips-elf/elf-rel-xgot-n64-embed.d: Likewise.
	* ld-mips-elf/mips-elf.exp: Add new tests.
2014-07-29 11:27:59 +01:00
H.J. Lu 144bed8d4d Properly match PLT entry against .got.plt relocation
Relocations against .got.plt section may not be in the same order as
entries in PLT section.  It is incorrect to assume that the Ith reloction
index against .got.plt section always maps to the (I + 1)th entry in PLT
section.  This patch matches the .got.plt relocation offset/index in PLT
entry against the index in .got.plt relocation table.  It only checks
R_*_JUMP_SLOT and R_*_IRELATIVE relocations.  It ignores R_*_TLS_DESC
and R_*_TLSDESC relocations since they have different PLT entries.

bfd/

	PR binutils/17154
	* elf32-i386.c (elf_i386_plt_sym_val): Only match R_*_JUMP_SLOT
	and R_*_IRELATIVE relocation offset with PLT entry.
	* elf64-x86-64.c (elf_x86_64_plt_sym_val): Likewise.
	(elf_x86_64_plt_sym_val_offset_plt_bnd): New.
	(elf_x86_64_get_synthetic_symtab): Use it.

ld/testsuite/

	PR binutils/17154
	* ld-ifunc/pr17154-i386.d: New file.
	* ld-ifunc/pr17154-x86-64.d: Likewise.
	* ld-ifunc/pr17154-x86.s: Likewise.
	* ld-x86-64/bnd-ifunc-2.d: Likewise.
	* ld-x86-64/bnd-ifunc-2.s: Likewise.
	* ld-x86-64/mpx.exp: Run bnd-ifunc-2.
	* ld-x86-64/tlsdesc-nacl.pd: Updated.
	* ld-x86-64/tlsdesc.pd: Likewise.
2014-07-16 10:57:49 -07:00
H.J. Lu 998d811a23 Update elf_i386_compute_jump_table_size
Commit e1f987424b changed how
next_tls_desc_index was set up.  This patch updates
elf_i386_compute_jump_table_size to use elf.srelplt->reloc_count
instead of next_tls_desc_index.

bfd/

	PR ld/17057
	* elf32-i386.c (elf_i386_compute_jump_table_size): Replace
	next_tls_desc_index with elf.srelplt->reloc_count.

ld/testsuite/

	PR ld/17057
	* ld-i386/i386.exp: Run pr17057.
	* ld-i386/pr17057.d: New file.
	* ld-i386/pr17057.s: Likewise.
2014-07-15 13:09:55 -07:00
Jiong Wang d6f18fe6ca [AArch64] Fix ld testcase linker script glitch.
Specify -T relocs.ld for emit-relocs-local-addend.d to be consistent
  will all other emit-relocs* testcases

  ld/testsuite/
    * ld-aarch64/emit-relocs-local-addend.d: Use target linker script.
2014-07-15 10:08:55 +01:00
Will Newton 6a2619f953 Fix tests when configured for arm-linux and arm-elf
With this change all gas and most ld tests pass when configured for
arm-linux. It doesn't look like these configurations have been
tested in a long time but this attempts to stem the bit-rot slightly.

gas/testsuite/ChangeLog:

2014-07-10  Will Newton  <will.newton@linaro.org>

	* gas/arm/bl-local-2.d: Only enable the test on EABI and
	NaCl configurations.
	* gas/arm/bl-local-v4t.d: Likewise.
	* gas/arm/blx-local.d: Likewise.
	* gas/arm/branch-reloc.d: Likewise.

ld/testsuite/ChangeLog:

2014-07-10  Will Newton  <will.newton@linaro.org>

	* ld-arm/arm-elf.exp (armelftests_nonacl): Move Cortex-A8 fix
	tests, IFUNC tests and other EABI requiring tests to...
	(armeabitests_nonacl): ...here.
	* ld-arm/arm-app-abs32.d: Loosen regex for architecture type
	to allow test to pass on configurations without an attributes
	section.
	* ld-arm/arm-app.d: Likewise.
	* ld-arm/arm-lib-plt32.d: Likewise.
	* ld-arm/arm-lib.d: Likewise.
	* ld-arm/arm-static-app.d: Likewise.
	* ld-arm/armthumb-lib.d: Likewise.
	* ld-arm/cortex-a8-far.d: Likewise.
	* ld-arm/farcall-mixed-app.d: Likewise.
	* ld-arm/farcall-mixed-lib-v4t.d: Likewise.
	* ld-arm/farcall-mixed-lib.d: Likewise.
	* ld-arm/mixed-app-v5.d: Likewise.
	* ld-arm/mixed-app.d: Likewise.
	* ld-arm/mixed-lib.d: Likewise.
	* ld-arm/tls-app.d: Likewise.
	* ld-arm/tls-descrelax-be32.d: Likewise.
	* ld-arm/tls-descrelax.d: Likewise.
	* ld-arm/tls-descseq.d: Likewise.
	* ld-arm/tls-gdesc-got.d: Likewise.
	* ld-arm/tls-gdesc.d: Likewise.
	* ld-arm/tls-gdierelax.d: Likewise.
	* ld-arm/tls-gdierelax2.d: Likewise.
	* ld-arm/tls-gdlerelax.d: Likewise.
	* ld-arm/tls-lib-loc.d: Likewise.
	* ld-arm/tls-lib.d: Likewise.
	* ld-arm/tls-thumb1.d: Likewise.
2014-07-10 09:32:56 +01:00
Will Newton 6f86b3b000 ld/testsuite: Disable non-PIC shared library tests on ARM
ARM doesn't support non-PIC shared libraries so don't run those
tests.

ld/testsuite/ChangeLog:

2014-07-10  Will Newton  <will.newton@linaro.org>

	* ld-elfvers/vers.exp: Set pic to yes for ARM targets.
2014-07-10 09:32:42 +01:00
Will Newton 7572ca8989 ld/ARM: Increase maximum page size to 64kB
Increase the maximum page size to 64kB and align the TEXT_START_ADDR
to a 64kB boundary. This brings AArch32 in line with AArch64 and
improves compatability under certain conditions.

bfd/ChangeLog:

2014-07-08  Will Newton  <will.newton@linaro.org>

	* elf32-arm.c (ELF_MAXPAGESIZE): Increase the default
	value to 64kB and remove custom setting for NaCl.

ld/ChangeLog:

2014-07-08  Will Newton  <will.newton@linaro.org>

	* emulparams/armelf_linux.sh (TEXT_START_ADDR): Increase
	alignment to 64kB boundary.

ld/testsuite/ChangeLog:

2014-07-08  Will Newton  <will.newton@linaro.org>

	* ld-arm/arm-lib.ld: Increase MAXPAGESIZE value to
	match bfd.
	* ld-arm/cortex-a8-fix-bl-rel-plt.d: Update offsets to
	take into account increased segment alignment.
	* ld-arm/ifunc-gdesc.r: Likewise.
	* ld-arm/tls-lib.d: Likewise.
2014-07-08 15:00:12 +01:00
Alan Modra bffebb6ba5 Copy st_other for linker script symbol assignments
This fixes a problem seen on powerpc64le ELFv2 when creating a
function symbol alias with ld --defsym.  st_other needs to be copied
from the source symbol to the alias in order to set up the local entry
offset for the alias.  I decided to make this change in the generic
ELF code rather than in elf64-ppc.c since it looks like other targets
that use st_other bits might benefit too.

bfd/
	* elflink.c (_bfd_elf_copy_link_hash_symbol_type): Copy st_other
	bits from source to dest.
	* linker.c (_bfd_generic_copy_link_hash_symbol_type): Update comment.
	* targets.c (struct bfd_target <_bfd_copy_link_hash_symbol_type>):
	Likewise.
	* bfd-in2.h: Regenerate.
ld/testsuite/
	* ld-powerpc/defsym.s, * ld-powerpc/defsym.d: New test.
	* ld-powerpc/powerpc.exp: Run it.
2014-07-08 19:42:03 +09:30
Jiong Wang 2e0488d33f Enable elf_backend_rela_normal for AArch64
If we are generating non-relocatable object and --emit-relocs specified,
  aarch64 ld is actually generating wrong addend for rela entry when
  relocate against local symbol.

  for example, for simple testcase

  foo.c
  ===

  const char * const a = "foo";

  const char *
  foo ()
  {
    return a;
  }

  bar.c
  ===

  const char * const b = "bar";

  const char * bar ()
  {
    return b;
  }

  aarch64-none-linux-gnu-ld --emit-relocs -o x.o  foo.o bar.o
  aarch64-none-linux-gnu-readelf -r x.o

   ... R_AARCH64_ADR_PRE 0000000000400018 .rodata + 0
   ... R_AARCH64_ADD_ABS 0000000000400018 .rodata + 0
   ... R_AARCH64_ADR_PRE 0000000000400018 .rodata + 0
   ... R_AARCH64_ADD_ABS 0000000000400018 .rodata + 0

   while it should be:

   ... R_AARCH64_ADR_PRE 0000000000400018 .rodata + 0
   ... R_AARCH64_ADD_ABS 0000000000400018 .rodata + 0
   ... R_AARCH64_ADR_PRE 0000000000400018 .rodata + 10
   ... R_AARCH64_ADD_ABS 0000000000400018 .rodata + 10

   bfd generic code could actually handle this properly, but only when
   elf_backend_rela_normal set to '1'.

   this patch enable this and remove those target specific hack.

    bfd/
      * elfnn-aarch64.c (elf_backend_rela_normal): Set to 1.
      (elfNN_aarch64_relocate_section): Remove duplicated addend adjustment
      when info->relocatable be true.

    ld/testsuite/
      * ld-aarch64/emit-relocs-local-addend-bar.s: * New source file.
      * ld-aarch64/emit-relocs-local-addend-foo.s: * Likewise.
      * ld-aarch64/emit-relocs-local-addend.d: * New testcase.
      * ld-aarch64/local-addend-r.d: Likewise.
2014-07-08 09:29:06 +01:00
Alan Modra 37a6ac445d Run ar with --plugin for LTO 11 test
Objects built with -fno-fat-lto-objects (the default for gcc-4.9) have
no normal symbols, except things like __gnu_lto_slim.  These useless
symbols are the ones put into the archive index, and of course nothing
references them so no objects are extracted by the linker.  Running
ar with --plugin changes ar behaviour to put the lto symbols into the
archive index.

	PR 17112
	* ld-plugin/lto.exp: When building liblti-11.a, pass
	--plugin path_to_gcc/liblto_plugin.so to ar.
2014-07-08 10:01:47 +09:30
Alan Modra 3bb9e7b43f Reinstate compiler check
* lib/ld-lib.exp (check_lto_shared_available): Reinstate compiler
	check here too.
2014-07-07 23:46:37 +09:30
Nick Clifton 19aef622f3 This patch prevents a linker testsuite error if the checks are run with a
toolchain that just contains the binutils - ie without a compiler.

	* lib/ld-lib.exp (check_lto_available): Check that a compiler is
	available before testing for LTO support.
2014-07-07 14:41:10 +01:00
Alan Modra f1d7f4a64c Ensure ld testsuite gcc -B options precede $CC -B options
Various ld-elf/shared.exp and ld-plugin/lto.exp tests simply appended
the testsuite -B options intended to force gcc use the linker under test.
This fails if $CC itself has -B options, as when setting CC to run gcc
out of a build directory.  Net result is that tests were run using
the gcc build dir collect-ld.

	* config/default.exp: Don't make tmpdir/gas.  Put as symlink into
	tmpdir/ld.
	(gcc_gas_flag, gcc_ld_flag): Delete.
	(gcc_B_opt, ld_L_opt): New globals.
	ld-elf/shared.exp: Remove all refs to gcc_gas_flag and gcc_ld_flag.
	ld-plugin/lto.exp: Likewise.
	lib/ld-lib.exp (run_host_cmd): Add gcc_B_opt and ld_L_opt here.
	(ld_simple_link): Remove -B handling now that this is done in
	run_host_cmd.  Simplify.
	(default_ld_compile): Simplify.
	(check_lto_available): Use run_host_cmd_yesno.
	(check_lto_shared_available): Likewise.
2014-07-07 13:37:16 +09:30
Alan Modra abc868c609 Rid libdummy.a from lto.exp
libdummy.a is used to make run_cc_link_tests compile objects and
archive them.  libdummy.a isn't used.  What we're really doing is
preventing a final link.  So do that directly.

	* lib/ld-lib.exp (run_ld_link_tests): Stop after assembling objects
	if binfile is empty.
	(run_ld_link_exec_tests, run_cc_link_tests): Likewise.  Tidy
	status checks.
	* ld-plugin/lto.exp: Don't use libdummy.a trick to compile objects.
	Instead use an empty output file.
2014-07-05 12:54:40 +09:30
Alan Modra d215621ebe Reload --as-needed libraries inside groups
When a shared library appears within --start-group/--end-group ld may
only discover a need for loading the library on the second or
subsequent pass over archive libraries, as more objects are extracted.

ld/
	PR 17068
	* ldlang.c (load_symbols): Always check flags.reload.
	(open_input_bfds): Always reload --as-needed shared libraries,
	not just when rescanning.
	* ldlang.h (struct lang_input_statement_flags): Update reload comment.
	* plugin.c (plugin_should_reload): Assume shared library arg.
	* plugin.h (plugin_should_reload): Update comment.
ld/testsuite
	* ld-elf/pr17068.s: New.
	* ld-elf/pr17068a.s: New.
	* ld-elf/pr17068b.s: New.
	* ld-elf/pr17068c.s: New.
	* ld-elf/pr17068d.s: New.
	* ld-elf/pr17068e.s: New.
	* ld-elf/pr17068ez.s: New.
	* ld-elf/elf.exp: Run new test.
2014-07-03 17:05:42 +09:30
Alan Modra d1eca1e41d Taking an undefined function's address in an executable
doesn't always mean you need to define a function symbol on plt code.
If all references are in read-write sections, then using dynamic relocs
is OK.

bfd/
	* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Clear
	pointer_equality_needed when !readonly_dynrelocs.
	* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
ld/testsuite/
	* ld-powerpc/ambiguousv1.d: Match symbol table too.
	* ld-powerpc/ambiguousv2.d: Likewise.
	* ld-powerpc/ambiguousv1b.d: New.
	* ld-powerpc/ambiguousv2b.d: New.
	* ld-powerpc/powerpc.exp: Run new tests.
2014-07-02 18:16:14 +09:30
Kyle McMartin 28bf260962 ld/arm: adjust offsets in tls-gdierelax2.d
Addition of DF_STATIC_TLS in eea6dad2 results in the addition of
flags to the dynamic section, which in turn changes these addresses.
Fix them up to match their new positions.

ld/testsuite/Changelog:

2014-06-24  Kyle McMartin  <kyle@redhat.com>

	* ld-arm/tls-gdierelax2.d: Fix expected offsets.
2014-06-25 10:57:45 -04:00
Will Newton 9f19ab6dfa ld/ARM: Fix IFUNC and TLS descriptors in the same shared object
Combining TLS descriptors and GNU indirect functions in the same
object could lead to assertions or multiple dynamic relocations
for the same GOT slot. Fix the bookkeeping so this doesn't happen.

This allows building and make checking glibc with -mtls-dialect=gnu2.

bfd/ChangeLog:

2014-06-16  Will Newton  <will.newton@linaro.org>

	* elf32-arm.c (elf32_arm_allocate_plt_entry): Increment
	htab->next_tls_desc_index in the non-IPLT case.
	Calculate GOT offset correctly for the non-IPLT case.
	(allocate_dynrelocs_for_symbol): Don't increment
	htab->next_tls_desc_index here.

ld/testsuite/ChangeLog:

2014-06-16  Will Newton  <will.newton@linaro.org>

	* ld-arm/arm-elf.exp: Add ifunc-gdesc test.
	* ld-arm/ifunc-gdesc.r: New file.
	* ld-arm/ifunc-gdesc.s: Likewise.
	* ld-arm/ifunc-gdesc.ver: Likewise.
2014-06-16 15:51:21 +01:00
Ryan Mansfield 203e84589f Remove reference to GASp from linker testsuite configuration.
* config/default.exp (GASP): Remove.
2014-06-09 15:09:02 +01:00
Alan Modra 397998fc32 Support fusion for ELFv2 stubs
Power8 fuses addis,addi and addis,ld sequences when the target of the
addis is the same as the addi/ld.  Thus
    addis r12,r2,xxx@ha
    addi r12,r12,xxx@l / ld r12,xxx@l(r12)
is faster than
    addis r11,r2,xxx@ha
    addi r12,r11,xxx@l / ld r12,xxx@l(r11)
So use the form that allows fusion in plt call and branch stubs.

bfd/
	* elf64-ppc.c (ADDIS_R12_R2): Define.
	(build_plt_stub): Support fusion on ELFv2 stub.
	(ppc_build_one_stub): Likewise for plt branch stubs.
gold/
	* powerpc.cc (addis_12_2): Define.
	(Stub_table::do_write): Support fusion on ELFv2 stubs.
ld/testsuite/
	* ld-powerpc/elfv2exe.d: Update for changed plt call stubs.
gdb/
	* ppc64-tdep.c (ppc64_standard_linkage8): New.
	(ppc64_skip_trampoline_code): Recognise ELFv2 stub supporting fusion.
2014-06-03 10:55:29 +09:30
mfortune 9854d43d40 Add objcopy stage between assembly and linking for run_dump_test
ld/testsuite/

	* lib/ld-lib.exp: Add objcopy_objects command to run_dump_test.
	This allows each input object to be optionally run through
	objcopy before linking.
2014-05-28 16:21:19 +01:00
Will Newton 273dc27930 ld/aarch64: xfail non-PIC shared object tests on aarch64
aarch64 does not support building non-PIC shared objects, so mark
tests for these as xfail.

ld/testsuite/ChangeLog:

2014-05-20  Will Newton  <will.newton@linaro.org>

	* ld-shared/shared.exp: Mark non-PIC shared object tests
	as xfail on aarch64.
2014-05-20 09:47:29 +01:00
Andreas Tobler fb2c6e43b8 Don't link FreeBSD tests with -ldl.
* ld-elf/shared.exp: Introduce the extralibs variable to control
    the libraries to be linked. Don't link -ldl on *-*-freebsd*.

    * ld-bootstrap/bootstrap.exp: Do not add -ldl to the extralibs on
    *-*-freebsd*.
2014-05-19 08:49:55 +02:00
Hans-Peter Nilsson eae25ec577 Fix freeing of link_info.hash
ld:
	* ldlang.c (lang_finish): Don't call bfd_link_hash_table_free here.
	(output_bfd_hash_table_free_fn): New variable.
	(open_output): Save the _bfd_link_hash_table_free function for the
	output_bfd into output_bfd_hash_table_free_fn.
	* ldmain.c (ld_cleanup): If set, call output_bfd_hash_table_free_fn
	on link_info.hash.
	* ldlang.h (output_bfd_hash_table_free_fn): Declare.

ld/testsuite:
	* ld-mmix/wrap1.d, ld-mmix/wrap1a.s, ld-mmix/wrap1b.s,
	ld-mmix/wrap1c.s, ld-mmix/wrap2.d, ld-mmix/wrap3.d,
	ld-mmix/wrap3a.s, ld-mmix/wrap3b.s, ld-mmix/wrap4.d: New
	tests.
2014-05-10 02:52:14 +02:00
H.J. Lu df18fdba5d Properly display extra data/address size prefixes
X86 disassembler checks data and address size prefixes when displaying
instruction mnemonic and operands.  For the extra data and address size
prefixes, their names depend only on the address mode, not the data and
address size prefixes.  This patch changes x86 disassembler not to check
the data and address size prefix when printing extra data and address size
prefixes.

gas/testsuite/

	* gas/i386/nops-1-core2.d: Replace data32 with data16.
	* gas/i386/nops-4a-i686.d: Likewise.
	* gas/i386/nops-5-i686.d: Likewise.
	* gas/i386/nops-5.d: Likewise.
	* gas/i386/x86-64-cbw-intel.d: Likewise.
	* gas/i386/x86-64-cbw.d: Likewise.
	* gas/i386/x86-64-io-intel.d: Likewise.
	* gas/i386/x86-64-io-suffix.d: Likewise.
	* gas/i386/x86-64-io.d: Likewise.
	* gas/i386/x86-64-nops-1-core2.d: Likewise.
	* gas/i386/x86-64-nops-1-g64.d: Likewise.
	* gas/i386/x86-64-nops-1-nocona.d: Likewise.
	* gas/i386/x86-64-nops-1.d: Likewise.
	* gas/i386/x86-64-nops-2.d: Likewise.
	* gas/i386/x86-64-nops-3.d: Likewise.
	* gas/i386/x86-64-nops-4-core2.d: Likewise.
	* gas/i386/x86-64-nops-4.d: Likewise.
	* gas/i386/x86-64-nops-5-k8.d: Likewise.
	* gas/i386/x86-64-nops-5.d: Likewise.
	* gas/i386/x86-64-stack-intel.d: Likewise.
	* gas/i386/x86-64-stack-suffix.d: Likewise.
	* gas/i386/x86-64-stack.d: Likewise.
	* gas/i386/ilp32/x86-64-cbw-intel.d: Likewise.
	* gas/i386/ilp32/x86-64-cbw.d: Likewise.
	* gas/i386/ilp32/x86-64-io-intel.d: Likewise.
	* gas/i386/ilp32/x86-64-io-suffix.d: Likewise.
	* gas/i386/ilp32/x86-64-io.d: Likewise.
	* gas/i386/ilp32/x86-64-nops-1-core2.d:
	* gas/i386/ilp32/x86-64-nops-1-nocona.d: Likewise.
	* gas/i386/ilp32/x86-64-nops-1.d: Likewise.
	* gas/i386/ilp32/x86-64-nops-2.d: Likewise.
	* gas/i386/ilp32/x86-64-nops-3.d: Likewise.
	* gas/i386/ilp32/x86-64-nops-4-core2.d: Likewise.
	* gas/i386/ilp32/x86-64-nops-4.d: Likewise.
	* gas/i386/ilp32/x86-64-nops-5-k8.d: Likewise.
	* gas/i386/ilp32/x86-64-nops-5.: Likewise.
	* gas/i386/ilp32/x86-64-stack-intel.d: Likewise.
	* gas/i386/ilp32/x86-64-stack-suffix.: Likewise.
	* gas/i386/ilp32/x86-64-stack.d: Likewise.

ld/testsuite/

	* ld-x86-64/tlsbin.dd: Replace data32 with data16.
	* ld-x86-64/tlsdesc-nacl.pd: Likewise.
	* ld-x86-64/tlsgdesc.dd: Likewise.
	* ld-x86-64/tlsld1.dd: Likewise.
	* ld-x86-64/tlsld3.dd: Likewise.
	* ld-x86-64/tlspic.dd: Likewise.

opcodes/

2014-05-09  H.J. Lu  <hongjiu.lu@intel.com>

	* i386-dis.c (ADDR16_PREFIX): Removed.
	(ADDR32_PREFIX): Likewise.
	(DATA16_PREFIX): Likewise.
	(DATA32_PREFIX): Likewise.
	(prefix_name): Updated.
	(print_insn): Simplify data and address size prefixes processing.
2014-05-09 10:58:00 -07:00
Volodymyr Arbatov 1058c7532d Use signed data type for R_XTENSA_DIFF* relocation offsets.
R_XTENSA_DIFF relocation offsets are in fact signed. Treat them as such.
Add testcase that examines ld behaviour on R_XTENSA_DIFF relocation
changing sign during relaxation.

2014-05-02  Volodymyr Arbatov  <arbatov@cadence.com>
	    David Weatherford  <weath@cadence.com>
	    Max Filippov  <jcmvbkbc@gmail.com>

bfd/
  * elf32-xtensa.c (relax_section): treat R_XTENSA_DIFF* relocations as
  signed.

gas/
  * config/tc-xtensa.c (md_apply_fix): mark BFD_RELOC_XTENSA_DIFF*
  fixups as signed.

ld/testsuite/
  * ld-xtensa/diff_overflow.exp, * ld-xtensa/diff_overflow1.s,
  * ld-xtensa/diff_overflow2.s: Add test for DIFF* relocation
  signedness and overflow checking.
2014-05-08 01:55:41 +04:00
Hans-Peter Nilsson b46fa76826 ld/testsuite:
* ld-mmix/sec-11.d, ld-mmix/sec-11.ld, ld-mmix/sec-10.s,
	ld-mmix/sec-10.d, ld-mmix/b-offlocmis.s, ld-mmix/sec-12.d: New
	tests.
	* ld-mmix/b-offloc.s: Correct address in comment.
2014-05-02 00:31:58 +02:00
Will Newton 8a52f0d983 ld/arm: Fix testsuite failures for armeb-linux-eabi
Fix all the cases where endianness needs to be taken into account
in the ARM ld dump tests.

ld/testsuite/ChangeLog:

2014-04-23  Will Newton  <will.newton@linaro.org>

	* ld-arm/arm-no-rel-plt.ld: Remove OUTPUT_FORMAT and
	SEARCH_DIR commands.
	* ld-arm/arm-rel32.d: Update regexps to allow test to
	pass on armeb-linux-eabi configuration.
	* ld-arm/data-only-map.d: Likewise.
	* ld-arm/fix-arm1176-off.d: Likewise.
	* ld-arm/fix-arm1176-on.d: Likewise.
	* ld-arm/ifunc-1.gd: Likewise.
	* ld-arm/ifunc-10.gd: Likewise.
	* ld-arm/ifunc-11.gd: Likewise.
	* ld-arm/ifunc-12.gd: Likewise.
	* ld-arm/ifunc-13.gd: Likewise.
	* ld-arm/ifunc-14.gd: Likewise.
	* ld-arm/ifunc-15.gd: Likewise.
	* ld-arm/ifunc-16.gd: Likewise.
	* ld-arm/ifunc-17.gd: Likewise.
	* ld-arm/ifunc-2.gd: Likewise.
	* ld-arm/ifunc-3.gd: Likewise.
	* ld-arm/ifunc-4.gd: Likewise.
	* ld-arm/ifunc-5.gd: Likewise.
	* ld-arm/ifunc-6.gd: Likewise.
	* ld-arm/ifunc-7.gd: Likewise.
	* ld-arm/ifunc-8.gd: Likewise.
	* ld-arm/ifunc-9.gd: Likewise.
	* ld-arm/jump-reloc-veneers-long.d: Likewise.
	* ld-arm/reloc-boundaries.d: Likewise.
2014-04-23 13:56:49 +01:00
H.J. Lu 43c001c7d6 Add tests for PR ld/16846
PR ld/16846
	* ld-plugin/lto.exp (lto_link_tests): Add tests for PR ld/16846.
	* ld-plugin/pr16846a.c: New file.
	* ld-plugin/pr16846b.c: Likewise.
	* ld-plugin/pr16846c.c: Likewise.
2014-04-22 10:22:39 -07:00
Christian Svensson 73589c9dbd Remove support for the (deprecated) openrisc and or32 configurations and replace
with support for the new or1k configuration.
2014-04-22 15:57:47 +01:00
Kwok Cheung Yeung cb22ccf411 This patch causes local GOT entries addressed via a 16-bit index to
be placed towards the front of local GOT space, while entries addressed
via a 32-bit index are placed towards the rear.

Provided that there are fewer than ~16K local GOT entries addressed via
a 16-bit index in total, this should eliminate any relocation overflows
caused by such GOT entries being allocated beyond the addressable range.

bfd/
	* elfxx-mips.c (struct mips_got_info): Delete assigned_gotno
	field.  Add assigned_low_gotno and assigned_high_gotno fields.
	(mips_elf_create_local_got_entry): Update out-of-space condition.
	Set index of new GOT entry to assigned_low_gotno if required by
	the current relocation, else set it to assigned_high_gotno.
	(mips_elf_set_global_gotidx): Replace uses of assigned_gotno
	with assigned_low_gotno.
	(mips_elf_multi_got): Initialize assigned_low_gotno and
	assigned_high_gotno in secondary GOTs.  Use assigned_low_gotno
	in place of assigned_gotno when handling global GOT entries.
	(mips_elf_lay_out_got): Initialize assigned_low_gotno and
	assigned_high_gotno.
	(_bfd_mips_elf_finish_dynamic_sections): Account for a possible
	gap in the middle of local GOT space.

ld/testsuite/
	* ld-mips-elf/elf-rel-xgot-n32.d: Update for new GOT layout.
	* ld-mips-elf/elf-rel-xgot-n32-embed.d: Likewise.
	* ld-mips-elf/elf-rel-xgot-n64.d: Likewise.
	* ld-mips-elf/elf-rel-xgot-n64-embed.d: Likewise.
	* ld-mips-elf/elf-rel-xgot-n64-linux.d: Likewise.
2014-04-17 14:40:08 +01:00
Marcus Shawcroft fa85fb9a1b [AArch64] Fix off by one error in instruction relaxation mask.
The AArch64 TLSDESC to IE relaxation code uses a bit mask intended to
ensure that destination register in a relaxed ldr instruction is
always X0.  The mask has an off by one error resulting in the most
significant bit of the destination register being retained in the
relaxed instruction.  The issue generally appears when the compiler
emits TLS accesses code under high register pressure resulting in a
broken code sequence.
2014-04-15 17:46:07 +01:00
Denis Chertykov e4ef1b6c3f bfd/ChangeLog
* elf32-avr.c: Add DIFF relocations for AVR.
	(avr_final_link_relocate): Handle the DIFF relocs.
	(bfd_elf_avr_diff_reloc): New.
	(elf32_avr_is_diff_reloc): New.
	(elf32_avr_adjust_diff_reloc_value): Reduce difference value.
	(elf32_avr_relax_delete_bytes): Recompute difference after deleting
	bytes.

	* reloc.c: Add BFD_RELOC_AVR_DIFF8/16/32 relocations

gas/ChangeLog

	* config/tc-avr.c: Add new flag mlink-relax.
	(md_show_usage): Add flag and help text.
	(md_parse_option): Record whether link relax is turned on.
	(relaxable_section): New.
	(avr_validate_fix_sub): New.
	(avr_force_relocation): New.
	(md_apply_fix): Generate DIFF reloc.
	(avr_allow_local_subtract): New.

	* config/tc-avr.h (TC_LINKRELAX_FIXUP): Define to 0.
	(TC_FORCE_RELOCATION): Define.
	(TC_FORCE_RELOCATION_SUB_SAME): Define.
	(TC_VALIDATE_FIX_SUB): Define.
	(avr_force_relocation): Declare.
	(avr_validate_fix_sub): Declare.
	(md_allow_local_subtract): Define.
	(avr_allow_local_subtract): Declare.

gas/testsuite/ChangeLog

	* gas/avr/diffreloc_withrelax.d: New testcase.
	* gas/avr/noreloc_withoutrelax.d: Likewise.
	* gas/avr/relax.s: Likewise.

include/ChangeLog

	* elf/avr.h: Add new DIFF relocs.

ld/testsuite/ChangeLog

	* ld-avr/norelax_diff.d: New testcase.
	* ld-avr/relax_diff.d: Likewise.
	* ld-avr/relax.s: Likewise.
2014-04-10 19:50:33 +04:00
Andreas Schwab 17c34b8f3d Fix spurious failures in ld-plugin/lto.exp
* ld-plugin/lto.exp: Make "-Wp," prefix optional when filtering
out _FORTIFY_SOURCE.
("Build libdummy.a 9", "PR ld/12696"): Mark as c++.
2014-04-07 19:07:03 +02:00
Alan Modra ffe54b3798 Pad sections according to current script FILL.
When aligning input sections, we are supposed to take the fill pattern
from a FILL statement, if there is one in the output section statement.

ld/
	* ldlang.c (lang_size_sections_1 <lang_input_section_enum>): Use
	current "fill", not "output_section_statement->fill".
ld/testsuite/
	* ld-scripts/fill.d, * ld-scripts/fill.t, * ld-scripts/fill_0.s,
	* ld-scripts/fill_1.s, * ld-scripts/fill_2.s: New test.
	* ld-scripts/data.exp: Run it.
2014-04-04 19:06:35 +10:30
Marcus Shawcroft 72c56015dd [AArch64] Fixup ld-aarch64/eh-frame.d expected PC range.
Fix the expected output for ld-aarch64/eh-frame.d.  This issue was
exposed by the recent fix to the output of objdump -Wf here:
https://sourceware.org/ml/binutils/2014-03/msg00251.html
2014-03-31 12:58:48 +01:00
H.J. Lu 4c6d802e59 Scan all input files for symbol reference warning
This patch scans all input files for symbol reference warning if the
symbol reference doesn't exist in the current input file.

ld/

	PR ld/16756
	* ldmain.c (symbol_warning): New function.
	(warning_callback): Use it.  Scan all input files for a reference
	to SYMBOL.

ld/testsuite/

	PR ld/16756
	* ld-plugin/lto.exp: Expect filename and line number for PR
	ld/12760 test.
2014-03-27 08:12:17 -07:00
Yury Gribov 6a631e86cf Add support for limited pretty-printing of ARM PLT entries on eabi and nacl targets.
* elf32-arm.c (elf32_arm_get_synthetic_symtab): Add new callback.
    	(elf32_arm_nacl_plt_sym_val): Likewise.
    	(elf32_arm_plt0_size): Add helper function.
    	(elf32_arm_plt_size): Likewise.

    	* ld-arm/arm-app-abs32.d: Updated test.
    	* ld-arm/arm-app.d: Likewise.
    	* ld-arm/arm-lib-plt32.d: Likewise.
    	* ld-arm/arm-lib.d: Likewise.
    	* ld-arm/armthumb-lib.d: Likewise.
    	* ld-arm/cortex-a8-fix-b-plt.d: Likewise.
    	* ld-arm/cortex-a8-fix-bcc-plt.d: Likewise.
    	* ld-arm/cortex-a8-fix-bl-plt.d: Likewise.
    	* ld-arm/cortex-a8-fix-bl-rel-plt.d: Likewise.
    	* ld-arm/cortex-a8-fix-blx-plt.d: Likewise.
    	* ld-arm/farcall-mixed-app-v5.d: Likewise.
    	* ld-arm/farcall-mixed-app.d: Likewise.
    	* ld-arm/farcall-mixed-lib-v4t.d: Likewise.
    	* ld-arm/farcall-mixed-lib.d: Likewise.
    	* ld-arm/ifunc-10.dd: Likewise.
    	* ld-arm/ifunc-14.dd: Likewise.
    	* ld-arm/ifunc-15.dd: Likewise.
    	* ld-arm/ifunc-3.dd: Likewise.
    	* ld-arm/ifunc-4.dd: Likewise.
    	* ld-arm/ifunc-7.dd: Likewise.
    	* ld-arm/ifunc-8.dd: Likewise.
    	* ld-arm/ifunc-9.dd: Likewise.
    	* ld-arm/long-plt-format.d: Likewise.
    	* ld-arm/mixed-app-v5.d: Likewise.
    	* ld-arm/mixed-app.d: Likewise.
    	* ld-arm/mixed-lib.d: Likewise.
    	* ld-arm/thumb2-bl-undefweak.d: Likewise.
    	* ld-arm/thumb2-bl-undefweak1.d: Likewise.
2014-03-27 13:54:03 +00:00
Alan Modra f6c7c3e8b7 Referencing a function's address on PowerPC64 ELFv2
ELFv2 needs to create plt entries in a non-PIC executable for an
address reference to a function defined in a shared object.  It's
possible that an object file has no features that distinguish it as
ELFv1 or ELFv2, eg. an object only containing data.  Such files need
to be handled like those that are known to be ELFv2.
However, this unnecessarily creates plt entries for the analogous
ELFv1 case, so arrange to set output abi version earlier, and use the
output abi version to further distinguish ambiguous input files.

bfd/
	* elf64-ppc.c (ppc64_elf_check_relocs): Account for possibly
	needed plt entries when taking the address of functions for
	abiversion == 0 (ie. unknown) as well as abiversion == 2.
	Move opd setup and abiversion checks to..
	(ppc64_elf_before_check_relocs): ..here.  Renamed from
	ppc64_elf_process_dot_syms.  Set output abiversion from input and
	input abiversion from output, if either is not set.
	(ppc64_elf_merge_private_bfd_data): Don't merge flags here.
	(elf_backend_check_directives): Update.
ld/testsuite/
	* ld-powerpc/startv1.s, * ld-powerpc/startv2.s, * ld-powerpc/funref.s,
	* ld-powerpc/funv1.s, * ld-powerpc/funv2.s,
	* ld-powerpc/ambiguousv1.d, * ld-powerpc/ambiguousv2.d: New test files.
	* ld-powerpc/powerpc.exp: Run new tests.
2014-03-27 00:49:38 +10:30
Will Newton c955de363b bfd/elfnn-aarch64.c: Fix calculation of DT_RELASZ
The current code subtracts the size of the output section containing
relplt from RELASZ. In some cases this will be the same output
section as the dynamic relocs causing a value of zero to be output.
Calculating the size from input sections seems to make more sense.

bfd/ChangeLog:

2014-03-25  Will Newton  <will.newton@linaro.org>

	 * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_sections):
	 Set value of DT_PLTRELSZ and DT_RELASZ based on the size
	 of input sections rather than output sections.

ld/testsuite/ChangeLog:

2014-03-25  Will Newton  <will.newton@linaro.org>

	 * ld-aarch64/aarch64-elf.exp: Add relasz dump test.
	 * ld-aarch64/relasz.d: New file.
	 * ld-aarch64/relasz.s: Likewise.
2014-03-25 09:01:50 +00:00
Richard Sandiford d56a8dda6d gas/
* config/tc-mips.h (DIFF_EXPR_OK, CFI_DIFF_EXPR_OK): Define.
	* config/tc-mips.c (md_pcrel_from): Remove error message.
	(md_apply_fix): Convert PC-relative BFD_RELOC_32s to
	BFD_RELOC_32_PCREL.  Report a specific error message for unhandled
	PC-relative expressions.  Handle BFD_RELOC_8.

gas/testsuite/
	* gas/all/gas.exp: Remove XFAIL of forward.d for MIPS.
	* gas/mips/pcrel-1.s, gas/mips/pcrel-1.d, gas/mips/pcrel-2.s,
	gas/mips/pcrel-2.d, gas/mips/pcrel-3.s, gas/mips/pcrel-3.l,
	gas/mips/pcrel-4.s, gas/mips/pcrel-4-32.d, gas/mips/pcrel-4-n32.d,
	gas/mips/pcrel-4-64.d: New tests.
	* gas/mips/mips.exp: Run them.
	* gas/mips/lui-2.l: Tweak error message for line 7.

ld/testsuite/
	* ld-elf/merge.d: Remove MIPS XFAIL.
2014-03-20 21:18:43 +00:00
Will Newton 97323ad113 bfd/elf32-arm.c: Set st_value to zero for undefined symbols
Unless pointer_equality_needed is set then set st_value to be zero
for undefined symbols.

bfd/ChangeLog:

2014-03-20  Will Newton  <will.newton@linaro.org>

	PR ld/16715
	* elf32-arm.c (elf32_arm_check_relocs): Set
	pointer_equality_needed for absolute references within
	executable links.
	(elf32_arm_finish_dynamic_symbol): Set st_value to zero
	unless pointer_equality_needed is set.

ld/testsuite/ChangeLog:

2014-03-20  Will Newton  <will.newton@linaro.org>

	* ld-arm/ifunc-14.rd: Update symbol values.
2014-03-20 11:43:33 +00:00
Nick Clifton e57190430e Fix RX linker testsuite failures by making the assembler use conventional section names.
* config/default.exp (ASFLAGS): For the RX target add:
	-muse-conventional-section-names.
2014-03-19 12:21:39 +00:00
Alan Modra e5b98723a5 Correct ld-powerpc/vle-reloc-2 test
* ld-powerpc/vle-reloc-3.d: Remove addresses.
2014-03-15 00:12:56 +10:30
Alan Modra c3301df1da Fix overflow handling of VLE_SDA21
bfd/
	* elf32-ppc.c (ppc_elf_relocate_section): Correct overflow
	handling for VLE_SDA21 relocs.
ld/testsuite/
	* ld-powerpc/vle.ld: Place .PPC.EMB.sdata0 within 32k of 0.
	* ld-powerpc/vle-reloc-3.d: Update.
2014-03-14 15:01:53 +10:30
Roland McGrath c125dbfb8c Apply ld-arm/gc-hidden-1 to all ELF targets, not just *eabi* targets
ld/testsuite/
	* ld-arm/gc-hidden-1.d: Remove target, add not-target to match
	other ELF-only tests in this directory.  Loosen regexps so they
	don't care what the exact addresses are.
2014-03-06 09:46:15 -08:00
Roland McGrath 8548f8419a Disable --long-plt test for arm-nacl targets.
ld/testsuite/
	* ld-arm/arm-elf.exp (armelftests_common): Move long-plt case ...
	(armelftests_nonacl): ... here.
2014-03-06 09:44:25 -08:00
Alan Modra 4b95cf5c0c Update copyright years 2014-03-05 22:16:15 +10:30
Alan Modra 45965137be Support R_PPC64_ADDR64_LOCAL
This adds support for "func@localentry", an expression that returns the
ELFv2 local entry point address of function "func".  I've excluded
dynamic relocation support because that obviously would require glibc
changes.

include/elf/
	* ppc64.h (R_PPC64_REL24_NOTOC, R_PPC64_ADDR64_LOCAL): Define.
bfd/
	* elf64-ppc.c (ppc64_elf_howto_raw): Add R_PPC64_ADDR64_LOCAL entry.
	(ppc64_elf_reloc_type_lookup): Support R_PPC64_ADDR64_LOCAL.
	(ppc64_elf_check_relocs): Likewise.
	(ppc64_elf_relocate_section): Likewise.
	* Add BFD_RELOC_PPC64_ADDR64_LOCAL.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
gas/
	* config/tc-ppc.c (ppc_elf_suffix): Support @localentry.
	(md_apply_fix): Support R_PPC64_ADDR64_LOCAL.
ld/testsuite/
	* ld-powerpc/elfv2-2a.s, ld-powerpc/elfv2-2b.s: New files.
	* ld-powerpc/elfv2-2exe.d, ld-powerpc/elfv2-2so.d: New files.
	* ld-powerpc/powerpc.exp: Run new test.
elfcpp/
	* powerpc.h (R_PPC64_REL24_NOTOC, R_PPC64_ADDR64_LOCAL): Define.
gold/
	* powerpc.cc (Target_powerpc::Scan::local, global): Support
	R_PPC64_ADDR64_LOCAL.
	(Target_powerpc::Relocate::relocate): Likewise.
2014-03-05 19:57:39 +10:30
Alan Modra 2c80b75360 Fix various copyright issues
binutils/
	* README: Add "Copyright Notices" paragraph.
gas/
	* config/bfin-lex-wrapper.c: Correct copyright date.
	* config/tc-frv.c: Correct copyright punctuation.
	* config/tc-ip2k.c: Likewise.
	* config/tc-iq2000.c: Likewise.
	* config/tc-mep.c: Likewise.
	* config/tc-tic4x.c: Likewise.
	* config/tc-tic4x.h: Likewise.
ld/testsuite/
	* ld-scripts/phdrs2.exp: Correct copyright punctuation.
	* ld-v850/v850.exp: Correct copyright typo.
opcodes/
	* i386-gen.c (process_copyright): Emit copyright notice on one line.
gold/
	* dwp.cc (print_version): Update copyright year to current.
2014-03-03 11:03:08 +10:30
Yuri Gribov 512c56d662 ld-arm/long-plt-format.d, ld-arm/arm-elf.exp: Adjust for arm-eabi. 2014-03-01 12:19:53 +01:00
Yuri Gribov 1db37fe627 This patch adds support for ARM PLT entries that support a full 32-bit offset range.
Enabled via the use of a new linker command line option: --long-plt.

	* bfd-in.h: Add export of bfd_elf32_arm_use_long_plt.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (elf32_arm_plt_entry_long): New array.
	(elf32_arm_link_hash_table_create): Set plt_entry_size to 16 if
	using long PLT entries.
	(bfd_elf32_arm_use_long_plt): New function.
	(elf32_arm_populate_plt_entry): Add support for long PLT entries.

	* emultempl/armelf.em (OPTION_LONG_PLT): Define.
	(PARSE_AND_LIST_LONGOPTS): Add long-plt.
	(PARSE_AND_LIST_OPTIONS): Likewise.
	(PARSE_AND_LIST_ARGS_CASES): Handle long-plt.
	* ld.texinfo: Document --long-plt.

	* ld-arm/long-plt-format.s: New test case.
	* ld-arm/long-plt-format.d: Expected disassembly.
	* ld-arm/arm-elf.exp: Run the new test.
2014-02-27 14:35:37 +00:00
Nick Clifton 5063daf735 This patch adds a default manifest in to the final links performed by the Cygwin and MinGW targets.
The manifest is necessary in order for the linked binaries to be executed in a Windows 8 environment.

The manifest is added using a linker script so that this feature will be compiler-neutral.  The resource
merging code in the linker means that if an application provides its own manifest then the default
manifest will be ignored.

	* configure.in (all_emul_extra_binaries): New variable.  Populated
	by invoking configure.tgt.
	(EMUL_EXTRA_BINARIES): New substitution.
	* configure: Regenerate.
	* configure.tgt (target_extra_binaries): New variable.  Set to
	default-manifest.o for Cygwin and MinGW targets.
	* Makefile.am (EMUL_EXTRA_BINARIES): New variable.  Initialised
	by the configure script.
	(ALL_EMUL_EXTRA_BINARIES): New variable.
	(default-manifest.o): New rule to build the default manifest.
	(ld_new_DEPENDENCIES): Add EMUL_EXTRA_BINARIES.
	(install-data-local): Add EMUL_EXTRA_BINARIES.
	* Makefile.in: Regenerate.
	* ld.texinfo: Document default manifest support.
	* emulparams/i386pe.sh (DEFAULT_MANIFEST): Define.
	* emulparams/i386pep.sh (DEFAULT_MANIFEST): Define.
	* emultempl/default-manifest.rc: New file.
	* scripttempl/pe.sc (R_RSRC): Include DEFAULT_MANIFEST, if defined.
	* scripttempl/pep.sc (R_RSRC): Likewise.

	* ld-pe/longsecn-1.d: Allow for extra sections.
	* ld-pe/longsecn-2.d: Likewise.
	* ld-pe/longsecn.d: Likewise.
	* ld-pe/secrel.d: Likewise.
2014-02-27 14:13:43 +00:00
Alan Modra a97726da10 Add ppc476 workaround bootstrap test
I was running this by hand to test out --ppc476-workaround.  Another
bootstrap test doesn't take all that long, so let's add it to the
testsuite.

	* ld-bootstrap/bootstrap.exp: Add ppc476 workaround test.
	* ld-bootstrap/ppc476.t: New file.
2014-02-21 10:22:51 +10:30
H.J. Lu 0ff2b86e7c Create the second PLT for BND relocations
Intel MPX introduces 4 bound registers, which will be used for parameter
passing in x86-64.  Bound registers are cleared by branch instructions.
Branch instructions with BND prefix will keep bound register contents.
This leads to 2 requirements to 64-bit MPX run-time:

1. Dynamic linker (ld.so) should save and restore bound registers during
symbol lookup.
2. Change the current 16-byte PLT0:

  ff 35 08 00 00 00	pushq  GOT+8(%rip)
  ff 25 00 10 00	jmpq  *GOT+16(%rip)
  0f 1f 40 00		nopl   0x0(%rax)

and 16-byte PLT1:

  ff 25 00 00 00 00    	jmpq   *name@GOTPCREL(%rip)
  68 00 00 00 00       	pushq  $index
  e9 00 00 00 00       	jmpq   PLT0

which clear bound registers, to preserve bound registers.

We use 2 new relocations:

to mark branch instructions with BND prefix.

When linker sees any R_X86_64_PC32_BND or R_X86_64_PLT32_BND relocations,
it switches to a different PLT0:

  ff 35 08 00 00 00	pushq  GOT+8(%rip)
  f2 ff 25 00 10 00	bnd jmpq *GOT+16(%rip)
  0f 1f 00		nopl   (%rax)

to preserve bound registers for symbol lookup and it also creates an
external PLT section, .pl.bnd.  Linker will create a BND PLT1 entry
in .plt:

  68 00 00 00 00       	pushq  $index
  f2 e9 00 00 00 00     bnd jmpq PLT0
  0f 1f 44 00 00        nopl 0(%rax,%rax,1)

and a 8-byte BND PLT entry in .plt.bnd:

  f2 ff 25 00 00 00 00  bnd jmpq *name@GOTPCREL(%rip)
  90			nop

Otherwise, linker will create a legacy PLT1 entry in .plt:

  68 00 00 00 00       	pushq  $index
  e9 00 00 00 00        jmpq PLT0
  66 0f 1f 44 00 00     nopw 0(%rax,%rax,1)

and a 8-byte legacy PLT in .plt.bnd:

  ff 25 00 00 00 00     jmpq  *name@GOTPCREL(%rip)
  66 90                 xchg  %ax,%ax

The initial value of the GOT entry for "name" will be set to the the
"pushq" instruction in the corresponding entry in .plt.  Linker will
resolve reference of symbol "name" to the entry in the second PLT,
.plt.bnd.

Prelink stores the offset of pushq of PLT1 (plt_base + 0x10) in GOT[1]
and GOT[1] is stored in GOT[3].  We can undo prelink in GOT by computing
the corresponding the pushq offset with

GOT[1] + (GOT offset - &GOT[3]) * 2

Since for each entry in .plt except for PLT0 we create a 8-byte entry in
.plt.bnd, there is extra 8-byte per PLT symbol.

We also investigated the 16-byte entry for .plt.bnd.  We compared the
8-byte entry vs the the 16-byte entry for .plt.bnd on Sandy Bridge.
There are no performance differences in SPEC CPU 2000/2006 as well as
micro benchmarks.

Pros:
	No change to undo prelink in dynamic linker.
	Only 8-byte memory overhead for each PLT symbol.
Cons:
	Extra .plt.bnd section is needed.
	Extra 8 byte for legacy branches to PLT.
	GDB is unware of the new layout of .plt and .plt.bnd.

bfd/

	* elf64-x86-64.c (elf_x86_64_bnd_plt0_entry): New.
	(elf_x86_64_legacy_plt_entry): Likewise.
	(elf_x86_64_bnd_plt_entry): Likewise.
	(elf_x86_64_legacy_plt2_entry): Likewise.
	(elf_x86_64_bnd_plt2_entry): Likewise.
	(elf_x86_64_bnd_arch_bed): Likewise.
	(elf_x86_64_link_hash_entry): Add has_bnd_reloc and plt_bnd.
	(elf_x86_64_link_hash_table): Add plt_bnd.
	(elf_x86_64_link_hash_newfunc): Initialize has_bnd_reloc and
	plt_bnd.
	(elf_x86_64_copy_indirect_symbol): Also copy has_bnd_reloc.
	(elf_x86_64_check_relocs): Create the second PLT for Intel MPX
	in 64-bit mode.
	(elf_x86_64_allocate_dynrelocs): Handle the second PLT for IFUNC
	symbols.  Resolve call to the second PLT if it is created.
	(elf_x86_64_size_dynamic_sections): Keep the second PLT section.
	(elf_x86_64_relocate_section): Resolve PLT references to the
	second PLT if it is created.
	(elf_x86_64_finish_dynamic_symbol): Use BND PLT0 and fill the
	second PLT entry for BND relocation.
	(elf_x86_64_finish_dynamic_sections): Use MPX backend data if
	the second PLT is created.
	(elf_x86_64_get_synthetic_symtab): New.
	(bfd_elf64_get_synthetic_symtab): Likewise.  Undefine for NaCl.

ld/

	* emulparams/elf_x86_64.sh (TINY_READONLY_SECTION): New.

ld/testsuite/

	* ld-x86-64/mpx.exp: Run bnd-ifunc-1 and bnd-plt-1.
	* ld-x86-64/bnd-ifunc-1.d: New file.
	* ld-x86-64/bnd-ifunc-1.s: Likewise.
	* ld-x86-64/bnd-plt-1.d: Likewise.
2014-02-19 11:48:23 -08:00
Jack Carter 5db3e65d39 The PT_DYNAMIC segment was being hard coded to have read, write, and
execute permission regardless of the underlying PT_LOAD segment permissions.
Deleting this code allows the default linker behavior which is to set the
dynamic segment to the same permissions as the sections that make it up.

This change alters one existing test case to check the segment flags for
PT_DYNAMIC.

bfd/ChangeLog
        * elfxx-mips.c(_bfd_mips_elf_modify_segment_map): Deleted hard coding of
        PT_DYNAMIC segment flags.

ld/testsuite/ChangeLog
	* ld-mips-elf/pic-and-nonpic-3a.sd: Check DYNAMIC segment flags.
2014-02-18 16:23:48 -08:00
Thomas Schwinge 6e03f3da7d Missing ChangeLog entry from commit 60ef20e285. 2014-02-16 09:01:29 +01:00
H.J. Lu d6f6f45577 Mark symbol in executables if it matches dynamic_list
bfd/

	PR gold/16530
	* elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Mark symbol in
	executables if it matches dynamic_list.

ld/testsuite/

	PR gold/16530
	* ld-elf/dynamic-1.c: New file.
	* ld-elf/dynamic-1.rd: Likewise.
	* ld-elf/dynamic-1.syms: Likewise.

	* ld-elf/shared.exp (build_tests): Add dynamic-1.
2014-02-10 08:05:54 -08:00
Sebastian Huber 13075d049d Fix ALIGN_WITH_INPUT
ld/

2014-02-02  Sebastian Huber  <sebastian.huber@embedded-brains.de>

	* ld/ld.texinfo: Change ALIGN_WITH_INPUT documentation.
	* ld/ldlang.c (lang_size_sections_1): Add dotdelta
	variable which reflects the VMA change due to alignment
	requirements.  Use dotdelta do change the LMA if
	ALIGN_WITH_INPUT is requested.

ld/testsuite/ChangeLog

2014-02-02  Sebastian Huber  <sebastian.huber@embedded-brains.de>

	* ld-scripts/rgn-at9.d: New file.
	* ld-scripts/rgn-at9.t: Likewise.
	* ld-scripts/rgn-at10.d: Likewise.
	* ld-scripts/rgn-at10.s: Likewise.
	* ld-scripts/rgn-at10.t: Likewise.
	* ld-scripts/rgn-at11.d: Likewise.
	* ld-scripts/rgn-at11.t: Likewise.
2014-02-02 06:39:39 -08:00
Sandra Loosemore 78058a5e4f Nios II CALL26 linker relaxation
2014-01-30  Sandra Loosemore  <sandra@codesourcery.com>

	bfd/
	* bfd-in2.h: Update from reloc.c.
	* elf32-nios2.c: Include elf32-nios2.h.
	(elf_nios2_howto_table_rel): Add entry for R_NIOS2_CALL26_NOAT.
	(nios2_reloc_map): Likewise.
	(enum elf32_nios2_stub_type): Declare.
	(struct elf32_nios2_stub_hash_entry): Declare.
	(nios2_stub_hash_entry, nios2_stub_hash_lookup): New macros.
	(struct elf32_nios2_link_hash_entry): Add hsh_cache field.
	(struct elf32_nios2_link_hash_table): Add new fields bstab,
	stub_bfd, add_stub_section, layout_sections_again, stub_group,
	bfd_count, top_index, input_list, all_local_syms.
	(nios2_call26_stub_entry): New.
	(nios2_elf32_install_imm16): Move up in file.
	(nios2_elf32_install_data): Move up in file.
	(hiadj): Move up in file.
	(stub_hash_newfunc): New.
	(link_hash_newfunc): Initialize hsh_cache field.
	(STUB_SUFFIX): New.
	(nios2_stub_name): New.
	(nios2_get_stub_entry): New.
	(nios2_add_stub): New.
	(nios2_elf32_setup_section_lists): New.
	(nios2_elf32_next_input_section): New.
	(CALL26_SEGMENT): New.
	(MAX_STUB_SECTION_SIZE): New.
	(group_sections): New.
	(nios2_type_of_stub): New.
	(nios2_build_one_stub): New.
	(nios2_size_one_stub): New.
	(get_local_syms): New.
	(nios2_elf32_size_stubs): New.
	(nios2_elf32_build_stubs): New.
	(nios2_elf32_do_call26_relocate): Correct CALL26 overflow test.
	(nios2_elf32_relocate_section): Handle R_NIOS2_CALL26_NOAT.  Add
	trampolines for R_NIOS2_CALL26 stubs.
	(nios2_elf32_check_relocs): Handle R_NIOS2_CALL26_NOAT.
	(nios2_elf32_gc_sweep_hook): Likewise.
	(nios2_elf32_link_hash_table_create): Initialize the stub hash table.
	(nios2_elf32_link_hash_table_free): New.
	(bfd_elf32_bfd_link_hash_table_free): Define.
	* elf32-nios2.h: New file.
	* libbfd.h: Update from reloc.c.
	* reloc.c (BFD_RELOC_NIOS2_CALL26_NOAT): New.

	gas/
	* config/tc-nios2.c (md_apply_fix): Handle BFD_RELOC_NIOS2_CALL26_NOAT.
	(nios2_assemble_args_m): Likewise.
	(md_assemble): Likewise.

	gas/testsuite/
	* gas/nios2/call26_noat.d: New.
	* gas/nios2/call26_noat.s: New.
	* gas/nios2/call_noat.d: New.
	* gas/nios2/call_noat.s: New.

	include/elf/
	* nios2.h (elf_nios2_reloc_type): Add R_NIOS2_CALL26_NOAT.

	ld/
	* Makefile.am (enios2elf.c, enios2linux.c): Update dependencies.
	* Makefile.in: Regenerated.
	* emulparams/nios2elf.sh (EXTRA_EM_FILE): Set.
	* emulparams/nios2linux.sh (EXTRA_EM_FILE): Set.
	* emultempl/nios2elf.em: New file.
	* gen-doc.texi (NIOSII): Set.
	* ld.texinfo (NIOSII): Set.

	ld/testsuite/
	* ld-nios2/relax_call26.s: New.
	* ld-nios2/relax_call26_boundary.ld: New.
	* ld-nios2/relax_call26_boundary.s: New.
	* ld-nios2/relax_call26_boundary_c8.d: New.
	* ld-nios2/relax_call26_boundary_cc.d: New.
	* ld-nios2/relax_call26_boundary_d0.d: New.
	* ld-nios2/relax_call26_boundary_d4.d: New.
	* ld-nios2/relax_call26_boundary_d8.d: New.
	* ld-nios2/relax_call26_boundary_dc.d: New.
	* ld-nios2/relax_call26_boundary_f0.d: New.
	* ld-nios2/relax_call26_boundary_f4.d: New.
	* ld-nios2/relax_call26_boundary_f8.d: New.
	* ld-nios2/relax_call26_boundary_fc.d: New.
	* ld-nios2/relax_call26_cache.d: New.
	* ld-nios2/relax_call26_cache.ld: New.
	* ld-nios2/relax_call26_cache.s: New.
	* ld-nios2/relax_call26_multi.d: New.
	* ld-nios2/relax_call26_multi.ld: New.
	* ld-nios2/relax_call26_norelax.d: New.
	* ld-nios2/relax_call26_shared.d: New.
	* ld-nios2/relax_call26_shared.ld: New.
2014-01-30 17:47:07 -08:00
H.J. Lu 50a53d3ffe Add rdynamic-1 test
It is added for

commit 409ff343a4
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Nov 8 13:49:11 2011 +0000

      * elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Mark syms in
      executables when export_dynamic.

	* ld-elf/rdynamic-1.c: New file.
	* ld-elf/rdynamic-1.rd: Likewise.

	* ld-elf/shared.exp (build_tests): Add rdynamic-1.
2014-01-29 14:30:41 -08:00
Nick Clifton bcf1df010c Update the tic6x linker tests to match the current behaviour of the linker and readelf.
PR binutils/16317
	* ld-tic6x/shlib-1.rd: Expect I attribute with RELA sections.
	* ld-tic6x/shlib-1b.rd: Likewise.
	* ld-tic6x/shlib-1r.rd: Likewise.
	* ld-tic6x/shlib-1rb.rd: Likewise.
	* ld-tic6x/shlib-app-1rd: Likewise.
	* ld-tic6x/shlib-app-1b.rd: Likewise.
	* ld-tic6x/shlib-app-1r.rd: Likewise.
	* ld-tic6x/shlib-app-1rb.rd: Likewise.
	* ld-tic6x/shlib-noindex.rd: Likewise.
	* ld-tic6x/static-app-1.rd: Likewise.
	* ld-tic6x/static-app-1b.rd: Likewise.
	* ld-tic6x/static-app-1r.rd: Likewise.
	* ld-tic6x/static-app-1rb.rd: Likewise.

	PR binutils/16318
	* ld-tic6x/tic6x.exp: Expect C6000 osabi value in relocatable
	objects.
2014-01-28 11:56:13 +00:00
H.J. Lu a5262f834a Replace .align with .p2align
* ld-elf/pr16498a.s: Replace .align with .p2align.
2014-01-24 10:01:56 -08:00
H.J. Lu a78ad74bbf Add another testcase for PR ld/16498
PR ld/16498
	* ld-elf/pr16498b.d: New file.
	* ld-elf/pr16498b.t: Likewise.
2014-01-24 09:03:21 -08:00
H.J. Lu d85e71fec0 Improve orphaned TLS section handling
ld/

	PR ld/16498
	* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Improve
	orphaned TLS section handling.

ld/testsuite/

	PR ld/16498
	* ld-elf/pr16498a.d: New file.
	* ld-elf/pr16498a.s: Likewise.
	* ld-elf/pr16498a.t: Likewise.
2014-01-24 08:56:07 -08:00
Alan Modra 7dd9c6eb05 Miscellaneous ld tidies
Localise a struct, prevent an unneeded symbol lookup, and fix a
testcase.

ld/
	* ld.h (struct map_symbol_def): Move to..
	* ldlang.h: ..here.
	* ldlang.c (print_assignment): Don't set expld.assign_name to dot.
ld/testsuite/
	* ld-scripts/pr14962-2.d: Correct target triple.
2014-01-22 12:51:19 +10:30