Commit Graph

6144 Commits

Author SHA1 Message Date
Nick Clifton 9ed1348c20 Updated Bulgarian and Russian translations for some of the binutils sub-directories 2019-01-25 11:48:55 +00:00
Sebastian Huber 6406a2701b ld: Add LTO warning to --wrap documentation
ld/

	* ld.texi (--wrap): Add warning that LTO may make this feature
	ineffective.
2019-01-23 09:47:28 +01:00
Nick Clifton a6c9b40429 Updated Brazilian Portuguese translation for the ld/ subdirectory. 2019-01-21 13:05:44 +00:00
Nick Clifton 375cd4233d Updated translations for various binutils subdirectories. 2019-01-21 12:59:20 +00:00
Yuri Chornoivan acef8081ec Fix spelling mistakes in BFD library.
PR 24108
bfd	* elf32-nds32.c (nds32_relocate_section): Add space between words
	in error message.
	* elfnn-riscv.c (riscv_version_mismatch): Fix spelling mistake in
	error message.
	(riscv_i_or_e_p): Likewise.
	(riscv_merge_arch_attr_info): Likewise.

ld	* testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Update
	expected error message.
2019-01-21 12:39:24 +00:00
Nick Clifton f48dfe417e Change version to 2.32.51 and regenerate configure and pot files. 2019-01-19 16:51:42 +00:00
Nick Clifton f974f26cb1 Add markers for 2.32 branch to NEWS and ChangeLog files. 2019-01-19 15:55:50 +00:00
Jim Wilson 7d7a7d7ccf RISC-V: Merge ELF attribute for ld.
2019-01-16  Kito Cheng  <kito@andestech.com>
		    Nelson Chu  <nelson@andestech.com>

	bfd/
	* elfnn-riscv.c (in_subsets): New.
	(out_subsets): Likewise.
	(merged_subsets): Likewise.
	(riscv_std_ext_p): Likewise.
	(riscv_non_std_ext_p): Likewise.
	(riscv_std_sv_ext_p): Likewise.
	(riscv_non_std_sv_ext_p): Likewise.
	(riscv_version_mismatch): Likewise.
	(riscv_i_or_e_p): Likewise.
	(riscv_merge_std_ext): Likewise.
	(riscv_merge_non_std_and_sv_ext): Likewise.
	(riscv_merge_arch_attr_info): Likewise.
	(riscv_merge_attributes): Likewise.
	(_bfd_riscv_elf_merge_private_bfd_data): Merge attribute.
	ld/
	* testsuite/ld-elf/orphan-region.d: XFAIL for RISC-V, because add new
	section.
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Add new tests.
	* testsuite/ld-riscv-elf/attr-merge-arch-01.d: New test.
	* testsuite/ld-riscv-elf/attr-merge-arch-01a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-01b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-02a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-02b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-03a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-03b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align-a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align-b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align-failed-a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align-failed-b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align-failed.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-01.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-01a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-01b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-02.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-02a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-02b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-03.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-03a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-03b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-04.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-04a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-04b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-05.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-05a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-05b.s: Likewise.
2019-01-16 13:28:35 -08:00
Nick Clifton f466c3053d Correct PR number in prevvious delta 2019-01-14 16:04:18 +00:00
Maamoun Tarsha 5a12586d44 Add support to GNU ld to separate got related plt entries from normal ones in order to be able to switch the non-plt got entries to read-only after startup, conforming to revised Linux for zSeries ABI.
PR 20133
	* emulparams/elf64_s390.sh (SEPARATE_GOTPLT): Define.
	* emulparams/elf_s390.sh (SEPARATE_GOTPLT): Define.
	* testsuite/ld-s390/gotreloc_31-1.dd: Update expected output.
	* testsuite/ld-s390/tlsbin.dd: Likewise.
	* testsuite/ld-s390/tlsbin.rd: Likewise.
	* testsuite/ld-s390/tlsbin.sd: Likewise.
	* testsuite/ld-s390/tlsbin_64.dd: Likewise.
	* testsuite/ld-s390/tlsbin_64.rd: Likewise.
	* testsuite/ld-s390/tlsbin_64.sd: Likewise.
	* testsuite/ld-s390/tlspic.dd: Likewise.
	* testsuite/ld-s390/tlspic.rd: Likewise.
	* testsuite/ld-s390/tlspic.sd: Likewise.
	* testsuite/ld-s390/tlspic_64.dd: Likewise.
	* testsuite/ld-s390/tlspic_64.rd: Likewise.
	* testsuite/ld-s390/tlspic_64.sd: Likewise.
	* testsuite/ld-s390/s390.exp: Skip s390 tests for tpf targets.
2019-01-14 16:00:14 +00:00
Sebastian Huber 4ea904edb7 ld: Clarify --wrap documentation
ld/

	* ld.texi (--wrap): Add example to emphasise that only undefined
	references are replaced by the linker.
2019-01-14 08:24:44 +01:00
Nick Clifton 8379fac67e Updated Spanish translation for the ld sub-directory.
* po/es.po: Updated Spanish translation.
2019-01-09 12:34:28 +00:00
Andrew Paprocki 3107326d3d Adjust bfd/warning.m4 egrep patterns
Adjust the `bfd/warning.m4` `egrep` patterns to handle preprocessors
that do not define `__GNUC__`, leaving the string in the output.

bfd/
	* warning.m4: Adjust egrep pattern for non-GNU compilers.
	* configure: Regenerate.
binutils/
	* configure: Regenerate.
gas/
	* configure: Regenerate.
gold/
	* configure: Regenerate.
gprof/
	* configure: Regenerate.
ld/
	* configure: Regenerate.
opcodes/
	* configure: Regenerate.
2019-01-09 13:51:08 +10:30
Alan Modra 171b8e1957 run_dump_test source in build directory
Some existing tests build .s and .d files for run_dump_test, using an
absolute #source: line in the .d file.  This patch changes that scheme
a little to instead use "#source: ./..." in .d files rather than
"#source: $objdir/...", which is more useful in cases where the .d
file is not generated.

This allows RX gas test files to be built in the build directory,
rather than in a source directory (which might be read-only).

binutils/
	* testsuite/lib/binutils-common.exp (run_dump_test): Don't prepend
	$srcdir/$subdir to source file name if it starts with "./".
gas/
	* testsuite/gas/rx/rx.exp: Create generated test source in
	current directory.
	* testsuite/gas/rx/Xtod.d, * testsuite/gas/rx/abs.d,
	* testsuite/gas/rx/adc.d, * testsuite/gas/rx/add.d,
	* testsuite/gas/rx/and.d, * testsuite/gas/rx/bclr.d,
	* testsuite/gas/rx/bcnd.d, * testsuite/gas/rx/bfmov.d,
	* testsuite/gas/rx/bmcnd.d, * testsuite/gas/rx/bnot.d,
	* testsuite/gas/rx/bra.d, * testsuite/gas/rx/brk.d,
	* testsuite/gas/rx/bset.d, * testsuite/gas/rx/bsr.d,
	* testsuite/gas/rx/btst.d, * testsuite/gas/rx/clrpsw.d,
	* testsuite/gas/rx/cmp.d, * testsuite/gas/rx/dabs.d,
	* testsuite/gas/rx/dadd.d, * testsuite/gas/rx/dbt.d,
	* testsuite/gas/rx/dcmp.d, * testsuite/gas/rx/ddiv.d,
	* testsuite/gas/rx/div.d, * testsuite/gas/rx/divu.d,
	* testsuite/gas/rx/dmov.d, * testsuite/gas/rx/dmul.d,
	* testsuite/gas/rx/dneg.d, * testsuite/gas/rx/dpopm.d,
	* testsuite/gas/rx/dpushm.d, * testsuite/gas/rx/dround.d,
	* testsuite/gas/rx/dsqrt.d, * testsuite/gas/rx/dsub.d,
	* testsuite/gas/rx/dtoX.d, * testsuite/gas/rx/emaca.d,
	* testsuite/gas/rx/emsba.d, * testsuite/gas/rx/emul.d,
	* testsuite/gas/rx/emula.d, * testsuite/gas/rx/emulu.d,
	* testsuite/gas/rx/fadd.d, * testsuite/gas/rx/fcmp.d,
	* testsuite/gas/rx/fdiv.d, * testsuite/gas/rx/fmul.d,
	* testsuite/gas/rx/fsqrt.d, * testsuite/gas/rx/fsub.d,
	* testsuite/gas/rx/ftoi.d, * testsuite/gas/rx/ftou.d,
	* testsuite/gas/rx/gprel.d, * testsuite/gas/rx/int.d,
	* testsuite/gas/rx/itof.d, * testsuite/gas/rx/jmp.d,
	* testsuite/gas/rx/jsr.d, * testsuite/gas/rx/machi.d,
	* testsuite/gas/rx/maclh.d, * testsuite/gas/rx/maclo.d,
	* testsuite/gas/rx/max.d, * testsuite/gas/rx/min.d,
	* testsuite/gas/rx/mov.d, * testsuite/gas/rx/movco.d,
	* testsuite/gas/rx/movli.d, * testsuite/gas/rx/movu.d,
	* testsuite/gas/rx/msbhi.d, * testsuite/gas/rx/msblh.d,
	* testsuite/gas/rx/msblo.d, * testsuite/gas/rx/mul.d,
	* testsuite/gas/rx/mulhi.d, * testsuite/gas/rx/mullh.d,
	* testsuite/gas/rx/mullo.d, * testsuite/gas/rx/mvfacgu.d,
	* testsuite/gas/rx/mvfachi.d, * testsuite/gas/rx/mvfaclo.d,
	* testsuite/gas/rx/mvfacmi.d, * testsuite/gas/rx/mvfc.d,
	* testsuite/gas/rx/mvfcp.d, * testsuite/gas/rx/mvfdc.d,
	* testsuite/gas/rx/mvfdr.d, * testsuite/gas/rx/mvtacgu.d,
	* testsuite/gas/rx/mvtachi.d, * testsuite/gas/rx/mvtaclo.d,
	* testsuite/gas/rx/mvtc.d, * testsuite/gas/rx/mvtcp.d,
	* testsuite/gas/rx/mvtdc.d, * testsuite/gas/rx/neg.d,
	* testsuite/gas/rx/nop.d, * testsuite/gas/rx/not.d,
	* testsuite/gas/rx/opecp.d, * testsuite/gas/rx/or.d,
	* testsuite/gas/rx/pop.d, * testsuite/gas/rx/popc.d,
	* testsuite/gas/rx/popm.d, * testsuite/gas/rx/push.d,
	* testsuite/gas/rx/pushc.d, * testsuite/gas/rx/pushm.d,
	* testsuite/gas/rx/r-bcc.d, * testsuite/gas/rx/r-bra.d,
	* testsuite/gas/rx/racl.d, * testsuite/gas/rx/racw.d,
	* testsuite/gas/rx/rdacl.d, * testsuite/gas/rx/rdacw.d,
	* testsuite/gas/rx/revl.d, * testsuite/gas/rx/revw.d,
	* testsuite/gas/rx/rmpa.d, * testsuite/gas/rx/rolc.d,
	* testsuite/gas/rx/rorc.d, * testsuite/gas/rx/rotl.d,
	* testsuite/gas/rx/rotr.d, * testsuite/gas/rx/round.d,
	* testsuite/gas/rx/rstr.d, * testsuite/gas/rx/rte.d,
	* testsuite/gas/rx/rtfi.d, * testsuite/gas/rx/rts.d,
	* testsuite/gas/rx/rtsd.d, * testsuite/gas/rx/sat.d,
	* testsuite/gas/rx/satr.d, * testsuite/gas/rx/save.d,
	* testsuite/gas/rx/sbb.d, * testsuite/gas/rx/sccnd.d,
	* testsuite/gas/rx/scmpu.d, * testsuite/gas/rx/setpsw.d,
	* testsuite/gas/rx/shar.d, * testsuite/gas/rx/shll.d,
	* testsuite/gas/rx/shlr.d, * testsuite/gas/rx/smovb.d,
	* testsuite/gas/rx/smovf.d, * testsuite/gas/rx/smovu.d,
	* testsuite/gas/rx/sstr.d, * testsuite/gas/rx/stnz.d,
	* testsuite/gas/rx/stz.d, * testsuite/gas/rx/sub.d,
	* testsuite/gas/rx/suntil.d, * testsuite/gas/rx/swhile.d,
	* testsuite/gas/rx/tst.d, * testsuite/gas/rx/utof.d,
	* testsuite/gas/rx/wait.d, * testsuite/gas/rx/xchg.d,
	* testsuite/gas/rx/xor.d: Add #source line.
ld/
	* testsuite/ld-elf/sec64k.exp: Use . rather than $objdir in
	generated source file names.
	* testsuite/ld-m68k/m68k-got.exp: Likewise.
2019-01-08 18:50:54 +10:30
Alan Modra 827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
Alan Modra d5c04e1bf8 ChangeLog rotation 2019-01-01 21:25:40 +10:30
Alan Modra 8fd04a4255 PR24042, Global-buffer-overflow problem in output_rel_find
place_orphan handled ELF SHT_REL/SHT_RELA specially, output_rel_find
didn't.  This mismatch was a bug and also meant it was possible to
craft an object where ld accessed section->name out of bounds.

	PR 24042
	* emultempl/elf32.em (output_rel_find): Drop "sec" param.  Add
	"rela".
	(gld${EMULATION_NAME}_place_orphan): Use sh_type to calculate
	"rela" param of output_rel_find when ELF.  Tidy uses of elfinput.
2018-12-31 17:56:32 +10:30
H.J. Lu b9519cfe98 x86: Properly handle PLT expression in directive
For PLT expressions, we should subtract the PLT relocation size only for
jump instructions.  Since PLT relocations are PC relative, we only allow
"symbol@PLT" in PLT expression.

gas/

	PR gas/23997
	* config/tc-i386.c (x86_cons): Check for invalid PLT expression.
	(md_apply_fix): Subtract the PLT relocation size only for jump
	instructions.
	* testsuite/gas/i386/reloc32.s: Add test for invalid PLT
	expression.
	* testsuite/gas/i386/reloc64.s: Likewise.
	* testsuite/gas/i386/ilp32/reloc64.s: Likewise.
	* testsuite/gas/i386/reloc32.l: Updated.
	* testsuite/gas/i386/reloc64.l: Likewise.
	* testsuite/gas/i386/ilp32/reloc64.l: Likewise.

ld/

	PR gas/23997
	* testsuite/ld-i386/i386.exp: Run PR gas/23997 test.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-x86-64/pr23997a.s: New file.
	* testsuite/ld-x86-64/pr23997b.c: Likewise.
	* testsuite/ld-x86-64/pr23997c.c: Likewise.
2018-12-19 12:22:12 -08:00
H.J. Lu fc999e8020 Rename PR ld/22842 run-time test to "Run pr22842"
* testsuite/ld-x86-64/x86-64.exp: Rename PR ld/22842 run-time
	test to "Run pr22842".
2018-12-19 11:51:08 -08:00
H.J. Lu 0a59decbb8 elf: Add PT_GNU_PROPERTY segment type
Linkers group input note sections with the same name into one output
note section with the same name.  One output note section is placed in
one PT_NOTE segment.  New linkers merge all input .note.gnu.property
sections into one output .note.gnu.property section with a single
NT_GNU_PROPERTY_TYPE_0 note in a single PT_NOTE segment.  Since older
linkers treat input .note.gnu.property section as a generic note section
and just concatenate all input .note.gnu.property sections into one
output .note.gnu.property section without merging them, we may
see one or more NT_GNU_PROPERTY_TYPE_0 notes in PT_NOTE segment, which
are invalid.

GNU_PROPERTY_X86_UINT32_VALID was defined to address this issue such
that linker sets the bit for non-relocatable outputs.  But it isn't
sufficient:

1. It doesn't cover generic properties.
2. When -mx86-used-note=yes is passed to x86 assembler, the
GNU_PROPERTY_X86_UINT32_VALID bit is set in GNU_PROPERTY_X86_ISA_1_USED
property in object file and older linkers generate invalid
NT_GNU_PROPERTY_TYPE_0 notes with the GNU_PROPERTY_X86_UINT32_VALID bit
set.

I am proposing the following changes:

1. Add PT_GNU_PROPERTY segment type:

 # define PT_GNU_PROPERTY (PT_LOOS + 0x474e553)

which covers .note.gnu.property section.
2. Remove GNU_PROPERTY_X86_UINT32_VALID.

bfd/

	PR ld/23900
	* elf.c (get_program_header_size): Add a PT_GNU_PROPERTY
	segment for NOTE_GNU_PROPERTY_SECTION_NAME.
	(_bfd_elf_map_sections_to_segments): Create a PT_GNU_PROPERTY
	segment for NOTE_GNU_PROPERTY_SECTION_NAME.
	* elfxx-x86.c (_bfd_elf_link_setup_gnu_properties): Don't set
	GNU_PROPERTY_X86_UINT32_VALID.

binutils/

	PR ld/23900
	* readelf.c (get_segment_type): Support PT_GNU_PROPERTY.
	(decode_x86_isa): Don't check GNU_PROPERTY_X86_UINT32_VALID.
	(decode_x86_feature_1): Likewise.
	(decode_x86_feature_2): Likewise.
	(print_gnu_property_note): Remove GNU_PROPERTY_X86_UINT32_VALID
	check.
	* testsuite/binutils-all/i386/empty.d: Updated.
	* testsuite/binutils-all/x86-64/empty-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/empty.d: Likewise.
	* testsuite/binutils-all/i386/pr21231b.s: Change
	GNU_PROPERTY_X86_ISA_1_USED bits to 0x7fffffff.
	* testsuite/binutils-all/x86-64/pr21231b.s: Likewise.

gas/

	PR ld/23900
	* config/tc-i386.c (x86_cleanup): Don't set
	GNU_PROPERTY_X86_UINT32_VALID.
	* testsuite/gas/i386/property-1.s: Change
	GNU_PROPERTY_X86_ISA_1_USED bits to 0.

include/

	PR ld/23900
	* elf/common.h (PT_GNU_PROPERTY): New.
	(GNU_PROPERTY_X86_UINT32_VALID): Removed.

ld/

	PR ld/23900
	* testsuite/ld-elf/elf.exp: Run PR ld/23900 test.
	* testsuite/ld-elf/pr23900-1-32.rd: New file.
	* testsuite/ld-elf/pr23900-1-64.rd: Likewise.
	* testsuite/ld-elf/pr23900-1.d: Likewise.
	* testsuite/ld-elf/pr23900-1.s: Likewise.
	* testsuite/ld-elf/pr23900-2.s: Likewise.
	* testsuite/ld-elf/pr23900-2a.d: Likewise.
	* testsuite/ld-elf/pr23900-2b.d: Likewise.
	* testsuite/ld-i386/ibt-plt-1.d: Adjusted.
	* testsuite/ld-i386/ibt-plt-2c.d: Likewise.
	* testsuite/ld-i386/ibt-plt-2d.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3d.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-1.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2c.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2c.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3c.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d.d: Likewise.
	* testsuite/ld-i386/pr23372c.d: Expect <None>
	for GNU_PROPERTY_X86_ISA_1_USED.
	* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372c.d: Likewise.
	* testsuite/ld-x86-64/pr23372d-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372d.d: Likewise.
	* testsuite/ld-x86-64/property-x86-5a.s: Change
	GNU_PROPERTY_X86_ISA_1_USED bits to 0.
	* testsuite/ld-x86-64/property-x86-5b.s: Likewise.
2018-12-14 04:55:34 -08:00
H.J. Lu 550892eb5a Fix a typo in scripttempl/elf32xc16x.sc
* scripttempl/elf32xc16x.sc: Fix a typo.
2018-12-11 06:18:12 -08:00
H.J. Lu fbcc8bafeb Override the previous definition from IR object
Mark the previous definition from IR object as undefined so that the
generic linker will override it.

bfd/

	PR ld/23958
	* elflink.c (_bfd_elf_add_default_symbol): Override the previous
	definition from IR object.

ld/

	PR ld/23958
	* testsuite/ld-plugin/lto.exp: Run PR ld/23958 test.
	* testsuite/ld-plugin/pr23958.c: New file.
	* testsuite/ld-plugin/pr23958.t: Likewise.
2018-12-07 15:40:02 -08:00
H.J. Lu d2ef37ebd9 elf: Report property change when merging properties
With merging properties, report property change in linker map file, like

Merging program properties

Removed property 0xc0010000 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (0x0) and /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crti.o (0x0)
Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (0x3) and x.o (not found)
Removed property 0xc0000000 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (not found) and /usr/lib64/libc_nonshared.a(elf-init.oS) (0x0)
Removed property 0xc0000001 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (not found) and /usr/lib64/libc_nonshared.a(elf-init.oS) (0x0)

bfd/

	* elf-properties.c (elf_find_and_remove_property): Add a
	bfd_boolean argument to indicate if the property should be
	removed.
	(elf_merge_gnu_property_list): Updated.  Report
	property change in linker map file.
	(elf_get_gnu_property_section_size): Skip property_remove
	properties.
	(elf_write_gnu_properties): Likewise.
	(_bfd_elf_link_setup_gnu_properties): Report property merge
	in linker map file.  Pass abfd to elf_merge_gnu_property_list.

include/

	* bfdlink.h (bfd_link_info): Add has_map_file.

ld/

	* NEWS: Updated for property change report.
	* ld.texi: Document property change report.
	* ldmain.c (main): Set link_info.has_map_file to TRUE when
	linker map file is used.
	* testsuite/ld-scripts/rgn-over1.d: Updated.
	* testsuite/ld-scripts/rgn-over2.d: Likewise.
	* testsuite/ld-scripts/rgn-over3.d: Likewise.
	* testsuite/ld-scripts/rgn-over4.d: Likewise.
	* testsuite/ld-scripts/rgn-over5.d: Likewise.
	* testsuite/ld-scripts/rgn-over6.d: Likewise.
	* testsuite/ld-scripts/rgn-over7.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Check linker map
	file.
	* testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a.map: New file.
2018-12-07 08:30:43 -08:00
H.J. Lu fde51dd189 x86: Don't remove empty GNU_PROPERTY_X86_UINT32_OR_AND properties
For GNU_PROPERTY_X86_COMPAT_ISA_1_USED and GNU_PROPERTY_X86_UINT32_OR_AND
properties, a bit in the output pr_data field is set if it is set in any
relocatable input pr_data fields and this property is present in all
relocatable input files.  A missing property implies that its bits have
unknown values.  When all bits in the the output pr_data field are zero,
this property should not be removed from output to indicate it has zero
in all bits.

bfd/

	PR ld/23372
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Don't remove
	empty properties for GNU_PROPERTY_X86_COMPAT_ISA_1_USED and
	GNU_PROPERTY_X86_UINT32_OR_AND.
	(_bfd_x86_elf_link_fixup_gnu_properties): Likewise.

ld/

	PR ld/23372
	* testsuite/ld-i386/pr23372a.d: Updated.
	* testsuite/ld-i386/pr23372c.d: Likewise.
	* testsuite/ld-x86-64/pr23372a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372a.d: Likewise.
	* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372c.d: Likewise.
2018-12-04 06:01:14 -08:00
H.J. Lu b44ee3a8cf x86: Delay setting the iplt section alignment
Delay setting its alignment until we know it is non-empty.  Otherwise an
empty iplt section may change vma and lma of the following sections, which
triggers moving dot of the following section backwards, resulting in a
warning and section lma not being set properly.  It later leads to a
"File truncated" error.

bfd/

	PR ld/23930
	* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Update
	the iplt section alignment if it is non-empty.
	(_bfd_x86_elf_link_setup_gnu_properties): Set plt.iplt_alignment
	and delay setting the iplt section alignment.
	* elfxx-x86.h (elf_x86_plt_layout): Add iplt_alignment.

ld/

	PR ld/23930
	* testsuite/ld-i386/i386.exp: Run pr23930.
	* testsuite/ld-i386/pr23930.d: New file.
	* testsuite/ld-x86-64/pr23930-32.t: Likewise.
	* testsuite/ld-x86-64/pr23930-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23930.d: Likewise.
	* testsuite/ld-x86-64/pr23930.t: Likewise.
	* testsuite/ld-x86-64/pr23930a.s: Likewise.
	* testsuite/ld-x86-64/pr23930b.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr23930 and pr23930-x32.
2018-12-01 06:35:03 -08:00
Alan Modra ba85c15dab PR23937, powerpc64le local ifunc IRELATIVE relocs are wrong
IFUNC resolvers must always be called via their global entry point.
They will be called from ld.so rather than from the local executable.

	PR 23937
bfd/
	* elf64-ppc.c (write_plt_relocs_for_local_syms): Don't add local
	entry offset for ifuncs.
ld/
	* testsuite/ld-powerpc/pr23937.d,
	* testsuite/ld-powerpc/pr23937.s: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run it.
2018-11-30 16:18:58 +10:30
Thomas Preud'homme e368bf56d3 Document purpose of each ld statement lists
When discovering the statement lists via their header variable
statement_list, file_chain and input_file_chain it can be confusing to
figure out what they are for. They can point to the same initial
statement and the relation between the next field they use is not
obvious from the name.

This commit adds comment for each of those statement list header to
explain what they are for and what next field they use. It also rewrite
the comment for the next fields to simply redirect the reader to the
list header to avoid duplication of documentation.

2018-11-29  Thomas Preud'homme  <thomas.preudhomme@linaro.org>

ld/
	* ldlang.c (statement_list): Document purpose and what next field it
	uses.
	(file_chain): Likewise.
	(input_file_chain): Likewise.
	* ldlang.h (lang_statement_header_type): Document statement list header
	the next pointer correspond to.
	(lang_statement_header_type): Replace comment for next and
	next_real_file field to refer the reader to their corresponding
	statement list header.
2018-11-29 13:42:49 +00:00
Maciej W. Rozycki 3c7687b9cd MIPS/LD: Accept high-part relocations in PIC code with absolute symbols
Accept R_MIPS_HI16, R_MIPS_HIGHER and R_MIPS_HIGHEST relocations and
their compressed counterparts in PIC code where the symbol referred is
absolute.  Such an operation is meaningful, because an absolute symbol
effectively is a constant the calculation of the value of which has been
deferred to the static link time, and which is not going to change any
further at the dynamic load time.  Therefore there is no need ever to
refuse the use of these relocations with such symbols, as the resulting
run-time value observed by the program will be correct even in PIC code.

This is not the case with R_MIPS_26 and its compressed counterparts,
because the run-time value calculated by the instructions these
relocations are used with depends on the address of the instruction
itself, and that can change according to the base address used by the
dynamic loader.  Therefore these relocations have to continue being
rejected in PIC code even with absolute symbols.

This allows successful linking of code that relies on previous linker
behavior up to commit 861fb55ab5 ("Defer allocation of R_MIPS_REL32
GOT slots"), <https://sourceware.org/ml/binutils/2008-08/msg00096.html>,
which introduced the problematic check missing this special exception
for absolute symbols.

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_check_relocs) <R_MIPS16_HI16>
	<R_MIPS_HI16, R_MIPS_HIGHER, R_MIPS_HIGHEST, R_MICROMIPS_HI16>
	<R_MICROMIPS_HIGHER, R_MICROMIPS_HIGHEST>: Also accept an
	absolute symbol in PIC code.

	ld/
	* testsuite/ld-mips-elf/pic-reloc-0.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-1.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-2.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-3.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-4.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-absolute-hi.ld: New test
	linker script.
	* testsuite/ld-mips-elf/pic-reloc-absolute-lo.ld: New test
	linker script.
	* testsuite/ld-mips-elf/pic-reloc-ordinary.ld: New test linker
	script.
	* testsuite/ld-mips-elf/pic-reloc-j.s: New test source.
	* testsuite/ld-mips-elf/pic-reloc-lui.s: New test source.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2018-11-27 16:34:03 +00:00
Maciej W. Rozycki a5990ada63 LD: Convert `%P: %H:' to `%H:' in error messages
Similarly to commit 174d0a74a2 ("PowerPC/BFD: Convert `%P: %H:' to
`%H:' in error messages") convert linker relocation error messages to
use `%H:' rather `%P: %H:', removing inconsistent message composition
like:

$ cat reloc-j.s
	.text
	.globl	foo
	.ent	foo
foo:
	j	bar
	j	bar
	.end	foo
$ cat reloc-j.ld
SECTIONS
{
  bar = 0x12345678;
  .text : { *(.text) }
  /DISCARD/ : { *(*) }
}
$ as -o reloc-j.o reloc-j.s
$ ld -T reloc-j.ld -o reloc-j reloc-j.o
ld: tmpdir/reloc-j.o: in function `foo':
(.text+0x0): relocation truncated to fit: R_MIPS_26 against `bar'
ld: (.text+0x8): relocation truncated to fit: R_MIPS_26 against `bar'
$

where subsequent lines referring to issues within a single function have
the name of the linker executable prepended, but the first one does not.

As noted with the commit referred this breaks a GNU Coding Standard's
requirement that error messages from compilers should look like this:

source-file-name:lineno: message

also quoted in `vfinfo' code handling these specifiers.

Remove the linker name prefix then, making the messages now look like:

$ ld -T reloc-j.ld -o reloc-j reloc-j.o
tmpdir/reloc-j.o: in function `foo':
(.text+0x0): relocation truncated to fit: R_MIPS_26 against `bar'
(.text+0x8): relocation truncated to fit: R_MIPS_26 against `bar'
$

instead.

	ld/
	* ldmain.c (reloc_overflow): Use `%H:' rather than `%P: %H:'
	with `einfo'.
	(reloc_dangerous): Likewise.
	(unattached_reloc): Likewise.
2018-11-27 16:34:03 +00:00
Tamar Christina 9fca35fc34 AArch64: Fix regression in Cortex A53 erratum when PIE. (PR ld/23904)
The fix for PR ld/22263 causes TLS relocations using ADRP to be relaxed
into MOVZ, however this causes issues for the erratum code.

The erratum code scans the input sections looking for ADRP instructions
and notes their location in the stream.

It then later tries to find them again in order to generate the linker
stubs.  Due to the relaxation it instead finds a MOVZ and hard aborts.

Since this relaxation is a valid one, and in which case the erratum no
longer applies, it shouldn't abort but instead just continue.

This changes the TLS relaxation code such that when it finds an ADRP and
it relaxes it, it removes the erratum entry from the work list by changing
the stub type into none so the stub is ignored.

The entry is not actually removed as removal is a more expensive operation
and we have already allocated the memory anyway.

The clearing is done for IE->LE and GD->LE relaxations, and a testcase is
added for the IE case. The GD case I believe to be impossible to get together
with the erratum sequence due to the required BL which would break the sequence.
However to cover all basis I have added the guard there as well.

build on native hardware and regtested on
  aarch64-none-elf, aarch64-none-elf (32 bit host),
  aarch64-none-linux-gnu, aarch64-none-linux-gnu (32 bit host)

Cross-compiled and regtested on
  aarch64-none-linux-gnu, aarch64_be-none-linux-gnu

Testcase in PR23940 tested and works as expected now and benchmarks ran on A53
showing no regressions and no issues.

bfd/ChangeLog:

	PR ld/23904
	* elfnn-aarch64.c (_bfd_aarch64_adrp_p): Use existing constants.
	(_bfd_aarch64_erratum_843419_branch_to_stub): Use _bfd_aarch64_adrp_p.
	(struct erratum_835769_branch_to_stub_clear_data): New.
	(_bfd_aarch64_erratum_843419_clear_stub): New.
	(clear_erratum_843419_entry): New.
	(elfNN_aarch64_tls_relax): Use it.
	(elfNN_aarch64_relocate_section): Pass input_section.
	(aarch64_map_one_stub): Handle branch type none as valid.

ld/ChangeLog:

	PR ld/23904
	* testsuite/ld-aarch64/aarch64-elf.exp: Add erratum843419_tls_ie.
	* testsuite/ld-aarch64/erratum843419_tls_ie.d: New test.
	* testsuite/ld-aarch64/erratum843419_tls_ie.s: New test.
2018-11-27 12:42:22 +00:00
Nick Clifton 81c688d54f (Another) Updated Spanish translation for the ld subdirectory.
* po/es.po: Updated Spanish translation.
2018-11-16 11:36:08 +00:00
Nick Clifton 92b3642af0 Updated Spanish translation for the ld subdirectory.
ld	* po/es.po: Updated Spanish translation.
2018-11-15 11:55:24 +00:00
H.J. Lu f77984e974 i386: Accept both .plt.got and .plt.sec sections
Glibc commit:

commit a15529fda8d132621328c3fe32997a3d9c55aef4
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon May 14 09:23:55 2018 -0700

    i386: Replace PREINIT_FUNCTION@PLT with *%eax in call

    Since we have loaded address of PREINIT_FUNCTION into %eax, we can
    avoid extra branch to PLT slot.

changed __gmon_start__ relocations in crt1.o from

00000015  0000092b R_386_GOT32X           00000000   __gmon_start__
0000001e  00000904 R_386_PLT32            00000000   __gmon_start__

to

00000015  00000a2b R_386_GOT32X           00000000   __gmon_start__

As the result, .plt.sec section may be generated instead of .plt.got
section, depending on __gmon_start__ relocations.

	* testsuite/ld-i386/plt-main-ibt.dd: Accept both .plt.got and
	.plt.sec sections.
2018-11-12 09:29:49 -08:00
Nick Clifton 8a758655b3 Update documentation describing how the linker chooses a start address.
PR 10865
	* ld.texi (Entry Point): Make it clear that the text refers to
	PE-based systems rather than just a PE system.
2018-11-12 15:12:15 +00:00
Nick Clifton d1b603a74e Updated Spanish translation for the ld subdirectory.
ld	* po/es.po: Updated Spanish translation.
2018-11-12 11:24:18 +00:00
Nick Clifton fda57deda7 Updated French translation for the ld subdirectory.
* po/fr.po: Updated French translation.
2018-11-09 14:18:02 +00:00
Claudiu Zissulescu 0d0b0a378e [ARC] Update ld tests.
ld/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* testsuite/ld-arc/tls_gd-01.d: Update test.
	* testsuite/ld-arc/arclinux-nps.d: Add cpu option.
2018-11-09 13:24:29 +02:00
Marc 73af69e749 Allow for compilers that do not produce aligned .rdat sections in PE format files.
PR 23872
	* scripttempl/pep.sc (pe.sc): Ensure rdata_runtime_pseudo_relocs
	are aligned.
	* scripttempl/pep.sc (pep.sc): Likewise.
2018-11-09 11:13:50 +00:00
H.J. Lu 8a6b075bc0 elfedit: Add --enable-x86-feature/--disable-x86-feature
Add --enable-x86-feature and --disable-x86-feature options to elfedit
to set and clear the IBT and SHSTK bits in program property in ELF
executables and shared objects.

binutils/

	* doc/binutils.texi: Document --enable-x86-feature and
	--disable-x86-feature options for elfedit.
	* elfedit.c: Include "config.h" and <sys/mman.h>.
	(enable_x86_features): New.
	(disable_x86_features): Likewise.
	(update_gnu_property): Likewise.
	(elf_x86_feature): Likewise.
	(process_file): Call update_gnu_property on ET_EXEC or ET_DYN
	file.
	(command_line_switch): Add OPTION_ENABLE_X86_FEATURE and
	OPTION_DISABLE_X86_FEATURE.
	(options): Add--enable-x86-feature and --disable-x86-feature.
	(usage): Likewise.
	(main): Handle OPTION_ENABLE_X86_FEATURE and
	OPTION_DISABLE_X86_FEATURE.

ld/

	* testsuite/config/default.exp (ELFEDIT): New.
	* testsuite/ld-elf/linux-x86.exp (elfedit_test): New proc.
	Run elfedit tests.
	* testsuite/ld-elf/x86-feature-1a.rd: New file.
	* testsuite/ld-elf/x86-feature-1b.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1c.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1d.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1e.rd: Likewise.
2018-11-06 09:38:51 -08:00
H.J. Lu a4749e56ca Correct ChangeLog entries for PR gas/23854 commit
commit e60f4d3bda
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Nov 5 09:01:26 2018 -0800

    x86: Disable GOT relaxation with data prefix

    Since linker GOT relaxation isn't valid for 16-bit GOT access, we should
    disable GOT relaxation with data prefix.
2018-11-05 11:13:30 -08:00
H.J. Lu e60f4d3bda x86: Disable GOT relaxation with data prefix
Since linker GOT relaxation isn't valid for 16-bit GOT access, we should
disable GOT relaxation with data prefix.

gas/

	PR gas/r23854
	* config/tc-i386.c (output_disp): Disable GOT relaxation with
	data prefix.
	* testsuite/gas/i386/mixed-mode-reloc32.d: Updated.

ld/

	PR gas/r23854
	* testsuite/ld-i386/i386.exp: Run pr23854.
	* testsuite/ld-x86-64/x86-64.exp: Likewwise.
	* testsuite/ld-i386/pr23854.d: New file.
	* testsuite/ld-i386/pr23854.s: Likewwise.
	* testsuite/ld-i386/pr23854.d: Likewwise.
	* testsuite/ld-x86-64/pr23854.d: Likewwise.
	* testsuite/ld-x86-64/pr23854.s: Likewwise.
2018-11-05 09:01:43 -08:00
Thomas Preud'homme 33ea299c25 Fix ld action in run_dump_test
run_dump_test proposes an ld action but when trying to make use of it in
a gas test it gave me some Tcl error. It turns out that it references
the check_shared_lib_support procedure and ld_elf_shared_opt variable
both only available in ld-lib.exp. I've thus moved the procedure in
binutils-common.exp and defined the variable needed in the various
default.exp of testsuite that seem to be using run_dump_test.

Since check_shared_lib_support itself references the ld variable not
defined in binutils-common I've defined it from LD in run_dump_test and
fixed LD and LDFLAGS to be defined as expected by run_dump_test in the
various default.exp of testsuite using run_dump_test.

2018-11-01  Thomas Preud'homme  <thomas.preudhomme@linaro.org>

binutils/
	* testsuite/config/default.exp: Define LD, LDFLAGS and
	ld_elf_shared_opt.
	* testsuite/lib/binutils-common.exp (check_shared_lib_support): Moved
	from ld-lib.exp.
	(run_dump_test): Set ld to $LD.

gas/
	* testsuite/config/default.exp: Define LD, LDFLAGS and
	ld_elf_shared_opt.

ld/
	* testsuite/lib/ld-lib.exp (check_shared_lib_support): Moved to
	binutils-common.exp.
2018-11-01 17:19:17 +00:00
Alan Modra 727a29badd Report scripts and libraries searched for ld --trace
The idea of this change is to make -t output useful for users wanting
to package all the object files involved in linking for a bug report.

Something like the following should do the trick.
gcc hello.c -save-temps -Wl,-t | xargs realpath | sort | uniq > files
tar cJf test.tar.xz `cat files`

	* ldlang.c (load_symbols): When -t, print file names for script
	files and archives.
	* ldmain.c (trace_files): Make an int.
	(add_archive_element): Print archive elements only with multiple
	-t options, or when archive is thin.
	* ldmain.h (trace_files): Update.
	* ldmisc.c (vfinfo): Don't print both original path and path in
	sysroot.
	* lexsup.c (parse_args <t>): Increment trace_files.
2018-10-29 18:21:05 +10:30
Alan Modra 5c87f94bb8 Remove some ld --trace output
This output really belongs in ld --verbose.

	* ldmain.c (main): Print emulation mode and "deleting executable"
	for --verbose, not --trace.
	(add_archive_element): Only print "no new IR symbols" for --verbose.
2018-10-29 18:21:05 +10:30
Alan Modra 55d5520ae3 Simplify --sysroot=/
Prepending '/' to absolute paths doesn't gain us much, and results in
the current implementation of --trace emitting silly path-in-sysroot
output, eg.
/lib/ld-linux-x86-64.so.2 (//lib/ld-linux-x86-64.so.2)

	* ldmain.c (get_sysroot): Return "" for "--sysroot=/".
2018-10-29 18:21:05 +10:30
Alan Modra c2e863866d ld -r script fixes
For ld -r, we generally set the VMA of sections to zero.  This is done
to make the output of ld -r most similar to that output by the
assembler, which generally has sections starting at VMA zero.  In some
cases that covers for backend bugs which would mis-handle relocatable
object files with non-zero section VMAs.

This patch fixes a few sections that didn't have zero VMAs for ld -r.
A missing zero on .note.gnu.build-id and .eh_frame_hdr doesn't matter
much since these are linker generated symbols only output on final
link, but it's good to be consistent.

	* Makefile.am (ei386beos.c, ei386go32.c): Correct dependencies.
	* Makefile.in: Regenerate.
	* scripttempl/elf.sc (.note.gnu.build-id, .eh_frame_hdr): Set
	address with ${RELOCATING-0}.
	* scripttempl/arclinux.sc: Likewise.
	* scripttempl/armbpabi.sc: Likewise.
	* scripttempl/avr.sc: Likewise.
	* scripttempl/elf64hppa.sc: Likewise.
	* scripttempl/elf_chaos.sc: Likewise.
	* scripttempl/elfarc.sc: Likewise.
	* scripttempl/elfxtensa.sc: Likewise.
	* scripttempl/mep.sc: Likewise.
	* scripttempl/nds32elf.sc: Likewise.
	* scripttempl/pru.sc: Likewise.
	* scripttempl/elf32msp430.sc: Likewise, and for other sections.
	* scripttempl/epiphany_4x4.sc: Similarly.
2018-10-29 17:50:40 +10:30
Christoph Conrads b69e1ff350 ELF: update ld man page on `--gc-sections`
Commit 91ae256e33 fixes the behavior of ld when `--gc-sections` and
`--gc-keep-exported` are both given on the linker command line.  This
updates the ld documentation to suit.

	* ld.texi (--gc-sections): Update.
2018-10-26 09:01:36 +10:30
H.J. Lu 0a640d7196 ELF: Hide symbols defined in discarded input sections
When assigning symbol version, we should hide debug symbols defined in
discarded sections from IR objects so that they can be removed later.

bfd/

	PR ld/23818
	* elflink.c (_bfd_elf_link_assign_sym_version): Hide symbols
	defined in discarded input sections.

ld/

	PR ld/23818
	* testsuite/ld-plugin/lto.exp: Run PR ld/23818 test.
	* testsuite/ld-plugin/pr23818.d: New file.
	* testsuite/ld-plugin/pr23818.t: Likewise.
	* testsuite/ld-plugin/pr23818a.c: Likewise.
	* testsuite/ld-plugin/pr23818b.c: Likewise.
2018-10-24 18:08:24 -07:00
Alan Modra 8e3152af14 alpha testsuite fixes
Fixes a couple of ERROR results due to .set difference on alpha.

	* testsuite/ld-elf/shared.exp: Don't build pr19073 test on alpha.
	* testsuite/ld-elf/pr18720b.c: Don't use .set on alpha.
2018-10-23 21:09:09 +10:30
Alan Modra 91ae256e33 Relax a -r --gc-sections requirement
A symbol root is not needed if --gc-keep-exported is also given.

	* ldlang.c (lang_end): Don't error if no --entry or --undefined
	is given with -r -gc-sections if --gc-keep-exported.
2018-10-20 19:46:43 +10:30