Commit Graph

5478 Commits

Author SHA1 Message Date
Alan Modra d933941d6c Fix ld uninitialized read of script ASSERT data structure
lang_assignment_statement serves both assignments and asserts.

	* ldlang.c (open_input_bfds): Check that lang_assignment_statement
	is not an assert before referencing defsym.
2017-03-07 12:33:28 +10:30
Alan Modra 2e0ce1c84d Align eh_frame FDEs according to their encoding
bfd/
	* elf-bfd.h (struct eh_cie_fde): Add u.cie.per_encoding_aligned8.
	* elf-eh-frame.c (size_of_output_cie_fde): Don't align here.
	(next_cie_fde_offset): New function.
	(_bfd_elf_parse_eh_frame): Set u.cie.per_encoding_aligned8.
	(_bfd_elf_discard_section_eh_frame): Align zero terminator to
	four bytes.  Align CIEs to four or eight bytes depending on
	per_encoding_aligned8.  Align FDEs according to their encoding.
	Pad last FDE to output section alignment.
	(_bfd_elf_write_section_eh_frame): Adjust to suit.  Remove
	assertion.
	* elf64-ppc.c (glink_eh_frame_cie): Delete padding.
	(ppc64_elf_size_stubs): Pad glink eh_frame as per elf-eh-frame.c.
	(ppc64_elf_finish_dynamic_sections): Adjust to suit.
ld/
	* testsuite/ld-elf/eh3.d: Adjust for eh_frame alignment change.
	* testsuite/ld-elf/eh6.d: Likewise.
	* testsuite/ld-alpha/tlsbin.dd: Likewise.
	* testsuite/ld-alpha/tlsbin.td: Likewise.
	* testsuite/ld-alpha/tlsbinr.dd: Likewise.
	* testsuite/ld-alpha/tlspic.dd: Likewise.
	* testsuite/ld-alpha/tlspic.rd: Likewise.
	* testsuite/ld-alpha/tlspic.sd: Likewise.
	* testsuite/ld-alpha/tlspic.td: Likewise.
	* testsuite/ld-mips-elf/eh-frame1-n64.d: Likewise.
	* testsuite/ld-mips-elf/eh-frame2-n64.d: Likewise.
	* testsuite/ld-mips-elf/eh-frame3.d: Likewise.
	* testsuite/ld-x86-64/pr20830a.d: Likewise.
	* testsuite/ld-x86-64/pr21038a.d: Likewise.
	* testsuite/ld-x86-64/pr21038b.d: Likewise.
	* testsuite/ld-x86-64/pr21038c.d: Likewise.
2017-03-05 14:49:54 +10:30
Nick Clifton 611a3ca929 Make the linker fail if asked to create more than 1^16 ordinal values for PE targets.
PR 12969
	* pe-dll.c (generate_edata): Fail if the input file(s) require too
	many ordinals.
2017-03-03 11:35:03 +00:00
Alan Modra 199add01b6 Avoid gcc-7 warning killing ld testcases
* testsuite/ld-elf/shared.exp: Pass -ansi when compiling new.cc
	and dl3.cc.
2017-03-02 10:40:06 +10:30
Alan Modra 4ef97a1b45 Nios2 dynobj handling fixes
A number of places in elf32-nios.c created dynamic sections but didn't
set the hash table dynobj.  That meant we could have duplicate dynamic
sections connected to a number of bfds, so size_dynamic_sections
didn't properly discard or allocate contents.

Also, the entire set of dynamic sections was created in check_relocs
on seeing GOT relocs, when only .got related sections are needed,
probably done to hide segfaults later in finish_dynamic_sections.

The patch fixes these issues and makes the assembler emit errors when
nios2 lacks the necessary pc-relative relocs for subtraction
expressions, rather than silently generating bad code.
eg. ld-elf/merge.  I've also tidied uses of elf32_nios2_hash_table and
elf_hash_table.

bfd/
	PR 20995
	* elf32-nios2.c (nios2_elf32_relocate_section): Use htab
	rather than elf32_nios2_hash_table or elf_hash_table.
	(create_got_section): Likewise.
	(nios2_elf32_finish_dynamic_symbol): Likewise.
	(nios2_elf32_adjust_dynamic_symbol): Likewise.
	(nios2_elf32_size_dynamic_sections): Likewise.
	(nios2_elf32_check_relocs): Delete dynobj, sgot, and srelgot
	vars.  Use htab equivalents directly instead.  Don't create
	all dynamic sections on needing just the GOT.  Use a goto
	rather than a fall-through with reloc test.  Ensure
	htab->dynobj is set when making dynamic sreloc section.
	(nios2_elf32_finish_dynamic_sections): Delete dynobj, use htab
	equivalent directly instead.  Don't segfault on looking for
	.dynamic when dynamic sections have not been created.  Don't
	segfault on .got.plt being discarded.
	(nios2_elf32_size_dynamic_sections): Delete plt and got vars.
	Don't set "relocs" on .rela.plt.  Do handle .sbss.  Delete
	fixme and another not so relevant comment.
	(nios2_elf_add_symbol_hook): Delete dynobj var.  If not
	already set, set hash table dynobj on creating .sbss.
gas/
	* config/tc-nios2.h (TC_FORCE_RELOCATION_SUB_LOCAL): Define.
ld/
	* testsuite/ld-elf/merge.d: xfail for nios.
2017-02-28 13:20:21 +10:30
Alan Modra 7ba71655a4 PowerPC addpcis fix
This came up because I was looking at ld/tmpdir/addpcis.o and noticed
the odd addends on REL16DX_HA.  They ought to both be -4.  The error
crept in due REL16DX_HA howto being pc-relative (as indeed it should
be), and code at gas/write.c:1001 after this comment
	      /* Make it pc-relative.  If the back-end code has not
		 selected a pc-relative reloc, cancel the adjustment
		 we do later on all pc-relative relocs.  */
*not* cancelling the pc-relative adjustment.  So I've made a dummy
non-relative split reloc so that the generic code handles this, rather
than attempting to add hacks later in md_apply_fix which would not be
very robust.  Having the new internal reloc also makes it easy to
support

 addpcis rx,sym@ha

as an equivalent to

 addpcis rx,(sym-0f)@ha
0:

The patch also fixes overflow checking, which must test whether the
addi will overflow too since @l relocs don't have any overflow check.

Lastly, since I was poking at md_apply_fix, I arranged to have the
generic gas/write.c code emit errors for subtraction expressions where
we lack reloc support.

include/
	* elf/ppc64.h (R_PPC64_16DX_HA): New.  Expand fake reloc comment.
	* elf/ppc.h (R_PPC_16DX_HA): Likewise.
bfd/
	* reloc.c (BFD_RELOC_PPC_16DX_HA): New.
	* elf64-ppc.c (ppc64_elf_howto_raw <R_PPC64_16DX_HA>): New howto.
	(ppc64_elf_reloc_type_lookup): Translate new bfd reloc.
	(ppc64_elf_ha_reloc): Correct overflow test on REL16DX_HA.
	(ppc64_elf_relocate_section): Likewise.
	* elf32-ppc.c (ppc_elf_howto_raw <R_PPC_16DX_HA>): New howto.
	(ppc_elf_reloc_type_lookup): Translate new bfd reloc.
	(ppc_elf_check_relocs): Handle R_PPC_16DX_HA to pacify gcc.
	* libbfd.h: Regenerate.
	* bfd-in2.h: Regenerate.
gas/
	* config/tc-ppc.c (md_assemble): Use BFD_RELOC_PPC_16DX_HA for addpcis.
	(md_apply_fix): Remove fx_subsy check.  Move code converting to
	pcrel reloc earlier and handle BFD_RELOC_PPC_16DX_HA.  Remove code
	emiiting errors on seeing fx_pcrel set on unexpected relocs, as
	that is done now by the generic code via..
	* config/tc-ppc.h (TC_FORCE_RELOCATION_SUB_LOCAL): ..this. Define.
	(TC_VALIDATE_FIX_SUB): Define.
ld/
	* testsuite/ld-powerpc/addpcis.d: Define ext1 and ext2 at
	limits of addpcis range.
2017-02-28 11:59:47 +10:30
Maciej W. Rozycki 0e39210161 MIPS/BFD: Also handle `jalr $0, $25' with R_MIPS_JALR
Interpret the `jalr $0, $25' instruction encoding with an R_MIPS_JALR
relocation attached as an alias to `jr $25' and convert the jump to an
equivalent branch where possible, consequently covering the MIPSr6
architecture for the purpose of this optimization too.

	bfd/
	* elfxx-mips.c (mips_elf_perform_relocation): Also handle the
	`jalr $0, $25' instruction encoding.

	gas/
	* testsuite/gas/mips/jalr4.s: Add `jalr $0, $25' instructions.
	* testsuite/gas/mips/jalr4.d: Adjust accordingly.  Remove MIPSr6
	encoding patterns.
	* testsuite/gas/mips/jalr4-n64.d: Likewise.
	* testsuite/gas/mips/mipsr6@jalr4.d: New test.
	* testsuite/gas/mips/mipsr6@jalr4-n32.d: New test.
	* testsuite/gas/mips/mipsr6@jalr4-n64.d: New test.

	ld/
	* testsuite/ld-mips-elf/jalr4.dd: Adjust for `jalr $0, $25'
	instructions.
	* testsuite/ld-mips-elf/jalr4-r6.dd: New test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
2017-02-28 00:22:36 +00:00
Georg-Johann Lay fbf25dfdfd Place read-only data in the text section on AVR Tiny targets.
PR target/20849
        * scripttempl/avrtiny.sc (__RODATA_PM_OFFSET__): New define.
        (.rodata): New section.
        (.data): Remove .rodata*.
2017-02-27 17:05:53 +00:00
Alan Modra dd803a2430 Testsuite fixes for hppa64-hpux
HPUX has a different .comm syntax, and anything in the first column
is a label.

gas/
	* testsuite/gas/elf/strtab.s: Don't put directives on first
	column or continuation with labels not in first column.
ld/
	* testsuite/ld-elf/elf.exp: Xfail pr20995 tests on hppa64-hpux.
	Set up HPUX defsym.  Run pr14170 tests and build symbol3 objects,
	defining HPUX where necessary.  Define HPUX for implib tests.
	* testsuite/ld-elf/comm-data4.d: Run for hpux.
	* testsuite/ld-elf/endsym.d: Likewise.
	* testsuite/ld-elf/linkoncerdiff.d: Likewise.
	* testsuite/ld-elf/comm-data4.s: Add alternate .comm when HPUX.
	* testsuite/ld-elf/comm-data5.s: Likewise.
	* testsuite/ld-elf/endsym.s: Likewise.
	* testsuite/ld-elf/pr14170c.s: Likewise.
	* testsuite/ld-elf/symbol3.s: Likewise.
	* testsuite/ld-elf/implib.s: Likewise.  Don't start directives
	in first column.
	* testsuite/ld-elf/linkoncerdiff2.s: Don't use numeric labels.
	* testsuite/ld-elf/warn3.d: Run for hpux.
	* testsuite/ld-scripts/rgn-at10.d: Xfail for hpux.
	* testsuite/ld-scripts/rgn-at11.d: Likewise.
	* testsuite/ld-scripts/size-2.d: Remove xfail for hpux.
2017-02-25 19:13:34 +10:30
Maciej W. Rozycki c9f02c3e29 readelf: Fix incorrect "Version definition past end of section" message
Fix a commit 74e1a04b97 ("More fixes for reading corrupt ELF files.")
`readelf --version-info' regression that caused "Version definition past
end of section" to be always printed at the end, even with good section
data.

For example with the `mips-linux' target we get:

$ cat ver_def.s
	.data
	.globl	new_foo
	.type	new_foo, %object
new_foo:
	.symver	new_foo, foo@@ver_foo
$ cat ver_def.ver
{ global: *foo*; local: *; };
$ as -o ver_def.o ver_def.s
$ ld -e 0 --export-dynamic --version-script=ver_def.ver -o ver_def ver_def.o
$ readelf -V ver_def

Version symbols section '.gnu.version' contains 4 entries:
 Addr: 000000000000007e  Offset: 0x01007e  Link: 2 (.dynsym)
  000:   0 (*local*)       2 (ver_foo)       1 (*global*)      2 (ver_foo)

Version definition section '.gnu.version_d' contains 2 entries:
  Addr: 0x0000000000000088  Offset: 0x010088  Link: 3 (.dynstr)
  000000: Rev: 1  Flags: BASE   Index: 1  Cnt: 1  Name: ver_def
  0x001c: Rev: 1  Flags: none  Index: 2  Cnt: 1  Name: ver_foo
  Version definition past end of section
$

The cause is the `if (idx + ent.vd_next <= idx)' condition introduced to
ensure forward progress, which however always triggers for good version
definition section data as the last entry will have its `vd_next' value
set to 0.

Adjust the condition then, to say `if (idx + ent.vd_next < idx)' instead
and to ensure forward progress limit the number of entries processed to
the size of the version definition section, removing the problematic
message from output quoted above, while ensuring the original PR 17531
test case is still handled gracefully.

Add a suitable test case so that we have `readelf --version-info'
coverage; due to the lack of infrastructure needed to run the linker in
the `binutils' test suite and limited justification to implement it add
a new `readelf.exp' script to the `ld' test suite instead, intended to
gather any `readelf' test cases that require the linker to be run.  If
ever we decide to have linker infrastructure added to the `binutils'
test suite, then the script can be moved between the test suites.

	binutils/
	* readelf.c (process_version_sections) <SHT_GNU_verdef>: Limit
	the number of entries processed by the section size.  Don't
	break out of the loop if `ent.vd_next' is 0.

	ld/
	* testsuite/ld-elf/ver_def.d: New test.
	* testsuite/ld-elf/ver_def.ld: New test linker script.
	* testsuite/ld-elf/ver_def.ver: New test version script.
	* testsuite/ld-elf/ver_def.s: New test source.
	* testsuite/ld-elf/readelf.exp: New test script.
2017-02-24 13:48:10 +00:00
Maciej W. Rozycki 5d58c73379 MIPS/BFD: Remove duplicate NewABI JALR relocation handling
Remove separate original NewABI JALR relocation handling, introduced
with commit d06471104a ("relax jalr $t9 [R_MIPS_JALR symbol] to bal
symbol"), <https://sourceware.org/ml/binutils/2003-03/msg00394.html>,
and only used by LD with the `--relax' option specified, and rely solely
on `mips_elf_perform_relocation' code, which has been introduced with
commit 1367d393bb ("On the RM9000 convert jal to bal if in range"),
<https://www.sourceware.org/ml/binutils/2004-12/msg00088.html> and since
made more complete, across all the three ABIs.

Also remove the `--relax' option, now irrelevant, from the tests added
with the former commit.

	bfd/
	* elfxx-mips.h (_bfd_mips_relax_section): Remove prototype.
	* elfxx-mips.c (_bfd_mips_relax_section): Remove function.
	* elf64-mips.c (bfd_elf64_bfd_relax_section): Remove macro.
	* elfn32-mips.c (bfd_elf32_bfd_relax_section): Likewise.

	ld/
	* testsuite/ld-mips-elf/relax-jalr-n32.d: Remove `--relax'
	option.
	* testsuite/ld-mips-elf/relax-jalr-n32-shared.d: Likewise.
	* testsuite/ld-mips-elf/relax-jalr-n64.d: Likewise.
	* testsuite/ld-mips-elf/relax-jalr-n64-shared.d: Likewise.
2017-02-23 23:49:14 +00:00
Maciej W. Rozycki c1556ecd78 MIPS/BFD: Discard ineligible JALR relocations right away
Discard R_MIPS_JALR and R_MICROMIPS_JALR relocations associated with
jumps that cannot be converted to an equivalent branch right away in
`mips_elf_calculate_relocation' rather than letting them through to
`mips_elf_perform_relocation'.  This includes cross-mode jumps which
need to flip the ISA bit or jumps to a misaligned location that cannot
be encoded with a branch, in addition to preemptible symbol references
already handled.

Cross-mode jumps are actually already rejected as the conversion is made
in `mips_elf_perform_relocation', so in this case this change only saves
some processing.  Jumps to a misaligned location are however converted,
with bits causing misalignment lost, making resulting code functionally
different even if the lone effect is avoiding an address error exception
with an instruction fetch at the jump destination requested.

Add test cases suitable, also including GAS verification to confirm that
the JALR relocations explicitly requested have indeed been output in the
intermediate objects used.

	bfd/
	* elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_JALR>
	<R_MICROMIPS_JALR>: Discard relocation if `cross_mode_jump_p'
	or misaligned.

	gas/
	* testsuite/gas/mips/jalr4.d: New test.
	* testsuite/gas/mips/jalr4-n32.d: New test.
	* testsuite/gas/mips/jalr4-n64.d: New test.
	* testsuite/gas/mips/jalr4.s: New test source.
	* testsuite/gas/mips/mips.exp: Run the new tests.

	ld/
	* testsuite/ld-mips-elf/jalr4.dd: New test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
2017-02-23 23:45:14 +00:00
Alan Modra 5499c7c71c Correct VLE 16D and SDAREL relocations
PR 20744
bfd/
	* elf32-ppc.c (ppc_elf_howto_raw): Correct dst_mask on all VLE
	16D relocations.
	(ppc_elf_vle_split16): Correct field mask and shift for 16D relocs.
	(ppc_elf_relocate_section): Correct calculation for VLE SDAREL
	relocs.
ld/
	* testsuite/ld-powerpc/vle-reloc-2.s: Use r6 for last insn of
	each group.
	* testsuite/ld-powerpc/vle-reloc-2.d: Update for above change
	and sdarel reloc fix.
2017-02-23 12:33:51 +10:30
Maciej W. Rozycki 902e9fc76a PR ld/20828: Move symbol version processing ahead of GC symbol sweep
Complement commit b531344c34 ("PR ld/20828: Reorder the symbol sweep
stage of section GC") and commit 81ff47b3a5 ("PR ld/20828: Fix linker
script symbols wrongly forced local with section GC") and move symbol
version processing ahead of the symbol sweep stage of section GC, all in
`bfd_elf_size_dynamic_sections', so that version symbols created stay in
the global scope and are not output as local symbols to the dynamic
symbol table in the presence of corresponding symbol definitions pulled
from a DSO involved in a link.

Consolidate the whole of symbol version processing into a single block
from all parts scattered across the function and rearranging the local
variables used as necessary, however leaving the setting of dynamic
entries associated with the DT_VERDEF, DT_VERDEFNUM, DT_VERNEED and
DT_VERNEEDNUM tags and the SEC_EXCLUDE flag for unused `.gnu.version'
section in the original places.

With the rearrangement of code blocks `Elf_Internal_Verneed *t' would
shadow the previous definition of `struct bfd_elf_version_tree *t', so
rename the former variable to `vn'.

	bfd/
	PR ld/20828
	* elflink.c (bfd_elf_size_dynamic_sections): Move symbol version
	processing ahead of the call to `elf_gc_sweep_symbol'.

	ld/
	PR ld/20828
	* testsuite/ld-elf/pr20828-d.sd: New test.
	* testsuite/ld-elf/pr20828-e.sd: New test.
	* testsuite/ld-elf/pr20828-v.od: New test.
	* testsuite/ld-elf/pr20828-v.ver: New test version script.
	* testsuite/ld-elf/pr20828-v.ld: New test linker script.
	* testsuite/ld-elf/pr20828.ld: Add `.gnu.version' and
	`.gnu.version_d'.
	* testsuite/ld-elf/shared.exp: Run the new tests.
2017-02-22 18:16:28 +00:00
Nick Clifton 465197842a Fix compile time warning message in linker testsuite test.
* testsuite/ld-ifunc/pr18808b.c (bar): Fix compile time warning
	about non-void function returning without a result.
2017-02-21 11:00:21 +00:00
Alan Modra c48cfeddf7 PE ld -r script fixes
PR 15041
	* scripttempl/pe.sc: Don't combine sections for ld -r.
	* scripttempl/pep.sc: Likewise.
2017-02-21 00:14:03 +10:30
Alan Modra 246b91226b fix PR number 2017-02-20 21:31:02 +10:30
Alan Modra 74dc9032e7 Move .stack before debug sections
PR 20199
	* emulparams/elf32m32c.sh: Define STACK_ADDR and STACK_SENTINEL
	rather than using OTHER_SECTIONS.
	* emulparams/elf32mt.sh: Likewise.
	* emulparams/elf32rx.sh: Likewise.
	* emulparams/elf32rl78.sh: Likewise.  Use OTHER_SYMBOLS to
	define __rl78_abs__.
	* emulparams/shelf.sh: Define STACK_ADDR and STACK_SENTINEL
	rather than using OTHER_SECTIONS.
	* emulparams/shelf32.sh: Likewise.  Use OTHER_SECTIONS for .cranges.
	* emulparams/shelf64.sh: Unset OTHER_SECTIONS.
	* emulparams/shelf_nbsd.sh: Unset STACK_ADDR not OTHER_SECTIONS.
	* emulparams/shelf_uclinux.sh: Likewise.
	* emulparams/shlsymbian.sh: Unset STACK_ADDR.  Use OTHER_SYMBOLS
	to define _stack, not OTHER_SECTIONS.
	* scripttempl/elf.sc: Move STACK, TINY_DATA_SECTION, and
	TINY_BSS_SECTION before debug sections.  Add STACK_SENTINEL.
	* scripttempl/arclinux.sc: Likewise.
	* scripttempl/elf64hppa.sc: Likewise.
	* scripttempl/elfxtensa.sc: Likewise.
	* scripttempl/nds32elf.sc: Likewise.
	* scripttempl/armbpabi.sc: Move STACK before debug sections.
	* scripttempl/elf_chaos.sc: Likewise.
	* scripttempl/elfarc.sc: Delete STACK.
	* scripttempl/epiphany_4x4.sc: Delete STACK.  Move TINY_DATA_SECTION,
	TINY_BSS_SECTION, and .stack before debug sections.
2017-02-20 19:33:28 +10:30
Nick Clifton 67cecaba5f Fix documentation of the linker's --pop-state command line option.
PR ld/20825
	* ld.texinfo (Options): Add missing @item entry for --pop-state.
2017-02-17 16:31:09 +00:00
Alan Modra 262a40a540 Relax dwarf2 expected error match
* testsuite/ld-elf/dwarf2.err: Accept other errors between the
	multiple definition errors.
2017-02-17 18:02:40 +10:30
Alan Modra 002a5d4e58 Relax dwarf3 expected error match
* testsuite/ld-elf/dwarf2.err: Add missing newline at end.
	* testsuite/ld-elf/dwarf3.err: Likewise.  Allow match without filename.
2017-02-17 17:41:03 +10:30
Andrew Burgess 3239a4231f bfd: Improve lookup of file / line information for errors
When looking up file and line information (used from the linker to
report error messages) if no symbol is passed in, then use the symbol
list to look for a matching symbol.

If a matching symbol is found then use this to look up the file / line
information.

This should improve errors when looking up file / line information for
data sections.  Hopefully we should find a matching data symbol, which
should, in turn (we hope) match a DW_TAG_variable in the DWARF, this
should allow us to give accurate file / line errors for data symbols.

As the hope is to find a matching DW_TAG_variable in the DWARF then we
ignore section symbols, and prefer global symbols to locals.

bfd/ChangeLog:

	* dwarf2.c (_bfd_dwarf2_find_nearest_line): Perform symbol lookup
	before trying to fine matching file and line information.

ld/ChangeLog:

	* testsuite/ld-elf/shared.exp: Update expected results.
	* testsuite/ld-elf/dwarf2.err: Likewise
2017-02-16 13:06:14 +00:00
Andrew Burgess 90ed9b8bc1 bfd/dwarf: Improve use of previously loaded dwarf information
When parsing DWARF data in order to report file/line type error messages
we perform section placement to make section addresses unique within
relocatable object files.

Currently, if we reuse previously loaded (and cached) dwarf data then we
neglect to perform section placement, the result is that the section
addresses will not be unique, and we might, incorrectly associate an
address with the wrong debug information, and so report an incorrect
file and line number.

Further we neglect to check that that bfd for which we are looking up
debug information is actually the bfd for which the previous debug
information was loaded, it is possible that we will reuse previously
loaded debug information for a different bfd.

And finally, due to following of gnu_debuglink links in one bfd to
another, the process of checking that the cached debug information is
valid requires us to track the original bfd in the cached debug
information.  The original debug information here is either the bfd that
we're interested in, not the bfd we finally load the debug information
from.

bfd/ChangeLog:

	* dwarf2.c (struct dwarf2_debug): Add orig_bfd member.
	(_bfd_dwarf2_slurp_debug_info): If stashed debug information does
	not match current bfd, then reload debug information.  Record bfd
	we're loading debug info for in the stash.  If we have debug
	informatin in the cache then perform section placement before
	returning.

ld/ChangeLog:

	* testsuite/ld-elf/dwarf.exp (build_tests): Add new tests.
	* testsuite/ld-elf/dwarf2.err: New file.
	* testsuite/ld-elf/dwarf2a.c: New file.
	* testsuite/ld-elf/dwarf2b.c: New file.
	* testsuite/ld-elf/dwarf3.c: New file.
	* testsuite/ld-elf/dwarf3.err: New file.
2017-02-16 13:06:13 +00:00
Andrew Burgess 2bd7f877af ld: Add additional checking for warnings/errors in testsuite
This commit adds new actions to the run_cc_link_tests mechanism in the
linker testsuite.

Previously this procedure could take a parameter containing a regular
expression that would be matched against warnings from the linker.

After this commit the warnings parameter is removed, instead, the
actions list can contain the actions 'warning', 'error',
'warning_output', or 'error_output'.  The action names are chosen to
match the actions already present in the run_dump_test procedure.

These new actions allow for the current warning checking, but also allow
for checking of errors using a regular expression.  More interestingly,
the *_output actions allow for the warning/error patterns to be placed
in a separate file.

The small number of tests that make use of the warning parameter have
been updated to the new mechanism.  Later commits will make use of the
new features added in this commit.

ld/ChangeLog:

	* testsuite/lib/ld-lib.exp (run_cc_link_tests): Add warning,
	error, warning_output, and error_output actions.  Remove separate
	warnings parameter.
	* testsuite/ld-elf/shared.exp (build_tests): Updated to use
	'warning' action.
	* testsuite/ld-plugin/lto.exp (lto_link_tests): Likewise.
2017-02-16 13:06:12 +00:00
Alan Modra 37d7d56cae ld testsuite function pointer comparisons vs. hppa
ld/testsuite/ld-elf/check-ptr-eq.c fails for hppa, since function
pointers may point at plabels.  It isn't valid to cast two function
pointers to void* and then compare the void pointers.

	* testsuite/ld-elf/check-ptr-eq.c (check_ptr_eq): Change params
	from void pointers to function pointers.
	* testsuite/ld-elf/pr18718.c: Update to suit.
	* testsuite/ld-elf/pr18720a.c: Update to suit.
2017-02-16 23:10:09 +10:30
Alan Modra a8c75b765e hppa -z relro again
I misunderstood the hppa alias problem.  File offsets of segments need
to be such that no page is mapped twice with different permissions.
(Which still seems to me like something the kernel could fix, but
anyhow, this is not so difficult to achieve in ld.)

	PR 21000
bfd/
	* elf-bfd.h (struct elf_backend_data): Add no_page_alias.
	* elfxx-target.h (elf_backend_no_page_alias): Define.
	(elfNN_bed): Init new field.
	* elf.c (assign_file_positions_for_load_sections): If no_page_alias
	ensure PT_LOAD segment starts on a new page.
	* elf32-hppa.c (elf_backend_no_page_alias): Define.
ld/
	* testsuite/ld-elf/loadaddr1.d: Adjust for hppa file offsets.
	* testsuite/ld-elf/loadaddr2.d: Likewise.
	* testsuite/ld-elf/loadaddr3a.d: Likewise.
	* testsuite/ld-scripts/rgn-at5.d: Likewise.
2017-02-16 23:09:38 +10:30
Alan Modra a48cda7f86 Fix more powerpc testsuite source errors
* testsuite/ld-powerpc/vxworks1-lib.s: Correct addi to addic.
	* testsuite/ld-powerpc/vxworks1-lib.dd: Adjust to suit.
2017-02-16 22:39:51 +10:30
H.J. Lu 2a5684011e i386: Allow "lea foo@GOT, %reg" in PIC
"lea foo@GOT, %reg" is OK in PIC since it only loads the GOT offset
into register, which can be used later with a GOT base register to
get the value in the GOT entry.

bfd/

	PR ld/21168
	* elf32-i386.c (elf_i386_relocate_section): Allow
	"lea foo@GOT, %reg" in PIC.

ld/

	PR ld/21168
	* testsuite/ld-i386/i386.exp: Run pr21168.
	* testsuite/ld-i386/pr21168a.c: New file.
	* testsuite/ld-i386/pr21168b.S: Likewise.
2017-02-15 11:39:48 -08:00
H.J. Lu a5def14f1c Add a test for R_386_GOT32/R_386_GOT32X IFUNC reloc error
bfd/

	PR ld/20244
	* elf32-i386.c (elf_i386_relocate_section): Properly get IFUNC
	symbol name when reporting R_386_GOT32/R_386_GOT32X relocation
	error against local IFUNC symbol without a base register for
	PIC.

ld/

	PR ld/20244
	* testsuite/ld-i386/i386.exp: Run pr20244-4a, pr20244-4b and
	pr20244-4c.
	* testsuite/ld-i386/pr20244-4.s: New file.
	* testsuite/ld-i386/pr20244-4a.d: Likewise.
	* testsuite/ld-i386/pr20244-4b.d: Likewise.
	* testsuite/ld-i386/pr20244-4c.d: Likewise.
2017-02-15 11:11:40 -08:00
Maciej W. Rozycki ebf0b03c70 LD: vfinfo: Make clever formatters consistent WRT function name reporting
Remove an inconsistency in linker error message processing causing that
it depends on the ability to infer the name of the originating source
file whether or not the name of the offending function is repeated by
clever formatters for each issue reported within the function.

Taking the `ld/testsuite/ld-powerpc/tocopt7.s' test case source as an
example and the `powerpc-linux' target we have:

$ as -gdwarf2 -o tocopt.o -a64 tocopt.s
$ ld -o tocopt -melf64ppc tocopt.o
tocopt.o: In function `_start':
tocopt.s:35:(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction.
tocopt.s:49:(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction.
$

vs:

$ as -o tocopt.o -a64 tocopt.s
$ ld -o tocopt -melf64ppc tocopt.o
tocopt.o: In function `_start':
(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction.
tocopt.o: In function `_start':
(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction.
$

Similarly with the `mips-linux' target and this source:

$ cat jal-global-multi-overflow.s
	.text
	.set	noreorder
	.space	0x2000

	.align	4
	.globl	foo
	.ent	foo
foo:
	jal	bar
	 nor	$0, $0
	jal	bar
	 nor	$0, $0
	.end	foo

	.space	0x1ff0

	.align	4
	.globl	bar
	.ent	bar
bar:
	jal	foo
	 nor	$0, $0
	jal	foo
	 nor	$0, $0
	.end	bar
$ as -o jal-global-multi-overflow.o jal-global-multi-overflow.s
$ ld -Ttext 0x1fffd000 -e foo -o jal-global-multi-overflow jal-global-multi-overflow.o
jal-global-multi-overflow.o: In function `foo':
(.text+0x2000): relocation truncated to fit: R_MIPS_26 against `bar'
jal-global-multi-overflow.o: In function `foo':
(.text+0x2008): relocation truncated to fit: R_MIPS_26 against `bar'
jal-global-multi-overflow.o: In function `bar':
(.text+0x4000): relocation truncated to fit: R_MIPS_26 against `foo'
jal-global-multi-overflow.o: In function `bar':
(.text+0x4008): relocation truncated to fit: R_MIPS_26 against `foo'
$

Not only this is inconsistent, but it causes output clutter as well with
redundant information.

The cause for this is a check in `vfinfo' the intent of which is to
print the function heading whenever (among others) the name of the
source file has changed, which however does not take into account a
situation where the name couldn't have been established both now and
previously.

Adjust the check then for this situation, yielding:

$ as -o tocopt.o -a64 tocopt.s
$ ld -o tocopt -melf64ppc tocopt.o
tocopt.o: In function `_start':
(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction.
(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction.
$

and:

$ as -o jal-global-multi-overflow.o jal-global-multi-overflow.s
$ ld -Ttext 0x1fffd000 -e foo -o jal-global-multi-overflow jal-global-multi-overflow.o
jal-global-multi-overflow.o: In function `foo':
(.text+0x2000): relocation truncated to fit: R_MIPS_26 against `bar'
(.text+0x2008): relocation truncated to fit: R_MIPS_26 against `bar'
jal-global-multi-overflow.o: In function `bar':
(.text+0x4000): relocation truncated to fit: R_MIPS_26 against `foo'
(.text+0x4008): relocation truncated to fit: R_MIPS_26 against `foo'
$

respectively instead.  Adjust the test suite accordingly.

	ld/
	* ldmisc.c (vfinfo): Don't print the function name again either
	if no source file name has been found both now and previously.
	* testsuite/ld-cris/tls-err-20x.d: Adjust accordingly.
	* testsuite/ld-mips-elf/mode-change-error-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-mips16.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-micromips.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-r6-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-2.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-r6-2.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-ignore-2.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-ignore-mips16.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-ignore-micromips.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-ignore-r6-1.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-1.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-1.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-3.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jump.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jump-mips16.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jump-micromips.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-lwpc-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-ldpc-1.d: Likewise.
	* testsuite/ld-powerpc/tocopt.out: Likewise.
	* testsuite/ld-powerpc/tocopt7.out: Likewise.
2017-02-15 13:41:51 +00:00
Maciej W. Rozycki befe814dd9 LD: vfinfo: Remove static NULL initializers
Remove static NULL initializers, moving the respective variables from
data to BSS and saving some storage space.

	ld/
	* ldmisc.c (vfinfo) <'H'>: Remove static NULL initializers.
2017-02-15 13:40:08 +00:00
Igor Kudrin defe6f56b7 Use Windows style directory separators when running sysroot tests under MinGW and Cygwin.
* testsuite/ld-scripts/sysroot-prefix.exp
	(get_base_dir_for_scripts): New function.
	(run_sysroot_prefix_test): Use get_base_dir_for_scripts.
2017-02-15 09:13:56 +00:00
Palmer Dabbelt 10ddfe62f8 Don't use "_gp" on RISC-V, use "_global_pointer$" instead
"_gp" could conflict with ABI-complient code.  While it's probably OK
because MIPS uses this name, we figured it'd be good to clean this up
before a release with RISC-V in it.

ld/ChangeLog:

2017-02-13  Palmer Dabbelt  <palmer@dabbelt.com>

        * emulparams/elf32lriscv-defs.sh (SDATA_START_SYMBOLS): Change
        _gp to __global_pointer$.

bfd/ChangeLog:

2017-02-13  Palmer Dabbelt  <palmer@dabbelt.com>

        * elfnn-riscv.c (riscv_global_pointer_value): Change _gp to
        __global_pointer$.
2017-02-13 09:53:54 -08:00
Andrew Burgess d7488716ee ld/arc: Change default linker emulation for nps400
If we are configuring for an arc/linux target, and --with-cpu=nps400 is
used at configure time then change the default linker emulation to the
nps specific version.  All of the alternative linker emulations are
still available using the -mNAME option for ld.

ld/ChangeLog:

	* configure.tgt (arc*-*-linux*): Change the default linker
	emulation based on --with-cpu selection.
	* NEWS: Mention new configuration option.
2017-02-08 23:47:43 +00:00
Jiong Wang 65f90e8259 [ld, testsuite] Don't print to stdout for "readelf -w" to avoid buffer overflow
ld/
	* testsuite/ld-elf/compress.exp: Don't print to stdout for all
	"readelf -w".
2017-02-06 15:25:18 +00:00
Maciej W. Rozycki fa93e3d347 CRIS/LD/testsuite: tls-err-20x.d: Fix a typo, s/n/\n/
ld/
	* testsuite/ld-cris/tls-err-20x.d: Fix a typo, s/n/\n/.
2017-02-02 22:31:57 +00:00
Maciej W. Rozycki 2e9af2d0de LD/testsuite: ld-lib.exp: Fix a typo, s/regexp/regex/
Match `$check_ld(source)' against "regex" rather than "regexp" in
reporting, correcting test framework diagnostics, e.g.:

tmpdir/undefined.o: In function `foo':
(.text+0x0): undefined reference to `bar'
failed with: <tmpdir/undefined.o: In function `foo':
(.text+0x0): undefined reference to `bar'>, no expected output
tmpdir/undefined.o: In function `foo':
(.text+0x0): undefined reference to `bar'
PASS: MIPS undefined reference

(current) vs:

tmpdir/undefined.o: In function `foo':
(.text+0x0): undefined reference to `bar'
failed with: <tmpdir/undefined.o: In function `foo':
(.text+0x0): undefined reference to `bar'>, expected: <\A[^\n]*\.o: In function `foo':\n\(\.text\+0x0\): undefined reference to `bar'\Z>
tmpdir/undefined.o: In function `foo':
(.text+0x0): undefined reference to `bar'
PASS: MIPS undefined reference

(corrected).  No functional change.

	ld/
	* ld/testsuite/lib/ld-lib.exp (run_dump_test): Fix a typo,
	s/regexp/regex/.
2017-02-02 22:30:55 +00:00
Jiong Wang fd121c5c45 [ld, testsuite] Restrict dl1*main and dl6*main tests on platforms which have libdl support
ld/
	* testsuite/lib/ld-lib.exp (check_libdl_available): New function.
	* testsuite/ld-elf/shared.exp (run_tests): Split tests which require
	dlopen support into "dlopen_run_tests".  These tests include dl1*main
	and dl6*main.
	(dlopen_run_tests): New and only run it when check_libdl_available
	returns true.  XFAIL on *-*-netbsdelf*.
2017-02-02 09:57:26 +00:00
Maciej W. Rozycki c0c237fcdd MIPS/LD/testsuite: Correct relocation addends in VxWorks tests
Fix commit 171191bac5 ("Add support for STT_IFUNC"),
<https://sourceware.org/ml/binutils/2008-12/msg00052.html>, commit
e04d7088af ("PR ld/14088: Always display addend as signed hex
number"), <https://sourceware.org/ml/binutils/2012-05/msg00123.html> and
commit 343dbc36ff ("Print addend as signed in objdump"),
<https://sourceware.org/ml/binutils/2012-05/msg00163.html> regressions:

FAIL: VxWorks executable test 1 (dynamic)
FAIL: ld-mips-elf/vxworks-forced-local-1

seen with `mips-vxworks' and `mipsel-vxworks' targets and adjust dump
patterns according to changes made to the presentation of relocation
addends in `readelf -r' and `objdump -r' output.

	ld/
	* testsuite/ld-mips-elf/vxworks-forced-local-1.d: Correct the
	presentation of relocation addends.
	* testsuite/ld-mips-elf/vxworks1-lib.rd: Likewise.
	* testsuite/ld-mips-elf/vxworks1.dd: Likewise.
	* testsuite/ld-mips-elf/vxworks1.rd: Likewise.
2017-02-01 22:17:33 +00:00
Maciej W. Rozycki 5139cfdb55 MIPS/LD/testsuite: Fix a `tls-multi-got-1-1.s' build failure
Correct a commit ec9ab52c32 ("gas: consistently emit diagnostics for
non-zero data emission to .bss/.struct"),
<https://sourceware.org/ml/binutils/2015-12/msg00073.html> regression:

.../ld/testsuite/ld-mips-elf/tls-multi-got-1-1.s: Assembler messages:
.../ld/testsuite/ld-mips-elf/tls-multi-got-1-1.s:39: Error: attempt to store non-zero value in section `.tbss'
ERROR: -EB -march=mips1 -32 -KPIC .../ld/testsuite/ld-mips-elf/tls-multi-got-1-1.s: assembly failed
UNRESOLVED: Shared library with multiple GOTs and TLS

in MIPS target testing and move `tlsvar_ld' to `.tdata' section, in line
with the remaining local dynamic definitions introduced with the set of
tests added with commit f4e584bd00 ("TLS support for MIPS"),
<https://sourceware.org/ml/binutils/2005-02/msg00607.html>.

	ld/
	* testsuite/ld-mips-elf/tls-multi-got-1-1.s: Place `tlsvar_ld'
	in `.tdata' section.
	* testsuite/ld-mips-elf/tls-multi-got-1.got: Adjust accordingly.
	* testsuite/ld-mips-elf/tls-multi-got-1.r: Likewise.
2017-02-01 22:15:32 +00:00
Jiong Wang ce7903706d [ld, testsuite] Append $board_cflags in one more place in ld-unique/unique.exp
ld/
	* testsuite/ld-unique/unique.exp (Could not link a dynamic executable):
	Append $board_cflags to link commands.
2017-02-01 12:57:25 +00:00
Senthil Kumar Selvaraj 067869b677 Fix failing print-memory-usage-1 on Windows
ld/

2017-01-31  Senthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com>

	* testsuite/ld-scripts/print-memory-usage-1.l: Relax
	check for digit in second decimal place.
2017-02-01 11:55:19 +05:30
Maciej W. Rozycki 15a00b13ae PR ld/20828: LD/testsuite: Correct indentation
ld/
	PR ld/20828
	* testsuite/ld-elf/shared.exp: Correct PR ld/20828 test
	indentation.
2017-02-01 00:21:53 +00:00
Nick Clifton 1273da0414 Fix buffer overflows in ld when printing translated strings.
ld	* ldmain.c (add_archive_element): Eliminate string buffer.
	* ldlang.c (lang_print_asneeded): Likewise.
2017-01-31 12:07:04 +00:00
Maciej W. Rozycki 8b10b0b3e1 MIPS: Add options to control branch ISA checks
Complement commit 9d862524f6 ("MIPS: Verify the ISA mode and alignment
of branch and jump targets") and add GAS and LD options to control the
checks for invalid branches between ISA modes introduced there, to help
with some handwritten code lacking `.insn' annotation for labels used as
branch targets and code produced by older versions of GCC which suffers
from the issue with branches to code that has been optimized away,
addressed with GCC commit 242424 ("MIPS/GCC: Mark trailing labels with
`.insn'"), <https://gcc.gnu.org/ml/gcc-patches/2016-11/msg01061.html>.

	bfd/
	* elfxx-mips.h (_bfd_mips_elf_insn32): Rename prototype to...
	(_bfd_mips_elf_linker_flags): ... this.  Add another parameter.
	* elfxx-mips.c (mips_elf_link_hash_table): Add
	`ignore_branch_isa' member.
	(mips_elf_perform_relocation): Do not treat an ISA mode mismatch
	in branch relocation calculation as an error if
	`ignore_branch_isa' has been set.
	(_bfd_mips_elf_insn32): Rename to...
	(_bfd_mips_elf_linker_flags): ... this.  Rename the `on'
	parameter to `insn32' and add an `ignore_branch_isa' parameter.
	Handle the new parameter.

	gas/
	* config/tc-mips.c (mips_ignore_branch_isa): New variable.
	(options): Add OPTION_IGNORE_BRANCH_ISA and
	OPTION_NO_IGNORE_BRANCH_ISA enum values.
	(md_longopts): Add "mignore-branch-isa" and
	"mno-ignore-branch-isa" options.
	(md_parse_option): Handle OPTION_IGNORE_BRANCH_ISA and
	OPTION_NO_IGNORE_BRANCH_ISA.
	(fix_bad_cross_mode_branch_p): Return FALSE if
	`mips_ignore_branch_isa' has been set.
	(md_show_usage): Add `-mignore-branch-isa' and
	`-mno-ignore-branch-isa'.

	* doc/as.texinfo (Target MIPS options): Add
	`-mignore-branch-isa' and `-mno-ignore-branch-isa' options.
	(-mignore-branch-isa, -mno-ignore-branch-isa): New options.
	* doc/c-mips.texi (MIPS Options): Add `-mignore-branch-isa' and
	`-mno-ignore-branch-isa' options.

	* testsuite/gas/mips/branch-local-ignore-2.d: New test.
	* testsuite/gas/mips/branch-local-ignore-3.d: New test.
	* testsuite/gas/mips/branch-local-ignore-n32-2.d: New test.
	* testsuite/gas/mips/branch-local-ignore-n32-3.d: New test.
	* testsuite/gas/mips/branch-local-ignore-n64-2.d: New test.
	* testsuite/gas/mips/branch-local-ignore-n64-3.d: New test.
	* testsuite/gas/mips/mips.exp: Run the new tests.

	ld/
	* emultempl/mipself.em (ignore_branch_isa): New variable.
	(mips_create_output_section_statements): Rename
	`_bfd_mips_elf_insn32' called to `_bfd_mips_elf_linker_flags',
	add `ignore_branch_isa' argument.
	(PARSE_AND_LIST_PROLOGUE): Add OPTION_IGNORE_BRANCH_ISA and
	OPTION_NO_IGNORE_BRANCH_ISA enum values.
	(PARSE_AND_LIST_LONGOPTS): Add "ignore-branch-isa" and
	"no-ignore-branch-isa" options.
	(PARSE_AND_LIST_OPTIONS): Add `--ignore-branch-isa' and
	`--no-ignore-branch-isa'.
	(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_IGNORE_BRANCH_ISA and
	OPTION_NO_IGNORE_BRANCH_ISA.

	* ld.texinfo (Options specific to MIPS targets): Add
	`--ignore-branch-isa' and `--no-ignore-branch-isa' options.
	(ld and the MIPS family): Likewise.

	* testsuite/ld-mips-elf/bal-jalx-pic-ignore.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-pic-ignore-n32.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-pic-ignore-n64.d: New test.
	* testsuite/ld-mips-elf/unaligned-branch-ignore-2.d: New test.
	* testsuite/ld-mips-elf/unaligned-branch-ignore-r6-1: New test.
	* testsuite/ld-mips-elf/unaligned-branch-ignore-mips16: New
	test.
	* testsuite/ld-mips-elf/unaligned-branch-ignore-micromips: New
	test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2017-01-30 17:16:01 +00:00
Hans-Peter Nilsson ce6366f9ab Fix another typo in the last ChangeLog entry.
Gah!  Though this time I blame autocompletion.
2017-01-29 16:15:16 +01:00
Hans-Peter Nilsson 8dcdd12d21 Fix typo in ChangeLog 2017-01-29 14:18:13 +01:00
Hans-Peter Nilsson c1d4523838 PR binutils/19935
Fix long-standing buglet and fallout from now-default initfini-array.
	* emulparams/criself.sh (USER_LABEL_PREFIX): Define.
	(OTHER_READONLY_SECTIONS, ENTRY): Delete now-redunant defines.
2017-01-29 14:13:38 +01:00
Hans-Peter Nilsson bf382b306a Fix long-standing buglet and fallout from now-default initfini-array.
* emulparams/criself.sh (USER_LABEL_PREFIX): Define.
	(OTHER_READONLY_SECTIONS, ENTRY): Delete now-redunant defines.
2017-01-29 13:53:58 +01:00
Jiong Wang 4471a46f6f [ld, testsuite] XFAIL "pr20995-2", "Build pr20995-2.so" on arm*-*-eabi*
ld/
	* testsuite/ld-elf/elf.exp ("pr20995-2", "Build pr20995-2.so"): XFAIL on
	arm*-*-eabi*.

Some technical discussions about the reason of this XFAIL are available at

  https://sourceware.org/ml/binutils/2017-01/msg00441.html
2017-01-27 23:06:28 +00:00
Dilyan Palauzov 387dd77738 Update description of the -plugin option used by the linker, ar and nm.
PR 20343
ld	* ld.texinfo (Options): Extend documentation of the --plugin
	option.  Include a description of where the plugins should be
	located.

binutils* doc/binutils.texi (ar): Extend documentation of the --plugin
	option.  Include a description of where the plugins should be
	located.
	(nm): Likewise.
2017-01-27 13:20:24 +00:00
Nick Clifton 0348d4be16 Add Serbian translation for the LD directory.
ld	* po/sr.po: New Serbian translation.
	* configure.ac (ALL_LINGUAS): Add sr.
	* configure: Regenerate.
2017-01-27 11:27:50 +00:00
Sebastian Huber c75b4ebd4f Move RTEMS target configuration to ELF sections
bfd/
	* config.bfd (powerpcle-*-rtems*): Do not mark as removed.
	(arm-*-rtems*): Move to (arm*-*-eabi*).
	(i[3-7]86-*-rtems*): Move to (i[3-7]86-*-elf*).
	(m68-*-rtems*): Move to (m68*-*-elf*).
ld/
	* configure.tgt (arm-*-rtems*): Move to (arm*-*-eabi*).
	(bfin-*-rtems*): Move to (bfin*-*-elf*).
	(i[3-7]86-*-rtems*): Move to (i[3-7]86*-*-elf*).
	(m68*-*-rtems*): Move to (m68*-*-elf*).
	(mips*-*-rtems*): Move to (mips*-*-elf*).
	(or1k*-*-rtems*): Move to (or1k*-*-elf*).
	(powerpc*-*-rtems*): Move to (powerpc*-*-elf*).
	(sparc*-*-rtems*): Move to (sparc*-*-elf*).
	(sparc64*-*-rtems*): Move to (sparc64*-*-elf*).
2017-01-25 17:55:57 +10:30
Sebastian Huber 850d84f6a4 Remove all RTEMS COFF targets
bfd/
	* config.bfd (*-*-rtemscoff*): Mark as removed.
gas/
	* configure.tgt (sh-*-rtemscoff*): Remove.
ld/
	* configure.tgt (h8300-*-rtemscoff*): Remove.
	(i960-*-rtems*): Likewise.
	(m68*-*-rtemscoff*): Likewise.
	(sh-*-rtemscoff*): Likewise.
2017-01-25 17:52:27 +10:30
Maciej W. Rozycki 1a792e1c00 Solaris2/LD: Fix anonymous version script acceptance bug
Correct a bug in Solaris 2 linker emulation code triggered by a test
introduced with commit 81ff47b3a5 ("PR ld/20828: Fix linker script
symbols wrongly forced local with section GC") and only create implicit
version nodes if versioning is actually introduced with a version script
(or VERSION command) rather than only global vs local symbol visibility
selected, fixing an:

ld: anonymous version tag cannot be combined with other version tags

linker error produced whenever a version script (or VERSION command) is
used that does not assign symbol versions, such as:

{ global: foo; bar; local: *; };

and consequently removing a:

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

test suite failure with the `x86_64-solaris2' target.

	ld/
	* emultempl/solaris2.em (elf_solaris2_before_allocation): Do not
	add implicit version nodes if an anonymous version tag is being
	used.
2017-01-24 12:53:52 +00:00
Jiong Wang 077c11e867 [ld, testsuite] Always assemble those intermeidate .o files used later
ld/
	* testsuite/ld-plugin/lto.exp (lto_link_elf_tests): Move "Compile 7",
	"Compile 8a", "Compile 8b"...
	(lto_compile_elf_tests): ...to here.  Always run these tests.
	(lto_run_elf_tests): Move "LTO 7"...
	(lto_run_elf_shared_tests): ...to here.  Restrict these tests on
	environment where share library is supported.
2017-01-24 09:33:00 +00:00
Alan Modra f0158f4416 PowerPC dynamic relocations
This patch fixes a number of issues with powerpc dynamic relocations.

1) Both ppc and ppc64 were emitting more dynamic symbols and
relocations than necessary, due to not supporting static linker
resolution of tls_index entries for __tls_get_addr_opt.  This meant
that any @got@tlsgd or @got@tlsld reloc needed to make their symbols
dynamic and generate dptmod and dtprel relocs for the dynamic linker.
That would have been passable, but what happened was that practically
all @got relocations resulted in their symbols being made dynamic and
dynamic relocations emitted against the GOT entries.  (Mostly visible
on ppc32 executables since ppc64 gcc really only uses @got style
relocs for TLS.)

2) The PowerOpen syntax was not supported with __tls_get_addr_opt.
DTPMOD/DTPREL relocs on tls_index TOC entries did not use the trick of
forcing dynamic symbols and relocations so those entries always
resulted in the full __tls_get_addr processing.  gcc doesn't use the
PowerOpen syntax for TLS, and normally such code would be optimized to
TLS IE or LE so the impact of missing this support was minimal.

3) In an executable, relocations against GNU indirect functions always
used the value of their PLT stub.   While this is correct, it is
better in some cases to use a dynamic relocation.  An extra dynamic
relocation can mean that calls via function pointers need not bounce
through the PLT stub at runtime.

The patch also tidies the PLT handling code in ppc32
allocate_dynrelocs.  Allocating PLT entries after other dynamic relocs
allows the PLT loop to omit special handling for undefined weak
symbols, and that in turn allows the loop to be simplified.

bfd/
	* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Merge two cases
	where dynamic relocs are preferable.  Allow ifunc too.
	(ensure_undefweak_dynamic): New function.
	(allocate_dynrelocs): Use it here.  Move plt handling last and
	don't make symbols dynamic, simplifying loop.  Only make undef
	weak symbols with GOT entries dynamic.  Correct condition
	for GOT relocs.  Handle dynamic relocs on ifuncs.  Correct
	comments.  Remove goto.
	(ppc_elf_relocate_section): Correct test for using dynamic
	symbol on GOT relocs.  Rearrange test for emitting GOT relocs
	to suit.  Set up explicit tls_index entries and implicit GOT
	tls_index entries resolvable at link time for
	__tls_get_addr_opt.  Simplify test to clear mem for prelink.
	* elf64-ppc.c (allocate_got): Correct condition for GOT relocs.
	(ensure_undefweak_dynamic): New function.
	(allocate_dynrelocs): Use it here.  Only make undef weak symbols
	with GOT entries dynamic.  Remove unnecessary test of
	WILL_CALL_FINISH_DYNAMIC_SYMBOL in PLT handling.
	(ppc64_elf_relocate_section): Correct test for using dynamic
	symbol on GOT relocs.  Rearrange test for emitting GOT relocs
	to suit.  Set up explicit tls_index entries and implicit GOT
	tls_index entries resolvable at link time for __tls_get_addr_opt.
	Simplify expression to clear mem for prelink.
ld/
	* testsuite/ld-powerpc/tlsexe.r: Update for fewer dynamic relocs
	and symbols.
	* testsuite/ld-powerpc/tlsexe.d: Likewise.
	* testsuite/ld-powerpc/tlsexe.g: Likewise.
2017-01-24 12:15:54 +10:30
Yury Norov 2d0ca82411 Fix AArch64 relocation handling in ILP32 mode.
bfd	* elfnn-aarch64.c: Fix relaxations for ILP32 mode.

ld	* testsuite/ld-aarch64/aarch64-elf.exp: Run new tests.
	* testsuite/ld-aarch64/tls-desc-ie-ilp32.d: New test.
	* testsuite/ld-aarch64/tls-relax-all-ilp32.d: New test.
	* testsuite/ld-aarch64/tls-relax-gd-le-ilp32.d: New test.
	* testsuite/ld-aarch64/tls-relax-gdesc-le-2-ilp32.d: New test.
	* testsuite/ld-aarch64/tls-relax-gdesc-le-ilp32.d: New test.
	* testsuite/ld-aarch64/tls-relax-ie-le-2-ilp32.d: New test.
	* testsuite/ld-aarch64/tls-relax-ie-le-3-ilp32.d: New test.
	* testsuite/ld-aarch64/tls-relax-ie-le-ilp32.d: New test.
	* testsuite/ld-aarch64/tls-tiny-desc-ie-ilp32.d: New test.
	* testsuite/ld-aarch64/tls-tiny-desc-le-ilp32.d: New test.
	* testsuite/ld-aarch64/tls-tiny-gd-ie-ilp32.d: New test.
	* testsuite/ld-aarch64/tls-tiny-gd-le-ilp32.d: New test.
2017-01-23 17:07:13 +00:00
Nick Clifton 8069955ee0 Updated Irish translation for ld and Swedish translation for gas. 2017-01-23 13:32:12 +00:00
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