Commit Graph

5369 Commits

Author SHA1 Message Date
Maciej W. Rozycki 1e5f45bb15 PR ld/20828: Work around RISC-V failures
Complement commit 81ff47b3a5 ("PR ld/20828: Fix linker script symbols
wrongly forced local with section GC") and add `.plt' to the list of
output sections created, fixing:

FAIL: PR ld/20828 dynamic symbols with section GC (auxiliary shared library)
FAIL: PR ld/20828 dynamic symbols with section GC (plain)
FAIL: PR ld/20828 dynamic symbols with section GC (version script)

failures with `riscv32-elf', `riscv32-linux', `riscv64-elf' and
`riscv64-linux' targets caused by LD crashing in the absence of such a
section.

	ld/
	PR ld/20828
	* testsuite/ld-elf/pr20828.ld: Add `.plt'.
2017-01-23 11:27:06 +00:00
Maciej W. Rozycki fda46c417f PR ld/20828: Remove leading `_' from symbols used in tests
Complement commit 81ff47b3a5 ("PR ld/20828: Fix linker script symbols
wrongly forced local with section GC") and remove the leading underscore
from `_fdata' and `_edata' symbols used in tests, fixing a:

FAIL: PR ld/20828 dynamic symbols with section GC (version script)

failure with targets such as: `bfin-elf', `bfin-uclinux', `metag-elf',
`metag-linux' `mn10300-elf', `sh-elf', `sh64-elf', and possibly other
ones, that have `_' set (with `elf_symbol_leading_char') as the leading
character for symbols.  As from commit 93252b1cf4 ("bfd/ld: handle ABI
prefixes in version scripts") these targets strip the leading underscore
before applying version script rules, because the (default) syntax for
symbol names is that of the C language rather than their low-level
symbol table encoding.

	ld/
	PR ld/20828
	* testsuite/ld-elf/pr20828.ld: Rename `_fdata' and `_edata' to
	`fdata' and `edata' respectively.
	* testsuite/ld-elf/pr20828.ver: Adjust accordingly.
	* testsuite/ld-elf/pr20828-a.sd: Likewise.
	* testsuite/ld-elf/pr20828-b.sd: Likewise.
	* testsuite/ld-elf/pr20828-c.sd: Likewise.
2017-01-23 11:26:06 +00:00
Maciej W. Rozycki adcbdc63e5 PR ld/20828: Relax symbol ordering in tests
Complement commit 81ff47b3a5 ("PR ld/20828: Fix linker script symbols
wrongly forced local with section GC") and make tests check for the
presence of global `_fdata' and `_edata' symbols separately, removing
any dependency on symbol table ordering for tests to succeed and
removing:

FAIL: PR ld/20828 dynamic symbols with section GC (auxiliary shared library)
FAIL: PR ld/20828 dynamic symbols with section GC (plain)

failures with the `x86_64-solaris2' target, which has additional
intervening entries:

Symbol table '.dynsym' contains 6 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    1 _fdata
     2: 0000000000000000     0 OBJECT  GLOBAL DEFAULT    1 _DYNAMIC
     3: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS _PROCEDURE_LINKAGE_TABLE_
     4: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    1 _edata
     5: 00000000000001b8     0 OBJECT  GLOBAL DEFAULT    4 _GLOBAL_OFFSET_TABLE_

Rename dump pattern files accordingly for consistency.

	ld/
	PR ld/20828
	* testsuite/ld-elf/pr20828-1.sd: Remove test.
	* testsuite/ld-elf/pr20828-a.sd: New test.
	* testsuite/ld-elf/pr20828-2a.sd: Rename test to...
	* testsuite/ld-elf/pr20828-b.sd: ... this.
	* testsuite/ld-elf/pr20828-2b.sd: Rename test to...
	* testsuite/ld-elf/pr20828-c.sd: ... this.
	* testsuite/ld-elf/shared.exp: Adjust accordingly.
2017-01-23 11:24:21 +00:00
Jiong Wang 9966f7eece [ld, testsuite] Honor cflags when GCC used as linker driver
ld/
	* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Append
	board_cflags as gcc is used as linker driver.
	* testsuite/ld-unique/unique.exp: Likewise
2017-01-23 09:59:10 +00:00
Jiong Wang 7f784814df [AArch64] Optimize .gnu.hash table size for executable
bfd/
	* elfnn-aarch64.c (elf_aarch64_hash_symbol): New function.
	(elf_backend_hash_symbol): Define.

ld/
	* testsuite/ld-aarch64/aarch64-elf.exp (aarch64elflinktests): New tests.
	* testsuite/ld-aarch64/func-in-so.s: New test source file.
	* testsuite/ld-aarch64/func-sym-hash-opt.s: Likewise.
	* testsuite/ld-aarch64/func-sym-hash-opt.d: New expected test result.
2017-01-20 13:30:32 +00:00
Andrew Burgess 1737c64030 objdump: Better objdump section headers in wide mode
When displaying the section headers table using objdump (-h), the column
containing the section header name is currently fixed at 13 characters.
A section name that is longer than 13 characters will overflow the
column causing the table to become miss-aligned.

In this commit I change the behaviour so that _in wide mode_ (-w -h) the
section name column is dynamically resized to fit the longest section
name we plan to display.  In wide mode the column still retains a
minimum width of 13 characters.

In non-wide more the behaviour is completely unchanged.

While I was changing the dump_headers function I have unified the two
printf lines that handled the different address widths into a single
printf, the address width is now passed into printf using the '*' field
width format character.

binutils/ChangeLog:

	* objdump.c (dump_section_header): Extract max section name length
	from data parameter, use this when formatting output.
	(find_longest_section_name): New function.
	(dump_headers): Calculate longest section name when in wide mode,
	reformat to unify printing of header line.

ld/ChangeLog:

	* testsuite/ld-elf/eh-frame-hdr.d: Update expected results.
2017-01-20 09:05:41 +00:00
Maciej W. Rozycki 6984613a53 PR ld/20995: MIPS: Set GAS flags correctly for tests
Complement commit 9acc85a62e ("Use dynrelro for symbols in relro
sections too").

	ld/
	PR ld/20995
	* testsuite/ld-elf/elf.exp: Set GAS flags correctly for the
	`mips*-*-*' target and `pr20995' and `pr20995-2' tests.
2017-01-18 23:19:07 +00:00
Maciej W. Rozycki 81ff47b3a5 PR ld/20828: Fix linker script symbols wrongly forced local with section GC
Fix a generic ELF linker regression introduced with a chain of changes
made to unused input section garbage collection:

- commit 1a766c6843 ("Also hide symbols without PLT nor GOT
  references."),
  <https://sourceware.org/ml/binutils/2011-09/msg00076.html>,

- commit 1d5316ab67 ("PR ld/13177: garbage collector retains zombie
  references to external libraries"),
  <https://sourceware.org/ml/binutils/2011-10/msg00161.html>,

- commit 6673f753c0 ("Fix PR 12772, garbage collection of dynamic
  syms"), <https://sourceware.org/ml/binutils/2011-12/msg00077.html>,

causing the garbage collection of unused symbols present in a DSO
involved in a link to make identically named symbols ordinarily defined
(i.e. not hidden or PROVIDEd) by a linker script local, even though the
latter symbols are supposed to be global as if no DSO defined them as
well.

This is because linker script assignments are processed very late as
`lang_process' proceeds, down in the call to `ldemul_before_allocation',
which is made after the call to `lang_gc_sections' to do input section
garbage collecting.  Consequently if unused, then any such DSO-defined
symbol has already been garbage-collected and internally marked local.
It would ordinarily be removed from dynamic symbol table output, however
a linker script assignment correctly replaces its original definition
with the new one and enters it into the dynamic symbol table produced as
it is supposed to be exported.  The original local marking is however
retained making the symbol local in the dynamic symbol table and
therefore not available externally.  This also causes a sorting problem
with the MIPS target, which does not expect non-section local dynamic
symbols to be output and produces an invalid binary.

Fix the problem then, by removing the `forced_local' marking for the
offending case and add suitable test cases.  First to verify that unused
symbols ordinarily defined with linker script assignments remain
exported in the context of input section garbage collection whether or
not a DSO defining identically named symbols is present in the link.
Second that a linker version script still correctly retains or removes
such symbols as requested.

	bfd/
	PR ld/20828
	* elflink.c (bfd_elf_record_link_assignment): Clear any
	`forced_local' marking for DSO symbols that are not being
	provided.

	ld/
	PR ld/20828
	* testsuite/ld-elf/pr20828-1.sd: New test.
	* testsuite/ld-elf/pr20828-2a.sd: New test.
	* testsuite/ld-elf/pr20828-2b.sd: New test.
	* testsuite/ld-elf/pr20828.ld: New test linker script.
	* testsuite/ld-elf/pr20828.ver: New test version script.
	* testsuite/ld-elf/pr20828.s: New test source.
	* testsuite/ld-elf/shared.exp: Run the new test.
2017-01-18 18:30:34 +00:00
Maciej W. Rozycki 9e009953a5 PR gas/20649: MIPS: Fix GOT16/LO16 reloc pairing with comdat sections
Correct a regression from commit 8614eeee67 ("Traditional MIPS
patches"), <https://sourceware.org/ml/binutils/2000-07/msg00018.html>,
which caused symbols in linkonce or what is these days known as comdat
sections to be treated as external for the purpose of PIC relocation
generation even if their binding remains STB_LOCAL.  This in turn
disabled GOT16/LO16 relocation pairing with references to such symbols,
as no complementing LO16 relocation is expected for external GOT16
references in the o32 ABI, which ultimately leads to link errors, e.g.:

ld: comdat-reloc.o: Can't find matching LO16 reloc against `foo' for R_MIPS_GOT16 at 0x24 in section `.text.bar[bar]'

as with the LD test case included with this change.

Revert the special case for symbols in comdat sections then, making code
actually match `adjust_reloc_syms' as indicated in its explanatory
comment, and adjust calling code accordingly.  Also bring back the
corresponding description of what now is `s_is_linkonce', lost with
commit 5f0fe04bc5 ("Improved MIPS16/MIPS32 code intermixing for
gas."), <https://www.sourceware.org/ml/binutils/2006-07/msg00039.html>.

	gas/
	PR gas/20649
	* config/tc-mips.c (pic_need_relax): Don't check for linkonce
	symbols, remove the `segtype' parameter.
	(mips_frob_file, md_estimate_size_before_relax): Adjust
	accordingly.
	(s_is_linkonce): Add an explanatory comment.
	* testsuite/gas/mips/comdat-reloc.d: New test.
	* testsuite/gas/mips/comdat-reloc.s: New test source.
	* testsuite/gas/mips/mips.exp: Run the new test.

	ld/
	PR gas/20649
	* testsuite/ld-mips-elf/mips-elf.exp: Add PIC comdat GOT16/LO16
	relocation pairing link test.
2017-01-18 18:24:08 +00:00
Dimitar Dimitrov 319b82e47d Skip linker tests for unique symbols in shared libraries if the target does not support building shared libraries.
ld	* testsuite/ld-unique/unique.exp: Filter shared lib cases in
	uniqeue.exp, as not all targets have such support.
2017-01-18 12:23:19 +00:00
Nick Clifton 6aa1df2d44 Updated Swedish translations for GAS and LD subdirectories.
gas	* po/sv.po: Updated Swedish translation.
ld	* po/sv.po: Updated Swedish translation.
2017-01-16 10:59:23 +00:00
H.J. Lu 8361ed4d6b x86-64: Also generate unwind info for .plt.bnd
Also generate unwind info for the .plt.bnd section.  Sine it is the same
as unwind info for the .plt.got section, we use unwind info for the
.plt.got section to cover the the .plt.bnd section.

bfd/

	PR ld/21038
	* elf64-x86-64.c (elf_x86_64_link_hash_table): Add
	plt_bnd_eh_frame.
	(elf_x86_64_check_relocs): Create .eh_frame section for the
	.plt.bnd section.
	(elf_x86_64_size_dynamic_sections): Allocate and initialize
	.eh_frame section for the .plt.bnd section.
	(elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section
	for the .plt.bnd section.

ld/

	PR ld/21038
	* testsuite/ld-x86-64/pr21038b.d: Updated.
	* testsuite/ld-x86-64/pr21038c.d: New file.
	* testsuite/ld-x86-64/pr21038c.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr21038c.
2017-01-12 10:32:17 -08:00
H.J. Lu 9e65917652 x86-64: Correct unwind info for the BND PLT
Since the BND PLT has

 230:	68 00 00 00 00       	pushq  $0x0
 235:	f2 e9 e5 ff ff ff    	bnd jmpq 220 <.plt>
 23b:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)

instead of

 230:	ff 25 e2 0d 20 00    	jmpq   *0x200de2(%rip)        # 201018
<func>
 236:	68 00 00 00 00       	pushq  $0x0
 23b:	e9 e0 ff ff ff       	jmpq   220 <.plt>

its unwind info should be

DW_CFA_def_cfa_expression (DW_OP_breg7 (rsp): 8; DW_OP_breg16 (rip): 0;
DW_OP_lit15; DW_OP_and; DW_OP_lit5; DW_OP_ge; DW_OP_lit3; DW_OP_shl;
DW_OP_plus)

bfd/

	PR ld/21038
	* elf64-x86-64.c (elf_x86_64_eh_frame_bnd_plt): New.
	(elf_x86_64_bnd_arch_bed): Use elf_x86_64_eh_frame_bnd_plt and
	elf_x86_64_eh_frame_plt_got.
	(elf_x86_64_size_dynamic_sections): Get unwind info from
	elf_x86_64_bnd_arch_bed for the BND PLT.

ld/

	PR ld/21038
	* testsuite/ld-x86-64/pr21038a.d: New file.
	* testsuite/ld-x86-64/pr21038a.s: Likewise.
	* testsuite/ld-x86-64/pr21038b.d: Likewise.
	* testsuite/ld-x86-64/pr21038b.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr21038a and pr21038b.
2017-01-11 09:17:05 -08:00
Jeremy Soller f2e2d2f54b Add support for x86/64 redox target.
bfd	* config.bfd: Add entries for i686-redox and x86_64-redox.

gas	* configure.tgt: Add entry for i386-redox.

ld	* configure.tgt: Add entries for x86-redox and x86_64-redox.
2017-01-11 15:05:53 +00:00
H.J. Lu 52b232b366 i386/x32: Align .eh_frame section to 4 bytes
.eh_frame section covering PLT sections should be aligned to 4 bytes
for i386 and x32.

bfd/

	* elf32-i386.c (elf_i386_check_relocs): Align .eh_frame section
	to 4 bytes.
	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Align
	.eh_frame section to 4 bytes for x32.
	(elf_x86_64_check_relocs): Likewise.

ld/

	* testsuite/ld-x86-64/pr20830b.d: Updated.
2017-01-10 14:21:21 -08:00
H.J. Lu 59a1e29d9e X32: Place .plt.got section after .plt section
This patch places .plt.got section after .plt section for x32.

	* emulparams/elf32_x86_64.sh (TINY_READONLY_SECTION): New.
	* testsuite/ld-x86-64/pr20830.d: Renamed to ...
	* testsuite/ld-x86-64/pr20830a.d: This.  Updated.
	* testsuite/ld-x86-64/pr20830b.d: New file.
	* testsuite/ld-x86-64/x86-64.exp: Rename pr20830 to pr20830a.
	Run pr20830b.
2017-01-10 13:57:39 -08:00
H.J. Lu fff53daefb i386/x86-64: Add unwind info for .plt.got section
When there are both PLT and GOT references to the same function symbol,
linker combines GOTPLT and GOT slots into a single GOT slot and create
an entry in .plt.got section for PLT access via the GOT slot.  This
patch adds unwind info for .plt.got section.

bfd/

	PR ld/20830
	* elf32-i386.c (elf_i386_eh_frame_plt_got): New.
	(PLT_GOT_FDE_LENGTH): Likewise.
	(elf_i386_plt_layout): Add eh_frame_plt_got and
	eh_frame_plt_got_size.
	(elf_i386_plt): Updated.
	(elf_i386_link_hash_table): Add plt_got_eh_frame.
	(elf_i386_check_relocs): Create .eh_frame section for .plt.got.
	(elf_i386_size_dynamic_sections): Allocate and initialize
	.eh_frame section for .plt.got.
	(elf_i386_finish_dynamic_sections): Adjust .eh_frame section for
	.plt.got.
	(elf_i386_nacl_plt): Add FIXME for eh_frame_plt_got and
	eh_frame_plt_got_size.
	* elf64-x86-64.c (elf_x86_64_eh_frame_plt_got): New.
	(PLT_GOT_FDE_LENGTH): Likewise.
	(elf_x86_64_backend_data): Add eh_frame_plt_got and
	eh_frame_plt_got_size.
	(elf_x86_64_arch_bed): Updated.
	(elf_x86_64_bnd_arch_bed): Add FIXME for eh_frame_plt_got and
	eh_frame_plt_got_size.
	(elf_x86_64_nacl_arch_bed): Likewise.
	(elf_x86_64_link_hash_table): Add plt_got_eh_frame.
	(elf_x86_64_check_relocs): Create .eh_frame section for .plt.got.
	(elf_x86_64_size_dynamic_sections): Allocate and initialize
	.eh_frame section for .plt.got.
	(elf_x86_64_finish_dynamic_sections): Adjust .eh_frame section
	for .plt.got.

ld/

	PR ld/20830
	* testsuite/ld-i386/i386.exp: Run pr20830.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr20830.d: New file.
	* testsuite/ld-i386/pr20830.s: Likewise.
	* testsuite/ld-x86-64/pr20830.d: Likewise.
	* testsuite/ld-x86-64/pr20830.s: Likewise.
2017-01-10 13:31:59 -08:00
H.J. Lu e92372274e i386: Pass -Wl,-R,tmpdir/-Wl --as-needed to $CC
Since linker tests were changed to use $CC, instead of $LD, we need
to pass -Wl,-R,tmpdir and -Wl,--as-needed to $CC.

	* testsuite/ld-i386/i386.exp: Pass -Wl,-R,tmpdir to GCC driver.
	* testsuite/ld-i386/tls.exp: Likewise.
2017-01-10 10:58:51 -08:00
Nick Clifton 07e8e62387 Updated Swedish translations for GAS and LD 2017-01-10 11:28:36 +00:00
Graham Markall 07ccf83cf5 [ARC] Add new linker emulation for nps
The arc700 nps variant uses some specific named sections to
facilitate its CMEM based instructions, which operate on memory
regions fixed at specific addresses.

This commit adds the arclinux_nps emulation, which is based on the
arclinux emulation. The new emulation uses the OTHER_SECTIONS
variable in the emulation parameters script to provide symbols
mapping to various locations in the CMEM space on nps.

The accompanying test ensures that all symbols are provided at the
correct address in the linker script.

ld/ChangeLog:

  * Makefile.am: Add earclinux_nps.c target and add to
  ALL_EMULATION_SOURCES.
  * Makefile.in: Likewise, regenerated.
  * configure.tgt: Add arclinux_nps as an extra emulation for
  arc*-*-elf* and arc*-*-linux*.
  * emulparams/arc-nps.sh: New file.
  * emulparams/arclinux_nps.sh: New file.
  * testsuite/ld-arc/arclinux-nps.d,
  * testsuite/ld-arc/arclinux-nps.s: New test.
2017-01-10 10:55:13 +00:00
Palmer Dabbelt 6ec11ab97a Remove some custom sections from RISC-V's default linker scripts
This was added so compressed loads could have smaller offsets for
accessing the data section, but the result was that writable sections
ended up in INITIAL_READONLY_SECTIONS.  This is a bad idea.  The fix is
to just remove this micro-optimization.

Thanks to Alan Morda for finding the problem!

ld/ChangeLog

2017-01-09  Palmer Dabbelt <palmer@dabbelt.com>
            Kito Cheng <kito.cheng@gmail.com>

        * emulparams/elf32lriscv-defs.sh (INITIAL_READONLY_SECTIONS):
        Removed.
        (SDATA_START_SYMBOLS): Likewise.
2017-01-09 09:12:20 -08:00
Dilan Palauzov b055631694 Use noyywrap option in lex files.
ld	PR 20958
	* ldlex.l (option): Add noyywrap
	(yywrap): Delete.
	* ldlex.h (yywrap): Delete prototype.

binutils
	PR 20958
	* syslex.l (option): Add noyywrap
	(yywrap): Delete.
2017-01-04 16:05:22 +00:00
Alan Modra 47523653a3 Check for shared lib support before running ld tests with -shared
Another fix now that we run these tests non-native.

	* testsuite/ld-elf/audit.exp: Check for shared lib support.
	* testsuite/ld-elf/compress.exp: Likewise.
	* testsuite/ld-elf/dwarf.exp: Likewise.
	* testsuite/ld-elf/shared.exp: Likewise.
	* testsuite/ld-elf/wrap.exp: Likewise.
	* testsuite/ld-ifunc/ifunc.exp: Likewise.
	* testsuite/ld-plugin/lto.exp: Check $CXX exists.
2017-01-04 09:39:12 +10:30
Alan Modra a44d0bd787 Check ld_compile return status
* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Do not
	allow test to continue after compilation errors.
	(run_cc_link_tests): Likewise.
2017-01-03 23:04:48 +10:30
Dimitar Dimitrov 27c3ce29f8 Fix PRU LD for --enable-targets=all config option
I noticed that PRU LD is broken when BFD is configured
with --enable-targets=all.  This patch fixes it, and takes the
opportunity to clean the epruelf.c dependencies.

	* Makefile.am (ALL_EMULATION_SOURCES): Add epruelf.c.
	(epruelf.c): Remove unneeded dependencies.
	* Makefile.in: Regenerate

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2017-01-03 17:35:45 +10:30
Alan Modra 8cfc7cf8c2 Add -rpath-link to various tests
Needed for cross-builds without --sysroot, where USE_LIBPATH isn't
set.  See elf32.em after_open.  Perhap ld ought to look at -rpath in
this case?

	* testsuite/ld-elf/shared.exp: Add -rpath-link and -no-as-needed
	to various tests.
	* testsuite/ld-elfweak/elfweak.exp: Likewise.
	* testsuite/ld-elfvers/vers.exp (vers19): Fix -rpath-link option.
2017-01-03 12:36:02 +10:30
Alan Modra 4ce6ca2c78 Don't run C tests in ld testsuite unless we have a C compiler
Removing the [isnative] check requires that we test for a C compiler.

	* testsuite/ld-elf/elf.exp: Check that $CC exists before C tests.
	* testsuite/ld-pie/pie.exp: Likewise.
	* testsuite/ld-plugin/lto.exp: Likewise.
2017-01-03 11:47:47 +10:30
Alan Modra d981640286 Run more ld tests when not native
Many of the ld tests are not run for cross builds, in some cases
because the test needs to run a newly linked executable, and in others
simply because it was easier to write the test for native only.  Even
when a test needs to run, it's good to compile and link to exercise
the linker.  So that's what this patch does.  I've also rid us of
the old ld_link procedure with all the HOSTING_CRT0 etc. setup.  It's
much simpler to just link with $CC.

This does mean that a cross build with cross-compiler installed but
no cross C-library will give lots of failures.  If that turns out to
be too annoying, I guess we can write a tcl procedure to detect it and
not run all the extra tests.

	* Makefile.am (bootstrap): Delete rule.
	(ld-partial, ld1, ld1-full, ld2, ld3): Likewise.
	(HOSTING_CRT0, HOSTING_SCRT0): Don't define.
	(HOSTING_LIBS, HOSTING_SLIBS, HOSTING_EMU): Likewise.
	* configure.ac (HOSTING_CRT0, HOSTING_SCRT0): Don't define.
	(HOSTING_LIBS, HOSTING_SLIBS): Likewise.
	* configure.host (HOSTING_CRT0, HOSTING_LIBS): Don't define.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* testsuite/config/default.exp (get_link_files): Delete.
	(HOSTING_CRT0, HOSTING_SCRT0, HOSTING_LIBS, HOSTING_SLIBS): Don't
	define.
	(ld_simple_link): Delete.
	* testsuite/lib/ld-lib.exp (default_ld_link): Delete
	(default_ld_simple_link): Rename to default_ld_link.
	(ld_simple_link_defsyms): Rename to ld_link_defsyms.
	(run_ld_link_tests): Use ld_link, not ld_simple_link.
	(run_cc_link_tests): Likewise.
	(run_ld_link_exec_tests): Use $CC or $CXX to link, not $ld.
	Don't run exe when not native, and return unsupported.
	* testsuite/ld-bootstrap/bootstrap.exp: Create gccld1 etc. dirs.
	Link ld1 etc. using $CC.
	* testsuite/ld-cdtest/cdtest.exp: Link cdtest using $CC.
	* testsuite/ld-checks/checks.exp: Use ld_link, not ld_simple_link.
	* testsuite/ld-cygwin/exe-export.exp: Likewise.
	* testsuite/ld-elf/binutils.exp: Likewise.
	* testsuite/ld-elf/eh-group.exp: Likewise.
	* testsuite/ld-elf/exclude.exp: Likewise.
	* testsuite/ld-elf/frame.exp: Likewise.
	* testsuite/ld-elf/sec-to-seg.exp: Likewise.
	* testsuite/ld-elf/tls_common.exp: Likewise.
	* testsuite/ld-elfcomm/elfcomm.exp: Likewise.
	* testsuite/ld-fastcall/fastcall.exp: Likewise.
	* testsuite/ld-gc/gc.exp: Likewise.
	* testsuite/ld-ifunc/binutils.exp: Likewise.
	* testsuite/ld-mep/mep.exp: Likewise.
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise.
	* testsuite/ld-mn10300/mn10300.exp: Likewise.
	* testsuite/ld-nios2/nios2.exp: Likewise.
	* testsuite/ld-pe/pe-compile.exp: Likewise.
	* testsuite/ld-pe/pe-run.exp: Likewise.
	* testsuite/ld-pe/pe-run2.exp: Likewise.
	* testsuite/ld-plugin/plugin.exp: Likewise.
	* testsuite/ld-scripts/align.exp: Likewise.
	* testsuite/ld-scripts/alignof.exp: Likewise.
	* testsuite/ld-scripts/assert.exp: Likewise.
	* testsuite/ld-scripts/defined.exp: Likewise.
	* testsuite/ld-scripts/extern.exp: Likewise.
	* testsuite/ld-scripts/log2.exp: Likewise.
	* testsuite/ld-scripts/map-address.exp: Likewise.
	* testsuite/ld-scripts/phdrs.exp: Likewise.
	* testsuite/ld-scripts/phdrs2.exp: Likewise.
	* testsuite/ld-scripts/script.exp: Likewise.
	* testsuite/ld-scripts/section-flags.exp: Likewise.
	* testsuite/ld-scripts/sizeof.exp: Likewise.
	* testsuite/ld-scripts/sysroot-prefix.exp: Likewise.
	* testsuite/ld-scripts/weak.exp: Likewise.
	* testsuite/ld-selective/selective.exp: Likewise.
	* testsuite/ld-sh/sh.exp: Likewise.
	* testsuite/ld-sh/sh64/relax.exp: Likewise.
	* testsuite/ld-sh/sh64/relfail.exp: Likewise.
	* testsuite/ld-srec/srec.exp: Likewise.
	* testsuite/ld-tic6x/tic6x.exp: Likewise.
	* testsuite/ld-undefined/weak-undef.exp: Likewise.
	* testsuite/ld-versados/versados.exp: Likewise.
	* testsuite/ld-x86-64/dwarfreloc.exp: Likewise.
	* testsuite/ld-xtensa/coalesce.exp: Likewise.
	* testsuite/ld-xtensa/diff_overflow.exp: Likewise.
	* testsuite/ld-xtensa/lcall.exp: Likewise.
	* testsuite/ld-elf/audit.exp: Run non-native too.
	* testsuite/ld-elf/compress.exp: Likewise.  Replace ld options with
	gcc -Wl, options.
	* testsuite/ld-elf/dwarf.exp: Run non-native too.  Use ld_link,
	not ld_simple_link.  Add -Wl,--no-as-needed to some tests.
	* testsuite/ld-elf/elf.exp: Run non-native too.  Formatting.
	* testsuite/ld-elf/indirect.exp: Run non-native too.  Add
	-Wl,--no-as-needed to most tests.
	* testsuite/ld-elf/shared.exp: Run non-native too.  Use braces
	to simplify quoting.  Set run_tests using [list] rather than
	brace assignment to expand $extralibs.  Add -Wl,--no-as-needed
	to many test.  Prefix ld options with -Wl,.
	(mix_pic_and_non_pic): Don't run exe if not native.
	* testsuite/ld-elf/wrap.exp: Run non-native too.  Add
	-Wl,--no-as-needed and prefix ld options with -Wl,.
	* testsuite/ld-elfvers/vers.exp: Run non-native too.  Use ld_link,
	not ld_simple_link.
	* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
	(visibility_test): Don't run exe if not native.
	* testsuite/ld-elfweak/elfweak.exp: Run non-native too.  Use ld_link,
	not ld_simple_link.
	(build_exec): Don't run exe if not native.
	* testsuite/ld-ifunc/ifunc.exp: Run non-native too.  Use ld_link,
	not ld_simple_link.  Link using $CC.  Add -Wl,--no-as-needed
	to some tests and prefix ld options with -Wl,.  Expect GNU
	for hppa-linux even when no ifuncs.  Delete cleanup.
	* testsuite/ld-pie/pie.exp: Run non-native too.
	* testsuite/ld-plugin/lto.exp: Likewise.
	* testsuite/ld-shared/shared.exp: Likewise.  Use ld_link,
	not ld_simple_link.
	(shared_test): Don't run exe if not native.
	* testsuite/ld-size/size.exp: Run non-native too.  Add
	-Wl,--no-as-needed to some tests.  Prefix ld options with -Wl,.
	* testsuite/ld-unique/unique.exp: Run non-native too.  Use ld_link,
	not ld_simple_link.  Link using $CC.  Add -Wl,--no-as-needed
	to some tests and prefix ld options with -Wl,.  Expect GNU
	for hppa-linux even when no unique syms.  Delete cleanup.
	* testsuite/ld-x86-64/tls.exp: Add -Wl,--no-as-needed to some
	tests and prefix ld options with -Wl,.
	* testsuite/ld-x86-64/x86-64.exp: Use ld_link, not ld_simple_link.
	Add -Wl,--no-as-needed to some tests.  Prefix ld options with -Wl,.
2017-01-02 23:48:08 +10:30
Alan Modra 64859e1487 Support -z relro on metag
* emulparams/elf32metag.sh (COMMONPAGESIZE): Define.
2017-01-02 22:44:29 +10:30
Alan Modra f5657270bd Support -z relro on hppa
PR ld/21000
	* emulparams/hppalinux.sh (DATA_ADDR, SHLIB_DATA_ADDR): Don't define.
	(DATA_SEGMENT_ALIGN, DATA_SEGMENT_END, DATA_SEGMENT_RELRO_END): Define.
	* scripttempl/elf.sc: Don't define the above if DATA_SEGMENT_ALIGN
	is already defined.
2017-01-02 22:42:45 +10:30
Alan Modra 2571583aed Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
Alan Modra 5c1ad6b5bb ChangeLog rotation 2017-01-02 13:55:05 +10:30
Dimitar Dimitrov 0220170b4d PRU LD Port
* NEWS: Mention new PRU target.
	* Makefile.am: Add PRU target.
	* configure.tgt: Ditto.
	* emulparams/pruelf.sh: New file.
	* emultempl/pruelf.em: New file.
	* scripttempl/pru.sc: New file.
	* Makefile.in: Regenerate.
	* testsuite/ld-pru/emit-relocs-1.d: New PRU testcase file.
	* testsuite/ld-pru/emit-relocs-1.ld: Ditto.
	* testsuite/ld-pru/emit-relocs-1a.s: Ditto.
	* testsuite/ld-pru/emit-relocs-1b.s
	* testsuite/ld-pru/ldi32.d: Ditto.
	* testsuite/ld-pru/ldi32.s: Ditto.
	* testsuite/ld-pru/ldi32_symbol.s: Ditto.
	* testsuite/ld-pru/norelax_ldi32-data.d: Ditto.
	* testsuite/ld-pru/norelax_ldi32-dis.d: Ditto.
	* testsuite/ld-pru/pcrel_s10.d: Ditto.
	* testsuite/ld-pru/pcrel_s10.s: Ditto.
	* testsuite/ld-pru/pcrel_s10_label.s: Ditto.
	* testsuite/ld-pru/pcrel_u8-illegal.d: Ditto.
	* testsuite/ld-pru/pcrel_u8-illegal.s: Ditto.
	* testsuite/ld-pru/pcrel_u8-illegal2.d: Ditto.
	* testsuite/ld-pru/pcrel_u8-illegal2.s: Ditto.
	* testsuite/ld-pru/pcrel_u8-illegal3.d: Ditto.
	* testsuite/ld-pru/pcrel_u8-illegal3.s: Ditto.
	* testsuite/ld-pru/pcrel_u8.d: Ditto.
	* testsuite/ld-pru/pcrel_u8.s: Ditto.
	* testsuite/ld-pru/pcrel_u8_label.s: Ditto.
	* testsuite/ld-pru/pmem.d: Ditto.
	* testsuite/ld-pru/pmem.s: Ditto.
	* testsuite/ld-pru/pmem_symbol.s: Ditto.
	* testsuite/ld-pru/pru.exp: Ditto.
	* testsuite/ld-pru/relax_ldi32-data.d: Ditto.
	* testsuite/ld-pru/relax_ldi32-dis.d: Ditto.
	* testsuite/ld-pru/relax_ldi32.s: Ditto.
	* testsuite/ld-pru/relax_ldi32_symbol.s: Ditto.
	* testsuite/ld-pru/reloc.d: Ditto.
	* testsuite/ld-pru/reloc.s: Ditto.
	* testsuite/ld-pru/reloc_symbol.s: Ditto.
	* testsuite/ld-pru/u16.d: Ditto.
	* testsuite/ld-pru/u16.s: Ditto.
	* testsuite/ld-pru/u16_symbol.s: Ditto.

PRU does not export __end symbol because it is ambiguous for it.
Users are expected to use instead the section markers __text_end,
__data_end, __bss_end or __noinit_end.

	* testsuite/lib/ld-lib.exp (check_shared_lib_support): No shared
	libraries are supported for PRU.
	(check_gc_sections_available): Mark PRU as not supported.
	* testsuite/ld-elf/eh-frame-hdr.d: Disable for PRU.
	* testsuite/ld-elf/endsym.d: Likewise.
	* testsuite/ld-elf/group8a.d: Likewise.
	* testsuite/ld-elf/group8b.d: Likewise.
	* testsuite/ld-elf/group9a.d: Likewise.
	* testsuite/ld-elf/group9b.d: Likewise.
	* testsuite/ld-elf/merge.d: Likewise.
	* testsuite/ld-elf/pr12851.d: Likewise.
	* testsuite/ld-elf/pr14926.d: Likewise.
	* testsuite/ld-elf/sec-to-seg.exp: Likewise.
	* testsuite/ld-elf/sec64k.exp: Mark sec64k case as too big for PRU.
	* testsuite/ld-srec/srec.exp (run_srec_test): Add setup for PRU.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2016-12-31 12:04:11 +10:30
Dimitar Dimitrov 517c416698 ld testsuite: Sanitize output from ld
Leading dashes from an LD error message confuse send_log, because the
string is taken to be an option.

This patch fixes the following DejaGnu error:

  --defsym:1: undefined symbol `foo2' referenced in expression
  failed with: <--defsym:1: undefined symbol `foo2' referenced in expression>, no expected output
  ERROR: tcl error sourcing .../ld/testsuite/ld-gc/gc.exp.
  ERROR: usage: send [args] string
      while executing
  "send_log "$comp_output\n""
      (procedure "run_dump_test" line 376)

	* testsuite/lib/ld-lib.exp (run_dump_test): Pass -- to send_log.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2016-12-31 12:00:42 +10:30
Alan Modra 9acc85a62e Use dynrelro for symbols in relro sections too
PR ld/20995
bfd/
	* elflink.c (elf_link_add_object_symbols): Mark relro sections
	in dynamic objects SEC_READONLY.
ld/
	* testsuite/ld-elf/pr20995c.s: New test file.
	* testsuite/ld-elf/pr20995-2so.r: Likewise.
	* testsuite/ld-elf/elf.exp: Run it.
2016-12-28 22:10:38 +10:30
Alan Modra 5474d94f03 dynrelro section for read-only dynamic symbols copied into executable
Variables defined in shared libraries are copied into an executable's
.bss section when code in the executable is non-PIC and thus would
require dynamic text relocations to access the variable directly in
the shared library.  Recent x86 toolchains also copy variables into
the executable to gain a small speed improvement.

The problem is that if the variable was originally read-only, the copy
in .bss is writable, potentially opening a security hole.  This patch
cures that problem by putting the copy in a section that becomes
read-only after ld.so relocation, provided -z relro is in force.

The patch also fixes a microblaze linker segfault on attempting to
use dynamic bss variables.

bfd/
	PR ld/20995
	* elf-bfd.h (struct elf_link_hash_table): Add sdynrelro and
	sreldynrelro.
	(struct elf_backend_data): Add want_dynrelro.
	* elfxx-target.h (elf_backend_want_dynrelro): Define.
	(elfNN_bed): Update initializer.
	* elflink.c (_bfd_elf_create_dynamic_sections): Create
	sdynrelro and sreldynrelro sections.
	* elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Place variables
	copied into the executable from read-only sections into sdynrelro.
	(elf32_arm_size_dynamic_sections): Handle sdynrelro.
	(elf32_arm_finish_dynamic_symbol): Select sreldynrelro for
	dynamic relocs in sdynrelro.
	(elf_backend_want_dynrelro): Define.
	* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol)
	(elf32_hppa_size_dynamic_sections, elf32_hppa_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elf32-i386.c (elf_i386_adjust_dynamic_symbol)
	(elf_i386_size_dynamic_sections, elf_i386_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elf32-metag.c (elf_metag_adjust_dynamic_symbol)
	(elf_metag_size_dynamic_sections, elf_metag_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elf32-microblaze.c (microblaze_elf_adjust_dynamic_symbol)
	(microblaze_elf_size_dynamic_sections)
	(microblaze_elf_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elf32-nios2.c (nios2_elf32_finish_dynamic_symbol)
	(nios2_elf32_adjust_dynamic_symbol)
	(nios2_elf32_size_dynamic_sections)
	(elf_backend_want_dynrelro): As above.
	* elf32-or1k.c (or1k_elf_finish_dynamic_symbol)
	(or1k_elf_adjust_dynamic_symbol, or1k_elf_size_dynamic_sections)
	(elf_backend_want_dynrelro): As above.
	* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol)
	(ppc_elf_size_dynamic_sections, ppc_elf_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elf32-s390.c (elf_s390_adjust_dynamic_symbol)
	(elf_s390_size_dynamic_sections, elf_s390_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elf32-tic6x.c (elf32_tic6x_adjust_dynamic_symbol)
	(elf32_tic6x_size_dynamic_sections)
	(elf32_tic6x_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elf32-tilepro.c (tilepro_elf_adjust_dynamic_symbol)
	(tilepro_elf_size_dynamic_sections)
	(tilepro_elf_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol)
	(ppc64_elf_size_dynamic_sections, ppc64_elf_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elf64-s390.c (elf_s390_adjust_dynamic_symbol)
	(elf_s390_size_dynamic_sections, elf_s390_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol)
	(elf_x86_64_size_dynamic_sections)
	(elf_x86_64_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elfnn-aarch64.c (elfNN_aarch64_adjust_dynamic_symbol)
	(elfNN_aarch64_size_dynamic_sections)
	(elfNN_aarch64_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elfnn-riscv.c (riscv_elf_adjust_dynamic_symbol)
	(riscv_elf_size_dynamic_sections, riscv_elf_finish_dynamic_symbol)
	(elf_backend_want_dynrelro): As above.
	* elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol)
	(_bfd_mips_elf_size_dynamic_sections)
	(_bfd_mips_vxworks_finish_dynamic_symbol): As above.
	* elfxx-sparc.c (_bfd_sparc_elf_adjust_dynamic_symbol)
	(_bfd_sparc_elf_size_dynamic_sections)
	(_bfd_sparc_elf_finish_dynamic_symbol): As above.
	* elfxx-tilegx.c (tilegx_elf_adjust_dynamic_symbol)
	(tilegx_elf_size_dynamic_sections)
	(tilegx_elf_finish_dynamic_symbol): As above.
	* elf32-mips.c (elf_backend_want_dynrelro): Define.
	* elf64-mips.c (elf_backend_want_dynrelro): Define.
	* elf32-sparc.c (elf_backend_want_dynrelro): Define.
	* elf64-sparc.c (elf_backend_want_dynrelro): Define.
	* elf32-tilegx.c (elf_backend_want_dynrelro): Define.
	* elf64-tilegx.c (elf_backend_want_dynrelro): Define.
	* elf32-microblaze.c (microblaze_elf_adjust_dynamic_symbol): Tidy.
	(microblaze_elf_size_dynamic_sections): Handle sdynbss.
	* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Make use
	of linker shortcuts to dynamic sections rather than comparing
	names.  Correctly set "got" flag.
ld/
	PR ld/20995
	* testsuite/ld-arm/farcall-mixed-app-v5.d: Update to suit changed
	stub hash table traversal caused by section id increment.  Accept
	the previous output too.
	* testsuite/ld-arm/farcall-mixed-app.d: Likewise.
	* testsuite/ld-arm/farcall-mixed-lib-v4t.d: Likewise.
	* testsuite/ld-arm/farcall-mixed-lib.d: Likewise.
	* testsuite/ld-elf/pr20995a.s, * testsuite/ld-elf/pr20995b.s,
	* testsuite/ld-elf/pr20995.r: New test.
	* testsuite/ld-elf/elf.exp: Run it.
2016-12-26 13:47:51 +10:30
Alan Modra 09a1b0e943 Correct .dynbss in script
The only target that renames .bss is tic6x, turning .bss into .far,
and .sbss into .bss.  .dynbss is not renamed to .dynfar by BFD.

	* scripttempl/elf.sc: Don't use $BSS_NAME in .dynbss.
2016-12-26 13:42:20 +10:30
Tristan Gingold 99b5dbf2e7 Bump version to 2.28.51
bfd/
2016-12-23  Tristan Gingold  <gingold@adacore.com>

	* version.m4: Bump version to 2.28.51
	* configure: Regenerate.

binutils/
2016-12-23  Tristan Gingold  <gingold@adacore.com>

	* configure: Regenerate.

gas/
2016-12-23  Tristan Gingold  <gingold@adacore.com>

	* configure: Regenerate.

gprof/
2016-12-23  Tristan Gingold  <gingold@adacore.com>

	* configure: Regenerate.

ld/
2016-12-23  Tristan Gingold  <gingold@adacore.com>

	* configure: Regenerate.

opcodes/
2016-12-23  Tristan Gingold  <gingold@adacore.com>

	* configure: Regenerate.
2016-12-23 09:50:53 +01:00
Tristan Gingold 9703a4ef4d Add marker in NEWS files
binutils/
2016-12-23  Tristan Gingold  <gingold@adacore.com>

	* NEWS: Add marker for 2.28.

gas/
2016-12-23  Tristan Gingold  <gingold@adacore.com>

	* NEWS: Add marker for 2.28.

ld/
2016-12-23  Tristan Gingold  <gingold@adacore.com>

	* NEWS: Add marker for 2.28.
2016-12-23 09:43:13 +01:00
Tristan Gingold e0e7a9d436 Regenerate pot files. 2016-12-23 09:32:28 +01:00
Alan Modra ab55d1a098 Don't call "error" in sysroot-prefix.exp
We don't want to report a test failure as a tcl error.

	* testsuite/ld-scripts/sysroot-prefix.exp (sysroot_prefix_test_setup):
	Call perror rather than error on "as" or "ar" failures.
2016-12-22 15:20:32 +10:30
Igor Kudrin 9ef7906f20 Do not add padding if an output section is marked as ignored
* ldlang.c (size_input_section): Avoid calling insert_pad
	if output_section_statement->ignored is set.
2016-12-22 00:12:36 +10:30
Alan Modra 4e25adb395 Remove high bit set characters
gas/
	* doc/c-lm32.texi: Fix chars with high bit set.
	* testsuite/gas/bfin/vector2.s: Likewise.
gold/
	* arm.cc: Fix comment chars with high bit set.
include/
	* coff/pe.h: Fix comment chars with high bit set.
	* opcode/xgate.h: Likewise.
ld/
	* testsuite/ld-scripts/sysroot-prefix.exp: Fix chars with high bit set.
2016-12-21 19:18:46 +10:30
fincs 221855059a Implement and document --gc-keep-exported
include/
	* bfdlink.h (struct bfd_link_info): Add gc_keep_exported.
bfd/
	* elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Add handling
	for info->gc_keep_exported.
	(bfd_elf_gc_sections): Likewise.
ld/
	* ld.texinfo: Document --gc-keep-exported.
	* ldlex.h (enum option_values): Add OPTION_GC_KEEP_EXPORTED.
	* lexsup.c (parse_args): Add handling for --gc-keep-exported.
2016-12-16 13:49:03 +10:30
Yury Norov c1fc2d7ee5 ld: aarch64: fix TLS relaxation where TCB_SIZE is used
TCB_SIZE is 2*sizeof(void *), which is 0x10 for lp64, and 0x8 for
ilp32. During relaxation, ld goes to do a replace:
bl   __tls_get_addr => add R0, R0, TCB_SIZE

But actual implementation is:
bfd_putl32 (0x91004000, contents + rel->r_offset + 4);

Which is equivalent of add x0, x0, 0x10. This is wrong for ilp32.

The possible fix for it is:
bfd_putl32 (0x91000000 | (TCB_SIZE<<10), contents + rel->r_offset + 4);

But ilp32 also needs w-registers, so it's simpler to put proper
instruction in #if/#else condition.

There are 2 such relaxations in elfNN_aarch64_tls_relax(), and so 2 new
tests added for ilp32 mode to test it.

Yury

	* bfd/elfnn-aarch64.c: fix TLS relaxations for ilp32 where
	TCB_SIZE is used.
	* ld/testsuite/ld-aarch64/aarch64-elf.exp: Add tests for the case.
	* ld/testsuite/ld-aarch64/tls-relax-ld-le-small-ilp32.d: New file.
	* ld/testsuite/ld-aarch64/tls-relax-ld-le-tiny-ilp32.d: New file.

Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
2016-12-14 12:00:59 +05:30
Yury Norov 98fa61facf Revert "ld: aarch64: fix TLS relaxation where TCB_SIZE is used"
This reverts commit 6650f7bd18.
2016-12-14 11:56:54 +05:30
Yury Norov 6650f7bd18 ld: aarch64: fix TLS relaxation where TCB_SIZE is used
TCB_SIZE is 2*sizeof(void *), which is 0x10 for lp64, and 0x8 for
ilp32. During relaxation, ld goes to do a replace:
bl   __tls_get_addr => add R0, R0, TCB_SIZE

But actual implementation is:
bfd_putl32 (0x91004000, contents + rel->r_offset + 4);

Which is equivalent of add x0, x0, 0x10. This is wrong for ilp32.

The possible fix for it is:
bfd_putl32 (0x91000000 | (TCB_SIZE<<10), contents + rel->r_offset + 4);

But ilp32 also needs w-registers, so it's simpler to put proper
instruction in #if/#else condition.

THere are 2 such relaxations in elfNN_aarch64_tls_relax(), and so 2 new
tests added for ilp32 mode to test it.

Yury
2016-12-14 11:07:24 +05:30
Nick Clifton aa785360cf PE linker script improvements.
PR ld/19254
	* scripttempl/pe.sc (.fini): KEEP this section.
	(.gcc_except_table): Likewise.
	(.pdata): Also accept .pdata*.
2016-12-13 17:05:20 +00:00
Jiong Wang 971f1d27d2 [AArch64] Make LD testcases support ILP32 mode
ld/
	* testsuite/ld-aarch64/aarch64-elf.exp (aarch64_choose_lp64_emul): New
	function.
	(run_dump_test_lp64): New function which pass LP64 mode options to both
	assembler and linker when building test binary.
	(aarch64elftests): Remove eh-frame-merge test.
	(eh-frame-merge-lp64): Restrict eh-frame-merge test to LP64 only.
	(run_dump_test): Migrate to run_dump_test_lp64 if the test source was
	written for LP64 only.
	* testsuite/ld-aarch64/erratum843419.d: Support ILP32 mode.
	* testsuite/ld-aarch64/farcall-b-defsym.d: Likewise.
	* testsuite/ld-aarch64/farcall-b-plt.d: Likewise.
	* testsuite/ld-aarch64/farcall-b.d: Likewise.
	* testsuite/ld-aarch64/farcall-bl-defsym.d: Likewise.
	* testsuite/ld-aarch64/farcall-bl-plt.d: Likewise.
	* testsuite/ld-aarch64/farcall-bl.d: Likewise.
	* testsuite/ld-aarch64/ifunc-15.d: Likewise.
	* testsuite/ld-aarch64/ifunc-16.d: Likewise.
	* testsuite/ld-aarch64/ifunc-5a-local.d: Likewise.
	* testsuite/ld-aarch64/ifunc-5a.d: Likewise.
	* testsuite/ld-aarch64/ifunc-5b-local.d: Likewise.
	* testsuite/ld-aarch64/ifunc-5b.d: Likewise.
	* testsuite/ld-aarch64/ifunc-5r-local.d: Likewise.
	* testsuite/ld-aarch64/ifunc-6a.d: Likewise.
	* testsuite/ld-aarch64/ifunc-6b.d: Likewise.
	* testsuite/ld-aarch64/ifunc-7a.d: Likewise.
	* testsuite/ld-aarch64/ifunc-7b.d: Likewise.
	* testsuite/ld-aarch64/ifunc-8.d: Likewise.
	* testsuite/ld-aarch64/limit-b.d: Likewise.
	* testsuite/ld-aarch64/limit-bl.d: Likewise.
2016-12-13 12:50:17 +00:00
Alan Modra 22b05d33b4 Don't add PHDR for objcopy/strip or ld script specifying PHDRS
HPPA64 needs to add a DT_PHDR header for shared libs.  That's fine
when linking but shouldn't happen for strip/objcopy.  Also PHDR must
come first so there's no need to look at all program headers.

bfd/
	* elf64-hppa.c (elf64_hppa_modify_segment_map): Don't add PHDR
	for objcopy/strip or when a ld script specifies PHDRS.
ld/
	* testsuite/ld-elf/nobits-1.d: Remove xfail for hppa64.
	* testsuite/ld-elf/note-1.d: Likewise.
	* testsuite/ld-elf/note-2.d: Likewise.
2016-12-13 09:37:59 +10:30