Commit Graph

4620 Commits

Author SHA1 Message Date
H.J. Lu 9e2dec4710 Properly mark the plugin symbol undefined
Mark the unused plugin defined symbol in elf_link_input_bfd instead of
_bfd_elf_fix_symbol_flags.  Limit the PR ld/12365 test to x86 targets.

bfd/

	PR ld/12365
	PR ld/14272
	* elflink.c (_bfd_elf_fix_symbol_flags): Revert the last change.
	(elf_link_input_bfd): Mark the plugin symbol undefined if it is
	referenced from a non-IR file.

ld/testsuite/

	PR ld/12365
	PR ld/14272
	* ld-plugin/lto.exp: Run the PR ld/12365 test only for x86 targets.
	* ld-plugin/plugin-7.d: Updated.
	* ld-plugin/plugin-8.d: Likewise.
2015-02-06 04:29:35 -08:00
H.J. Lu 119d62ffb8 Close fd only if fd != -1
This patch closes fd only if fd != -1.

	* plugin.c (release_input_file): Set fd to -1 after closing it.
	(plugin_maybe_claim): Close fd only if fd != -1.
2015-02-05 16:57:09 -08:00
H.J. Lu f4b78d1898 Add plugin_input_file_t
This patchs adds plugin_input_file_t to implement get_input_file, get_view
and release_input_file.  The maximum memeory overhead per IR input file
are about 40 bytes for plugin_input_file_t plus the memory to store input
IR filename.  According to

http://gcc.gnu.org/wiki/whopr/driver

RELEASE_INPUT_FILE: Function pointer to the linker interface that
releases a file descriptor for a claimed input file. The plug-in library
must call this interface for each file descriptor obtained by the "get
input file" interface. It must release all such file descriptors before
returning from the WPA phase.

However, GCC plug-in library doesn't use the "get input file" interface.
It processed the IR input in the claim file handler.  Since the the file
descriptor opened for the IR input was unused after the claim file
handler returns and GCC plug-in library before GCC 5 doesn't call the
RELEASE_INPUT_FILE function pointer, ld closed the file descriptor to
avoid leaking file descriptor.  But this approach doesn't work with
other plug-in libraries which uses the "get input file", "get view" and
"release input file" interfaces.  To avoid file descriptor leak with
GCC prior to GCC 5 and support other plug-in libraries at the same time,
we close the file descriptor only if the input IR file is a bfd_object
file.  This scheme doesn't work when a plug-in library needs the file
descriptor and its IR is stored in bfd_object file.

	PR ld/17878
	* plugin.c: Include <errno.h>.
	(errno): New.  Declare if needed.
	(plugin_input_file_t): New.
	(get_input_file): Implemented.
	(get_view): Likewise.
	(release_input_file): Likewise.
	(add_symbols): Updated.
	(get_symbols): Likewise.
	(plugin_maybe_claim): Allocate a plugin_input_file_t.  Close fd
	only for a bfd_object input.
2015-02-05 05:03:07 -08:00
H.J. Lu 8962a307ae Pass -flto-partition=none to the PR ld/12365 test
*  ld-plugin/lto.exp: Pass -flto-partition=none to the PR
	ld/12365 test.
2015-02-04 04:34:11 -08:00
H.J. Lu 60f7927512 Mark the plugin symbol undefined
LTO may optimize out a plugin symbol, which is also referenced by a
non-IR file.  When that happens, we should mark the plugin symbol
undefined.  It isn't the problem since LTO already determined the
symbols in the non-IR file aren't used.

bfd/

	PR ld/12365
	PR ld/14272
	* elflink.c (_bfd_elf_fix_symbol_flags): Mark the plugin symbol
	undefined if it is referenced from a non-IR file.

ld/testsuite/

	PR ld/12365
	* ld-plugin/pr12365a.c: New file.
	* ld-plugin/pr12365b.c: Likewise.
	* ld-plugin/pr12365c.c: Likewise.

	* ld-plugin/lto.exp (lto_link_tests): Prepare for the PR ld/12365
	test.
	Run the PR ld/12365 test.
2015-02-03 09:03:23 -08:00
H.J. Lu 9910b1c8f3 Add a testcase for PR ld/14918
PR ld/14918
	* ld-plugin/lto.exp (lto_link_elf_tests): Add PR ld/14918 test.

	* ld-plugin/pr14918.c: New file.
	* ld-plugin/pr14918.d: Likewise.
2015-02-03 08:24:50 -08:00
Alan Modra 6c2573b7ab xlc -z relro toc section fixes
Moving .toc out of .got caused us to lose toc sorting and multi-toc
support.

	* emultempl/ppc64elf.em (toc_section_name): New var.
	(ppc_after_open): Set it.
	(ppc_before_allocation): Use it.
	(gld${EMULATION_NAME}_after_allocation): Here too.
2015-02-02 21:54:10 +10:30
H.J. Lu 1a215085d4 Move -rc before $aropts
* lib/ld-lib.exp (ar_simple_create): Move -rc before $aropts.
2015-01-29 11:11:03 -08:00
H.J. Lu 716db898b7 Remove plugin_active_plugins_p()
Replace plugin_active_plugins_p() with link_info.lto_plugin_active.

	* ldfile.c (ldfile_try_open_bfd): Replace plugin_active_plugins_p()
	with link_info.lto_plugin_active.
	* ldlang.c (lang_process): Likewise.
	* ldmain.c (add_archive_element): Likewise.
	* plugin.c (plugin_active_plugins_p): Removed.
	* plugin.h (plugin_active_plugins_p): Likewise.
2015-01-29 04:56:39 -08:00
Alan Modra b86ac8e3a5 Correct PowerPC64 local-dynamic TLS linker optimization
The linker hardcoded r3 into a local-dynamic to local-exec TLS
optimization sequence.  This is normally the case since r3 is required
as a parameter to (the optimized out) __tls_get_addr call.  However,
it is possible for a compiler, LLVM in this case, to set up the
parameter value in another register then copy it to r3 before the
call.

When fixing this problem, I noticed that ppc32 had another bug when
optimizing away one of the TLS insns to a nop.

The patch also tidies a mask used by global-dynamic to initial-exec
TLS optimization, to just select the fields needed.  Leaving the
offset in the instruction wasn't a bug since it will be overwritten
anyway.

bfd/
	* elf64-ppc.c (ppc64_elf_relocate_section): Correct GOT_TLSLD
	optimization.  Tidy mask for GOT_TLSGD optimization.
	* elf32-ppc.c (ppc_elf_relocate_section): Likewise.  Correct
	location of nop zapping high insn too.
ld/testsuite/
	* ld-powerpc/tlsld.d, * ld-powerpc/tlsld.s: New test.
	* ld-powerpc/tlsld32.d, * ld-powerpc/tlsld32.s: New test.
	* ld-powerpc/powerpc.exp: Run them.  Move tocvar and tocnovar.
2015-01-29 13:13:02 +10:30
H.J. Lu 37a3056ad4 Make plugin_get_ir_dummy_bfd static
* plugin.h (plugin_get_ir_dummy_bfd): Removed.  Move comments to
	...
	* plugin.c (plugin_get_ir_dummy_bfd): Here.  Make it static.
2015-01-28 12:56:18 -08:00
H.J. Lu 15f7a26b0f The initial support for LDPT_GET_VIEW
This patch adds the initial support for LDPT_GET_VIEW.

ld/

	PR ld/17878
	* plugin.c (tv_header_tags(): Add LDPT_GET_VIEW.
	(get_view): New function.
	(set_tv_header): Handle LDPT_GET_VIEW.
	* testplug.c (tag_names): Add LDPT_GET_VIEW.
	(tv_get_view): New.
	(dump_tv_tag): Handle LDPT_GET_VIEW.
	(parse_tv_tag): Likewise.

ld/testsuite/

	PR ld/17878
	* ld-plugin/plugin-1.d: Add LDPT_GET_VIEW.
	* ld-plugin/plugin-10.d: Likewise.
	* ld-plugin/plugin-11.d: Likewise.
	* ld-plugin/plugin-2.d: Likewise.
	* ld-plugin/plugin-3.d: Likewise.
	* ld-plugin/plugin-4.d: Likewise.
	* ld-plugin/plugin-5.d: Likewise.
	* ld-plugin/plugin-6.d: Likewise.
	* ld-plugin/plugin-7.d: Likewise.
	* ld-plugin/plugin-8.d: Likewise.
	* ld-plugin/plugin-9.d: Likewise.
2015-01-28 10:27:31 -08:00
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
Alan Modra 3f8107ab38 FT32 initial support
FT32 is a new 32-bit RISC core developed by FTDI for embedded applications.

	* configure.ac: Add FT32 support.
	* configure: Regenerate.
bfd/
	* Makefile.am: Add FT32 files.
	* archures.c (enum bfd_architecture): Add bfd_arch_ft32.
	(bfd_mach_ft32): Define.
	(bfd_ft32_arch): Declare.
	(bfd_archures_list): Add bfd_ft32_arch.
	* config.bfd: Handle FT32.
	* configure.ac: Likewise.
	* cpu-ft32.c: New file.
	* elf32-ft32.c: New file.
	* reloc.c (BFD_RELOC_FT32_10, BFD_RELOC_FT32_20, BFD_RELOC_FT32_17,
	BFD_RELOC_FT32_18): Define.
	* targets.c (_bfd_target_vector): Add ft32_elf32_vec.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* po/SRC-POTFILES.in: Regenerate.
binutils/
	* readelf.c: Add FT32 support.
gas/
	* Makefile.am: Add FT32 files.
	* config/tc-ft32.c: New file.
	* config/tc-ft32.h: New file.
	* configure.tgt: Add FT32 support.
	* Makefile.in: Regenerate.
	* po/POTFILES.in: Regenerate.
gas/testsuite/
	* gas/ft32/ft32.exp: New file.
	* gas/ft32/insn.d: New file.
	* gas/ft32/insn.s: New file.
include/
	* dis-asm.h (print_insn_ft32): Declare.
include/elf/
	* common.h (EM_FT32): Define.
	* ft32.h: New file.
include/opcode/
	* ft32.h: New file.
ld/
	* Makefile.am: Add FT32 files.
	* configure.tgt: Handle FT32 target.
	* emulparams/elf32ft32.sh: New file.
	* scripttempl/ft32.sc: New file.
	* Makefile.in: Regenerate.
opcodes/
	* Makefile.am: Add FT32 files.
	* configure.ac: Handle FT32.
	* disassemble.c (disassembler): Call print_insn_ft32.
	* ft32-dis.c: New file.
	* ft32-opc.c: New file.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* po/POTFILES.in: Regenerate.
2015-01-28 16:25:18 +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
Alan Modra 5ad18f16ab Reorder more powerpc64 sections again for -z relro
.toc1 is the second level TOC section used by gcc's -mminimal-toc.  It
too should be read-only after relocation.  Also, the last patch
description mentioned .sbss moving but didn't actually do that, so fix
that problem.  .tocbss (whatever that is) was before .sbss previously,
so move that one too.

	* emulparams/elf64ppc.sh (OTHER_SDATA_SECTIONS): Use in place of..
	(OTHER_BSS_SYMBOLS): ..this.
	(OTHER_PLT_RELOC_SECTIONS): Don't define.
	(OTHER_GOT_RELOC_SECTIONS): Add rela.toc1 and rela.tocbss.
	(OTHER_READWRITE_SECTIONS): Don't define.  Move .toc1 to..
	(OTHER_RELRO_SECTIONS_2): ..here.
	* scripttempl/elf.sc: Move SBSS too when DATA_SDATA.
2015-01-20 21:46:07 +10:30
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 3e2b0f3116 Reorder powerpc64 sections for -z relro
More sections can be read-only after relocation.  .opd is an obvious
candidate.

	* emulparams/elf64ppc.sh (OTHER_READWRITE_SECTIONS): Move .opd to..
	(OTHER_RELRO_SECTIONS_2): ..here, new define.
	* scripttempl/elf.sc: Add OTHER_RELRO_SECTIONS_2.
2015-01-20 19:48:54 +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 52db4ec2d1 [ARM] Reject R_ARM_REL32 when trying to defer it to runtime
bfd/
    * elf32-arm.c (elf32_arm_final_link_relocate): Reject R_ARM_32/_NOI when
    trying to defer them to runtime.

  ld/testsuite/
    * ld-arm/elf32-reject.s: New testcase.
    * ld-arm/elf32-reject.d: Likewise.
    * ld-arm/elf32-reject-pie.s: Likewise.
    * ld-arm/elf32-reject-pie.d: Likewise.
    * ld-arm/arm-elf.exp: Run new testcases.
    * ld-arm/ifunc-7.s: Delete f2/f4 test items.
    * ld-arm/ifunc-7.rd: Likewise.
    * ld-arm/ifunc-7.gd: Likewise.
    * ld-arm/ifunc-7.dd: Likewise.
    * ld-arm/ifunc-8.s: Likewise.
    * ld-arm/ifunc-8.rd: Likewise.
    * ld-arm/ifunc-8.gd: Likewise.
    * ld-arm/ifunc-8.dd: Likewise.
2015-01-14 19:11:54 +00: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 2f5346cd7c Regenerate Makeile.in file for copyright update 2015-01-02 22:27:27 +10:30
Alan Modra efd321f91c Correct printed year in copyright notices 2015-01-02 01:08:15 +10:30
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 ca0694adf6 Don't create .eh_frame_hdr on shared lib bfd
If no object files have .eh_frame, but some shared library does, then
ld creates a .eh_frame_hdr section using the shared library bfd.  This
is silly since shared library .eh_frame sections don't contribute to
the output .eh_frame and thus no .eh_frame_hdr is needed.

Also, the bfd section list and count is cleared for shared libraries,
and a zero section count used as a flag in lang_check to omit a call
to bfd_merge_private_bfd_data for shared libraries.  If we create a
section on a shared lib bfd then ld will wrongly attempt to merge the
shared library private bfd data.

	PR 17742
	* ld/emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Exclude
	shared libraries in loop looking for .eh_frame sections.
	Similarly for build-id loop.
2014-12-24 23:47:56 +10:30
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 422f1c65c9 Report an error for script multiply defined symbols
or maybe not just yet, but this is better than a FIXME.

	* ldexp.c (update_definedness): Return false if script symbol is
	redefining a strong symbol in an object.
	(exp_fold_tree_1 <etree_assign>): Set up for reporting a multiple
	definition error, but for now leave disabled.
2014-12-23 23:36:51 +10:30
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
Alan Modra cd8e2bcf0d Correct logic for "defined by object"
The old code missed testing bfd_link_hash_undefweak, and wrongly
excluded bfd_link_hash_common symbols.  It is also clearer to invert
the set of enum bfd_link_hash_type values tested.
bfd_link_hash_indirect and bfd_link_hash_warning will never appear
here.

	* ldexp.c (update_definedness): Correct logic setting by_object.
2014-12-23 23:36:50 +10:30
Alan Modra 18d6a79d35 Move support code for linker script DEFINED to ldexp.c
This moves support code for DEFINED to ldexp.c where it is used,
losing the lang_ prefix on identifiers.  Two new functions are needed
to initialize and clean up to hash table, but other than that there
are no functional changes here.

	* ldexp.c (struct definedness_hash_entry, definedness_table)
	(definedness_newfunc, symbol_defined, update_definedness): Move
	and rename from..
	* ldlang.h (struct lang_definedness_hash_entry): ..here,..
	* ldlang.c (lang_definedness_table, lang_definedness_newfunc)
	(lang_symbol_defined, lang_update_definedness): ..and here.
	* ldexp.c (ldexp_init, ldexp_finish): New functions, extracted from..
	* ldlang.c (lang_init, lang_finish): ..here.
	* ldexp.h (ldexp_init, ldexp_finish): Declare.
	* ldlang.h (lang_symbol_defined, lang_update_definedness): Delete.
	* ldmain.c (main): Call ldexp_init and ldexp_finish.
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