Commit Graph

4825 Commits

Author SHA1 Message Date
H.J. Lu e5a764c49c Add ChangeLog for check_ifunc_attribute_available 2015-08-13 02:48:55 -07:00
H.J. Lu 13a2df29c9 Set EI_OSABI to ELFOSABI_GNU for local IFUNC symbols
Since the backend elf_add_symbol_hook isn't called on local symbols,
the EI_OSABI field isn't to ELFOSABI_GNU where are local IFUNC symbols.
This patch changes the x86 backends to set has_gnu_symbols if there are
relocations against IFUNC symbols.  Other backends with IFUNC support
may need a similar change.

This patch also changes the type of has_gnu_symbols from bfd_boolean to
enum elf_gnu_symbols.

bfd/

	PR ld/18815
	* elf-bfd.h (elf_gnu_symbols): New enum.
	(elf_obj_tdata): Use elf_gnu_symbols on has_gnu_symbols.
	* elf-s390-common.c (elf_s390_add_symbol_hook): Set
	has_gnu_symbols to elf_gnu_symbol_any.
	* elf32-arm.c (elf32_arm_add_symbol_hook): Likewise.
	* elf32-m68k.c (elf_m68k_add_symbol_hook): Likewise.
	* elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
	* elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise.
	* elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise.
	* elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise.
	* lfxx-aarch64.c (_bfd_aarch64_elf_add_symbol_hook): Likewise.
	* elf32-i386.c (elf_i386_check_relocs): Update has_gnu_symbols
	if there are relocations against IFUNC symbols.
	(elf_i386_add_symbol_hook): Don't check STT_GNU_IFUNC here.
	* elf64-x86-64. (elf_x86_64_check_relocs): Update has_gnu_symbols
	if there are relocations against IFUNC symbols.
	(elf_x86_64_add_symbol_hook): Don't check STT_GNU_IFUNC here.

ld/testsuite/

	PR ld/18815
	* ld-i386/i386.exp: Run pr18815.
	* ld-x86-64/x86-64.exp: Likewise.
	* ld-i386/pr18815.d: New file.
	* ld-i386/pr18815.s: Likewise.
	* ld-x86-64/pr18815.d: Likewise.
	* ld-x86-64/pr18815.s: Likewise.
2015-08-12 13:47:41 -07:00
Simon Dardis 40fc1451c6 [MIPS] Map 'move' to 'or'.
The MIPS assembly idiom 'move' now maps to the 'or' machine instruction. This
change affects microMIPS, MIPS32, MIPS64.

2015-08-12  Simon Dardis  <simon.dardis@imgtec.com>

opcodes/

	* micromips-opc.c (micromips_opcodes): Re-order table so that move
	based on 'or' is first.
	* mips-opc.c (mips_builtin_opcodes): Ditto.

bfd/

	* elfxx-mips.c (STUB_MOVE): Change to use 'or' only.
	(mips_o32_exec_plt0_entry, mips_n32_exec_plt0_entry,
	mips_n64_exec_plt0_entry, micromips_insn32_o32_exec_plt0_entry):
	Update to use 'or' instead of 'addu/daddu'.
	(_bfd_mips_elf_finish_dynamic_symbol): Update usage of STUB_MOVE.
	(move_insns_32): Reorder table.

gas/

	* config/tc-mips.c (move_register): Change to use 'or' only.
	(s_cpload, s_cpsetup, s_cprestore, s_cpreturn): Update to
	use or for move.

gas/testsuite/

	* gas/mips/elf-rel23.d: Update test.
	* gas/mips/elf-rel23.d: Ditto.
	* gas/mips/elf-rel23a.d: Ditto.
	* gas/mips/elf-rel23b.d: Ditto.
	* gas/mips/elf_e_flags1.d: Ditto.
	* gas/mips/elf_e_flags2.d: Ditto.
	* gas/mips/elf_e_flags3.d: Ditto.
	* gas/mips/elf_e_flags4.d: Ditto.
	* gas/mips/loc-swap-dis.d: Ditto.
	* gas/mips/micromips-insn32.d: Ditto.
	* gas/mips/micromips-noinsn32.d: Ditto.
	* gas/mips/micromips-trap.d: Ditto.
	* gas/mips/micromips.d: Ditto.
	* gas/mips/mips-abi32-pic.d: Ditto.
	* gas/mips/mips-abi32.d: Ditto.
	* gas/mips/mips-gp32-fp32-pic.d: Ditto.
	* gas/mips/mips-gp32-fp32.d: Ditto.
	* gas/mips/mips-gp32-fp64-pic.d: Ditto.
	* gas/mips/mips-gp32-fp64.d: Ditto.
	* gas/mips/mips-gp64-fp32-pic.d: Ditto.
	* gas/mips/mips-gp64-fp32.d: Ditto.
	* gas/mips/mips-gp64-fp64-pic.d: Ditto.
	* gas/mips/mips-gp64-fp64.d: Ditto.
	* gas/mips/mipsr6@loc-swap-dis.d: Ditto.
	* gas/mips/tls-o32.d: Ditto.
	* gas/mips/uld2-eb.d: Ditto.
	* gas/mips/uld2-el.d: Ditto.
	* gas/mips/ulw2-eb-ilocks.d: Ditto.
	* gas/mips/ulw2-eb.d: Ditto.
	* gas/mips/ulw2-el-ilocks.d: Ditto.
	* gas/mips/ulw2-el.d: Ditto.
	* gas/mips/move.d: New test.
	* gas/mips/move.s: Ditto.
	* gas/mips/micromips32-move.d: Ditto.
	* gas/mips/micromips32-move.s: Ditto.
	* gas/mips/mips.exp: Run the new tests.

gold/

	* mips.cc (plt0_entry_o32, plt0_entry_n32, plt0_entry_n64,
	lazy_stub_normal_1, lazy_stub_normal_1_n64,
	lazy_stub_normal_2, lazy_stub_normal_2_n64, lazy_stub_big,
	lazy_stub_big_n64, lazy_stub_micromips32_normal_1_n64,
	lazy_stub_micromips32_normal_2_n64, lazy_stub_micromips32_big,
	lazy_stub_micromips32_big_n64): Update to use 'or' for move instead
	of 'addu/daddu'.

ld/testsuite/

	* ld-mips-elf/compressed-plt-1-n32-mips16.od: Update test.
	* ld-mips-elf/compressed-plt-1-n32-umips.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-mips16-got.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-mips16-only.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-mips16-word.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-mips16.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-se.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-umips-got.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-umips-word.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-umips.od: Ditto.
	* ld-mips-elf/jalx-2.dd: Ditto.
	* ld-mips-elf/mips16-pic-3.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-3a.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-3b.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-5b.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-6-n32.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-6-o32.dd: Ditto.
	* ld-mips-elf/stub-dynsym-1-10000.d: Ditto.
	* ld-mips-elf/stub-dynsym-1-2fe80.d: Ditto.
	* ld-mips-elf/stub-dynsym-1-7fff.d: Ditto.
	* ld-mips-elf/stub-dynsym-1-8000.d: Ditto.
	* ld-mips-elf/stub-dynsym-1-fff0.d: Ditto.
	* ld-mips-elf/tlsbin-o32.d: Ditto.
	* ld-mips-elf/tlsdyn-o32-1.d: Ditto.
	* ld-mips-elf/tlsdyn-o32-2.d: Ditto.
	* ld-mips-elf/tlsdyn-o32-3.d: Ditto.
	* ld-mips-elf/tlsdyn-o32.d: Ditto.
	* ld-mips-elf/tlslib-o32.d: Ditto.
2015-08-12 17:10:22 +01:00
Alan Modra 6bf45b2495 Remove ChangeLog separator 2015-08-12 22:56:01 +09:30
Jiong Wang 87ad46af87 [AArch64] Fix test failures on elf configuration
This patch fixed those failures on elf configuration by:

   * Improve the ILP32 target selector "aarch64_choose_ilp32_emul",
     makes it more robust. Target triples copied from configure.tgt

   * Updated emit-relocs-86/-overflow.d to use aarch64_choose_ilp32_emul
     which is following what have done with emit-relocs-28.

   * Those instruction encoding mismatch is because those encoding
     contains pc-relative address. As for elf, we may have different
     start address. relaxed encodind check, especially for
     aarch64-farcall-b/bl-plt, as the main purpose of those check are
     ELF text/data layout, we just want to make sure veneer to plt stub
     is generated.

2015-08-12  Jiong Wang  <jiong.wang@arm.com>

ld/testsuite/
  * ld-aarch64/aarch64-elf.exp (aarch64_choose_ilp32_emul): Support all
  four triple shapes: aarch64-*-linux*, aarch64-*-elf,
  aarch64_be-*-linux*, aarch64_be-*-elf.
  * ld-aarch64/emit-relocs-86.d: Use aarch64_choose_ilp32_emul.
  * ld-aarch64/emit-relocs-86-overflow.d: Likewise.
  * ld-aarch64/ld-aarch64/farcall-b-plt.d: Relax instrucion encoding
  check when they reflect address.
  * ld-aarch64/ld-aarch64/farcall-bl-plt.d: Likewise.
2015-08-12 13:17:50 +01:00
H.J. Lu 995da1ffa7 Remove trailing spaces in ld 2015-08-12 04:46:43 -07:00
Thomas Preud'homme f63d6d9650 [AArch64] Rename relocs-257-symbolic-func ld test to relocs-1027-symbolic-func.
2015-08-12  Thomas Preud'homme  <thomas.preudhomme@arm.com>

ld/testsuite/
    * ld-aarch64/aarch64-elf.exp: Rename relocs-257-symbolic-func to
    relocs-1027-symbolic-func.
    * ld-aarch64/relocs-257-symbolic-func.d: Rename to ...
    * ld-aarch64/relocs-1027-symbolic-func.d: ... this.
    * ld-aarch64/relocs-257-symbolic-func.s: Rename to ...
    * ld-aarch64/relocs-1027-symbolic-func.s: ... this.
2015-08-12 09:34:13 +08:00
Jiong Wang b261b4db94 [AArch64] Commit missing testcases 2015-08-11 22:12:08 +01:00
Jiong Wang f678ded748 [AArch64] Long branch veneer support far symbol defined by --defsym
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * bfd/elfnn-aarch64.c (aarch64_type_of_stub): New parameter "sym_sec".
  Loose the check for symbol from ABS section.
  (elfNN_aarch64_size_stubs): Pass sym_sec.

ld/testsuite/
  * ld-aarch64/farcall-b-defsym.s: New test.
  * ld-aarch64/farcall-bl-defsym.s: Likewise.
  * ld-aarch64/farcall-b-defsym.d: New expectation.
  * ld-aarch64/farcall-bl-defsym.d: Likewise.
2015-08-11 21:55:52 +01:00
Jiong Wang 07f9ddfeba [AArch64] PR18668, repair long branch veneer for plt stub
2015-08-11  Jiong Wang  <jiong.wang@arm.com>
bfd/
   PR ld/18668
   * elfnn-aarch64.c (aarch64_type_of_stub): Update destination for
   calls go through plt stub.
   (elfNN_aarch64_final_link_relocate): Adjust code logic for CALL26,
   JUMP26 relocation to support inserting veneer for call to plt stub.

ld/testsuite/
   * ld-aarch64/farcall-b-gsym.s: New test.
   * ld-aarch64/farcall-b-plt.s: Likewise.
   * ld-aarch64/farcall-bl-plt.s: Likewise.
   * ld-aarch64/farcall-b-gsym.d: New expect file.
   * ld-aarch64/farcall-b-plt.d: Likewise.
   * ld-aarch64/farcall-bl-plt.d: Likewise.
2015-08-11 21:44:31 +01:00
Jiong Wang 40fbed8481 [AArch64][8/8] LD support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize
  BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12.
  (aarch64_reloc_got_type): Likewise.
  (elfNN_aarch64_final_link_relocate): Likewise.
  (elfNN_aarch64_relocate_section): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/emit-relocs-529.s: New testcase.
  * ld-aarch64/emit-relocs-529-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-86.s: Likewise.
  * ld-aarch64/emit-relocs-86-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-529.d: New expectation file.
  * ld-aarch64/emit-relocs-529-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-86.d: Likewise.
  * ld-aarch64/emit-relocs-86-overflow.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new testcases.
2015-08-11 21:26:41 +01:00
Jiong Wang 73f925cc20 [AArch64][6/8] LD support BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize
  BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC.
  (aarch64_reloc_got_type): Likewise.
  (elfNN_aarch64_final_link_relocate): Likewise.
  (elfNN_aarch64_relocate_section): Likewise.
  (elfNN_aarch64_gc_sweep_hook): Likewise.
  (elfNN_aarch64_check_relocs): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/tls-small-ld.s: Update testcase.
2015-08-11 21:26:13 +01:00
Jiong Wang f69e49203b [AArch64][3/8] LD support BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize
  BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21.
  (aarch64_reloc_got_type): Likewise.
  (elfNN_aarch64_final_link_relocate): Likewise.
  (elfNN_aarch64_relocate_section): Likewise.
  (elfNN_aarch64_gc_sweep_hook): Likewise.
  (elfNN_aarch64_check_relocs): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/tls-small-ld.s: New file.
  * ld-aarch64/tls-small-ld.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new test.
2015-08-11 21:25:04 +01:00
H.J. Lu 97dc35c88d Skip IFUNC relocations in debug sections
Skip IFUNC relocations in debug sections ignored by ld.so.

bfd/

	PR ld/18808
	* elf32-i386.c (elf_i386_relocate_section): Skip IFUNC
	relocations in debug sections.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.

ld/testsuite/

	PR ld/18808
	* ld-ifunc/ifunc.exp: Add a test for PR ld/18808.
	* ld-ifunc/pr18808.out: New file.
	* ld-ifunc/pr18808a.c: Likewise.
	* ld-ifunc/pr18808b.c: Likewise.
2015-08-11 12:59:11 -07:00
H.J. Lu 6e33951edc Properly merge hidden versioned symbol
The hidden versioned symbol can only be merged with the versioned
symbol with the same symbol version.  _bfd_elf_merge_symbol should
check the symbol version before merging the new hidden versioned
symbol with the existing symbol.  _bfd_elf_link_hash_copy_indirect can't
copy any references to the hidden versioned symbol.   We need to
bind a symbol locally when linking executable if it is locally defined,
hidden versioned, not referenced by shared library and not exported.

bfd/

	PR ld/18720
	* elflink.c (_bfd_elf_merge_symbol): Add a parameter to indicate
	if the new symbol matches the existing one.  The new hidden
	versioned symbol matches the existing symbol if they have the
	same symbol version. Update the existing symbol only if they
	match.
	(_bfd_elf_add_default_symbol): Update call to
	_bfd_elf_merge_symbol.
	(_bfd_elf_link_assign_sym_version): Don't set the hidden field
	here.
	(elf_link_add_object_symbols): Override a definition only if the
	new symbol matches the existing one.
	(_bfd_elf_link_hash_copy_indirect): Don't copy any references to
	the hidden versioned symbol.
	(elf_link_output_extsym): Bind a symbol locally when linking
	executable if it is locally defined, hidden versioned, not
	referenced by shared library and not exported.  Turn on
	VERSYM_HIDDEN only if the hidden vesioned symbol is defined
	locally.

ld/testsuite/

	PR ld/18720
	* ld-elf/indirect.exp: Run tests for PR ld/18720.
	* ld-elf/pr18720.out: New file.
	* ld-elf/pr18720a.c: Likewise.
	* ld-elf/pr18720b.c: Likewise.
	* ld-elf/pr18720c.c: Likewise.
2015-08-07 05:04:35 -07:00
Alan Modra e0a3af227e Revert ALIGN changes
Reverts a2c59f28 and e474ab13.  Since the unary form of ALIGN only
references "dot" implicitly, there isn't really a strong argument for
making ALIGN use a relative value when inside an output section.

	* ldexp.c (align_dot_val): Delete.
	(fold_unary <ALIGN_K, NEXT>): Revert 2015-07-10 change.
	(is_align_conditional): Revert 2015-07-20 change.
	(exp_fold_tree_1): Likewise, but keep expanded comment.
	* scripttempl/elf.sc (.ldata, .bss): Revert 2015-07-20 change.
	* ld.texinfo (<ALIGN>): Correct description.
2015-08-06 16:05:40 +09:30
Andrew Burgess 9c98104c4c ld: map option for run_dump_test requires no program.
When using run_dump_test with the map option to compare the linker map
file produced, no additional dump program should be required.  A dump
program can still be given if needed, but leaving it off will no longer
produce an error.

ld/testsuite/ChangeLog:

	* ld/ld-lib.exp (run_dump_test): When using the map option, no
	program is required.
2015-08-04 11:25:37 +01:00
Andrew Burgess bb57e4c7bd ld: Add file based error/warning regexp for run_dump_test.
The run_dump_test mechanism supports options error and warning, which
allow regexp to be specified within the test file, these regexp are
matched against the stderr output from the linker.

Similar dump test style functions for gas and gdb also support file
based matching versions of these options; the patterns are placed into a
file which the test driver then references.  It is sometimes clearer,
when the pattern to be matched spans multiple lines if the patterns can
be placed into a separate file.

This patch adds new options error_output and warning_output for the
linker run_dump_test function.  These new options take a filename
parameter, this file is then used (with regexp_diff) to compare against
the linker output.

ld/testsuite/ChangeLog:

	* ld/ld-lib.exp (run_dump_test): Add error_output and
	warning_output options.
2015-08-04 11:16:39 +01:00
Andrew Burgess 0a61824343 ld: Add '--require-defined' command line option.
Add a new command line option '--require-defined' to the linker.  This
option operates identically to the '--undefined' option, except that if
the symbol is not defined in the final output file then the linker will
exit with an error.

When making use of --gc-section, or just when trying to pull in parts of
a library, it is not uncommon for a user to use the '--undefined'
command line option to specify a symbol that the user then expects to be
defined by one of the object files supplied to the link.

However, if for any reason the symbol is not satisfied by an object
provided to the link the user will be left with an undefined symbol in
the output file, instead of a defined symbol.

In some cases the above behaviour is what the user wants, in other cases
though we can do better.  The '--require-defined' option tries to fill
this gap.  The symbol passed to the '--require-defined' option is
treated exactly as if the symbol was passed to '--undefined', however,
before the linker exits a check is made that all symbols passed to
'--require-defined' are actually defined, if any are not then the link
will fail with an error.

ld/ChangeLog:

	* ld.texinfo (Options): Document --require-defined option.
	* ldlang.c (struct require_defined_symbol): New structure.
	(require_defined_symbol_list): New variable.
	(ldlang_add_require_defined): New function.
	(ldlang_check_require_defined_symbols): New function.
	(lang_process): Check required symbols are defined.
	* ldlang.h (ldlang_add_require_defined): Declare.
	* ldlex.h (enum option_values): Add OPTION_REQUIRE_DEFINED_SYMBOL.
	* lexsup.c (ld_options): Add '--require-defined' entry.
	(parse_args): Handle '--require-defined' entry.
	* NEWS: Mention new '--require-defined' option.

ld/testsuite/ChangeLog:

	* ld-undefined/require-defined-1.d: New file.
	* ld-undefined/require-defined-2.d: New file.
	* ld-undefined/require-defined-3.d: New file.
	* ld-undefined/require-defined-4.d: New file.
	* ld-undefined/require-defined-5.d: New file.
	* ld-undefined/require-defined.exp: New file.
	* ld-undefined/require-defined.s: New file.
2015-08-04 10:00:05 +01:00
Andrew Burgess 127fcdff05 ld/doc: Document that multiple MEMORY commands are allowed.
The linker documentation explicitly states that there can be only one
MEMORY command.  This is not true.  Multiple MEMORY commands are
allowed, the contents of all will be treated as if a single MEMORY
command was given.

Update the documentation to make this clear to the users.

ld/ChangeLog:

	* ld.texinfo (MEMORY): Explain that multiple MEMORY commands are
	acceptable.
2015-08-03 20:18:49 +01:00
H.J. Lu c6e8a9a802 Don't change the default symbol for relocatable link
We should change the default symbol for the versioned symbol only when
not performing a relocatable link.

bfd/

	PR ld/18735
	* elflink.c (_bfd_elf_add_default_symbol): Add the default
	symbol if not performing a relocatable link.
	(elf_link_add_object_symbols): Adjust the default symbol if
	not performing a relocatable link.

ld/testsuite/

	PR ld/18735
	* ld-elf/pr18735.d: New file.
	* ld-elf/pr18735.s: Likewise.
2015-07-30 03:28:00 -07:00
H.J. Lu 60b57502ec Use noclone attribute only for GCC 4.5 or newer
noclone attribute was added to GCC 4.5.  We should check GCC version
before using it.

	* ld-elf/pr18718.c (bar): Use noclone attribute only for GCC
	4.5 or newer.
2015-07-29 11:20:04 -07:00
H.J. Lu de0a002639 Move run-time support check for size relocation
We must check run-time support for size relocation first before running
the tests.

	* ld-size/size.exp: Move run-time support check.
2015-07-29 10:52:38 -07:00
H.J. Lu e77e648e93 Don't set link_info.executable for "ld -r"
This patch changes "ld -r" not to set link_info.executable.  It
removes !info->relocatable check for info->executable and adds it
for !info->executable in elflink.c.

bfd/

	* elflink.c (elf_link_add_object_symbols): Remove
	!info->relocatable check for info->executable.  Add
	!info->relocatable check for !info->executable.
	(elf_link_output_extsym): Remove
	!info->relocatable check for info->executable.

ld/

	* lexsup.c (parse_args): Don't set link_info.executable to
	TRUE for link_info.relocatable.
2015-07-29 09:14:05 -07:00
Alan Modra e5654c0f84 Fallout from "Reorder more powerpc64 sections for -z relro"
Commit 23283c1b changed the layout of some bss style sections on
powerpc64, but neglected to add a page gap before the third PT_LOAD
segment created by this reording.  Without a page gap we get two
PT_LOAD headers that overlap by one page in memory.  That shouldn't be
allowed because the dynamic loader will load garbage from the first
page of the last segment over the last page of the previous segment.

bfd/
	* elf.c (_bfd_elf_map_sections_to_segments): Do not make a new
	segment for loaded sections after nonloaded sections if the
	sections are on the same page.
ld/testsuite/
	* ld-powerpc/elfv2so.d: Update
2015-07-28 18:42:43 +09:30
H.J. Lu 6f8ea6c424 Set NOPIE_CFLAGS and NOPIE_LDFLAGS
GCC 6 can be configured to generate PIE by default.  But some linker
size tests expect non-PIE.  This patch defines NOPIE_CFLAGS to
"-fno-PIE" and NOPIE_LDFLAGS to "-no-pie" if target compiler supports
them.  Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS to linker size tests if
needed.

	* config/default.exp (NOPIE_CFLAGS): New.
	(NOPIE_LDFLAGS): Likewise.
	* ld-size/size.exp (run_cc_link_tests): Add $NOPIE_CFLAGS and
	$NOPIE_LDFLAGS if needed.
	(run_ld_link_exec_tests): Add $NOPIE_CFLAGS if needed.
2015-07-27 16:20:49 -07:00
H.J. Lu c45bd4fd43 Check address of versined symbol
Since GCC 5 folds symbol address comparison, assuming each symbol has a
different address, &foo == &bar is always false for GCC 5.  This patch
adds check_ptr_eq if 2 addresses are the same and uses it to check the
address of versined symbol.

	PR ld/18718
	* ld-elf/check-ptr-eq.c: New file.
	* ld-elf/pr18718.c (main): Call check_ptr_eq.
	* ld-elf/shared.exp: Add check-ptr-eq.c to PR ld/18718 tests.
2015-07-27 10:11:33 -07:00
H.J. Lu 37a42ee9ad Regenerate configure files
bfd/

	* configure: Regenerated.

binutils/

	* configure: Regenerated.

gas/

	* configure: Regenerated.

gold/

	* configure: Regenerated.

gprof/

	* configure: Regenerated.

ld/

	* configure: Regenerated.

opcodes/

	* configure: Regenerated.
2015-07-27 07:56:32 -07:00
H.J. Lu 219a6876d4 Append $PLT_CFLAGS to CC/CXX for S-records tests
S-records tests don't work with -fno-plt.  This path appends $PLT_CFLAGS
to CC and CXX for S-records tests.

	* ld-srec/srec.exp (CC): Save and restore.  Append $PLT_CFLAGS.
	(CXX): Likewise.
2015-07-27 05:18:20 -07:00
H.J. Lu cda77e9efc Pass $PLT_CFLAGS to ld_compile
Some linker shard library tests without PIC expect PLT.  This patch
passes $PLT_CFLAGS to ld_compile.

	* ld-shared/shared.exp: Pass $PLT_CFLAGS to ld_compile.
2015-07-27 05:17:26 -07:00
H.J. Lu 379d3f1ffc Append $PLT_CFLAGS to CC for NOCROSSREFS tests
NOCROSSREFS tests don't work with -fno-plt.  This path appends
$PLT_CFLAGS to CC for NOCROSSREFS tests.

	* ld-scripts/crossref.exp (CC): Save and restore.  Append
	$PLT_CFLAGS.
2015-07-27 05:16:38 -07:00
H.J. Lu ea9fb8b3e9 Add $PLT_CFLAGS to -fPIC for run_cc_link_tests
Some x86 linker tests expect PLT.  This patch adds $PLT_CFLAGS to -fPIC
for run_cc_link_tests.

	* ld-i386/i386.exp (run_cc_link_tests): Add $PLT_CFLAGS to
	-fPIC if needed.
	* ld-x86-64/mpx.exp (run_cc_link_tests): Likewise.
	* ld-x86-64/x86-64.exp (run_cc_link_tests): Likewise.
2015-07-27 05:15:48 -07:00
H.J. Lu faebca0390 Pass $PLT_CFLAGS to ld_compile
Some linker visibility tests without PIC expect PLT.  This patch passes
$PLT_CFLAGS to ld_compile.

	* ld-elfvsb/elfvsb.exp (visibility_run): Pass $PLT_CFLAGS to
	ld_compile.
2015-07-27 05:15:01 -07:00
H.J. Lu c4972ed602 Pass $PLT_CFLAGS to build_binary
Some linker symbol version tests without PIC expect PLT.  This patch
adds $PLT_CFLAGS to CFLAGS.

	* ld-elfvers/vers.exp (build_vers_lib_no_pic): Pass $PLT_CFLAGS
	to build_binary.
2015-07-27 05:13:55 -07:00
H.J. Lu e10461aebd Set PLT_CFLAGS to "-fplt" if supported
GCC 6 supports -fno-plt.  But some linker tests expect PLT.  This patch
defines PLT_CFLAGS to "-fplt" if target compiler supports it.

	* config/default.exp (PLT_CFLAGS): New.
2015-07-27 05:12:02 -07:00
Szabolcs Nagy 32f573bcb3 [AArch64] Fix extern protected data handling
Emit *GLOB_DAT instead of *RELATIVE relocs for protected data
in shared objects.

This is needed for the fix of glibc bug 17711:
https://sourceware.org/bugzilla/show_bug.cgi?id=17711

bfd:
	PR ld/18705
	* elfnn-aarch64.c (elf_backend_extern_protected_data): Define.

ld/testsuite:
	PR ld/18705
	* ld-aarch64/protected-data.d: New.
	* ld-aarch64/protected-data.s: New.
	* ld-aarch64/aarch64-elf.exp: Add new test.
2015-07-27 11:48:48 +01:00
Szabolcs Nagy b68a20d667 [ARM] Fix extern protected data handling
Emit *GLOB_DAT instead of *RELATIVE relocs for protected data
in shared objects.

This is needed for the fix of glibc bug 17711:
https://sourceware.org/bugzilla/show_bug.cgi?id=17711

bfd:
	PR ld/18705
	* elf32-arm.c (elf_backend_extern_protected_data): Define.

ld/testsuite:
	PR ld/18705
	* ld-arm/protected-data.d: New.
	* ld-arm/protected-data.s: New.
	* ld-arm/arm-elf.exp: Add new test.
2015-07-27 11:45:27 +01:00
H.J. Lu edcab5e8bd Compile PR ld/18718 tests with -O2
PR ld/18718
	* ld-elf/shared.exp: Compile PR ld/18718 tests with -O2.
2015-07-26 14:55:39 -07:00
H.J. Lu d76b620743 Set errcnt and warncnt to 0 in run_host_cmd_yesno
run_host_cmd_yesno should set errcnt and warncnt to 0.  Otherwise, they
may leak to the next run.

	* lib/ld-lib.exp (run_host_cmd_yesno): Set errcnt and warncnt
	to 0.
2015-07-26 11:55:57 -07:00
H.J. Lu 18d9555c6e Add missing ChangeLog files 2015-07-25 08:10:51 -07:00
H.J. Lu 1659f720b0 Skip missing symbol version section check for executable
Missing symbol version section is a run-time problem only if it will
be referenced dynamically at run-time.  We should skip the check for
locally defined symbol, which isn't referenced by shared library, when
linking executable.

bfd/

	PR ld/18718
	* elflink.c (elf_link_output_extsym): Check symbol version
	section check only if not linking executable, the symbol is
	referenced by shared library or not locally defined.

ld/testsuite/

	PR ld/18718
	* ld-elf/pr18718.c: New file.
	* ld-elf/shared.exp: Run tests for PR ld/18718.
2015-07-25 08:07:33 -07:00
Alan Modra a496fbc880 Fix broken -Bsymbolic-functions
For selected targets.  The testcase reveals a number of targets that
still need fixing.

bfd/
	* elf32-arm.c (elf32_arm_final_link_relocate): Use SYMBOLIC_BIND to
	check if a symbol should be bound symbolically.
	* elf32-hppa.c (elf32_hppa_check_relocs,
	elf32_hppa_adjust_dynamic_symbol, elf32_hppa_relocate_section,
	elf32_hppa_finish_dynamic_symbol): Likewise.
	* elf32-m68k.c (elf_m68k_check_relocs,
	elf_m68k_relocate_section): Likewise.
	* elf32-nios2.c (nios2_elf32_relocate_section,
	nios2_elf32_check_relocs, allocate_dynrelocs): Likewise.
	* elf32-tic6x.c (elf32_tic6x_finish_dynamic_symbol,
	elf32_tic6x_relocate_section): Likewise.
ld/testsuite/
	* ld-elf/symbolic-func.s,
	* ld-elf/symbolic-func.r: New test.
	* ld-elf/elf.exp: Run it.
2015-07-25 20:41:04 +09:30
Nick Clifton aff1a65ecb Fix the evaluation of RL78 complex relocs, by making immediate values be computed relative to a new absolute symbol.
gas	* config/tc-rl78.c (rl78_abs_sym): New local variable.
	(md_begin): Initialise the new symbol.
	(OPIMM): Define the value to be relative to the new symbol and not
	the absolute section symbol.

ld	* emulparams/elf32rl78.sh (OTHER_SECTIONS): Provide a value for
	the _-rl78_abs__ symbol.

tests	* gas/all/struct.d: Allow for extra symbols in the output.
	* gas/macros/test1.d: Likewise.
	* gas/elf/elf.exp: Add an rl78 machine.
	* gas/elf/sections2e-rl78: New file.

tests	* binutils-all/localize-hidden-1.d: Allow for extra symbols in the
	output.
        * binutils-all/strip-11.d: Skip for the RL78.
2015-07-24 16:44:27 +01:00
H.J. Lu 84b74b498e Replace -g with -ggdb3 in ld compress tests
Use -ggdb3 to generate .debug_macro sections, which are bigger and are
always compressed.

	* ld-elf/compress.exp (build_tests): Replace -g with -ggdb3.
	* ld-elf/zlibbegin.rS: Also expect "GC".
	* ld-elf/zlibnormal.rS: Likewise.
2015-07-24 04:16:56 -07:00
H.J. Lu 72f4393d8c Remove leading/trailing white spaces in ChangeLog 2015-07-24 04:16:47 -07:00
H.J. Lu 7ac018954b Make binutils abort message GDB friendly
We used to generate abort messages like:

internal error, aborting at .../bfd/elf64-x86-64.c line 1554 in elf_x86_64_check_relocs

We can't cut and paste "file line ???" to GDB.  This patch changes those
abort messages to

internal error, aborting at .../bfd/elf64-x86-64.c:1554 in elf_x86_64_check_relocs

so that we can cut and paste "file:???" to GDB.

bfd/

	* bfd.c (_bfd_abort): Replace " line " with ":" in output
	message.

gas/

	* messages.c (as_assert): Replace " line " with ":" in output
	message.
	(as_abort): Likewise.

ld/

	* ldmisc.c (ld_abort): Replace " line " with ":" in output
	message.
2015-07-20 05:53:31 -07:00
Alan Modra d9d11c361c ALIGN change affects cris scripts
More fallout from a2c59f28.  This one could have been fixed by simply
using ". = ALIGN (ABSOLUTE (.), 2);" but it's nicer to align the
section.

	* emulparams/criself.sh (INIT_ADDR, FINI_ADDR): Define.
	(INIT_START, FINI_START): Don't ALIGN.
	* scriptempl/elf.sc (.init, .fini): Apply INIT_ADDR/FINI_ADDR.
2015-07-20 14:29:37 +09:30
Alan Modra e474ab13ec ALIGN change affects standard scripts
a2c59f28 changed the way the unary ALIGN behaved inside output sections,
resulting in cris-elf testsuite regressions.  This patch pads out .bss
in the same manner as it was prior to the ALIGN change.

	* scripttempl/elf.sc (.ldata, .bss): Align absolute value of dot.
	* ldexp.c (is_align_conditional): Handle binary ALIGN.
	(exp_fold_tree_1): Move code setting SEC_KEEP for assignments to
	dot inside output sections.  Handle absolute expressions.
2015-07-20 14:29:21 +09:30
Jiong Wang 77a69ff840 [AArch64][3/3] LD support BFD_RELOC_AARCH64_TLSLD_ADR_PREL21 2015-07-16 15:46:21 +01:00
H.J. Lu 19a7fe52ae Make default compression gABI compliant
All programs in binutils+gdb git repo now support gABI compression
with the SHF_COMPRESSED bit.  This patch makes the zlib-gabi option
as compression default for gas, gold, ld and objcopy, instead of the
zlib-gnu option whose outputs are incompatible with gABI.

binutils/

	* objcopy.c (copy_file): Set BFD_COMPRESS_GABI if not
	zlib-gnu.
	* doc/binutils.texi: Change --compress-debug-sections and
	--compress-debug-sections=zlib to zlib-gabi.

binutils/testsuite/

	* binutils-all/compress.exp: Update.

gas/

	* as.c (parse_args): Make --compress-debug-sections and
	--compress-debug-sections=zlib the same as
	--compress-debug-sections=zlib-gabi.
	* doc/as.texinfo: Change --compress-debug-sections and
	--compress-debug-sections=zlib to zlib-gabi.

gold/

	* compressed_output.cc (Output_compressed_section::set_final_data_size):
	Make --compress-debug-sections=zlib the same as
	--compress-debug-sections=zlib-gabi.
	* testsuite/Makefile.am (flagstest_compress_debug_sections.check):
	Expect ".debug_.*" with the SHF_COMPRESSED bit, instead of
	".zdebug_".
	* testsuite/Makefile.in: Regenerated.

ld/

	* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Make
	--compress-debug-sections=zlib the same as
	--compress-debug-sections=zlib-gabi.
	* ld.texinfo: Change --compress-debug-sections=zlib to zlib-gabi.

ld/testsuite/

	* ld-elf/zlibbegin.rS: Updated to .debug_.* with the
	SHF_COMPRESSED bit.
	* ld-elf/zlibnormal.rS: Likewise.
2015-07-14 10:26:23 -07:00