Commit Graph

4700 Commits

Author SHA1 Message Date
Alan Modra 6166ed9330 Mark _init and _fini for --gc-sections
gold marks _init and _fini via symbol, ld marks them via section
(default scripts set .init and .fini section KEEP).  This makes it
possible for people to write their own _init and not bother to put the
function into the right section.

	PR ld/18223
	* ldlang.c (lang_process): Add _init and _fini to gc_sym_list.
2015-04-10 10:27:03 +09:30
H.J. Lu eba27bd781 Remove BNDPLT and add PARSE_AND_LIST_ARGS_CASE_Z
* emulparams/elf_x86_64.sh (BNDPLT): Removed.
	(PARSE_AND_LIST_OPTIONS): New.
	(PARSE_AND_LIST_ARGS_CASE_Z): Likewise.
	* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Remove
	BNDPLT check.  Handle PARSE_AND_LIST_ARGS_CASE_Z.
	(gld${EMULATION_NAME}_list_options): Remove BNDPLT check.
2015-04-09 07:53:00 -07:00
Nick Clifton 233723a43c Update French translation of ld strings.
* po/fr.po: Updated French translation.
2015-04-09 14:56:29 +01:00
H.J. Lu 82d8e420ab Enable ELF ld_list_options for --enable-targets=all
When --enable-targets=all is used with non-ELF target, we should enable
ELF ld_list_options.

	* configure.ac (elf_list_options): Set to TRUE for
	--enable-targets=all.
	(elf_shlib_list_options): Likewise.
	(elf_plt_unwind_list_options): Likewise.
	* configure: Regenerated.
2015-04-08 17:08:45 -07:00
H.J. Lu 31b94bbb7b Skip empty EMULATION_NAME
* emulparams/elf32bmipn32-defs.sh: Skip empty EMULATION_NAME.
2015-04-08 09:46:50 -07:00
H.J. Lu 151411f8af Add SHF_COMPRESSED support to gas and objcopy
This patch adds --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}
options to gas and objcopy for ELF files. They control how DWARF debug
sections are compressed.  --compress-debug-sections=none is equivalent to
--nocompress-debug-sections.  --compress-debug-sections=zlib and
--compress-debug-sections=zlib-gnu are equivalent to
--compress-debug-sections.  --compress-debug-sections=zlib-gabi compresses
DWARF debug sections with SHF_COMPRESSED from the ELF ABI.  No linker
changes are required to support SHF_COMPRESSED.

bfd/

	* archive.c (_bfd_get_elt_at_filepos): Also copy BFD_COMPRESS_GABI
	bit.
	* bfd.c (bfd::flags): Increase size to 18 bits.
	(BFD_COMPRESS_GABI): New.
	(BFD_FLAGS_SAVED): Add BFD_COMPRESS_GABI.
	(BFD_FLAGS_FOR_BFD_USE_MASK): Likewise.
	(bfd_update_compression_header): New fuction.
	(bfd_check_compression_header): Likewise.
	(bfd_get_compression_header_size): Likewise.
	(bfd_is_section_compressed_with_header): Likewise.
	* compress.c (MAX_COMPRESSION_HEADER_SIZE): New.
	(bfd_compress_section_contents): Return the uncompressed size if
	the full section contents is compressed successfully.  Support
	converting from/to .zdebug* sections.
	(bfd_get_full_section_contents): Call
	bfd_get_compression_header_size to get compression header size.
	(bfd_is_section_compressed): Renamed to ...
	(bfd_is_section_compressed_with_header): This.  Add a pointer
	argument to return compression header size.
	(bfd_is_section_compressed): Use it.
	(bfd_init_section_decompress_status): Call
	bfd_get_compression_header_size to get compression header size.
	Return FALSE if uncompressed section size is 0.
	* elf.c (_bfd_elf_make_section_from_shdr): Support converting
	from/to .zdebug* sections.
	* bfd-in2.h: Regenerated.

binutils/

	* objcopy.c (do_debug_sections): Add compress_zlib,
	compress_gnu_zlib and compress_gabi_zlib.
	(copy_options): Use optional_argument on compress-debug-sections.
	(copy_usage): Update --compress-debug-sections.
	(copy_file): Handle compress_zlib, compress_gnu_zlib and
	compress_gabi_zlib.
	(copy_main): Handle
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
	* doc/binutils.texi: Document
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.

binutils/testsuite/

	* compress.exp: Add tests for
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
	* binutils-all/dw2-3.rS: New file.
	* binutils-all/dw2-3.rt: Likewise.
	* binutils-all/libdw2-compressedgabi.out: Likewise.

gas/

	* as.c (show_usage): Update --compress-debug-sections.
	(std_longopts): Use optional_argument on compress-debug-sections.
	(parse_args): Handle
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
	* as.h (compressed_debug_section_type): New.
	(flag_compress_debug): Change type to compressed_debug_section_type.
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
	* write.c (compress_debug): Set BFD_COMPRESS_GABI for
	--compress-debug-sections=zlib-gabi.  Call
	bfd_get_compression_header_size to get compression header size.
	Don't rename section name for --compress-debug-sections=zlib-gabi.
	* config/tc-i386.c (compressed_debug_section_type): Set to
	COMPRESS_DEBUG_ZLIB.
	* doc/as.texinfo: Document
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.

gas/testsuite/

	* gas/i386/dw2-compressed-1.d: New file.
	* gas/i386/dw2-compressed-2.d: Likewise.
	* gas/i386/dw2-compressed-3.d: Likewise.
	* gas/i386/x86-64-dw2-compressed-2.d: Likewise.
	* gas/i386/i386.exp: Run dw2-compressed-2, dw2-compressed-1,
	dw2-compressed-3 and x86-64-dw2-compressed-2.

ld/testsuite/

	* ld-elf/compress.exp: Add a test for
	--compress-debug-sections=zlib-gabi.
	(build_tests): Add 2 tests for --compress-debug-sections=zlib-gabi.
	(run_tests): Likewise.
	Verify linker output with zlib-gabi compressed debug input.
	* ld-elf/compressed1a.d: New file.
	* ld-elf/compressed1b.d: Likewise.
	* ld-elf/compressed1c.d: Likewise.
2015-04-08 07:54:09 -07:00
H.J. Lu c58212eaf9 Add ld_list_options
This patch adds ld_list_options for ELF targets to avoid duplicated
outputs from ld --help.

	* Makefile.am (ELF_CLFAGS): New.
	(AM_CFLAGS): Add $(ELF_CLFAGS).
	* configure.ac (elf_list_options): New.  AC_SUBST.
	(elf_shlib_list_options): Likewise.
	(elf_plt_unwind_list_options): Likewise.
	* lexsup.c (elf_shlib_list_options): New.
	(elf_static_list_options): Likewise.
	(elf_plt_unwind_list_options): Likewise.
	(ld_list_options): Likewise.
	(help): Call ld_list_options.
	* Makefile.in: Regenerated.
	* configure: Likewise.
	* emulparams/plt_unwind.sh (PLT_UNWIND): New.
	(PARSE_AND_LIST_OPTIONS): Removed.
	* emultempl/elf32.em (gld_list_options): New.
	(gld${EMULATION_NAME}_list_options): Define only if BNDPLT or
	PARSE_AND_LIST_OPTIONS is defined.
	(ld_${EMULATION_NAME}_emulation): Replace
	gld${EMULATION_NAME}_list_options with ${gld_list_options.
2015-04-08 04:55:23 -07:00
Nick Clifton 3ea6077552 Add new linker option: --warn-orphan which generates warning messages when orphan sections are detected.
ld	* ld.h (struct ld_config_type): Add new field: warn_orphan.
	* ldlex.h (enum option_values): Add OPTION_WARN_ORPHAN and
	OPTION_NO_WARN_ORPHAN.
	* lexsup.c (ld_options): Add --warn-orphan and --no-warn-orphan.
	(parse_args): Handle the new options.
	* ldemul.c (ldemul_place_orphan): If requested, generate a warning
	message when an orphan section is placed in the output file.
	* ld.texinfo: Document the new option.
	* NEWS: Mention the new feature.

tests	* ld-elf/orphan-5.l: New test - checks the linker's output with
	--warn-orphan enabled.
	* ld-elf/elf.exp: Run the new test.
2015-04-07 16:29:41 +01:00
Alan Modra 87070c082f Modify get_reloc_section for targets that map .got.plt to .got
Fixes tic6x testsuite failures due to .rela.plt having a zero sh_info.
I considered passing link_info to get_reloc_section so we could
directly return the .got.plt output section, but we need the fallback
to name lookup anyway for objcopy.

bfd/
	* elf.c (_bfd_elf_get_reloc_section): Allow for .got.plt being
	mapped to output .got section.
ld/testsuite/
	* ld-arm/tls-gdesc-nlazy.g: Adjust for readelf note.
	* ld-tic6x/shlib-1.rd: Expect corrected .rela.plt sh_info.
	* 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.
2015-04-07 23:22:11 +09:30
Alan Modra 0fad6e4b94 Cast shift expression
PR ld/18176
	* ldlang.c (lang_size_sections): Cast shift expression.
2015-04-07 23:21:42 +09:30
Alan Modra d3e454b956 PowerPC non-PIC to PIC editing for protected var access
This is a linker-only solution to the incompatibility between shared
library protected visibility variables and using .dynbss and copy
relocs for non-PIC access to shared library variables.

bfd/
	* elf32-ppc.c (struct ppc_elf_link_hash_entry): Add has_addr16_ha
	and has_addr16_lo.  Make has_sda_refs a bitfield.
	(ppc_elf_check_relocs): Set new flags.
	(ppc_elf_link_hash_table_create): Update default_params.
	(ppc_elf_adjust_dynamic_symbol): Clear protected_def in cases
	where we won't be making .dynbss entries or editing code.  Set
	params->pic_fixup when we'll edit code for protected var access.
	(allocate_dynrelocs): Allocate got entry for edited code and
	discard dyn_relocs.
	(struct ppc_elf_relax_info): Add picfixup_size.
	(ppc_elf_relax_section): Rename struct one_fixup to struct
	one_branch_fixup.  Rename fixups to branch_fixups.  Size space for
	pic fixups.
	(ppc_elf_relocate_section): Edit non-PIC accessing protected
	visibility variables to PIC.  Don't emit dyn_relocs for code
	we've edited.
	* elf32-ppc.h (struct ppc_elf_params): Add pic_fixup.
ld/
	* emultempl/ppc32elf.em: Handle --no-pic-fixup.
	(params): Init new field.
	(ppc_before_allocation): Enable relaxation for pic_fixup.
2015-04-07 23:00:07 +09:30
H.J. Lu dae148f3b9 Remove is_zlib_supported
Since zlib is always supported, there is no need for is_zlib_supported.

binutils/testsuite/

	* binutils-all/compress.exp: Remove is_zlib_supported check.
	* binutils-all/objdump.exp: Likewise.
	* binutils-all/readelf.exp (readelf_compressed_wa_test): Likewise.
	* lib/utils-lib.exp (run_dump_test): Likewise.
	* lib/binutils-common.exp (is_zlib_supported): Removed.

gas/testsuite/

	* lib/gas-defs.exp (run_dump_test): Remove is_zlib_supported check.

ld/testsuite/

	* ld-elf/compress.exp: Remove is_zlib_supported check.
	Fail if --compress-debug-sections doesn't work.
	* lib/ld-lib.exp (run_dump_test): Remove is_zlib_supported check.
2015-04-06 12:19:13 -07:00
Andrew Turner 15c7659fd1 Add support for configuring an aarch64-freebsd target.
ld	* Makefile.am: Add FreeBSD aarch64 files.
	* Makefile.in: Regenerate.
	* configure.tgt: Add aarch64-*-freebsd* target triple.
	* emulparams/aarch64fbsd.sh: New file.
	* emulparams/aarch64fbsdb.sh: New file.

bfd	* config.bfd: Add aarch64-*-freebsd* target triple.
2015-04-02 15:07:27 +01:00
H.J. Lu a0bde39842 Work around a GCC uninitialized warning bug
* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Work
	around a GCC uninitialized warning bug fixed in GCC 4.6.
2015-04-01 08:14:32 -07:00
Marcus Shawcroft 4106101c44 [AArch64] Workaround for Cortex A53 erratum 843419
Some early revisions of the Cortex-A53 have an erratum (843419).  The
details of the erratum are quite complex and involve dynamic
conditions.  For the purposes of the workaround we have simplified the
static conditions to an ADRP in the last two instructions of a 4KByte
page, followed within four instructions by a load/store dependent on
the ADRP.

This patch adds support to conservatively scan for and workaround
Cortex A53 erratum 843419.  There are two different workaround
strategies used.  The first is to rewrite ADRP instructions which form
part of an erratum sequence with an ADR instruction.  In situations
where the ADR provides insufficient offset the dependent load or store
instruction from the sequence is moved to a stub section and branches
are inserted from the original sequence to the relocated instruction
and back again.

Stub section sizes are rounded up to a multiple of 4096 in order to
ensure that the act of inserting work around stubs does not create
more errata sequences.

Workaround stubs are always inserted into the stub section associated
with the input section containing the erratum sequence.  This ensures
that the fully relocated form of the veneered load store instruction
is available at the point in time when the stub section is written.
2015-04-01 13:16:38 +01:00
H.J. Lu 875b5b9d14 Add a testcase for PR ld/18176
PR ld/18176
	* ld-x86-64/pr18176.d: New file.
	* ld-x86-64/pr18176.s: Likewise.
	* ld-x86-64/pr18176.t: Likewise.
	* ld-x86-64/x86-64.exp: Run pr18176.
2015-04-01 04:24:24 -07:00
Chen Gang 16c1c9d6a6 Prevent multiple definitions for _HEAP_START, _HEAP_MAX, and _STACK_START when performing a relocatable link with a tic6x target.
* emulparams/elf32_tic6x_le.sh: Skip OTHER_BSS_SECTIONS for
	relocating operation.
2015-04-01 11:29:46 +01:00
Alan Modra 6c1aca3e2d Start of relro segment adjustment
Adjusting the start of the relro segment in order to make it end
exactly on a page boundary runs into difficulties when sections in the
relro segment are aligned;  Adjusting the start by (next_page - end)
sometimes results in more than that adjustment occurring at the end,
overrunning the page boundary.  So when that occurs we try a new lower
start position by masking the adjusted start with the maximum section
alignment.  However, we didn't consider that this masked start address
may in fact be before the initial relro base, which is silly since
that can only increase padding at the relro end.

I've also moved some calculations closer to where they are used, and
comments closer to the relevant statements.

	* ldlang.c (lang_size_sections): When alignment of sections
	results in relro base adjustment being too large, don't go lower
	than the initial value.
	* ldexp.c (fold_binary <DATA_SEGMENT_RELRO_END>): Comment.
	* scripttempl/elf.sc (DATA_SEGMENT_ALIGN): Omit SEGMENT_SIZE
	alignment when SEGMENT_SIZE is the same as MAXPAGESIZE.
2015-04-01 19:37:58 +10:30
Alan Modra 4a0bc59ef6 Yet another warning fix
Older compilers that warn wrongly will just need -Wno-error.  No way
am I going to init every single field, then have to edit this code
whenever bfd_link_hash_entry changes.  Another option, making the
struct static, isn't very nice since it means larger binaries and
worse code.

	* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Don't
	init ehdr_start_save.
2015-04-01 13:14:53 +10:30
Alan Modra 42271ec540 Fix ld eelf32ppcvxworks.c dependencies
* Makefile.am (eelf32ppcvxworks.c): Depend on ppc32elf.em and
	ldemul-list.h.
	(eelf32lppc.c, eelf32lppclinux.c, eelf32lppcnto.c, eelf32lppcsim.c,
	eelf32ppc.c, eelf32ppc_fbsd.c, eelf32ppclinux.c, eelf32ppcnto.c,
	eelf32ppcsim.c): Rearrange deps for consistency.
	* Makefile.in: Regenerate.
2015-04-01 11:06:14 +10:30
Ed Schouten 4e791d0fb1 Fixes for a small number of compiler warnings
The ehdr_start_save variable does not need to be initialized.  However,
not initializing it will trigger a compiler warning when using older
versions of GCC.  Self-assignment unfortunately doesn't work for Clang
as Clang has a warning similar to -Winit-self as part of -Wall.

	* emultempl/elf32.em (gld*_before_allocation): Zero-initialize
	the ehdr_start_save variable.
2015-04-01 11:06:14 +10:30
Ed Schouten 6036f48621 Add support for Nuxi CloudABI on x86-64
bfd/

	* config.bfd (targ_defvec): Set to x86_64_elf64_cloudabi_vec
	for x86_64-*-cloudabi*.
	* configure.ac: Handle x86_64_elf64_cloudabi_vec.
	* configure: Regenerated.
	* elf64-x86-64.c (TARGET_LITTLE_SYM): Support x86_64-*-cloudabi*.
	(TARGET_LITTLE_NAME): Likewise.
	(ELF_OSABI): Likewise.
	(elf64_bed): Likewise.
	* targets.c (x86_64_elf64_cloudabi_vec): New.
	(_bfd_target_vector): Add x86_64_elf64_cloudabi_vec.

gas/

	* configure.tgt (fmt): Set to elf for *-*-cloudabi*.

ld/

	* Makefile.am (ALL_64_EMULATION_SOURCES): Add
	eelf_x86_64_cloudabi.c.
	(eelf_x86_64_cloudabi.c): New.
	* configure.tgt (targ_emul): Set to elf_x86_64_cloudabi for
	x86_64-*-cloudabi*.
	* Makefile.in: Regenerated.
	* emulparams/elf_x86_64_cloudabi.sh: New file.
2015-03-31 08:11:08 -07:00
H.J. Lu f24173ebf7 Remove --with-zlib from ld
This patch removes --with-zlib from ld.

ld/

	* configure.ac (AM_ZLIB): Removed.
	* Makefile.in: Regenerated.
	* config.in: Likewise.
	* configure: Likewise.

ld/testsuite/

	* ld-bootstrap/bootstrap.exp (extralibs): Add -lz.
2015-03-31 03:59:04 -07:00
H.J. Lu bd53a53af4 Properly set sh_info for .rela.plt/rel.plt section
Since .rela.plt/rel.plt section may contain relocations against .got.plt
section, we set sh_info for .rela.plt/rel.plt section to .got.plt section
index if target has .got.plt section.

bfd/

	PR ld/18169
	* elf-bfd.h (elf_backend_data): Add get_reloc_section.
	(_bfd_elf_get_reloc_section): New.
	* elf.c (_bfd_elf_get_reloc_section): Likewise.
	(assign_section_numbers): Call get_reloc_section to look up the
	section the relocs apply.
	* elfxx-target.h (elf_backend_get_reloc_section): Likewise.
	(elfNN_bed): Initialize get_reloc_section with
	elf_backend_get_reloc_section.

ld/testsuite/

	PR ld/18169
	* ld-elf/linkinfo1a.d: Updated.
	* ld-elf/linkinfo1b.d: Likewise.
2015-03-30 04:40:49 -07:00
H.J. Lu 5e228181d4 Don't run ld-x86-64/pr18160.d for x86_64-*-nacl*
* ld-x86-64/pr18160.d: Don't run for x86_64-*-nacl* target.
2015-03-27 14:40:43 -07:00
Tejas Belagod 93ca856967 [AArch64] Fix branch stubs for BE
2015-03-26  Tejas Belagod  <tejas.belagod@arm.com>

ld/testsuite
  * ld-aarch64/farcall-back-be.d: New.

bfd/
  * elfnn-aarch64.c (aarch64_build_one_stub): Replace the call to generic
  _bfd_final_link_relocate with aarch64_relocate.
2015-03-26 16:20:38 +00:00
H.J. Lu b19a8f8545 Skip gc-sections if relocation is incompatible
This patch skips gc-sections if input relocation is incompatible with
output.

bfd/

	PR ld/18160
	* elflink.c (elf_gc_sweep): Skip if relocation is incompatible.
	(bfd_elf_gc_sections): Likewise.

ld/testsuite/

	PR ld/18160
	* ld-x86-64/pr18160.d: New file.
	* ld-x86-64/pr18160.s: Likewise.
	* ld-x86-64/pr18160.t: Likewise.
	* ld-x86-64/x86-64.exp: Run pr18160.
2015-03-26 08:22:55 -07:00
Marcus Shawcroft 618655192f [AArch64] Implement branch over stub section.
Ensure that injection of a stub section does not break a link where
there is an xpectation that flow of control can pass from one input
section to another simply by linking the input sections in series.

The solution here is to allow stub sections to be inserted after any
input section (existing behaviour), but inject an additional branch at
the start of each stub section such that control flow falling into the
stub section will branch over the stub section.
2015-03-25 15:16:04 +00:00
Marcus Shawcroft d9ced15d6e [AArch64] Remove padding before stub sections.
Lower stub alignment from 8 to 4 bytes thus removing padding between
input section content and stub section content.
2015-03-25 15:15:40 +00:00
Senthil Kumar Selvaraj d422d1c433 Garbage collecting debug sections
I noticed that _bfd_elf_gc_mark_extra_sections attempts to unmark
related debug sections when it finds an unmarked code section.
When it finds .text.foo is unmarked, for example, it removes
.debug_line.text.foo as well (using the section name as a suffix
match check.

However, it bails out after finding one such section.

bfd/
	* elflink.c (_bfd_elf_gc_mark_extra_sections): Don't break on
	first matching debug section.
ld/testsuite/
	* ld-gc/all-debug-sections.d: New file.
	* ld-gc/all-debug-sections.s: Likewise.
	* ld-gc/gc.exp: Execute new testcase.
2015-03-25 20:42:00 +10:30
Marcus Shawcroft 499c37b59a [AArch64] Adjust layout emultempl/aarch64elf.em. 2015-03-23 14:35:21 +00:00
Chen Gang b3862264bc Use %F instead of %X for einfo
When src or dst is NULL, the next fread or fwrite will cause a
segmentation fault, so we need to treat it as fatal.

	* ldmain.c (main): Use %F instead of %X for einfo.
2015-03-18 11:45:12 +10:30
Alan Modra 1079403cc0 Fix ppc32 synthetic symbols when __tls_get_addr_opt stub is generated
Also update the 32-bit tls testcases to be secure plt.

bfd/
	* elf32-ppc.c (ppc_elf_get_synthetic_symtab): Examine stubs in
	reverse order.  Account for larger size of __tls_get_addr_opt stub.
ld/testsuite/
	* ld-powerpc/tls32.s: Add GOT pointer setup.
	* ld-powerpc/tls32.d: Update.
	* ld-powerpc/tls32.g: Update.
	* ld-powerpc/tls32.t: Update.
	* ld-powerpc/tlsexe.d: Update.
	* ld-powerpc/tlsexe32.d: Update.
	* ld-powerpc/tlsexe32.g: Update.
	* ld-powerpc/tlsexe32.r: Update.
	* ld-powerpc/tlsexetoc.d: Update.
	* ld-powerpc/tlsso32.d: Update.
	* ld-powerpc/tlsso32.g: Update.
	* ld-powerpc/tlsso32.r: Update.
2015-03-11 18:04:25 +10:30
H.J. Lu ca3fe95e46 Add extern_protected_data and set it for x86
With copy relocation, address of protected data defined in the shared
library may be external.  This patch adds extern_protected_data and
changes _bfd_elf_symbol_refs_local_p to return false for protected data
if extern_protected_data is true.

bfd/

	PR ld/pr15228
	PR ld/pr17709
	* elf-bfd.h (elf_backend_data): Add extern_protected_data.
	* elf32-i386.c (elf_backend_extern_protected_data): New.
	Defined to 1.
	* elf64-x86-64.c (elf_backend_extern_protected_data): Likewise.
	* elflink.c (_bfd_elf_adjust_dynamic_copy): Don't error on
	copy relocs against protected symbols if extern_protected_data
	is true.
	(_bfd_elf_symbol_refs_local_p): Don't return true on protected
	non-function symbols if extern_protected_data is true.
	* elfxx-target.h (elf_backend_extern_protected_data): New.
	Default to 0.
	(elfNN_bed): Initialize extern_protected_data with
	elf_backend_extern_protected_data.

ld/testsuite/

	PR ld/pr15228
	PR ld/pr17709
	* ld-i386/i386.exp (i386tests): Add a test for PR ld/17709.
	* ld-i386/pr17709-nacl.rd: New file.
	* ld-i386/pr17709.rd: Likewise.
	* ld-i386/pr17709a.s: Likewise.
	* ld-i386/pr17709b.s: Likewise.
	* ld-i386/protected3.d: Updated.
	* ld-i386/protected3.s: Likewise.
	* ld-x86-64/pr17709-nacl.rd: New file.
	* ld-x86-64/pr17709.rd: Likewise.
	* ld-x86-64/pr17709a.s: Likewise.
	* ld-x86-64/pr17709b.s: Likewise.
	* ld-x86-64/protected3.d: Updated.
	* ld-x86-64/protected3.s: Likewise.
	* ld-x86-64/x86-64.exp (x86_64tests): Add a test for PR ld/17709.
2015-03-05 06:34:53 -08:00
Richard Sandiford e09ab7ac78 Allow MOVK for R_AARCH64_TLSLE_MOVW_TPREL_G{0,1}NC
bfd/
	PR gas/17843
	* elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Expect
	R_AARCH64_TLSLE_MOVW_TPREL_G0_NC and R_AARCH64_TLSLE_MOVW_TPREL_G1_NC
	to be used with MOVK rather than MOVZ.

gas/
	PR gas/17843
	* config/tc-aarch64.c (process_movw_reloc_info): Allow
	R_AARCH64_TLSLE_MOVW_TPREL_G0_NC and R_AARCH64_TLSLE_MOVW_TPREL_G1_NC
	for MOVK.

gas/testsuite/
	PR gas/17843
	* gas/aarch64/tls.s, gas/aarch64/tls.d: Add test for
	R_AARCH64_TLSLE_MOVW_TPREL_G0/R_AARCH64_TLSLE_MOVW_TPREL_G1_NC
	sequence.

ld/testsuite/
	PR gas/17843
	* ld-aarch64/tlsle.s, ld-aarch64/tlsle.d: New test.
	* ld-aarch64/aarch64-elf.exp: Run it.
2015-03-04 09:09:05 +00:00
Alan Modra daf220f0a7 Correct -z nocopyreloc doc
This option is misnamed.  It should probably be called -z nodynbss,
but it's too late to change now.

	* ld.texinfo (Options <-z nocopyreloc>): Rewrite.
2015-03-02 16:57:08 +10:30
Alan Modra 9028d9432c Pad only text sections at end by default
gas/
	* write.c (SUB_SEGMENT_ALIGN): Don't pad non-code sections at
	end to their alignment.
gas/testsuite/
	* gas/sparc/pcrel.d: Update for changed padding in data sections.
	* gas/sparc/pcrel64.d: Likewise.
ld/testsuite/
	* ld-sparc/gotop32.rd: Update for changed padding in data sections.
	* ld-sparc/gotop32.td: Likewise.
	* ld-sparc/gotop64.rd: Likewise.
	* ld-sparc/gotop64.td: Likewise.
	* ld-tilegx/external.s: Align .data.
	* ld-tilepro/external.s: Likewise.
2015-02-28 22:26:56 +10:30
Nick Clifton f0673d2040 Fixes a problem with the linker script parser not always handling the ! character in memort region attributes.
PR ld/17900
	* ldlang.c (lang_set_flags): Allow exclamation mark to reverse the
	sense of the following memory region attribute characters.
2015-02-27 16:19:57 +00:00
Alan Modra 330b17b30f Fix recent h8300 configury changes
* Makefile.am (ALL_EMULATION_SOURCES): Sort new h8300 entries.
	(eh8300elf_linux.c, eh8300helf_linux.c, eh8300self_linux.c,
	eh8300sxelf_linux.c): Do not invoke genscripts here.
	* Makefile.in: Regenerate.
2015-02-27 11:47:20 +10:30
Marcus Shawcroft 60d1b0d6a4 [AArch64] Add tiny DESC test cases. 2015-02-26 22:59:27 +00:00
Marcus Shawcroft b480a4819b Add tiny memory model GD test cases. 2015-02-26 22:23:09 +00:00
Marcus Shawcroft b108998791 Adding tls-tiny-ie test. 2015-02-26 22:23:09 +00:00
Terry Guo 99654aaf36 [ARM]Update for Tag_ABI_HardFP_use per EABI doc
Updated how we merge and display this attribute per the latest
EABI documents.

bfd/ChangeLog
	* elf32-arm.c (elf32_arm_merge_eabi_attributes): Update how we
	merge Tag_ABI_HardFP_use.

binutils/ChangeLog
	* readelf.c (arm_attr_tag_ABI_HardFP_use): Update how we
	display it.

ld/testsuite/ChangeLog
	* ld-arm/attr-merge-3.attr: Remove Tag_ABI_HardFP_use.
	* ld-arm/attr-merge-vfp-10.d: Likewise.
	* ld-arm/attr-merge-vfp-10r.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/attr-merge-vfp-6.d: Likewise.
	* ld-arm/attr-merge-vfp-6r.d: Likewise.
	* ld-arm/attr-merge-vfp-7.d: Likewise.
	* ld-arm/attr-merge-vfp-7r.d: Likewise.
	* ld-arm/attr-merge-vfp-8.d: Likewise.
	* ld-arm/attr-merge-vfp-8r.d: Likewise.
2015-02-26 14:11:41 +08:00
Andrew Burgess bac13f5a4c AVR/ld: Use .avr.prop data during linker relaxation.
Make use of the data held within the .avr.prop section during linker
relaxation in order to maintain the properties of the .org and .align
directives.

In relation to the .align directives, if enough bytes are deleted before
a .align directive then the alignment can be moved while still
maintaining the alignment requirement.

bfd/ChangeLog:

	* elf32-avr.c (struct elf_avr_section_data): New structure.
	(struct avr_relax_info): New structure.
	(elf_avr_new_section_hook): New function.
	(struct elf_avr_section_data): Add relax_info.
	(get_avr_relax_info): New function.
	(init_avr_relax_info): New function.
	(elf32_avr_relax_delete_bytes): Find next property record before
	deleting bytes.  When deleting don't move bytes beyond the next
	property record.
	(avr_elf32_assign_records_to_section): New function.
	(avr_property_record_compare): New function.
	(avr_load_all_property_sections): New function.
	(elf32_avr_relax_section): Load property data.  After relaxing the
	section, move any .align directives that have enough deleted bytes
	before them.
	(bfd_elf32_new_section_hook): Define.

ld/testsuite/ChangeLog:

	* ld-avr/avr-prop-1.d: New file.
	* ld-avr/avr-prop-1.s: New file.
	* ld-avr/avr-prop-2.d: New file.
	* ld-avr/avr-prop-2.s: New file.
	* ld-avr/avr-prop-3.d: New file.
	* ld-avr/avr-prop-3.s: New file.
	* ld-avr/avr-prop-4.d: New file.
	* ld-avr/avr-prop-4.s: New file.
2015-02-25 23:19:11 +00:00
Oleg Endo ac99436572 [SH] Fix clrs, sets, pref insn arch memberships.
opcodes/
	* sh-opc.h (clrs, sets): Mark as arch_sh3_nommu_up instead of
	arch_sh_up.
	(pref): Mark as arch_sh2a_nofpu_or_sh3_nommu_up instead of
	arch_sh2a_nofpu_or_sh4_nommu_nofpu_up.

gas/testsuite/
	* gas/sh/arch/arch.exp: Replace dead code to generate expected .s files
	with ...
	* gas/sh/arch/sh-opc-gen-as.pl: ... this new script.
	* gas/sh/arch/arch_expected.txt: Regenerate.
	* gas/sh/arch/sh-dsp.s: Likewise.
	* gas/sh/arch/sh-opc-gen-as.pl: Likewise.
	* gas/sh/arch/sh.s: Likewise.
	* gas/sh/arch/sh2.s: Likewise.
	* gas/sh/arch/sh2a-nofpu-or-sh3-nommu.s: Likewise.
	* gas/sh/arch/sh2a-nofpu-or-sh4-nommu-nofpu.s: Likewise.
	* gas/sh/arch/sh2a-nofpu.s: Likewise.
	* gas/sh/arch/sh2a-or-sh3e.s: Likewise.
	* gas/sh/arch/sh2a-or-sh4.s: Likewise.
	* gas/sh/arch/sh2a.s: Likewise.
	* gas/sh/arch/sh2e.s: Likewise.
	* gas/sh/arch/sh3-dsp.s: Likewise.
	* gas/sh/arch/sh3-nommu.s: Likewise.
	* gas/sh/arch/sh3.s: Likewise.
	* gas/sh/arch/sh3e.s: Likewise.
	* gas/sh/arch/sh4-nofpu.s: Likewise.
	* gas/sh/arch/sh4-nommu-nofpu.s: Likewise.
	* gas/sh/arch/sh4.s: Likewise.
	* gas/sh/arch/sh4a-nofpu.s: Likewise.
	* gas/sh/arch/sh4a.s: Likewise.
	* gas/sh/arch/sh4al-dsp.s: Likewise.

ld/testsuite/
	* ld-sh/arch/arch_expected.txt: Regenerate.
	* ld-sh/arch/sh-dsp.s: Likewise.
	* ld-sh/arch/sh.s: Likewise.
	* ld-sh/arch/sh2.s: Likewise.
	* ld-sh/arch/sh2a-nofpu-or-sh3-nommu.s: Likewise.
	* ld-sh/arch/sh2a-nofpu-or-sh4-nommu-nofpu.s: Likewise.
	* ld-sh/arch/sh2a-nofpu.s: Likewise.
	* ld-sh/arch/sh2a-or-sh3e.s: Likewise.
	* ld-sh/arch/sh2a-or-sh4.s: Likewise.
	* ld-sh/arch/sh2a.s: Likewise.
	* ld-sh/arch/sh2e.s: Likewise.
	* ld-sh/arch/sh3-dsp.s: Likewise.
	* ld-sh/arch/sh3-nommu.s: Likewise.
	* ld-sh/arch/sh3.s: Likewise.
	* ld-sh/arch/sh3e.s: Likewise.
	* ld-sh/arch/sh4-nofpu.s: Likewise.
	* ld-sh/arch/sh4-nommu-nofpu.s: Likewise.
	* ld-sh/arch/sh4.s: Likewise.
	* ld-sh/arch/sh4a-nofpu.s: Likewise.
	* ld-sh/arch/sh4a.s: Likewise.
	* ld-sh/arch/sh4al-dsp.s: Likewise.
2015-02-25 21:26:59 +01:00
Nick Clifton 685080f210 Adds support for generating notes in V850 binaries.
bfd	* elf32-v850.c (v850_set_note): New function.  Creates a Renesas
	style note entry.
	(v850_elf_make_note_section): New function.  Creates a note
	section.
	(v850_elf_create_sections): New function.  Create a note section
	if one is not already present.
	(v850_elf_set_note): New function.  Adds a note to a bfd.
	(v850_elf_copy_private_bfd_data): New function.  Copies V850
	notes.
	(v850_elf_merge_notes): New function.  Merges V850 notes.
	(print_v850_note): New function.  Displays a V850 note.
	(v850_elf_print_notes): New function. Displays all notes attached
	to a bfd.
	(v850_elf_merge_private_bfd_data): Call v850_elf_merge_notes.
	(v850_elf_print_private_bfd_data): Call v850_elf_print_notes.
	(v850_elf_fake_sections): Set the type of the V850 note section.
	* bfd-in.h (v850_elf_create_sections): Add prototype.
	(v850_elf_set_note): Add prototype.
	* bfd-in2.h: Regenerate.

binutils* readelf.c (get_machine_flags): Remove deprecated V850 machine
	flags.
	(get_v850_section_type_name): New function.  Handles V850 special
	sections.
	(get_section_type_name): Add support for V850.
	(get_v850_elf_note_type): New function.  Returns the name of a
	V850 note.
	(print_v850_note): New function.  Prints a V850 note.
	(process_v850_notes): New function.  Prints V850 notes.
	(process_note_sections): Add support for V850.

binutils/testsute
	* binutils-all/objcopy.exp: Skip the strip-10 test for the V850.

gas	* config/tc-v850.c (soft_float): New variable.
	(v850_data_8): New variable.
	(md_show_usage): Add -msoft-float/-mhard-float.
	(md_parse_option): Likewise.
	(md_begin): Set the default value of soft_float.
	(v850_md_end): New function.  Creates a note section.
	* config/tc-v850.h (md_end): Define.
	* doc/c-v850.texi: Document -msoft-float/-mhard-float.

gas/testsuite
	* gas/elf/elf.exp: Add special version of the section2 test for
	the V850.
	* gas/elf/section2.e-v850: New file.

include/elf
	* v850.h (EF_RH850_SIMD): Delete deprecated flag.
	(EF_RH850_CACHE): Likewise.
	(EF_RH850_MMU): Likewise.
	(EF_RH850_DATA_ALIGN8): Likewise.
	(SHT_RENESAS_IOP): Fix typo in name.
	(SHT_RENESAS_INFO): Define.
	(V850_NOTE_SECNAME): Define.
	(SIZEOF_V850_NOTE): Define.
	(V850_NOTE_NAME): Define.
	(enum v850_notes): New enum.
	(NUM_V850_NOTES): Define.

ld/ChangeLog
2015-02-24  Nick Clifton  <nickc@redhat.com>

	* Makefile.am (ev850.c): Add dependency upon
	$(srcdir)/emultempl/v850elf.em.
	(ev850_rh850.c): Likewise.
	* Makefile.in: Regenerate.
	* emultempl/v850elf.em: New file.
	* emulparams/v850.sh (EXTRA_EM_FILE): Define.
	* emulparams/v850_rh850.sh (EXTRA_EM_FILE): Define.
	* scripttempl/v850.sc: Add .note.renesas section.
	* scripttempl/v850_rh850.sc: Likewise.

ld/testsuite
	* ld-elf/extract-symbol-1sec.d: Expect to fail on the V850.
2015-02-24 17:54:09 +00:00
Alan Modra 884151a7b8 Add aligned string merge test
* ld-elf/merge3.s, * ld-elf/merge3.d: New test.
2015-02-25 00:15:26 +10:30
Senthil Kumar Selvaraj cb0728165e This patch modifies the AVR linker script templates to use __<name>_REGION_LENGTH__ symbols, if provided, for setting memory region lengths, defaulting to the current constant values otherwise.
ld	* scripttempl/avr.sc: Add new user_signatures region. Define and Use
	symbols for all region lengths.
	* scripttempl/avrtiny.sc: Define and use symbols for all region lengths.

testsuite * ld-avr/region_overflow.d: New test.
	* ld-avr/region_overflow.s: Likewise.
2015-02-24 11:26:28 +00:00
Yoshinori Sato 5518c738a4 Add support for the h8300-linux target.
ld	* Makefile.am: (ALL_EMULATION_SOURCES): Add new emulations.
	* Makefile.in: Regenerate.
	* configure.tgt: Add h8300-*-linux
	* emulparams/h8300elf_linux.sh: Add new emulation.
	* emulparams/h8300helf_linux.sh: Likewise.
	* emulparams/h8300self_linux.sh: Likewise.
	* emulparams/h8300sxelf_linux.sh: Likewise.

bfd	* config.bfd: Add h8300-*-linux.
	* configure.ac: Add h8300_elf32_linux_vec.
	* configure: Regenerate.
	* elf32-h8300.c: Likewise.
	* targets.c(_bfd_target_vector): Likewise.

gas	* config/tc-h8300.c (line_separater_chars): Add a version for
	h8300-linux that includes a separator.
	(default_mach): New variable.
	(md_main): Use it.
	(md_longopts): Add '--march' option.
	(md_parse_option): Parse the new option.
	* config/tc-h8300.h (TARGET_FORMAT): Add elf32-h8300-linux.
	* configure.tgt: Add h8300-*-linux
	* doc/c-h8300.texi: Document --march.
2015-02-23 17:04:53 +00:00
Nick Clifton f971c12fc5 Fixes a problem where "ld -ixxx" would report an error of "ld: bad -rpath option".
* lexsup.c (parse_args): Produce a more reasonable error message
	when -ixxx or -rxxx is the last option on the linker command line.
2015-02-23 15:33:56 +00:00