1. 14 Jan, 2019 3 commits
    • Nick Clifton's avatar
      Correct PR number in prevvious delta · f466c305
      Nick Clifton authored
      f466c305
    • Maamoun Tarsha's avatar
      Add support to GNU ld to separate got related plt entries from normal ones in... · 5a12586d
      Maamoun Tarsha authored
      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.
      5a12586d
    • Sebastian Huber's avatar
      ld: Clarify --wrap documentation · 4ea904ed
      Sebastian Huber authored
      ld/
      
      	* ld.texi (--wrap): Add example to emphasise that only undefined
      	references are replaced by the linker.
      4ea904ed
  2. 09 Jan, 2019 2 commits
    • Nick Clifton's avatar
      Updated Spanish translation for the ld sub-directory. · 8379fac6
      Nick Clifton authored
      	* po/es.po: Updated Spanish translation.
      8379fac6
    • Andrew Paprocki's avatar
      Adjust bfd/warning.m4 egrep patterns · 3107326d
      Andrew Paprocki authored
      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.
      3107326d
  3. 08 Jan, 2019 1 commit
    • Alan Modra's avatar
      run_dump_test source in build directory · 171b8e19
      Alan Modra authored
      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.
      171b8e19
  4. 01 Jan, 2019 2 commits
  5. 31 Dec, 2018 1 commit
    • Alan Modra's avatar
      PR24042, Global-buffer-overflow problem in output_rel_find · 8fd04a42
      Alan Modra authored
      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.
      8fd04a42
  6. 19 Dec, 2018 2 commits
    • H.J. Lu's avatar
      x86: Properly handle PLT expression in directive · b9519cfe
      H.J. Lu authored
      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.
      b9519cfe
    • H.J. Lu's avatar
      Rename PR ld/22842 run-time test to "Run pr22842" · fc999e80
      H.J. Lu authored
      	* testsuite/ld-x86-64/x86-64.exp: Rename PR ld/22842 run-time
      	test to "Run pr22842".
      fc999e80
  7. 14 Dec, 2018 1 commit
    • H.J. Lu's avatar
      elf: Add PT_GNU_PROPERTY segment type · 0a59decb
      H.J. Lu authored
      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.
      0a59decb
  8. 11 Dec, 2018 1 commit
  9. 07 Dec, 2018 2 commits
    • H.J. Lu's avatar
      Override the previous definition from IR object · fbcc8baf
      H.J. Lu authored
      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.
      fbcc8baf
    • H.J. Lu's avatar
      elf: Report property change when merging properties · d2ef37eb
      H.J. Lu authored
      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.
      d2ef37eb
  10. 04 Dec, 2018 1 commit
    • H.J. Lu's avatar
      x86: Don't remove empty GNU_PROPERTY_X86_UINT32_OR_AND properties · fde51dd1
      H.J. Lu authored
      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.
      fde51dd1
  11. 01 Dec, 2018 1 commit
    • H.J. Lu's avatar
      x86: Delay setting the iplt section alignment · b44ee3a8
      H.J. Lu authored
      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.
      b44ee3a8
  12. 30 Nov, 2018 1 commit
    • Alan Modra's avatar
      PR23937, powerpc64le local ifunc IRELATIVE relocs are wrong · ba85c15d
      Alan Modra authored
      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.
      ba85c15d
  13. 29 Nov, 2018 1 commit
    • Thomas Preud'homme's avatar
      Document purpose of each ld statement lists · e368bf56
      Thomas Preud'homme authored
      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.
      e368bf56
  14. 27 Nov, 2018 3 commits
    • Maciej W. Rozycki's avatar
      MIPS/LD: Accept high-part relocations in PIC code with absolute symbols · 3c7687b9
      Maciej W. Rozycki authored
      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 861fb55a ("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.
      3c7687b9
    • Maciej W. Rozycki's avatar
      LD: Convert `%P: %H:' to `%H:' in error messages · a5990ada
      Maciej W. Rozycki authored
      Similarly to commit 174d0a74 ("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.
      a5990ada
    • Tamar Christina's avatar
      AArch64: Fix regression in Cortex A53 erratum when PIE. (PR ld/23904) · 9fca35fc
      Tamar Christina authored
      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.
      9fca35fc
  15. 16 Nov, 2018 1 commit
  16. 15 Nov, 2018 1 commit
  17. 12 Nov, 2018 3 commits
    • H.J. Lu's avatar
      i386: Accept both .plt.got and .plt.sec sections · f77984e9
      H.J. Lu authored
      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.
      f77984e9
    • Nick Clifton's avatar
      Update documentation describing how the linker chooses a start address. · 8a758655
      Nick Clifton authored
      	PR 10865
      	* ld.texi (Entry Point): Make it clear that the text refers to
      	PE-based systems rather than just a PE system.
      8a758655
    • Nick Clifton's avatar
      Updated Spanish translation for the ld subdirectory. · d1b603a7
      Nick Clifton authored
      ld	* po/es.po: Updated Spanish translation.
      d1b603a7
  18. 09 Nov, 2018 3 commits
  19. 06 Nov, 2018 1 commit
    • H.J. Lu's avatar
      elfedit: Add --enable-x86-feature/--disable-x86-feature · 8a6b075b
      H.J. Lu authored
      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.
      8a6b075b
  20. 05 Nov, 2018 2 commits
    • H.J. Lu's avatar
      Correct ChangeLog entries for PR gas/23854 commit · a4749e56
      H.J. Lu authored
      commit e60f4d3b
      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.
      a4749e56
    • H.J. Lu's avatar
      x86: Disable GOT relaxation with data prefix · e60f4d3b
      H.J. Lu authored
      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.
      e60f4d3b
  21. 01 Nov, 2018 1 commit
    • Thomas Preud'homme's avatar
      Fix ld action in run_dump_test · 33ea299c
      Thomas Preud'homme authored
      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.
      33ea299c
  22. 29 Oct, 2018 4 commits
    • Alan Modra's avatar
      Report scripts and libraries searched for ld --trace · 727a29ba
      Alan Modra authored
      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.
      727a29ba
    • Alan Modra's avatar
      Remove some ld --trace output · 5c87f94b
      Alan Modra authored
      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.
      5c87f94b
    • Alan Modra's avatar
      Simplify --sysroot=/ · 55d5520a
      Alan Modra authored
      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=/".
      55d5520a
    • Alan Modra's avatar
      ld -r script fixes · c2e86386
      Alan Modra authored
      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.
      c2e86386
  23. 25 Oct, 2018 2 commits
    • Christoph Conrads's avatar
      ELF: update ld man page on `--gc-sections` · b69e1ff3
      Christoph Conrads authored
      Commit 91ae256e 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.
      b69e1ff3
    • H.J. Lu's avatar
      ELF: Hide symbols defined in discarded input sections · 0a640d71
      H.J. Lu authored
      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.
      0a640d71