Commit Graph

4416 Commits

Author SHA1 Message Date
Alan Modra 0aa0727c8f PR25002, ld/ldelf.c missing safe-ctype.h include
PR 25002
	* ldelf.c: Include safe-ctype.h.
2019-09-16 23:51:48 +09:30
Phil Blundell bb6959602b Update version to 2.33.50 and regenerate configure scripts. 2019-09-16 11:03:53 +01:00
Alan Modra 1f1f5b92e8 Always add input_statement to statement_list
I think this is safer than leaving an input_statement added during
open_input_bfds off the list.  There are a number of places that
fiddle with various lists and might be confused by an off-list
statement, eg. orphan handling.

	* ldlang.c (new_afile): Remove add_to_list parameter.
	(lang_add_input_file): Update new_afile calls.
	(lookup_name): Splice input_statement added by new_afile into
	statement_list after current input_file_chain entry.
	(lang_process): Update comment.
2019-09-13 12:43:42 +09:30
Alan Modra 0d41d9a2aa LOAD in linker map file
For some reason, commit 906e58cab5 2008-05-15 excluded input
statements with BFD_LINKER_CREATED BFDs from being printed to map
files.  This isn't ideal since it loses claimed plugin BFDs.

	* ldlang.c (print_input_statement): Do not exclude linker created
	BFDs.
2019-09-12 22:46:25 +09:30
Alan Modra a19826f4c4 PR24981, Hit assertion failure in ld/ldlang.c:7504
This fixes a problem with commit 128bf1fe60, a patch I made
2019-08-06.   Apparently it is possible to trigger the assertion I
added during an LTO bootstrap, something I haven't reproduced.
However, I did find a case triggered by an odd linker script feature
that allows a file to be loaded from the script without specifying
that file on the command line.  Regarding input sections:
  "When you use a file name which is not an archive:file specifier
   and does not contain any wild card characters, the linker will
   first see if you also specified the file name on the linker command
   line or in an INPUT command.  If you did not, the linker will
   attempt to open the file as an input file, as though it appeared on
   the command line."

So putting
  .foo : { foo.a(*) }
into a script supposedly extracts foo.a into .foo.  Except it doesn't,
since this feature is meant for object files only.  Well anyway,
assuming --whole-archive was given on the command line, foo.a contains
a -flto object and no other objects involved were -flto then we'll hit
the assert due to files added like foo.a here *not* having their input
statement put on the general statement list.  Why these are not put on
the statement list isn't obvious but it has been that way since commit
193c5f93a1 in 1994.

	PR 24981
	* ldlang.c (lang_process): Remove assertion.  Comment.
2019-09-12 21:45:25 +09:30
Alan Modra 075a2b89c7 Rename elf32.em to elf.em
* emultempl/elf32.em: Remove "misnamed" comment.  Rename to..
	* emultempl/elf.em: ..this.
	* configure.ac (elf_list_options): Adjust TEMPLATE_NAME grep.
	* emulparams/aarch64cloudabi.sh (TEMPLATE_NAME): Set to elf.
	* emulparams/aarch64elf.sh: Likewise.
	* emulparams/aarch64elf32.sh: Likewise.
	* emulparams/aarch64fbsd.sh: Likewise.
	* emulparams/aarch64linux.sh: Likewise.
	* emulparams/aarch64linux32.sh: Likewise.
	* emulparams/arcelf.sh: Likewise.
	* emulparams/arcelf_prof.sh: Likewise.
	* emulparams/arclinux.sh: Likewise.
	* emulparams/arclinux_prof.sh: Likewise.
	* emulparams/arcv2elf.sh: Likewise.
	* emulparams/arcv2elfx.sh: Likewise.
	* emulparams/armelf.sh: Likewise.
	* emulparams/armelf_fuchsia.sh: Likewise.
	* emulparams/armelf_linux.sh: Likewise.
	* emulparams/armelf_phoenix.sh: Likewise.
	* emulparams/armnto.sh: Likewise.
	* emulparams/avr1.sh: Likewise.
	* emulparams/avr2.sh: Likewise.
	* emulparams/avr25.sh: Likewise.
	* emulparams/avr3.sh: Likewise.
	* emulparams/avr31.sh: Likewise.
	* emulparams/avr35.sh: Likewise.
	* emulparams/avr4.sh: Likewise.
	* emulparams/avr5.sh: Likewise.
	* emulparams/avr51.sh: Likewise.
	* emulparams/avr6.sh: Likewise.
	* emulparams/avrtiny.sh: Likewise.
	* emulparams/avrxmega1.sh: Likewise.
	* emulparams/avrxmega2.sh: Likewise.
	* emulparams/avrxmega3.sh: Likewise.
	* emulparams/avrxmega4.sh: Likewise.
	* emulparams/avrxmega5.sh: Likewise.
	* emulparams/avrxmega6.sh: Likewise.
	* emulparams/avrxmega7.sh: Likewise.
	* emulparams/criself.sh: Likewise.
	* emulparams/crislinux.sh: Likewise.
	* emulparams/cskyelf.sh: Likewise.
	* emulparams/d10velf.sh: Likewise.
	* emulparams/elf32_sparc.sh: Likewise.
	* emulparams/elf32_spu.sh: Likewise.
	* emulparams/elf32_tic6x_le.sh: Likewise.
	* emulparams/elf32_x86_64.sh: Likewise.
	* emulparams/elf32am33lin.sh: Likewise.
	* emulparams/elf32bfin.sh: Likewise.
	* emulparams/elf32bfinfd.sh: Likewise.
	* emulparams/elf32bmip.sh: Likewise.
	* emulparams/elf32bmipn32-defs.sh: Likewise.
	* emulparams/elf32cr16.sh: Likewise.
	* emulparams/elf32cr16c.sh: Likewise.
	* emulparams/elf32crx.sh: Likewise.
	* emulparams/elf32epiphany.sh: Likewise.
	* emulparams/elf32epiphany_4x4.sh: Likewise.
	* emulparams/elf32frvfd.sh: Likewise.
	* emulparams/elf32ip2k.sh: Likewise.
	* emulparams/elf32lm32.sh: Likewise.
	* emulparams/elf32lm32fd.sh: Likewise.
	* emulparams/elf32lriscv-defs.sh: Likewise.
	* emulparams/elf32m32c.sh: Likewise.
	* emulparams/elf32mb_linux.sh: Likewise.
	* emulparams/elf32mbel_linux.sh: Likewise.
	* emulparams/elf32mcore.sh: Likewise.
	* emulparams/elf32mep.sh: Likewise.
	* emulparams/elf32metag.sh: Likewise.
	* emulparams/elf32microblaze.sh: Likewise.
	* emulparams/elf32mipswindiss.sh: Likewise.
	* emulparams/elf32or1k.sh: Likewise.
	* emulparams/elf32ppccommon.sh: Likewise.
	* emulparams/elf32rl78.sh: Likewise.
	* emulparams/elf32rx.sh: Likewise.
	* emulparams/elf32tilegx.sh: Likewise.
	* emulparams/elf32tilepro.sh: Likewise.
	* emulparams/elf32vax.sh: Likewise.
	* emulparams/elf32visium.sh: Likewise.
	* emulparams/elf32xc16x.sh: Likewise.
	* emulparams/elf32xc16xl.sh: Likewise.
	* emulparams/elf32xc16xs.sh: Likewise.
	* emulparams/elf32xstormy16.sh: Likewise.
	* emulparams/elf32xtensa.sh: Likewise.
	* emulparams/elf64_aix.sh: Likewise.
	* emulparams/elf64_ia64.sh: Likewise.
	* emulparams/elf64_s390.sh: Likewise.
	* emulparams/elf64_sparc.sh: Likewise.
	* emulparams/elf64alpha.sh: Likewise.
	* emulparams/elf64bpf.sh: Likewise.
	* emulparams/elf64hppa.sh: Likewise.
	* emulparams/elf64mmix.sh: Likewise.
	* emulparams/elf64rdos.sh: Likewise.
	* emulparams/elf64tilegx.sh: Likewise.
	* emulparams/elf_i386.sh: Likewise.
	* emulparams/elf_i386_be.sh: Likewise.
	* emulparams/elf_i386_ldso.sh: Likewise.
	* emulparams/elf_i386_vxworks.sh: Likewise.
	* emulparams/elf_iamcu.sh: Likewise.
	* emulparams/elf_k1om.sh: Likewise.
	* emulparams/elf_l1om.sh: Likewise.
	* emulparams/elf_s390.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.
	* emulparams/h8300elf.sh: Likewise.
	* emulparams/h8300elf_linux.sh: Likewise.
	* emulparams/hppa64linux.sh: Likewise.
	* emulparams/hppaelf.sh: Likewise.
	* emulparams/hppalinux.sh: Likewise.
	* emulparams/i386lynx.sh: Likewise.
	* emulparams/i386moss.sh: Likewise.
	* emulparams/i386nto.sh: Likewise.
	* emulparams/m32relf.sh: Likewise.
	* emulparams/m32relf_linux.sh: Likewise.
	* emulparams/m68hc11elf.sh: Likewise.
	* emulparams/m68hc11elfb.sh: Likewise.
	* emulparams/m68hc12elf.sh: Likewise.
	* emulparams/m68hc12elfb.sh: Likewise.
	* emulparams/m68kelf.sh: Likewise.
	* emulparams/mn10300.sh: Likewise.
	* emulparams/nds32elf.sh: Likewise.
	* emulparams/nds32elf16m.sh: Likewise.
	* emulparams/nds32elf_linux.sh: Likewise.
	* emulparams/nios2elf.sh: Likewise.
	* emulparams/nios2linux.sh: Likewise.
	* emulparams/pruelf.sh: Likewise.
	* emulparams/score3_elf.sh: Likewise.
	* emulparams/shelf.sh: Likewise.
	* emulparams/shelf_nto.sh: Likewise.
	* emulparams/shelf_vxworks.sh: Likewise.
	* emulparams/shlelf_linux.sh: Likewise.
	* emulparams/shlelf_nto.sh: Likewise.
	* emulparams/v850.sh: Likewise.
	* emulparams/v850_rh850.sh: Likewise.
	* ldelf.c: Update comment.
	* ldelf.h: Likewise.
	* emultempl/aarch64elf.em: Likewise.
	* emultempl/alphaelf.em: Likewise.
	* emultempl/arclinux.em: Likewise.
	* emultempl/armelf.em: Likewise.
	* emultempl/avrelf.em: Likewise.
	* emultempl/bfin.em: Likewise.
	* emultempl/cr16elf.em: Likewise.
	* emultempl/crxelf.em: Likewise.
	* emultempl/cskyelf.em: Likewise.
	* emultempl/elf-generic.em: Likewise.
	* emultempl/elf-x86.em: Likewise.
	* emultempl/epiphanyelf_4x4.em: Likewise.
	* emultempl/hppaelf.em: Likewise.
	* emultempl/ia64elf.em: Likewise.
	* emultempl/m68hc1xelf.em: Likewise.
	* emultempl/m68kelf.em: Likewise.
	* emultempl/metagelf.em: Likewise.
	* emultempl/mmix-elfnmmo.em: Likewise.
	* emultempl/mmixelf.em: Likewise.
	* emultempl/mmo.em: Likewise.
	* emultempl/needrelax.em: Likewise.
	* emultempl/nios2elf.em: Likewise.
	* emultempl/ppc32elf.em: Likewise.
	* emultempl/ppc64elf.em: Likewise.
	* emultempl/pruelf.em: Likewise.
	* emultempl/rxelf.em: Likewise.
	* emultempl/scoreelf.em: Likewise.
	* emultempl/spuelf.em: Likewise.
	* emultempl/tic6xdsbt.em: Likewise.
	* emultempl/v850elf.em: Likewise.
	* emultempl/vms.em: Likewise.
	* emultempl/vxworks.em: Likewise.
	* emultempl/xtensaelf.em: Likewise.
	* scripttempl/arclinux.sc: Likewise.
	* scripttempl/armbpabi.sc: Likewise.
	* scripttempl/elf.sc: Likewise.
	* scripttempl/elf64bpf.sc: Likewise.
	* scripttempl/elf64hppa.sc: Likewise.
	* scripttempl/elf_chaos.sc: Likewise.
	* scripttempl/elfarc.sc: Likewise.
	* scripttempl/elfarcv2.sc: Likewise.
	* scripttempl/elfd10v.sc: Likewise.
	* scripttempl/elfm68hc11.sc: Likewise.
	* scripttempl/elfm68hc12.sc: Likewise.
	* scripttempl/elfm9s12z.sc: Likewise.
	* scripttempl/elfxgate.sc: Likewise.
	* scripttempl/elfxtensa.sc: Likewise.
	* scripttempl/epiphany_4x4.sc: Likewise.
	* scripttempl/iq2000.sc: Likewise.
	* scripttempl/mep.sc: Likewise.
	* scripttempl/nds32elf.sc: Likewise.
	* scripttempl/v850.sc: Likewise.
	* scripttempl/v850_rh850.sc: Likewise.
	* scripttempl/xstormy16.sc: Likewise.
	* testsuite/ld-arm/arm-dyn.ld: Likewise.
	* testsuite/ld-arm/arm-lib.ld: Likewise.
	* testsuite/ld-arm/arm-no-rel-plt.ld: Likewise.
	* testsuite/ld-arm/fdpic-main.ld: Likewise.
	* testsuite/ld-arm/fdpic-shared.ld: Likewise.
	* testsuite/ld-elf/elf.exp: Likewise.
	* testsuite/ld-elf/orphan-region.d: Likewise.
	* testsuite/ld-elf/orphan.d: Likewise.
	* testsuite/ld-elf/pr349.d: Likewise.
	* testsuite/ld-elf/warn2.d: Likewise.
	* testsuite/ld-elfvsb/elf-offset.ld: Likewise.
	* testsuite/ld-mips-elf/mips-dyn.ld: Likewise.
	* testsuite/ld-mips-elf/mips-lib.ld: Likewise.
	* testsuite/ld-scripts/dynamic-sections.t: Likewise.
	* testsuite/ld-shared/elf-offset.ld: Likewise.
	* configure: Regenerate.
2019-09-11 13:45:18 +09:30
Alan Modra d871d47806 Move elf32.em and elf-generic.em functions
Many ELF linker targets support multiple "emulations" and thus have
multiple copies of elf32.em being compiled and linked into ld.  This
patch moves much of elf32.em and elf-generic.em into files which will
be compiled just once, resulting in a 20% decrease in ld size for
--enable-targets=all.

	* Makefile.am (ALL_EMUL_EXTRA_OFILES): Add ldelf and ldelfgen.
	(CFILES, HFILES, EXTRA_ld_new_SOURCES): Likewise.
	* configure.tgt: Formatting.
	(targ_extra_ofiles): Init to ldelf.o ldelfgen.o, reset to just
	ldelfgen.o for generic ELF targets, and empty for non-ELF.
	* emultempl/aarch64elf.em (gldaarch64_layout_sections_again): Use
	ldelf_map_segments.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, aarch64_for_each_input_file_wrapper),
	(aarch64_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/alphaelf.em (alpha_after_parse): Use ldelf_map_segments.
	* emultempl/armelf.em (gldarm_layout_sections_again): Likewise.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, arm_for_each_input_file_wrapper),
	(arm_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/cr16elf.em (cr16elf_after_parse): Use ldelf_map_segments.
	* emultempl/crxelf.em (crxelf_after_parse): Likewise.  Delete
	declaration.
	* emultempl/cskyelf.em (gldcsky_layout_sections_again): Use
	ldelf_map_segments.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, csky_for_each_input_file_wrapper),
	(csky_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/genelf.em: Include ldelfgen.h.
	(gld${EMULATION_NAME}_before_allocation): Use ldelf_map_segments.
	* emultempl/hppaelf.em (hppaelf_after_parse): Likewise.
	(hppaelf_layout_sections_again): Likewise.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, hppa_for_each_input_file_wrapper),
	(hppa_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/ia64elf.em (ia64elf_after_parse): Use ldelf_map_segments.
	* emultempl/m68hc1xelf.em (real_func),
	(m68hc11_for_each_input_file_wrapper),
	(m68hc11_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/metagelf.em (metagelf_layout_sections_again): Use
	ldelf_map_segments.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, metag_for_each_input_file_wrapper),
	(metag_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/mipself.em (real_func),
	(mips_for_each_input_file_wrapper),
	(mips_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/mmo.em: Don't include elf-bfd.h, do include ldelfgen.h.
	(gld${EMULATION_NAME}_after_allocation): Use ldelf_map_segments.
	* emultempl/nds32elf.em (nds32_elf_after_parse): Use ldelf_after_parse.
	(nds32_elf_after_allocation): Comment fix.
	* emultempl/nios2elf.em (nios2elf_layout_sections_again): Use
	ldelf_map_segments.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, nios2_for_each_input_file_wrapper),
	(nios2_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/ppc32elf.em (gld${EMULATION_NAME}_load_symbols): Delete
	declaration.
	(ppc_recognized_file): Call ldelf_load_symbols.
	* emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, ppc_for_each_input_file_wrapper),
	(ppc_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	(gld${EMULATION_NAME}_load_symbols): Don't declare.
	(ppc64_recognized_file): Call ldelf_load_symbols.
	* emultempl/riscvelf.em (gld${EMULATION_NAME}_after_allocation):
	Use ldelf_map_segments.
	* emultempl/spuelf.em (spu_place_special_section): Use
	ldelf_place_orphan.
	* emultempl/tic6xdsbt.em (gld${EMULATION_NAME}_after_allocation):
	Use ldelf_map_segments.
	* emultempl/vms.em: Include ldelfgen.h.
	(gld${EMULATION_NAME}_after_allocation): Use ldelf_map_segments.
	* emultempl/elf32.em: Remove unnecessary headers, include ldelf.h
	and ldelfgen.h.  Move much of file content to..
	* ldelf.c: ..here.  New file.
	* ldelf.h: New file.
	* emultempl/elf-generic.em: Move gld${EMULATION_NAME}_map_segments..
	* ldelfgen.c: ..to here.
	* ldelfgen.h: New file.
	* ldlang.c (lang_for_each_input_file): Adjust to only call func
	on real files.
	(lang_for_each_file): Likewise.
	* po/SRC-POTFILES.in: Regenerate.
	* Makefile.in: Regenerate.
2019-09-11 13:44:22 +09:30
Alan Modra cb7f4b298e Tidy ld/ldmisc.c
The idea here is to not use elf-bfd.h and coff-bfd.h in generic linker
code.

bfd/
	* targets.c (struct bfd_target): Add _bfd_group_name.
	(BFD_JUMP_TABLE): Likewise.
	* coffgen.c (bfd_coff_group_name): New function.
	* elf.c (bfd_elf_group_name): New function.
	* linker.c (_bfd_nolink_bfd_group_name): New function.
	* section.c (bfd_generic_group_name): New function.
	* elf-bfd.h (bfd_elf_group_name): Declare.
	* libbfd-in.h (_bfd_nolink_bfd_group_name): Declare.
	* libcoff-in.h (bfd_coff_group_name): Declare.
	* aout-target.h (MY_bfd_group_name): Define.
	* aout-tic30.c (MY_bfd_group_name): Define.
	* bfd.c (bfd_group_name): Define.
	* binary.c (binary_bfd_group_name): Define.
	* coff-alpha.c (_bfd_ecoff_bfd_group_name): Define.
	* coff-mips.c (_bfd_ecoff_bfd_group_name): Define.
	* coff-rs6000.c (_bfd_xcoff_bfd_group_name): Define.
	* coffcode.h (coff_bfd_group_name): Define.
	* elfxx-target.h (bfd_elfNN_bfd_group_name): Define.
	* i386msdos.c (msdos_bfd_group_name): Define.
	* ihex.c (ihex_bfd_group_name): Define.
	* mach-o-target.c (bfd_mach_o_bfd_group_name): Define.
	* mmo.c (mmo_bfd_group_name): Define.
	* pef.c (bfd_pef_bfd_group_name): Define.
	* plugin.c (bfd_plugin_bfd_group_name): Define.
	* ppcboot.c (ppcboot_bfd_group_name): Define.
	* som.c (som_bfd_group_name): Define.
	* srec.c (srec_bfd_group_name): Define.
	* tekhex.c (tekhex_bfd_group_name): Define.
	* verilog.c (verilog_bfd_group_name): Define.
	* vms-alpha.c (vms_bfd_group_name, alpha_vms_bfd_group_name): Define.
	* xsym.c (bfd_sym_bfd_group_name): Define.
	* coff64-rs6000.c (rs6000_xcoff64_vec): Init new field.
	(rs6000_xcoff64_aix_vec): Likewise.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
ld/
	* ldmisc.c: Don't #include elf-bfd.h or coff-bfd.h.
	(vfinfo): Use bfd_group_name.
2019-09-11 13:43:29 +09:30
Alan Modra 0410b45003 Tidy ld/plugin.c
* plugin.c (asymbol_from_plugin_symbol): Move code handling
	ELF common symbols to block handling ELF visibility.  Simplify
	visibility setting.
2019-09-11 13:24:41 +09:30
H.J. Lu 6715fe29ff i386: Adjust for new output format from readelf
PR binutils/24887
	* testsuite/ld-i386/property-1.r: Adjust for new output format
	from readelf.
	* testsuite/ld-i386/property-1a.r: Likewise.
	* testsuite/ld-i386/property-2.r: Likewise.
	* testsuite/ld-i386/property-2a.r: Likewise.
	* testsuite/ld-i386/property-3.r: Likewise.
	* testsuite/ld-i386/property-3a.r: Likewise.
	* testsuite/ld-i386/property-4.r: Likewise.
	* testsuite/ld-i386/property-4a.r: Likewise.
	* testsuite/ld-i386/property-5.r: Likewise.
	* testsuite/ld-i386/property-5a.r: Likewise.
	* testsuite/ld-i386/property-6.r: Likewise.
	* testsuite/ld-i386/property-7.r: Likewise.
	* testsuite/ld-i386/property-7a.r: Likewise.
	* testsuite/ld-i386/property-1.r: Likewise.
	* testsuite/ld-i386/property-1a.r: Likewise.
	* testsuite/ld-i386/property-2.r: Likewise.
	* testsuite/ld-i386/property-2a.r: Likewise.
	* testsuite/ld-i386/property-3.r: Likewise.
	* testsuite/ld-i386/property-3a.r: Likewise.
	* testsuite/ld-i386/property-4.r: Likewise.
	* testsuite/ld-i386/property-4a.r: Likewise.
	* testsuite/ld-i386/property-5.r: Likewise.
	* testsuite/ld-i386/property-5a.r: Likewise.
	* testsuite/ld-i386/property-6.r: Likewise.
	* testsuite/ld-i386/property-7.r: Likewise.
	* testsuite/ld-i386/property-7a.r: Likewise.
2019-09-09 09:21:36 -07:00
Phil Blundell 60391a255b Add markers for 2.33 branch to NEWS and ChangeLog files. 2019-09-09 10:27:40 +01:00
Alan Modra f5c3a9e305 beos.em qsort predicate tidy
lang_input_section_type** is better than lang_statement_union_type**
here since that is in fact the type passed to the qsort predicate,
and I think it's worth factoring out the common indirections.

	* emultempl/beos.em (sort_by_file_name): Use appropriate
	intermediary variables.
	(sort_by_section_name): Likewise.
2019-09-06 12:55:37 +09:30
Alan Modra b16c44debc bfd_get_filename
This macro says:
/* Cast from const char * to char * so that caller can assign to
   a char * without a warning.  */

I reckon that isn't such a good idea since it can result in char*
variables where const char* is appropriate.  Not very many places
need the char* cast.

bfd/
	* aout-target.h (object_p): Formatting.
	* bfd-in.h (bfd_get_filename): Don't cast to char*.
	* corefile.c (generic_core_file_matches_executable_p): Constify
	variables and remove cast.
	* bfd-in2.h: Regenerate.
binutils/
	* nm.c (print_object_filename_bsd, print_object_filename_sysv),
	(print_object_filename_posix, print_archive_filename_bsd),
	(print_archive_filename_sysv, print_archive_filename_posix),
	(print_archive_member_bsd, print_archive_member_sysv),
	(print_archive_member_posix): Constify parameter.
	(struct output_fns <print_object_filename, print_archive_filename>),
	(<print_archive_member>): Likewise.
	* objcopy.c (copy_archive): Add cast for make_tempdir.
ld/
	* emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Constify
	variable.
	* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise.
	* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
gdb/
	* coffread.c (coff_symfile_read): Constify filename variable.
	* dbxread.c (dbx_symfile_init, coffstab_build_psymtabs),
	(elfstab_build_psymtabs, stabsect_build_psymtabs): Likewise.
	* gdb_bfd.c (gdb_bfd_close_or_warn): Likewise.
	* solib.c (reload_shared_libraries_1): Likewise.
	* symfile.c (reread_symbols): Likewise.
	* solib-aix.c (solib_aix_bfd_open): Add cast for xfree of filename.
	* solib-darwin.c (darwin_bfd_open): Likewise.
	* symfile-mem.c (symbol_file_add_from_memory): Likewise.
sim/cris/
	* sim-if.c (sim_open): Constify filename variable.
2019-09-06 12:22:59 +09:30
Eric Botcazou de07a74580 Fix PR ld/24574
This restores a line that has been dropped when the auto-import feature
of the PE-COFF linker was overhauled about one year.  It is necessary
for GDB to properly resolve extern symbol in DLLs.

ld/ChangeLog
	* pe-dll.c (pe_find_data_imports): Replace again the original name
	of the undefined symbol with the __imp_ prefixed one after it is
	resolved.
2019-09-05 18:23:37 +02:00
Alan Modra 77486630b1 R_PPC64_PCREL_OPT
The loads and stores handled in the second instruction of a sequence
marked by R_PPC64_PCREL_OPT may be a prefix instruction.  For example:
 pld ra,symbol@got@pcrel
0:
 pld rt,off(ra)
 .reloc 0b-8,R_PPC64_PCREL_OPT,(.-8)-(0b-8)
can be optimised to
 pld rt,symbol+off@pcrel
 pnop

	* elf64-ppc.c (xlate_pcrel_opt): Handle prefix loads and stores
	in second instruction.
	(ppc64_elf_relocate_section): Likewise.
2019-09-05 13:56:20 +09:30
Alan Modra a78fca7b57 Segfault in ld building SPEC CPU2017 527.cam4_r with -flto
Caused by the PR24406 fix.  unwrap_hash_lookup shouldn't be called
with link_info.wrap_hash NULL.

	PR ld/24406
	* plugin.c (get_symbols): Test link_info.wrap_hash before calling
	unwrap_hash_lookup.
2019-08-29 00:33:49 +09:30
Tamar Christina 652afeef24 AArch64: Fix LD crash on weak and undefined TLS symbols. (PR/24602).
This patch fixes a few linker crashes due to TLS code reaching an assert when it
shouldn't.

The first scenario is with weak TLS symbols that remain weak during linking.  In
this case the mid-end would not have seen a TLS symbol and so wouldn't have
allocated the TLS section.  We currently assert here and the linker crashes with
a not very useful message.

This patch changes this to return the value 0 for the TLS symbol in question
emulating what lld and gold and other BFD targets do.  However because weak TLS
is implementation defined and we don't define any behavior for it I also emit a
warning to the user to inform them of such.

Secondly when a strong TLS reference is undefined. The linker crashes even after
it correctly reported that there is an undefined reference.  This changes it so
that it gracefully exits and reports a useful error.

bfd/ChangeLog:

	PR ld/24601
	* elfnn-aarch64.c (aarch64_relocate): Handle weak TLS and undefined TLS.
	Also Pass input_bfd to _bfd_aarch64_elf_resolve_relocation.
	* elfxx-aarch64.c (_bfd_aarch64_elf_resolve_relocation): Use it.
	* elfxx-aarch64.h (_bfd_aarch64_elf_resolve_relocation): Emit warning
	for weak TLS.

ld/ChangeLog:

	PR ld/24601
	* testsuite/ld-aarch64/aarch64-elf.exp (undef-tls, weak-tls): New.
	* testsuite/ld-aarch64/undef-tls.d: New test.
	* testsuite/ld-aarch64/undef-tls.s: New test.
	* testsuite/ld-aarch64/weak-tls.d: New test.
	* testsuite/ld-aarch64/weak-tls.s: New test.
2019-08-22 11:43:15 +01:00
Tamar Christina b4e87f2c1e Arm: Fix performance issue with thumb-2 tailcalls
We currently use a padding NOP after a Thumb to Arm interworking veneer (BX pc).
The NOP is never executed but may result in a performance penalty on some cores.

For this reason this patch changes the NOPs after Thumb to Arm veneers into B .-2
and adds a note to this in the source code for future reference.

bfd/ChangeLog:

	* elf32-arm.c (elf32_thumb2_plt_entry, elf32_arm_plt_thumb_stub,
	elf32_arm_stub_long_branch_v4t_thumb_thumb,
	elf32_arm_stub_long_branch_v4t_thumb_arm,
	elf32_arm_stub_short_branch_v4t_thumb_arm,
	elf32_arm_stub_long_branch_v4t_thumb_arm_pic,
	elf32_arm_stub_long_branch_v4t_thumb_thumb_pic,
	elf32_arm_stub_long_branch_v4t_thumb_tls_pic): Change nop to branch to
	previous instruction.

ld/ChangeLog:

	* testsuite/ld-arm/cortex-a8-fix-b-plt.d: Update Testcase.
	* testsuite/ld-arm/cortex-a8-fix-b-rel-arm.d: Likewise.
	* testsuite/ld-arm/cortex-a8-fix-bcc-plt.d: Likewise.
	* testsuite/ld-arm/farcall-cond-thumb-arm.d: Likewise.
	* testsuite/ld-arm/farcall-mixed-app.d: Likewise.
	* testsuite/ld-arm/farcall-mixed-app2.d: Likewise.
	* testsuite/ld-arm/farcall-mixed-lib-v4t.d: Likewise.
	* testsuite/ld-arm/farcall-thumb-arm-pic-veneer.d: Likewise.
	* testsuite/ld-arm/farcall-thumb-arm-short.d: Likewise.
	* testsuite/ld-arm/farcall-thumb-arm.d: Likewise.
	* testsuite/ld-arm/farcall-thumb-thumb-pic-veneer.d: Likewise.
	* testsuite/ld-arm/farcall-thumb-thumb.d: Likewise.
	* testsuite/ld-arm/fix-arm1176-on.d: Likewise.
	* testsuite/ld-arm/ifunc-10.dd: Likewise.
	* testsuite/ld-arm/ifunc-2.dd: Likewise.
	* testsuite/ld-arm/ifunc-4.dd: Likewise.
	* testsuite/ld-arm/ifunc-6.dd: Likewise.
	* testsuite/ld-arm/ifunc-8.dd: Likewise.
	* testsuite/ld-arm/jump-reloc-veneers-long.d: Likewise.
	* testsuite/ld-arm/mixed-app.d: Likewise.
	* testsuite/ld-arm/thumb2-b-interwork.d: Likewise.
	* testsuite/ld-arm/tls-longplt.d: Likewise.
	* testsuite/ld-arm/tls-thumb1.d: Likewise.
2019-08-20 16:35:28 +01:00
H.J. Lu 81e8046dc0 x86-64: Move PIC check for PC-relative relocations back
commit 83924b3846
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Feb 5 18:45:23 2019 -0800

    x86-64: Restore PIC check for PCREL reloc against protected symbol

moved PIC check for PC-relative relocations to elf_x86_64_check_relocs.
Since linker defined symbols may not be processed at the time, we need
to move the check back to elf_x86_64_relocate_section.

bfd/

	PR ld/24905
	* elf64-x86-64.c (elf_x86_64_check_relocs): Move PIC check for
	PC-relative relocations back to ...
	(elf_x86_64_relocate_section): Here.

ld/

	PR ld/24905
	* testsuite/ld-x86-64/pr24905-x32.d: New file.
	* testsuite/ld-x86-64/pr24905.d: Likewise.
	* testsuite/ld-x86-64/pr24905.s: Likewise.
	* testsuite/ld-x86-64/pr24905.t: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr24905 and pr24905-x32.
2019-08-16 14:25:58 -07:00
Christophe Lyon fdfc8cf7f0 [ld] [arm] Add support for noinit section
2019-08-16  Christophe Lyon  <christophe.lyon@linaro.org>

	* emulparams/armelf.sh (OTHER_SECTIONS): Add support for noinit
	section.

Change-Id: Ib293f28cc5f21e9e9a13abf4d4e37f0a0eec41c0
2019-08-16 08:28:52 +00:00
Alan Modra 7df6aecc97 PowerPC gcc bootstrap fail with bss-plt
git commit 3e04d7655b introduced a bug by sizing output sections
earlier in ppc_before_allocation.  That meant PLT (and GOT) sizes were
not included when calculating total executable section sizes.

	* emultempl/ppc32elf.em (ppc_before_allocation): Force running
	prelim_size_sections before deciding whether branch trampolines
	might be needed.
2019-08-16 13:38:11 +09:30
Jim Wilson 080a488354 RISC-V: Fix lui relaxation issue with code at address 0.
This fixes a problem originally reported at
    https://github.com/riscv/riscv-binutils-gdb/issues/173

If you have code linked at address zero, you can have a lui instruction
loading a value 0x800 which gets relaxed to a c.lui which is valid (c.lui 0x1
followed by addi -0x800).  Relaxation can reduce the value below 0x800 at which
point the c.lui 0x0 is no longer valid.  We can fix this by converting the
c.lui to a c.li which can load 0.

	bfd/
	* elfnn-riscv.c (perform_relocation) <R_RISCV_RVC_LUI>: If
	RISCV_CONST_HIGH_PART (value) is zero, then convert c.lui instruction
	to c.li instruction, and use ENCODE_RVC_IMM to set value.

	ld/
	* testsuite/ld-riscv-elf/c-lui-2.d: New.
	* testsuite/ld-riscv-elf/c-lui-2.ld: New.
	* testsuite/ld-riscv-elf/c-lui-2.s: New.
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run the c-lui-2 test.
2019-08-15 12:01:13 -07:00
Alan Modra dc02848a69 Sort statement_enum and lang_statement_union
To make comparing the two easier.

	* ldlang.h (enum statement_enum): Sort.
	(union lang_statement_union): Sort.
2019-08-10 17:16:16 +09:30
Alan Modra 4cfbdbfd26 Delete unused ldlang.h structs
* ldlang.h (lang_common_statement_type): Delete.
	(lang_object_symbols_statement_type): Delete.
	(union lang_statement_union): Remove common_statement and
	object_symbols_statement.
2019-08-10 17:16:16 +09:30
Alan Modra 988de25b36 stat_alloc casts
Casts from a void* just clutter the source.

	* ldexp.c (exp_intop, exp_bigintop, exp_relop, exp_binop, exp_trinop),
	(exp_unop, exp_nameop, exp_assop, exp_assert): Remove casts of
	stat_alloc return value.
	* ldlang.c (new_statement, new_afile, sort_def_symbol),
	(lang_memory_region_lookup, lang_memory_region_alias),
	(ldlang_add_undef, ldlang_add_require_defined, insert_pad),
	(lang_add_gc_name, lang_new_phdr): Likewise.
	* lexsup.c (set_segment_start): Likewise.
2019-08-10 17:16:16 +09:30
Alan Modra 36983a93bb lang_input_statement_type next pointers
"next" and "next_real_file" in lang_input_statement_type always point
to another lang_input_statement_type, so it makes sense for these to
not be the generic lang_statement_union_type.  This patch also updates
a number of variables in ldlang.c for the same reason, and modifies
lang_statement_append to reduce the need for casts.

	* ldlang.h (lang_input_statement_type): Make next
	and next_real_file a lang_input_statement_type pointer.
	(lang_statement_append): Delete prototype.
	(LANG_FOR_EACH_INPUT_STATEMENT): Update for lang_input_statement_type
	change.
	* ldmain.c (add_archive_element): Likewise.
	* ldlang.c: Likewise throughout.
	(lang_statement_append): Make static.  Make element and field
	void pointers.  Remove casts in calls.
	(lang_check): Use a lang_input_statement_type pointer for "file".
	(find_rescan_insertion): Similarly for "iter" and return value.
	(lang_process): Similarly for "insert", "iter" and "temp".
	* emultempl/spuelf.em (embedded_spu_file): Likewise.
	* emultempl/aix.em (gld${EMULATION_NAME}_before_allocation): Expand
	lang_statment_append call.
2019-08-10 17:16:16 +09:30
Mihailo Stojanovic f16a9783c5 Add support for a MIPS specific .MIPS.xhash section.
This patch is a reimplementation of [1] which was submitted in 2015 by
Neil Schellenberger. Copyright issue was sorted out [2] last year.
It proposed a new section (.gnu.xhash) and related dynamic tag
(DT_GNU_XHASH). The new section would be virtually identical to the
existing .gnu.hash except for the translation table (xlat) which would
contain correct MIPS .dynsym indexes corresponding to the hashvals in
chains. This is because MIPS ABI imposes a different ordering on the
dynsyms than the one expected by the .gnu.hash section. Another addition
would be a leading word (ngnusyms) which would contain the number of
entries in the translation table.

  In this patch, the new section name and dynamic tag are changed to
reflect the fact that the section should be treated as MIPS-specific
(.MIPS.xhash and DT_MIPS_XHASH).

  This patch addresses the alignment issue as reported in [3], which is
caused by the leading word added to the .MIPS.xhash section. Leading word
is removed in this patch, and the number of entries in the translation
table is now calculated using DT_MIPS_SYMTABNO dynamic tag (this is
addressed by the corresponding glibc patch).

  Suggestions on coding style in [4] were taken into account. Existing
GNU hash testcase was covered, and another one was added in the MIPS
part of the testsuite.

  The other major change is reserving MIPS ABI version 5 for .MIPS.xhash,
marking the need of support for .MIPS.xhash in the dynamic linker (again,
addressed in the corresponding glibc patch). This is something which I
am not sure of, especially after reading [5]. I am confused on whether
this ABI version is reserved for IFUNC, or it can be used for this
purpose.

Already mentioned glibc patch is submitted at:
https://sourceware.org/ml/libc-alpha/2019-06/msg00456.html

[1] https://sourceware.org/ml/binutils/2015-10/msg00057.html
[2] https://sourceware.org/ml/binutils/2018-03/msg00025.html
[3] https://sourceware.org/ml/binutils/2016-01/msg00006.html
[4] https://sourceware.org/ml/binutils/2016-02/msg00097.html
[5] https://sourceware.org/ml/libc-alpha/2016-12/msg00853.html

ld      * emulparams/elf32bmip.sh: Add .MIPS.xhash section.
        * emulparams/elf32bmipn32-defs.sh: Add .MIPS.xhash section.
        * emulparams/elf64bmip-defs.sh: Add .MIPS.xhash section.
        * emultempl/mipself.em: Remove mips_after_parse function.
        * testsuite/ld-elf/hash.d: Update comment.
        * testsuite/ld-mips-elf/hash1.d: New test.
        * testsuite/ld-mips-elf/hash1.s: Ditto.
        * testsuite/ld-mips-elf/hash1a.d: Remove.
        * testsuite/ld-mips-elf/hash1b.d: Ditto.
        * testsuite/ld-mips-elf/hash1c.d: Ditto
        * testsuite/ld-mips-elf/hash2.d: New test.
        * testsuite/ld-mips-elf/mips-elf.exp: New tests.
        * testsuite/ld-mips-elf/start.s: New test.

bfd     * elf-bfd.h (struct elf_backend_data): New members.
        * elflink.c (_bfd_elf_link_create_dynamic_sections): Create
        .gnu.hash section if necessary.
        (struct collect_gnu_hash_codes): New member.
        (elf_gnu_hash_process_symidx): New function name.
        (elf_renumber_gnu_hash_syms): Ignore local and undefined
        symbols. Record xlat location for every symbol which should have
        a .MIPS.xhash entry.
        (bfd_elf_size_dynamic_sections): Add DT_GNU_HASH dynamic tag to
        dynamic section if necessary.
        (GNU_HASH_SECTION_NAME): New define.
        (bfd_elf_size_dynsym_hash_dynstr): Get .MIPS.xhash section.
        Update the section size info.
        * elfxx-mips.c (struct mips_elf_hash_sort_data): New members.
        (struct mips_elf_link_hash_entry): New member.
        (mips_elf_link_hash_newfunc): Initialize .MIPS.xhash translation
        table location.
        (mips_elf_sort_hash_table): Initialize the pointer to the
        .MIPS.xhash section.
        (mips_elf_sort_hash_table_f): Populate the .MIPS.xhash
        translation table entry with the symbol dynindx.
        (_bfd_mips_elf_section_from_shdr): Add SHT_MIPS_XHASH.
        (_bfd_mips_elf_fake_sections): Initialize .MIPS.xhash section
        info.
        (_bfd_mips_elf_create_dynamic_sections): Create .MIPS.xhash
        section.
        (_bfd_mips_elf_size_dynamic_sections): Add DT_MIPS_XHASH tag to
        dynamic section.
        (_bfd_mips_elf_finish_synamic_sections): Add DT_MIPS_XHASH.
        (_bfd_mips_elf_final_write_processing): Set .MIPS.xhash section
        sh_link info.
        (_bfd_mips_elf_get_target_dtag): Get DT_MIPS_XHASH tag.
        (MIPS_LIBC_ABI_XHASH): New ABI version enum value.
        (_bfd_mips_post_process_headers): Mark the ABI version as
        MIPS_LIBC_ABI_XHASH if there exists a .MIPS.xhash section,
        but not a .hash section.
        (_bfd_mips_elf_record_xhash_symbol): New function. Record a
        position in the translation table, associated with the hash
        entry.
        * elfxx-mips.h (literal_reloc_p): Define
        elf_backend_record_xhash_symbol backend hook.
        * elfxx-target.h: Initialize elf_backend_record_xhash_symbol
        backend hook.

include * elf/mips.h (SHT_GNU_XHASH): New define.
        (DT_GNU_XHASH): New define.

binutils * readelf.c (get_mips_dynamic_type): Return MIPS_XHASH dynamic type.
        (get_mips_section_type_name): Return MI{S_XHASH name string.
        (dynamic_section_mips_val): Initialize the .MIPS.xhash dynamic
        info.
        (process_symbol_table): Initialize the .MIPS.xhash section
        pointer. Adjust the readelf output to support the new section.
        (process_object): Set the .MIPS.xhash dynamic info to zero.
2019-08-09 11:06:37 +01:00
Nick Clifton dbe15e4e1d Change the output of readelf's note display so that the "Data size" column header is left justified.
PR 24887
binutils* readelf.c (process_notes_at): Left justify the "Data size"
	column heading.
	* testsuite/binutils-all/i386/empty.d: Adjust for new output format.
	* testsuite/binutils-all/i386/ibt.d: Likewise.
	* testsuite/binutils-all/i386/pr21231a.d: Likewise.
	* testsuite/binutils-all/i386/pr21231b.d: Likewise.
	* testsuite/binutils-all/i386/shstk.d: Likewise.
	* testsuite/binutils-all/note-2-32.d: Likewise.
	* testsuite/binutils-all/note-2-64.d: Likewise.
	* testsuite/binutils-all/x86-64/empty-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/empty.d: Likewise.
	* testsuite/binutils-all/x86-64/ibt-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/ibt.d: Likewise.
	* testsuite/binutils-all/x86-64/pr21231a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
	* testsuite/binutils-all/x86-64/shstk-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/shstk.d: Likewise.

ld	* testsuite/ld-aarch64/bti-plt-2.d: Adjust for new output format
	from readelf.
	* testsuite/ld-aarch64/bti-plt-4.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-6.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
	* testsuite/ld-aarch64/bti-warn.d: Likewise.
	* testsuite/ld-aarch64/property-bti-pac1.d: Likewise.
	* testsuite/ld-aarch64/property-bti-pac2.d: Likewise.
	* testsuite/ld-aarch64/property-bti-pac3.d: Likewise.
	* testsuite/ld-elf/x86-feature-1a.rd: Likewise.
	* 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.
	* testsuite/ld-i386/ibt-plt-2d.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3d.d: Likewise.
	* testsuite/ld-i386/pr23372a.d: Likewise.
	* testsuite/ld-i386/pr23372c.d: Likewise.
	* testsuite/ld-i386/pr23486a.d: Likewise.
	* testsuite/ld-i386/pr23486b.d: Likewise.
	* testsuite/ld-i386/pr23486c.d: Likewise.
	* testsuite/ld-i386/pr23486d.d: Likewise.
	* testsuite/ld-i386/pr24322a.d: Likewise.
	* testsuite/ld-i386/pr24322b.d: Likewise.
	* testsuite/ld-i386/property-x86-3.d: Likewise.
	* testsuite/ld-i386/property-x86-4a.d: Likewise.
	* testsuite/ld-i386/property-x86-5.d: Likewise.
	* testsuite/ld-i386/property-x86-cet1.d: Likewise.
	* testsuite/ld-i386/property-x86-cet2a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt1b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt2.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt4.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt5.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk1a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk1b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk2.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk4.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk5.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2d.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d.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.
	* testsuite/ld-x86-64/pr23486a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486a.d: Likewise.
	* testsuite/ld-x86-64/pr23486b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486b.d: Likewise.
	* testsuite/ld-x86-64/pr23486c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486c.d: Likewise.
	* testsuite/ld-x86-64/pr23486d-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486d.d: Likewise.
	* testsuite/ld-x86-64/pr24322a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24322a.d: Likewise.
	* testsuite/ld-x86-64/pr24322b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24322b.d: Likewise.
	* testsuite/ld-x86-64/pr24458a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458a.d: Likewise.
	* testsuite/ld-x86-64/pr24458b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458b.d: Likewise.
	* testsuite/ld-x86-64/pr24458c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458c.d: Likewise.
	* testsuite/ld-x86-64/property-1.r: Likewise.
	* testsuite/ld-x86-64/property-1a.r: Likewise.
	* testsuite/ld-x86-64/property-2.r: Likewise.
	* testsuite/ld-x86-64/property-2a.r: Likewise.
	* testsuite/ld-x86-64/property-3.r: Likewise.
	* testsuite/ld-x86-64/property-3a.r: Likewise.
	* testsuite/ld-x86-64/property-4.r: Likewise.
	* testsuite/ld-x86-64/property-4a.r: Likewise.
	* testsuite/ld-x86-64/property-5.r: Likewise.
	* testsuite/ld-x86-64/property-5a.r: Likewise.
	* testsuite/ld-x86-64/property-6.r: Likewise.
	* testsuite/ld-x86-64/property-7.r: Likewise.
	* testsuite/ld-x86-64/property-7a.r: Likewise.
	* testsuite/ld-x86-64/property-x86-3-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-3.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk5.d: Likewise.

gas	* testsuite/gas/i386/property-1.d: Adjust for new output format
	from readelf.
	* testsuite/gas/i386/property-2.d: Likewise.
	* testsuite/gas/i386/x86-64-property-1.d: Likewise.
	* testsuite/gas/i386/x86-64-property-2.d: Likewise.
2019-08-08 17:04:31 +01:00
Jose E. Marchesi fca8e23c31 ld: use a specific linker script in BPF targets
This patch makes the elf64bpf emulation to use it's own linker script,
based on elf.sc.  At the moment, the only change is that the BPF
executable doesn't define an entry symbol (BPF programs feature
several entry points scattered in several sections.)

This is a step towards the goal of generating proper ELF executables
that would be loaded by the kernel's libbpf.  We are not there yet:
BPF "programs" should still be linked with -r.

This change removes a warning while linking executables, decreases the
number of unsupported tests in the target from 47 to 29, and increases
the number of expected passes from 104 to 145.

Regtested in x86_64 for all targets.
No regressions.

ld/ChangeLog:

2019-08-07  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* scripttempl/elf64bpf.sc: Adapted from elf.sc.
	* emulparams/elf64bpf.sh (SCRIPT_NAME): Use elf64bpf.
	(EMBEDDED): Define.
	* testsuite/ld-bpf/call-1.d: Do not expect a warning regarding an
	undefined entry symbol.
	* testsuite/ld-bpf/jump-1.d: Likewise.
	* testsuite/ld-undefined/undefined.exp: Do not pass '-e entry' to
	ld in BPF targets, and do not expect line number information.
	* testsuite/ld-srec/srec.exp (run_srec_test): xfail s-record tests
	in BPF targets.
2019-08-07 13:57:30 +02:00
Alan Modra 128bf1fe60 LTO object insertion point
This is a mostly cosmetic fix for cases like PR24873 where LTO
recompiled objects were supposed to be inserted inside a group.  The
specific case handled by this patch is when the first file inside a
group is an archive, the first file claimed by the plugin.  Prior to
this patch we would have inserted the recompiled objects before the
group, which doesn't matter really since the entire group will be
reloaded, but it looks a little wrong in map files.

	PR 24873
	* ldlang.c (find_replacements_insert_point): Return "before" flag.
	(find_next_input_statement): New function.
	(lang_process): When placing recompiled LTO objects before a
	claimed archive, place them immediately before in the statement
	list.
2019-08-06 15:47:41 +09:30
Alan Modra b02c4f1623 PR24873, gcc -flto objects result in --start-group .. --end-group failure to include --as-needed libraries
Reloading of archives (and checking --as-needed DSOs again) is
disabled until we hit the plugin insert point.  It's necessary to do
that because in a case like lib1.a lto.o lib2.a where lib1.a and
lib2.a contain duplicate symbols, we want the lto.o recompiled object
to pull in objects from lib2.a as necessary, but not from lib1.a.
Unfortunately this heuristic fails when the insert point is inside a
group, because ld actually loads the symbols from the recompiled
object before running over the contours of the script, thus missing
the fact that new undefs appeared in the group.

	PR 24873
	* ldlang.c (plugin_undefs): New static var.
	(open_input_bfds <lang_group_statement_enum>): Loop on
	plugin_undefs and hitting plugin_insert point.
	(lang_process <lto_plugin_active>): Set plugin_undefs.
2019-08-06 15:37:08 +09:30
Alan Modra 1b611b2dc3 PowerPC tlsie test fix
* testsuite/ld-powerpc/tlsie.s: Correct medium model ELF sequence.
2019-08-02 12:41:05 +09:30
Alan Modra 776ab89fe3 PR24806, Linking with -T inside --start-group/--end-group
This patch processes INSERT AFTER and INSERT BEFORE in a user -T
script when such a script is invoked on the command line inside
--start-group/--end-group.  Also, ld now warns when the user simply
forgot --end-group.

	PR 24806
	* ldlang.c (process_insert_statements): Add start of list
	parameter.  Use rather than lang_os_list.head.  Process insert
	statements inside group statements with a recursive call.
	(lang_process): Adjust process_insert_statements call.
	* lexsup.c (parse_args): Warn when adding missing --end-group.
2019-08-01 14:38:57 +09:30
Alan Modra 5c1e6d53a5 Rename lang_output_section_statement to lang_os_list
The idea is to make it a little easier to find uses of this list,
so searches don't hit occurrences of lang_output_section_statement_type
and lang_output_section_statement_enum.

	* ldlang.h (lang_os_list): Rename from lang_output_section_statement.
	* ldlang.c: Likewise throughout file.
	* emultempl/alphaelf.em: Likewise.
	* emultempl/elf32.em: Likewise.
	* emultempl/mmo.em: Likewise.
	* emultempl/pe.em: Likewise.
	* emultempl/pep.em: Likewise.
	* emultempl/ppc32elf.em: Likewise.
	* emultempl/spuelf.em: Likewise.
2019-08-01 11:57:25 +09:30
Alan Modra 6e99a238f0 Ajdust lto-3r and lto-5r tests for powerpc64
* testsuite/ld-plugin/lto-3r.d: Accept D for powerpc64 descriptors.
	* testsuite/ld-plugin/lto-5r.d: Likewise.
2019-07-26 10:02:34 +09:30
H.J. Lu 8f79c1075e Revert "Remove tests that test __gnu_lto_v1 symbol."
Revert

commit 8c728a9d93
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Jul 22 14:23:32 2019 +0200

    Remove tests that test __gnu_lto_v1 symbol.

since outputs of these tests are used by later tests.  Check the normal
symbol, foo, instead of __gnu_lto_v.*, which GCC stopped emitting after
r273662.

	* testsuite/ld-plugin/lto-3r.d: Restored.  Check foo instead
	of __gnu_lto_v.*.
	* testsuite/ld-plugin/lto-5r.d: Likewise.
	* testsuite/ld-plugin/lto.exp: Run lto-3r and lto-5r tests.
2019-07-24 08:17:33 -07:00
Claudiu Zissulescu ef551643dc [ARC] Add linker relaxation.
Add linker relaxation. The first relaxation added is converting
GOTPC32 to PCREL relocations. This relaxation doesn't change the size of
the binary.

bfd/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* elf32-arc.c (bfd_get_32_me): New function.
	(bfd_put_32_me): Likewise.
	(arc_elf_relax_section): Likewise.
	(bfd_elf32_bfd_relax_section): Define.

ld/testsuite/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* ld-arc/relax-local-pic.d: New test.
	* ld-arc/relax-local-pic.s: New file.
2019-07-24 16:33:29 +03:00
H.J. Lu 19889a5835 Add missing ChangeLog entries for
commit 8c728a9d93
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Jul 22 14:23:32 2019 +0200

    Remove tests that test __gnu_lto_v1 symbol.
2019-07-23 08:40:23 -07:00
Alan Modra df3a023bd6 SHF_GNU_MBIND requires ELFOSABI_GNU
When SHF_GNU_MBIND was added in the SHF_LOOS to SHF_HIOS range, it
should have required ELFOSABI_GNU since these flags are already in use
by other OSes.  HPUX SHF_HP_TLS in fact has the same value.  That
means no place in binutils should test SHF_GNU_MBIND without first
checking OSABI, and SHF_GNU_MBIND should not be set without also
setting OSABI.  At least, that's the ideal, but the patch accepts
SHF_GNU_MBIND on ELFOSABI_NONE object files since gas didn't always
set OSABI.  However, to reinforce the fact that SHF_GNU_MBIND isn't
proper without a non-zero OSABI, readelf will display the flag as
LOOS+0 if OSABI isn't set.

The clash with SHF_HP_TLS means that hppa64-linux either has that flag
on .tbss sections or supports GNU_MBIND, not both.  (hppa64-linux
users, if there are any, may have noticed that GNU ld since 2017
mysteriously aligned their .tbss sections to a 4k boundary.  That was
one consequence of SHF_HP_TLS being blindly interpreted as
SHF_GNU_MBIND.)  Since it seems that binutils, gdb, gcc, glibc, and
the linux kernel don't care about SHF_HP_TLS I took that flag out of
.tbss for hppa64-linux.

bfd/
	* elf-bfd.h (enum elf_gnu_osabi): Add elf_gnu_osabi_mbind.
	* elf.c (_bfd_elf_make_section_from_shdr): Set elf_gnu_osabi_mbind.
	(get_program_header_size): Formatting.  Only test SH_GNU_MBIND
	when elf_gnu_osabi_mbind is set.
	(_bfd_elf_map_sections_to_segments): Likewise.
	(_bfd_elf_init_private_section_data): Likewise.
	(_bfd_elf_final_write_processing): Update comment.
	* elf64-hppa.c (elf64_hppa_special_sections): Move .tbss entry.
	(elf_backend_special_sections): Define without .tbss for linux.
binutils/
	* readelf.c (get_parisc_segment_type): Split off hpux entries..
	(get_ia64_segment_type): ..and these..
	(get_hpux_segment_type): ..to here.
	(get_segment_type): Condition GNU_MBIND on osabi.  Use
	get_hpux_segment_type.
	(get_symbol_binding): Do not print UNIQUE for ELFOSABI_NONE.
	(get_symbol_type): Do not print IFUNC for ELFOSABI_NONE.
gas/
	* config/obj-elf.c (obj_elf_change_section): Don't emit a fatal
	error for non-SHF_ALLOC SHF_GNU_MBIND here.
	(obj_elf_parse_section_letters): Return SHF_GNU_MBIND in new
	gnu_attr param.
	(obj_elf_section): Adjust obj_elf_parse_section_letters call.
	Formatting.  Set SHF_GNU_MBIND and elf_osabi from gnu_attr.
	Emit normal error for non-SHF_ALLOC SHF_GNU_MBIND and wrong osabi.
	(obj_elf_type): Set elf_osabi for ifunc.
	* testsuite/gas/elf/section12a.d: xfail msp430 and hpux.
	* testsuite/gas/elf/section12b.d: Likewise.
	* testsuite/gas/elf/section13.d: Likewise.
	* testsuite/gas/elf/section13.l: Adjust expected error.
ld/
	* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Condition
	SHF_GNU_MBIND on osabi.  Set output elf_gnu_osabi_mbind.
2019-07-23 18:22:02 +09:30
Alan Modra ec49711a16 Move ld-scripts size tests
Also restore them somewhat closer to the original.  They originally
failed on many targets, and a month later I "simplified" them as part
of a larger patch fixing other failing tests.  That unfortunately lost
their main purpose, which was to test TLS layout.

	* testsuite/ld-elf/size-1.d,
	* testsuite/ld-elf/size-1.s,
	* testsuite/ld-elf/size-1.t: New test.
	* testsuite/ld-elf/size-2.d,
	* testsuite/ld-elf/size-2.s,
	* testsuite/ld-elf/size-2.t: New test.
	* testsuite/ld-scripts/size-1.d,
	* testsuite/ld-scripts/size-1.s,
	* testsuite/ld-scripts/size-1.t,
	* testsuite/ld-scripts/size-2.s,
	* testsuite/ld-scripts/size-2.d,
	* testsuite/ld-scripts/size-2.t,
	* testsuite/ld-scripts/size.exp: Delete.
2019-07-23 18:22:01 +09:30
Srinath Parvathaneni 0c628bba5a Fixes the linker testcase "Secure gateway veneers:cmse functions debug information missing" which was failing due to output regular expression mismatch on arm-none-linux-gnueabihf targets.
* ld/testsuite/ld-arm/cmse_main_sec_debug.d: Modify regexps to
	allow for output from a arm-none-linux-gnueabihf target.
2019-07-22 14:46:11 +01:00
Alan Modra 9ab3a74416 PR24827, Linker loops forever if unterminated multi-line comment in script
YY_INPUT returns 0 on end of input, not EOF.

	PR 24827
	* ldlex.l (comment): Check for 0 return from input(), not EOF.
2019-07-20 10:55:16 +09:30
Alan Modra c213164ad2 [PowerPC64] pc-relative TLS relocations
This patch supports using pcrel instructions in TLS code sequences.  A
number of new relocations are needed, gas operand modifiers to
generate those relocations, and new TLS optimisation.  For
optimisation it turns out that the new pcrel GD and LD sequences can
be distinguished from the non-pcrel GD and LD sequences by there being
different relocations on the new sequence.  The final "add ra,rb,13"
on IE sequences similarly needs a new relocation, or as I chose, a
modification of R_PPC64_TLS.  On pcrel IE code, the R_PPC64_TLS points
one byte into the "add" instruction rather than being on the
instruction boundary.

GD:
 pla 3,z@got@tlsgd@pcrel	  # R_PPC64_GOT_TLSGD34
 bl __tls_get_addr@notoc(z@tlsgd) # R_PPC64_TLSGD and R_PPC64_REL24_NOTOC
  edited to IE
   pld 3,z@got@tprel@pcrel
   add 3,3,13
  edited to LE
   paddi 3,13,z@tprel
   nop

LD:
 pla 3,z@got@tlsld@pcrel	  # R_PPC64_GOT_TLSLD34
 bl __tls_get_addr@notoc(z@tlsld) # R_PPC64_TLSLD and R_PPC64_REL24_NOTOC
 ..
 paddi 9,3,z2@dtprel
 pld 10,z3@got@dtprel@pcrel
 add 10,10,3
  edited to LE
   paddi 3,13,0x1000
   nop

IE:
 pld 9,z@got@tprel@pcrel	  # R_PPC64_GOT_TPREL34
 add 3,9,z@tls@pcrel		  # R_PPC64_TLS at insn+1
 ldx 4,9,z@tls@pcrel
 lwax 5,9,z@tls@pcrel
 stdx 5,9,z@tls@pcrel
  edited to LE
  paddi 9,13,z@tprel
  nop
  ld 4,0(9)
  lwa 5,0(9)
  std 5,0(9)

LE:
 paddi 10,13,z@tprel

include/
	* elf/ppc64.h (R_PPC64_TPREL34, R_PPC64_DTPREL34),
	(R_PPC64_GOT_TLSGD34, R_PPC64_GOT_TLSLD34),
	(R_PPC64_GOT_TPREL34, R_PPC64_GOT_DTPREL34): Define.
	(IS_PPC64_TLS_RELOC): Include new tls relocs.
bfd/
	* reloc.c (BFD_RELOC_PPC64_TPREL34, BFD_RELOC_PPC64_DTPREL34),
	(BFD_RELOC_PPC64_GOT_TLSGD34, BFD_RELOC_PPC64_GOT_TLSLD34),
	(BFD_RELOC_PPC64_GOT_TPREL34, BFD_RELOC_PPC64_GOT_DTPREL34),
	(BFD_RELOC_PPC64_TLS_PCREL): New pcrel tls relocs.
	* elf64-ppc.c (ppc64_elf_howto_raw): Add howtos for pcrel tls relocs.
	(ppc64_elf_reloc_type_lookup): Translate pcrel tls relocs.
	(must_be_dyn_reloc, dec_dynrel_count): Add R_PPC64_TPREL64.
	(ppc64_elf_check_relocs): Support pcrel tls relocs.
	(ppc64_elf_tls_optimize, ppc64_elf_relocate_section): Likewise.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
gas/
	* config/tc-ppc.c (ppc_elf_suffix): Map "tls@pcrel", "got@tlsgd@pcrel",
	"got@tlsld@pcrel", "got@tprel@pcrel", and "got@dtprel@pcrel".
	(fixup_size, md_assemble): Handle pcrel tls relocs.
	(ppc_force_relocation, ppc_fix_adjustable): Likewise.
	(md_apply_fix, tc_gen_reloc): Likewise.
ld/
	* testsuite/ld-powerpc/tlsgd.d,
	* testsuite/ld-powerpc/tlsgd.s,
	* testsuite/ld-powerpc/tlsie.d,
	* testsuite/ld-powerpc/tlsie.s,
	* testsuite/ld-powerpc/tlsld.d,
	* testsuite/ld-powerpc/tlsld.s: New tests.
	* testsuite/ld-powerpc/powerpc.exp: Run them.
2019-07-19 18:01:25 +09:30
Alan Modra 7a70898417 [PowerPC] Rename testcase
Just making room for a new tlsld test.

	* testsuite/ld-powerpc/tlsldopt.d: Rename from tlsld.d.
	* testsuite/ld-powerpc/tlsldopt.s: Rename from tlsld.s.
	* testsuite/ld-powerpc/tlsldopt32.d: Rename from tlsld32.d.
	* testsuite/ld-powerpc/tlsldopt32.s: Rename from tlsld32.s.
	* testsuite/ld-powerpc/powerpc.exp: Update.
2019-07-19 18:01:25 +09:30
Alan Modra 88468fe096 Re: ld -r: Don't merge with member of output section group
PR 24819
	* testsuite/ld-elf/pr24819.d: xfail for genelf targets.
2019-07-19 18:01:25 +09:30
H.J. Lu 54d7dae59a ld -r: Don't merge with member of output section group
When doing a relocatable link, members of input section group are
placed in their own output sections.  We need to make sure that no
input sections are merged with member of output section group.

	PR ld/24819
	* emultempl/elf32.em (elf_orphan_compatible): Return FALSE for
	member of output section group when doing a relocatable link.
	* testsuite/ld-elf/pr24819.d: New file.
	* testsuite/ld-elf/pr24819.s: Likewise.
2019-07-18 08:01:54 -07:00
Alan Modra f26a32876b Dynamic TLS section symbols
It is possible to create shared libraries on PowerPC using
-ftls-model=inital-exec or -ftls-model=local-exec.  The first is half
reasonable, getting you a shared library that can't be dlopen'd but
otherwise is reasonable.  The second is quite bad.  Not only do you
lose being able to dlopen, the library also has dynamic text
relocations.  Worse, the TPREL16_LO, TPREL16_HA and other TPREL16
dynamic relocs emitted were wrong, resulting in wrong values being
applied by ld.so.

Using the first TLS section symbol in dynamic relocations for local
TLS symbols doesn't work.  It's wrong because TLS symbols used by TLS
relocs have values relative to the TLS segment, whereas the TLS
section symbols are addresses.  This patch instead uses a symbol index
of zero which is used elsewhere by PowerPC on dynamic TLS relocs.
It's not strictly ABI compliant to use a non-TLS symbol with TLS
relocs but symbol index zero can be interpreted as "no symbol".  Not
using the first TLS section symbol means it doesn't need to be dynamic.

The patch also fixes a further problem with PowerPC32 dynamic TPREL16*
relocs, which shouldn't have the symbol value in the addend as we do
for non-TLS symbols.

bfd/
	* elflink.c (_bfd_elf_omit_section_dynsym_default): Don't keep
	tls_sec.
	(_bfd_elf_init_1_index_section): Prefer not using TLS sections.
	(_bfd_elf_init_2_index_sections): Likewise.
	* elf64-ppc.c (ppc64_elf_relocate_section): When emitting dynamic
	relocations for local TLS symbols, use STN_UNDEF as the relocation
	symbol.
	* elf32-ppc.c (ppc_elf_relocate_section): Likewise, and don't
	leave TLS symbol value in the addend.
ld/
	* testsuite/ld-powerpc/tlsso.r: Update.
	* testsuite/ld-powerpc/tlsso32.g: Update.
	* testsuite/ld-powerpc/tlsso32.r: Update.
	* testsuite/ld-powerpc/tlstocso.r: Update.
	* testsuite/ld-cris/tls-dso-dtpoffd2.d: Update.
	* testsuite/ld-cris/tls-dso-dtpoffd4.d: Update.
	* testsuite/ld-cris/tls-dso-tpoffgotcomm1.d: Update.
	* testsuite/ld-cris/tls-gd-1.d: Update.
	* testsuite/ld-cris/tls-gd-1h.d: Update.
	* testsuite/ld-cris/tls-gd-2.d: Update.
	* testsuite/ld-cris/tls-gd-2h.d: Update.
	* testsuite/ld-cris/tls-ie-10.d: Update.
	* testsuite/ld-cris/tls-ie-11.d: Update.
	* testsuite/ld-cris/tls-ie-8.d: Update.
	* testsuite/ld-cris/tls-ie-9.d: Update.
	* testsuite/ld-cris/tls-js1.d: Update.
	* testsuite/ld-cris/tls-ld-4.d: Update.
	* testsuite/ld-cris/tls-ld-5.d: Update.
	* testsuite/ld-cris/tls-ld-6.d: Update.
	* testsuite/ld-cris/tls-ld-7.d: Update.
	* testsuite/ld-cris/tls-ldgd-14.d: Update.
	* testsuite/ld-cris/tls-ldgd-15.d: Update.
	* testsuite/ld-cris/tls-ldgdx-14.d: Update.
	* testsuite/ld-cris/tls-ldgdx-15.d: Update.
	* testsuite/ld-cris/tls-local-54.d: Update.
	* testsuite/ld-cris/tls-local-60.d: Update.
	* testsuite/ld-cris/tls-local-61.d: Update.
	* testsuite/ld-cris/tls-local-63.d: Update.
	* testsuite/ld-cris/tls-local-64.d: Update.
	* testsuite/ld-cris/tls-ok-30.d: Update.
	* testsuite/ld-cris/tls-ok-32.d: Update.
	* testsuite/ld-cris/tls-ok-34.d: Update.
	* testsuite/ld-mips-elf/tls-multi-got-1.got: Update.
	* testsuite/ld-mips-elf/tls-multi-got-1.r: Update.
	* testsuite/ld-mips-elf/tlsdyn-pie-o32.d: Update.
	* testsuite/ld-mips-elf/tlsdyn-pie-o32.got: Update.
	* testsuite/ld-mips-elf/tlslib-o32-hidden.got: Update.
	* testsuite/ld-mips-elf/tlslib-o32-ver.got: Update.
	* testsuite/ld-mips-elf/tlslib-o32.got: Update.
	* testsuite/ld-s390/tlspic.rd: Update.
	* testsuite/ld-s390/tlspic_64.rd: Update.
	* testsuite/ld-sparc/tlssunnopic32.rd: Update.
	* testsuite/ld-sparc/tlssunnopic64.rd: Update.
	* testsuite/ld-sparc/tlssunpic32.rd: Update.
	* testsuite/ld-sparc/tlssunpic64.rd: Update.
2019-07-13 09:57:50 +09:30
Alan Modra 7b2438015c PR24786, wrong LMA if first section in overlay is empty
This stops the first overlay section being ignored when empty,
losing its LMA assignment

	PR 24786
	* ldlang.h (enum section_type): Add first_overlay_section.
	* ldlang.c (lang_add_section): Adjust switch statement.
	(map_input_to_output_sections): Likewise.
	(lang_size_sections_1): Always set last_os for first overlay section.
	(lang_leave_overlay): Set sectype to first_overlay_section.
2019-07-13 09:57:50 +09:30
Alan Modra 3836e1d1ab Re: PowerPC notoc call stub tests
Correct the tests for powerpc 32-bit targets.

	* testsuite/ld-powerpc/callstub-1.d: Pass -melf64ppc to ld.
	* testsuite/ld-powerpc/callstub-2.d: Likewise.
2019-07-08 15:24:14 +09:30
Jan Beulich f2d4ba38f5 gas/ELF: don't accumulate .type settings
Recently a patch was submitted for a Xen Project test harness binary to
override the compiler specified @object to @func (see [1]). In a reply I
suggested we shouldn't make ourselves dependent on currently unspecified
behavior of gas here: It accumulates all requests, and then
bfd/elf.c:swap_out_syms(), in an apparently ad hoc manner, prioritizes
certain flags over others.

Make the behavior predictable: Generally the last .type is what counts.
Exceptions are directives which set multiple bits (TLS, IFUNC, and
UNIQUE): Subsequent directives requesting just the more generic bit
(i.e. FUNC following IFUNC) won't clear the more specific one.  Warn
about incompatible changes, except from/to STT_NOTYPE.

Also add a new target hook, which hppa wants to use right away afaict.

In the course of adding the warning I ran into two ld testsuite
failures.  I can only assume that it was a copy-and-paste mistake that
lead to the same symbol having its type set twice.

[1] https://lists.xenproject.org/archives/html/xen-devel/2019-05/msg01980.html
2019-07-04 10:35:47 +02:00
Nick Clifton 125f83f66c Fix a bug recently introduced to the linker where it would complain about a section being larger than a file, even if the section was artificial.
PR 24753
bfd	* compress.c (bfd_get_full_section_contents): Do not complain
	about linker created sections that are larger than the file size.

ld	* emultempl/aarch64elf.em (_aarch64_add_stub_section): Include the
	LINKER_CREATED section flag when creating the stub section.
2019-07-02 14:14:13 +01:00
Srinath Parvathaneni bb32413ff7 Ensure that debug information is retained for ARMv8-M security functions.
Consider a file containing only Armv8-M secure entry functions.
This file is compiled and linked with "-march=armv8-m.main -mfloat-abi=hard
-mfpu=fpv5-sp-d16 -mcmse -static --specs=rdimon.specs
-Wl,--section-start,.gnu.sgstubs=0x190000 -ffunction-sections
-fdata-sections
-Wl,--gc-sections -g" options to generate an executable.

The executable generated does not contain any debug information of these
secure entry functions even though it contains secure entry functions in
the .text section.  This patch fixes this problem.
2019-07-02 12:43:59 +01:00
Nick Clifton 539300fb92 Correct the calculation of offsets for ARM exidx relocs when performing a partial link.
PR 23839
bfd	* elf32-arm.c (elf32_arm_update_relocs): Do not include the
	section VMA in the offset used to update exidx relocs.

ld	* testsuite/ld-arm/unwind-4.d: Adjust for corrected calculation of
	exidx relocs.
2019-07-01 11:17:01 +01:00
Alan Modra 60d53d7f03 PowerPC notoc call stub tests
* testsuite/ld-powerpc/callstub-1.d,
	* testsuite/ld-powerpc/callstub-1.s: New test.
	* testsuite/ld-powerpc/callstub-2.d,
	* testsuite/ld-powerpc/callstub-2.s: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run them.
2019-06-28 10:16:17 +09:30
Jan Beulich 8e5cb9a54e ld/plugins: avoid shadowing a C library symbol
With my (oldish) gcc/glibc combination I'm seeing

.../ld/plugin.c: In function ‘get_lto_kind’:
.../ld/plugin.c:664: error: declaration of ‘index’ shadows a global declaration
/usr/include/string.h:487: error: shadowed declaration is here
.../ld/plugin.c: In function ‘get_lto_resolution’:
.../ld/plugin.c:685: error: declaration of ‘index’ shadows a global declaration
/usr/include/string.h:487: error: shadowed declaration is here
.../ld/plugin.c: In function ‘get_lto_visibility’:
.../ld/plugin.c:711: error: declaration of ‘index’ shadows a global declaration
/usr/include/string.h:487: error: shadowed declaration is here
2019-06-25 12:02:23 +02:00
H.J. Lu f93ab3a0b8 elf: Remove the property after reporting its removal
commit d2ef37ebd9
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Dec 7 08:30:30 2018 -0800

    elf: Report property change when merging properties

failed to remove the property after reporting it has been removed.  This
patch corrects it.

bfd/

	PR ld/24721
	* elf-properties.c (elf_merge_gnu_property_list): Remove the
	property after reporting property removal.

ld/

	PR ld/24721
	* testsuite/ld-x86-64/x86-64.exp: Run PR ld/24721 tests.
	* testsuite/ld-x86-64/pr24721-x32.d: New file.
	* testsuite/ld-x86-64/pr24721.d: Likewise.
	* testsuite/ld-x86-64/pr24721.map: Likewise.
	* testsuite/ld-x86-64/pr24721a.s: Likewise.
	* testsuite/ld-x86-64/pr24721b.s: Likewise.
2019-06-24 11:08:57 -07:00
Alan Modra bb22a41815 PR24704, Internal error building skiboot for powerpc64-linux-gnu
While the skiboot linker script bears some culpability in this PR,
it's also true that the GOT indirect to GOT relative optimisation for
16-bit offsets isn't safe.  At least, it isn't safe to remove the GOT
entry based on distance between the GOT pointer and symbol calculated
from the preliminary layout.  So this patch removes that optimisation,
and reduces the range allowed for 32-bit and 34-bit offsets.

	PR 24704
bfd/
	* elf64-ppc.c (R_PPC64_GOT16_DS): Don't set has_gotrel.
	(ppc64_elf_edit_toc): Don't remove R_PPC64_GOT16_DS got entries.
	Reduce range of offsets allowed for other GOT relocs.
ld/
	* testsuite/ld-powerpc/elfv2exe.d: Update.
	* testsuite/ld-powerpc/elfv2so.d: Update.
2019-06-23 23:11:27 +09:30
Szabolcs Nagy e30d1fa1bf Add R_AARCH64_P32_MOVW_PREL_* ELF32 relocs
These ilp32 relocations were missing for some reason.

bfd/ChangeLog:

	* elfnn-aarch64.c: Enable MOVW_PREL relocs for ELF32.

include/ChangeLog:

	* elf/aarch64.h (R_AARCH64_P32_MOVW_PREL_G0): Define.
	(R_AARCH64_P32_MOVW_PREL_G0_NC): Define.
	(R_AARCH64_P32_MOVW_PREL_G1): Define.

ld/ChangeLog:

	* testsuite/ld-aarch64/aarch64-elf.exp: Add emit-relocs-22 and -23.
	* testsuite/ld-aarch64/emit-relocs-22.d: New test.
	* testsuite/ld-aarch64/emit-relocs-22.s: New test.
	* testsuite/ld-aarch64/emit-relocs-23.d: New test.
	* testsuite/ld-aarch64/emit-relocs-23.s: New test.
2019-06-14 12:02:19 +01:00
Alan Modra 3a3a077c4a Regenerate with approved autotools version
bfd/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
binutils/
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* doc/Makefile.in: Regenerate.
gas/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
ld/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
libctf/
	* configure: Regenerate.
2019-06-14 10:30:35 +09:30
Alan Modra e3fa7860f4 Fix alpha testsuite regression
readelf st_other display improved for alpha.

	PR 24662
	* testsuite/ld-alpha/tlsbin.rd: Update.
	* testsuite/ld-alpha/tlsbinr.rd: Update.
	* testsuite/ld-alpha/tlspic.rd: Update.
2019-06-14 10:23:20 +09:30
Maciej W. Rozycki c1b00498af LD/doc: Clarify `-rpath' option's semantics WRT link-time dependencies
Mention in the description of the `-rpath' LD option the restrictions
the option has with respect to searching link-time dependencies of
shared objects referred in the link.  Previously these restrictions were
only documented along with the `-rpath-link' option, which may not be
the place one would consider when looking for the semantics of `-rpath'.

Copy the relevant part of the `-rpath-link' option description then,
splitting the now overlong paragraph into three, for legibility.

	ld/
	* ld.texi (Options): Also document `-rpath' option restrictions
	in the description of the option itself.
2019-06-07 19:25:21 +01:00
Sudakshina Das 237df8fe18 [BFD, AArch64] Fix PT_GNU_PROPERTY alignment issue
If the new GNU property section was being created by the linker
(this will happen only if none of the inputs have any GNU property
section but the command line to the linker forces a bti with
--force-bti), the alignment of the section and hence the program
header of PT_GNU_PROPERTY type was not being set correctly. This
patch fixes this issue.

bfd/ChangeLog:

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Set
	alignment of the new gnu property section.

ld/ChangeLog:

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/ld-aarch64/aarch64-elf.exp: Add new tests.
	* testsuite/ld-aarch64/property-bti-pac4-a.d: New test.
	* testsuite/ld-aarch64/property-bti-pac4-b.d: New test.
	* testsuite/ld-aarch64/property-bti-pac4.s: New test.
2019-06-06 12:27:41 +01:00
Sudakshina Das 8bf6d176b0 [LD, AArch64] Move ELF options behind -z
This patch moves the current AArch64 ld options of --force-bti
and --pac-plt to -z force-bti and -z pac-plt since these are
ELF specific options.

*** bfd/ChangeLog ***

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

	* bfd-in.h: Change comment.
	* bfd-in2.h: Regenerate.
	* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update warning.
	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties):
	Likwise.

*** ld/ChangeLog ***

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

	* NEWS: Update options names.
	* emultempl/aarch64elf.em (OPTION_FORCE_BTI, OPTION_PAC_PLT): Remove.
	(PARSE_AND_LIST_LONGOPTS): Remove force-bti and pac-plt.
	(PARSE_AND_LIST_OPTIONS): Update to -z.
	(PARSE_AND_LIST_ARGS_CASE_Z_AARCH64): New.
	(PARSE_AND_LIST_ARGS_CASE_Z): Add PARSE_AND_LIST_ARGS_CASE_Z_AARCH64.
	(PARSE_AND_LIST_ARGS_CASES): Move cases for these options.
	* testsuite/ld-aarch64/bti-pac-plt-1.d: Update option.
	* testsuite/ld-aarch64/bti-pac-plt-2.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-1.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-2.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-3.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-4.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-6.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
	* testsuite/ld-aarch64/bti-warn.d: Likewise.
	* testsuite/ld-aarch64/pac-plt-1.d: Likewise.
	* testsuite/ld-aarch64/pac-plt-2.d: Likewise.
2019-06-06 12:21:14 +01:00
Nick Clifton ae9ac79e5e Harmonize readelf's output for version sections.
PR 24627
binutils * readelf.c (process_version_sections): Add 0x prefix to address
	display.  Correct indentation.

ld	* testsuite/ld-elf/ver_def.vd: Update expected output.
2019-05-30 10:17:29 +01:00
Alan Modra 6ff185b890 s12z genelf.em
This changes s12z to use generic.em and genelf.em, which is more
suited to targets that use the generic linker hash table.  A tweak or
two to some testsuite predicates then gives a clean testsuite result
on the target.

	PR 24596
binutils/
	* testsuite/lib/binutils-common.exp (supports_gnu_unique): Add
	s12z to targets not supporting this feature.
ld/
	* emulparams/m9s12zelf.sh (TEMPLATE_NAME): Set to generic.
	(EXTRA_EM_FILE): Define to genelf.
	* testsuite/lib/ld-lib.exp (uses_genelf): Add s12z.
2019-05-30 01:01:42 +09:30
Alan Modra 1336939d3c Support tcl procedure calls in run_dump_test xfail
Also support tcl procedure calls in the run_ld_link_tests and
run_ld_link_exec_tests optional "xfail" args.  Implements "is_generic"
and renames "is_generic_elf" to "uses_genelf", then uses these procs
in lots of ld tests.

moxie-elf  -FAIL: ld-elf/orphan3
mt-elf  -FAIL: ld-elf/merge
s12z-elf  -FAIL: ld-discard/extern
s12z-elf  -FAIL: ld-discard/start
s12z-elf  -FAIL: ld-discard/static
s12z-elf  -FAIL: PR ld/21703
s12z-elf  -FAIL: PR ld/21703 -r
s12z-elf  -FAIL: Symbol flags copy
s12z-elf  -FAIL: ld-elf/group1
s12z-elf  -FAIL: ld-elf/group3b
s12z-elf  -FAIL: ld-elf/group8a
s12z-elf  -FAIL: ld-elf/group8b
s12z-elf  -FAIL: ld-elf/group9a
s12z-elf  -FAIL: ld-elf/group9b
s12z-elf  -FAIL: ld-elf/linkonce2
s12z-elf  -FAIL: ld-elf/merge2
s12z-elf  -FAIL: ld-elf/merge3
s12z-elf  -FAIL: ld-elf/pr12851
s12z-elf  -FAIL: ld-elf/pr17550c
s12z-elf  -FAIL: ld-elf/pr17550d
s12z-elf  -FAIL: ld-elf/pr22677
s12z-elf  -FAIL: ld-elf/pr22836-1a
s12z-elf  -FAIL: ld-elf/pr22836-1b
s12z-elf  -FAIL: ld-elf/warn1
s12z-elf  -FAIL: ld-elf/warn3

binutils/
	* testsuite/lib/binutils-common.exp (run_dump_test): Support
	tcl procedures for xfail args.
ld/
	* testsuite/lib/ld-lib.exp (run_ld_link_tests): Support procedure
	calls in optional "xfail" args.
	(run_ld_link_exec_tests): Likewise.
	(is_generic): New.
	(uses_genelf): Rename from is_generic_elf.  Delete bogus semicolons.
	* testsuite/ld-scripts/align.exp: Rename is_generic_elf call.
	* testsuite/ld-elf/elf.exp: Use is_generic and uses_genelf.  Delete
	xfail_implib var.
	* testsuite/ld-elf/sec64k.exp: Use is_generic.
	* testsuite/ld-elf/shared.exp: Likewise.
	* testsuite/ld-discard/extern.d: Use is_generic in xfail.
	* testsuite/ld-discard/start.d: Likewise.
	* testsuite/ld-discard/static.d: Likewise.
	* testsuite/ld-elf/attributes.d: Likewise.
	* testsuite/ld-elf/group1.d: Likewise.
	* testsuite/ld-elf/group3b.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/linkonce2.d: Likewise.
	* testsuite/ld-elf/merge2.d: Likewise.
	* testsuite/ld-elf/merge3.d: Likewise.
	* testsuite/ld-elf/pr12851.d: Likewise.
	* testsuite/ld-elf/pr12975.d: Likewise.
	* testsuite/ld-elf/pr13177.d: Likewise.
	* testsuite/ld-elf/pr13195.d: Likewise.
	* testsuite/ld-elf/pr17550c.d: Likewise.
	* testsuite/ld-elf/pr17550d.d: Likewise.
	* testsuite/ld-elf/pr17615.d: Likewise.
	* testsuite/ld-elf/pr21562a.d: Likewise.
	* testsuite/ld-elf/pr21562b.d: Likewise.
	* testsuite/ld-elf/pr21562c.d: Likewise.
	* testsuite/ld-elf/pr21562d.d: Likewise.
	* testsuite/ld-elf/pr21562i.d: Likewise.
	* testsuite/ld-elf/pr21562j.d: Likewise.
	* testsuite/ld-elf/pr21562k.d: Likewise.
	* testsuite/ld-elf/pr21562l.d: Likewise.
	* testsuite/ld-elf/pr21562m.d: Likewise.
	* testsuite/ld-elf/pr21562n.d: Likewise.
	* testsuite/ld-elf/pr22677.d: Likewise.
	* testsuite/ld-elf/pr22836-1a.d: Likewise.
	* testsuite/ld-elf/pr22836-1b.d: Likewise.
	* testsuite/ld-elf/warn3.d: Likewise.
	* testsuite/ld-elf/warn1.d: Likewise and xfail sparc solaris
	targets rather than notarget.
	* testsuite/ld-elf/compressed1d.d: Use uses_genelf in xfail.
	* testsuite/ld-elf/orphan-10.d: Likewise.
	* testsuite/ld-elf/orphan-9.d: Likewise.
	* testsuite/ld-elf/orphan-region.d: Likewise.
	* testsuite/ld-elf/orphan.d: Likewise.
	* testsuite/ld-elf/orphan3.d: Likewise.
	* testsuite/ld-elf/pr20528a.d: Likewise.
	* testsuite/ld-elf/pr20528b.d: Likewise.
	* testsuite/ld-elf/pr23658-1a.d: Likewise.
	* testsuite/ld-elf/pr23658-1b.d: Likewise.
	* testsuite/ld-elf/pr349.d: Likewise.
	* testsuite/ld-elf/warn2.d: Likewise and xfail sparc solaris
	targets rather than notarget.
	* testsuite/ld-elf/merge.d: Correct ms1-*-* to mt-*-*.
2019-05-30 00:52:08 +09:30
Faraz Shahbazker 1e129bbefa MIPS/LD: Skip overflow check for %pcrel_hi relocations
Overflow checks were removed for all hi16 relocations except PC-relative
high relocations per PR ld/16720.  Remove overflow checks from %pcrel_hi
relocations so that we can correctly handle negative offsets from PC.

bfd/
	* elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_PCHI16>:
	Remove overflow check.

ld/
	* testsuite/ld-mips-elf/undefweak-overflow.s: Remove test case
	for pcrel_hi/pcrel_lo.
	* testsuite/ld-mips-elf/undefweak-overflow.d: Update to match.
	* testsuite/ld-mips-elf/reloc-pcrel-r6.s: New test source.
	* testsuite/ld-mips-elf/reloc-pcrel-r6.d: New test linker script.
	* testsuite/ld-mips-elf/reloc-pcrel-r6.ld: New test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
2019-05-28 10:49:16 -07:00
Alan Modra eabf307f1d PE linker segmentation fault with MALLOC_PERTURB_=1
PR 24596
	* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Check that
	the output is coff before accessing coff tdata.
	* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
2019-05-28 20:47:14 +09:30
Szabolcs Nagy 65f381e729 aarch64: fix variant_pcs ld tests
Force sysv hash style for reliable symbol table layout.

ld/ChangeLog:

	* testsuite/ld-aarch64/variant_pcs-now.d: Use --hash-style=sysv.
	* testsuite/ld-aarch64/variant_pcs-shared.d: Likewise.
2019-05-28 12:03:51 +01:00
Alan Modra 3d7d6a6ff4 Generic ELF target group signature symbol
Even though the generic ELF target doesn't handle groups correctly,
this helps avoid a segfault in bfd_elf_set_group_contents seen on
d30v-elf, dlx-elf, pj-elf, and xgate-elf when linking the pr22836
testcase.

	PR 24596
bfd/
	* linker.c (_bfd_generic_link_output_symbols): Heed BSF_KEEP.
ld/
	* emultempl/genelf.em (gld${EMULATION_NAME}_after_open): Set
	BFS_KEEP on group signature symbol.
2019-05-27 13:56:28 +09:30
Szabolcs Nagy 823710d585 aarch64: handle STO_AARCH64_VARIANT_PCS in bfd
Propagate STO_AARCH64_VARIANT_PCS st_other attribute to the output and
add DT_AARCH64_VARIANT_PCS dynamic tag if necessary.

Mismatching attributes are not diagnosed.

bfd/ChangeLog:

	* elfnn-aarch64.c (elfNN_aarch64_merge_symbol_attribute): New function.
	(struct elf_aarch64_link_hash_table): Add variant_pcs member.
	(elfNN_aarch64_allocate_dynrelocs): Update variant_pcs.
	(elfNN_aarch64_size_dynamic_sections): Add DT_AARCH64_VARIANT_PCS.
	(elf_backend_merge_symbol_attribute): Define.

ld/ChangeLog:

	* testsuite/ld-aarch64/aarch64-elf.exp: Add new tests.
	* testsuite/ld-aarch64/variant_pcs-1.s: New asm for tests.
	* testsuite/ld-aarch64/variant_pcs-2.s: New asm for tests.
	* testsuite/ld-aarch64/variant_pcs-now.d: New test.
	* testsuite/ld-aarch64/variant_pcs-r.d: New test.
	* testsuite/ld-aarch64/variant_pcs-shared.d: New test.
	* testsuite/ld-aarch64/variant_pcs.ld: New linker script for tests.
2019-05-24 15:11:00 +01:00
Alan Modra 405b5bd86f Regen POTFILES for bpf
bfd/
	* po/SRC-POTFILES.in: Regenerate.
gas/
	* po/POTFILES.in: Regenerate.
ld/
	* po/BLD-POTFILES.in: Regenerate.
opcodes/
	* po/POTFILES.in: Regenerate.
2019-05-24 23:15:07 +09:30
Alan Modra 04bdff6a76 PowerPC notoc linkage stubs
Use pcrel addressing instructions in linkage stubs.

bfd/
	* elf64-ppc.c: Comment on powerxx _notoc stub variants.
	(LI_R11_0, LIS_R11, ORI_R11_R11_0, SLDI_R11_R11_34): Define.
	(PADDI_R12_PC, PLD_R12_PC, D34, HA34): Define.
	(struct ppc_link_hash_table): Add powerxx_stubs.
	(ppc64_elf_check_relocs): Set powerxx_stubs.
	(build_powerxx_offset, size_powerxx_offset),
	(num_relocs_for_powerxx_offset),
	(emit_relocs_for_powerxx_offset): New functions.
	(plt_stub_size): Size powerxx stubs.
	(ppc_build_one_stub): Emit powerxx stubs.
	(ppc_size_one_stub): Size powerxx stubs.  Omit .eh_frame for
	powerxx stubs.
ld/
	* testsuite/ld-powerpc/notoc2.d,
	* testsuite/ld-powerpc/notoc2.s: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run it.
2019-05-24 10:28:07 +09:30
Alan Modra 4a421c53cf PowerPC GOT_PCREL34 optimisation
bfd/
	* elf64-ppc.c (ppc64_elf_check_relocs): Set has_gotrel for
	R_PPC64_GOT_PCREL34.
	(xlate_pcrel_opt): New function.
	(ppc64_elf_edit_toc): Handle R_PPC64_GOT_PCREL34.
	(ppc64_elf_relocate_section): Edit GOT indirect to GOT relative
	for R_PPC64_GOT_PCREL34.  Implement R_PPC64_PCREL_OPT optimisation.
ld/
	* testsuite/ld-powerpc/pcrelopt.s,
	* testsuite/ld-powerpc/pcrelopt.d,
	* testsuite/ld-powerpc/pcrelopt.sec: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run it.
2019-05-24 10:27:53 +09:30
Jose E. Marchesi 8376927b2c ld: add support for eBPF
This patch adds support to the linker for the Linux eBPF architecture.
A minimal testsuite is included.

ld/ChangeLog:

2019-05-23  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* Makefile.am (ALL_64_EMULATION_SOURCES): Add eelf64bpf.c.
	* Makefile.in (prefix): Regenerate.
	* configure.tgt (targ_extra_ofiles): Add case for bpf-*-* targets.
	* emulparams/elf64bpf.sh: New file.
	* testsuite/lib/ld-lib.exp (check_gc_sections_available): Add
	bpf-*-* to the list of targets not supporting gc-sections.
	* testsuite/ld-bpf/bar.s: New file.
	* testsuite/ld-bpf/jump-1.d: Likewise.
	* testsuite/ld-bpf/foo.s: Likewise.
	* testsuite/ld-bpf/call-1.d: Likewise.
	* testsuite/ld-bpf/bpf.exp: Likewise.
	* testsuite/ld-bpf/baz.s: Likewise.
2019-05-23 19:34:15 +02:00
Alan Modra 82d7a6f4e3 Re: Have the linker report an error if the same script is used twice
git commit 6ec6968b1b results in
... error: linker script file '/usr/local/lib64/libgcc_s.so' appears multiple times
collect2: error: ld returned 1 exit status
FAIL: bootstrap

This patch changes things so that an error is given only when a -T
script or the default script is invoked more than once.  I'm still a
little nervous that we match script file names, not the entire path.

	PR 24576
	* ldfile.c (enum script_open_style): New.
	(struct script_name_list): New.
	(ldfile_open_command_file_1): Take a script_open_style param
	rather than booleans.  Adjust callers.  Only fail when -T or
	default -T script is invoked twice.
	(ldfile_try_open_bfd): Revert last change.
2019-05-23 10:38:45 +09:30
Nick Clifton 6ec6968b1b Have the linker report an error if the same script is used twice.
PR 24576
	* ld/ldfile.c: (ldfile_open_command_file_1): Add new parameter -
	is_script.  If true check that the file has not already been
	parsed as a linker script.
	(ldfile_open_script_file): New function.
	(ldfile_try_open_bfd): Use the new function in place of
	ldfile_open_command_line.
	* ldmain.c (main): Likewise.
	* lexsup.c (parse_args): Use the new function for opening linker
	scripts with the -T option.
	* ldfile.h (ldfile_open_script_file): Add prototype.
2019-05-22 15:58:57 +01:00
Faraz Shahbazker b474a2022d MIPS/LD: Reject tprel_hi and tprel_lo relocations in shared library
bfd/
	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Generate error
	for TLS_TPREL_HI16(/LO16) relocations in shared library.

ld/
	* testsuite/ld-mips-elf/pic-reloc-5.s: Add tests for
	%tprel_hi and %tprel_lo relocations.
	* testsuite/ld-mips-elf/pic-reloc-6.s: Likewise.
	* testsuite/ld-mips-elf/pic-reloc-5.d: Update accordingly.
	* testsuite/ld-mips-elf/pic-reloc-6.d: Likewise.
	* testsuite/ld-mips-elf/pic-reloc-tls.ld: New test linker
	script file.
2019-05-21 11:55:08 -07:00
Faraz Shahbazker 304f09d0d4 MIPS/LD: Fix memory fault linking non-PIC object in to shared library
bfd/
	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Add NULL pointer
	checks.  Search the RELA table for n64 relocations.

ld/
	* testsuite/ld-mips-elf/pic-reloc-5.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-6.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-7.d: New test.
	* testsuite/ld-mips-elf/pic-reloc-5.s: New test source.
	* testsuite/ld-mips-elf/pic-reloc-6.s: New test source.
	* testsuite/ld-mips-elf/pic-reloc-7.s: New test source.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2019-05-21 11:55:08 -07:00
Matthew Fortune 3734320dc0 [MIPS] Add generation of PLT entries with compact jumps for MIPS R6
Add a new option to get the linker to emit PLTs that use compact
branches instead of delay slot branches.

bfd/
	* elfxx-mips.c (LA25_BC): New macro.
	(mips_elf_link_hash_table)<compact_branches>: New field.
	(STUB_JALRC): New macro.
	(mipsr6_o32_exec_plt0_entry_compact): New array.
	(mipsr6_n32_exec_plt0_entry_compact): Likewise.
	(mipsr6_n64_exec_plt0_entry_compact): Likewise.
	(mipsr6_exec_plt_entry_compact): Likewise.
	(mips_elf_create_la25_stub): Use BC instead of J for stubs
	when compact_branches is true.
	(_bfd_mips_elf_finish_dynamic_symbol): Choose the compact
	PLT for MIPSR6 with compact_branches.  Do not reorder the
	compact branches PLT.  Switch the lazy stub for MIPSR6
	with compact_branches to use JALRC.
	(mips_finish_exec_plt): Choose the compact PLT0 for MIPSR6
	when compact_branches is true.
	(_bfd_mips_elf_compact_branches): New function.
	* elfxx-mips.h (_bfd_mips_elf_compact_branches): New prototype.

ld/
	* emultempl/mipself.em (compact_branches): New static variable.
	(mips_create_output_section_statements): Call
	_bfd_mips_elf_compact_branches.
	(PARSE_AND_LIST_PROLOGUE): Add OPTION_COMPACT_BRANCHES and
	OPTION_NO_COMPACT_BRANCHES.
	(PARSE_AND_LIST_LONGOPTS): Add compact-branches,
	no-compact-branches.
	(PARSE_AND_LIST_OPTIONS): Add --compact-branches,
	--no-compact-branches.
	(PARSE_AND_LIST_ARGS_CASES): Handle the above.
	* ld.texinfo: Document --compact-branches, --no-compact-branches.
	* testsuite/ld-mips-elf/pic-and-nonpic-1-r6.dd: New test.
	* testsuite/ld-mips-elf/pic-and-nonpic-1-r6.nd: New test.
	* testsuite/ld-mips-elf/pic-and-nonpic-3a-r6.dd: New test.
	* testsuite/ld-mips-elf/pic-and-nonpic-3a-r6.gd: New test.
	* testsuite/ld-mips-elf/pic-and-nonpic-1a-r6.s: New test source.
	* testsuite/ld-mips-elf/pic-and-nonpic-3a-r6.s: New test source.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2019-05-21 09:22:28 -07:00
Andre Vieira e6f65e7573 [binutils][Arm] Fix Branch Future relocation handling and testisms
bfd/ChangeLog:
2019-05-21  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	PR/target 24460
	* elf32-arm.c (get_value_helper): Remove.
	(elf32_arm_final_link_relocate): Fix branch future relocations.

gas/ChangeLog:
2019-05-21  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* testsuite/gas/arm/armv8_1-m-bf.d: Allow different branch target naming
	conventions.
	* testsuite/gas/arm/armv8_1-m-bfl.d: Likewise.
	* testsuite/gas/arm/armv8_1-m-bfcsel.d: Likewise.
	* testsuite/gas/arm/armv8_1-m-loloop.d: Likewise.
	* testsuite/gas/arm/armv8_1-m-bf-rel.d: Skip for vxworks.
	* testsuite/gas/arm/armv8_1-m-bf-rela.d: New test.
	* testsuite/gas/arm/armv8_1-m-bfl-rel.d: Skip for vxworks.
	* testsuite/gas/arm/armv8_1-m-bfl-rela.d: New test.

ld/ChangeLog:
2019-05-21  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* testsuite/ld-arm/arm-elf.exp: Add tests
	* testsuite/ld-arm/bfs-0.s: New test.
	* testsuite/ld-arm/bfs-1.s: New test.
	* testsuite/ld-arm/branch-futures.d: New test.
2019-05-21 14:53:49 +01:00
Tamar Christina 739b5c9c77 AArch64: Implement choice between Cortex-A53 erratum workarounds. (PR ld/24373)
The Cortex-A53 erratum currently has two ways it can resolve the erratum when
using the flag --fix-cortex-a53-843419:

1) If the address is within the range of an ADR instruction it rewrites the ADRP
   into an ADR, and those doesn't need the use of a veneer.

2) If the address is not within range, it adds a branch to a veneer which will
   execute the final bit of the erratum workaround and branch back to the call
   site.

When we do this we always generate the veneers and we always align the size of
the text section to 4KB.  This is because we only know which workaround we can
use after all linking has finished and all addresses are known.  This means even
though the veneers are not used, we still generate the section and we still
change the size of the input section.

This is problematic for small memory devices as this would require the user to
take about a ~4KB hit in memory even though it's not even used.

Since there's no real way to restart the linking process from the final write
phase this patch solves the issue by allowing the user more control over which
erratum workaround gets used.

Concretely this changes the option --fix-cortex-a53-843419 to take optional
arguments --fix-cortex-a53-843419[=full|adr|adrp]

- full (default): Use both ADRP and ADR workaround. This is equivalent to not
		  specifying any options and is the default behavior before this
		  patch.

- adr: Only use the ADR workaround, this will not cause any increase in binary
       size but linking will fail if the referenced address is out of range of
       an ADR instruction.

- adrp: Use only the ADRP workaround, this will never rewrite your ADRP.

In the cases where the user knows how big their binaries are the `adr` option
would prevent the unneeded overhead.

bfd/ChangeLog:

	PR ld/24373
	* bfd-in.h (enum erratum_84319_opts): New
	(bfd_elf64_aarch64_set_options, bfd_elf32_aarch64_set_options): Change
	int to enum erratum_84319_opts.
	* bfd-in2.h: Regenerate.
	* elfnn-aarch64.c (struct elf_aarch64_link_hash_table): Change
	fix_erratum_843419 to use new enum, remove fix_erratum_843419_adr.
	(_bfd_aarch64_add_stub_entry_after): Conditionally create erratum stub.
	(aarch64_size_one_stub): Conditionally size erratum 843419 stubs.
	(_bfd_aarch64_resize_stubs): Amend comment.
	(elfNN_aarch64_size_stubs): Don't generate stubs when no workaround
	requested.
	(bfd_elfNN_aarch64_set_options): Use new fix_erratum_843419 enum.
	(_bfd_aarch64_erratum_843419_branch_to_stub): Implement selection of
	erratum workaround.
	(clear_erratum_843419_entry): Update erratum conditional.

ld/ChangeLog:

	PR ld/24373
	* emultempl/aarch64elf.em (PARSE_AND_LIST_LONGOPTS): Add optional args
	to flags.
	* NEWS: Add changes to flag.
	(PARSE_AND_LIST_OPTIONS): Update help descriptions.
	(PARSE_AND_LIST_ARGS_CASES): Add new options to parser.
	* testsuite/ld-aarch64/aarch64-elf.exp: Add new run_dump_tests.
	* testsuite/ld-aarch64/erratum843419-adr.d: New test.
	* testsuite/ld-aarch64/erratum843419-adrp.d: New test.
	* testsuite/ld-aarch64/erratum843419-far-adr.d: New test.
	* testsuite/ld-aarch64/erratum843419-far-full.d: New test.
	* testsuite/ld-aarch64/erratum843419-far.s: New test.
	* testsuite/ld-aarch64/erratum843419-full.d: New test.
	* testsuite/ld-aarch64/erratum843419-near.s: New test.
	* testsuite/ld-aarch64/erratum843419-no-args.d: New test.
2019-05-21 13:05:22 +01:00
Senthil Kumar Selvaraj 7622049e0b Fix PR 24571 - Relaxation does not shorten jmp or call to target at pc-relative range boundary
The range check done to transform an absolute call/jump to a pc-relative one is
off-by-one, and that causes this shortening optimization to be missed if the
branch target is right at the range boundary.

In the non-shrinkable case, the range is what is mentioned in the ISA - -4094
bytes in the backward direction, and 4096 bytes in the positive direction.

In the shrinkable case, the forward jump range increases by two bytes (deleted
because of the shortening from call/jmp to rcall/rjmp), and therefore, the
range is -4094 in the reverse, and 4098 in the positive direction.

Fix the ranges for !shrinkable and shrinkable cases, and add a test caes to
ensure jumps to max forward and backward ranges get relaxed to rjmp.
2019-05-21 12:48:06 +05:30
Senthil Kumar Selvaraj 338ba75534 Fix PR 24564 - link fails for some rcalls/rjmps with wraparound
The current code to compute relative distance in the wrap around case does not
handle the edge case of the target (after adjusting for implicit PC increment)
being exactly half of the wrap around distance. This patch fixes that and adds a
testcase.

The range for a forward relative jump call is 4096 bytes ((2 * 2047) + (2 bytes
for the implicit PC increment)). If the target of the jump is at a distance of
4098 bytes, it is out of range for a forward jump - however, a backward jump can
still reach that address if pmem-wrap-around is 8192.

Assume address 0 has rjmp to address 4098. With a wrap around of 8192 and
*without* adjusting for the implicit PC increment of 2 bytes, rjmp .-4096 will
jump to address 4096 (wrap around at 8192 and decreasing addresses from then
on). Adjusting 2 bytes for the implicit PC increment, the actual target is 4098.

avr_relative_distance_considering_wrap_around though, does the wrap around only
if the passed in distance is less than half of the wrap around distance. In this
case, it is exactly equal to half (original distance 4098, adjusted distance of
4096 and wraparound of 8192), and the bypassed wrap around causes the reloc
overflow error.

Fix by wrapping around even if adjusted distance is equal to half of wrap around
distance.
2019-05-21 12:34:22 +05:30
Faraz Shahbazker d87343802b [MIPS] PR gas/14798: Limit IRIX5 specific default typing to IRIX targets
On IRIX 5, every global symbol that is not explicitly labelled as
being a function is assumed to be an object.  There is no reason
why IRIX behaviour should extend to all MIPS targets, so limit this
to only IRIX targets.

gas/
	PR 14798
	* config/tc-mips.c (s_mips_globl): Only treat symbols that are
	not explicitly labelled as BSF_OBJECTs for IRIX targets.
	* testsuite/gas/mips/pr14798.s: New test source.
	* testsuite/gas/mips/pr14798-irix.d: New test.
	* testsuite/gas/mips/pr14798.d: Likewise.
	* testsuite/gas/mips/mips.exp: Run the new tests.

binutils/
	PR 14798
	* testsuite/binutils-all/readelf.ss-mips: Update reference output.
	* testsuite/binutils-all/readelf.ss-tmips: Likewise.

ld/
	PR 14798
	* testsuite/ld-mips-elf/reloc-6a.s: Specify .text section for
	global code symbols.
	* testsuite/ld-mips-elf/reloc-6b.s: Likewise.
2019-05-20 11:08:23 -07:00
Alan Modra af4fa23fba PR24567, assertion failure in ldlang.c:6868 when compiling with -flto
As the existing comment said: "a common ought to be overridden by a
def in a -flto object".  This patch makes the code actually do that,
rather than allowing a normal object file common to override a -flto
defined symbol.

	PR 24567
	* plugin.c (plugin_notice): Do not let a common symbol override
	a non-common definition in IR.
2019-05-17 21:06:07 +09:30
Dimitar Dimitrov dd3189990b Use the correct names for the init and fini array start symbols in the default Pru linker script.
* scripttempl/pru.sc (__init_array_begin, __init_array_begin):
	Rename.
2019-05-09 10:26:11 +01:00
Pekka Sepp?nen 46752c37b0 Fix compile time warning when building the linker in a MinGw32 environment using gcc 8.
PR 24536
	* ldbuildid.c (generate_build_id): Cast return value from
	GetProcAddress in order to avoid a compile time warning.
2019-05-08 16:54:16 +01:00
Alan Modra e1cbf07ac4 PicoJava weak undefined symbols
This fixes the recently added ld-elf/pr24511 test failure on pj-elf.
Incidentally, pj-elf has failed its gas "pj" test since 2005-12-22
(git commit 54758c3e39).  I think that makes the target ripe for
obsolescence.

bfd/
	* elf32-pj.c (pj_elf_reloc): Don't report undefined weak as an error.
ld/
	* testsuite/ld-undefined/weak-undef.exp: Don't xfail pj.
2019-05-06 11:41:28 +09:30
Alan Modra 27cdfa03b5 m32c padding with nops
m32c_md_end attempted to pad out a code section with nops, but this
was just plain wrong in many ways:
- The padding didn't happen at all if the last section emitted wasn't
  a code section.
- The padding went to the wrong place if subsections were used, and
  the last subseg used wasn't the highest numbered subseg.
- Padding wasn't added to all code sections.
- If the last section was empty, it was padded to 4 bytes.
- The padding didn't go to a 4-byte alignment boundary, instead it
  effectively made the last instruction 4 bytes in size.
- The padding didn't take into account that code sections may have
  contents other than machine instructions.

So, rip it out and handle nop padding properly, also fixing .align
.balign/.p2align in the middle of code.

gas/
	* config/tc-m32c.c (insn_size): Delete static var.
	(md_begin): Don't set it.
	(m32c_md_end): Delete.
	(md_assemble): Add insn_size auto var.
	* config/tc-m32c.h (md_end): Don't define.
	(m32c_md_end): Delete.
	(NOP_OPCODE, HANDLE_ALIGN, MAX_MEM_FOR_RS_ALIGN_CODE): Define.
	* testsuite/gas/all/align.d: Remove m32c from notarget list.
	* testsuite/gas/all/incbin.d: Likewise.
	* testsuite/gas/elf/dwarf2-11.d: Likewise.
	* testsuite/gas/macros/semi.d: Likewise.
	* testsuite/gas/all/gas.exp (do_comment): Similarly.
ld/
	* testsuite/ld-scripts/fill.d: Don't xfail m32c
	* testsuite/ld-scripts/fill16.d: Likewise.
2019-05-04 17:23:18 +09:30
Alan Modra a288c27099 PR24511, nm should not mark symbols in .init_array as "t"
This patch restricts the section names matched in coff_section_type,
a function that translates section names to symbol type, and arranges
to translate section flags to symbol type before looking at names.
The latter change resulted in various test failures due to improper
section flags being used in tests, and by the plugin support, so fix
that too.

The new test fails on many ELF targets that lack .init/fini_array
in their scripts.  I've just xfailed those.  pru-elf oddly defines
__init_array_begin rather than __init_array_start.  I've left that
target as a FAIL, and pj-elf too which reports an error for undefined
weak symbols.

bfd/
	PR 24511
	* syms.c (coff_section_type): Only allow '.', '$' and numeric
	following the standard section names.
	(bfd_decode_symclass): Prioritize section flag tests in
	decode_section_type before name tests in coff_section_type.
	* plugin.c (bfd_plugin_canonicalize_symtab): Init fake_section
	and fake_common_section using BFD_FAKE_SECTION.  Use "fake" as
	their names and choose standard .text section flags for
	fake_section.
ld/
	PR 24511
	* testsuite/ld-elf/pr14156a.d: Allow for .init/.fini being a
	data section on hppa64.
	* testsuite/ld-elf/pr14156b.d: Likewise.
	* testsuite/ld-scripts/pr18963.t: Map standard sections to set
	output section flags.
	* testsuite/ld-scripts/sane1.t: Likewise.
	* testsuite/ld-elf/init-fini-arrays.s: Reference __init_array_start
	and __fini_array_start.  Define __start et al.
	* testsuite/ld-elf/pr24511.d: New test.
2019-05-04 16:57:33 +09:30
Alan Modra 066f4018ae PowerPC64 GOT indirect to GOT relative optimisation
This implements an optimisation that converts sequences like
  addis r9,r2,sym@got@ha
  ld r3,sym@got@l(r9)
to
  addis r9,r2,sym@toc@ha
  addi r3,r9,sym@toc@l
when "sym" is locally defined and can't be overridden.

bfd/
	* elf64-ppc.c (struct ppc64_elf_obj_tdata): Add has_gotrel.
	(struct _ppc64_elf_section_data): Likewise.
	(ppc64_elf_check_relocs): Set above fields.
	(ppc64_elf_edit_toc): Add a pass over GOT relocs.
	(ppc64_elf_relocate_section): Edit GOT indirect to GOT relative
	when possible.
ld/
	* testsuite/ld-powerpc/elfv2exe.d: Update.
	* testsuite/ld-powerpc/elfv2so.d: Update.
	* testsuite/ld-powerpc/tocopt.d: Update.
	* testsuite/ld-powerpc/tocopt.s: Update.
	* testsuite/ld-powerpc/tocopt5.d: Update.
	* testsuite/ld-powerpc/tocopt5.s: Update.
	* testsuite/ld-powerpc/tocopt7.d: Update.
	* testsuite/ld-powerpc/tocopt7.s: Update.
	* testsuite/ld-powerpc/tocopt8.d: Update.
	* testsuite/ld-powerpc/tocopt8.s: Update.
2019-04-30 22:09:54 +09:30
Alan Modra 06ddcada14 ld.texi tweak for pod2man
Fixes the following error:
ld.pod around line 568: Expected '=item *'
POD document had syntax errors at /usr/bin/pod2man line 71.

	* ld.texi (How GNU properties are merged): Avoid pod2man error.
	Correct example.
2019-04-30 22:04:32 +09:30
H.J. Lu c54f15248e Don't complain undefined weak dynamic reference
When undefined non-weak references in IR objects are optimized out
by LTO, we can have weak dynamic referencs to symbols marked with
bfd_link_hash_undefined.  We shouldn't complain such undefined weak
dynamic references.

bfd/

	PR ld/24486
	* elflink.c (elf_link_output_extsym): Don't complain undefined
	weak dynamic reference.

ld/

	PR ld/24486
	* testsuite/ld-plugin/lto.exp: Run PR ld/24486 tests.
	* testsuite/ld-plugin/pr24486a.c: New file.
	* testsuite/ld-plugin/pr24486b.c: Likewise.
	* testsuite/ld-plugin/pr24486c.c: Likewise.
2019-04-26 07:52:09 -07:00
Nick Clifton 8e1920d611 Updated Russian translation for the ld subdirectory.
* po/ru.po: Updated Russian translation.
2019-04-26 15:29:39 +01:00
Christopher Yeleighton a094d01f01 Fix the hyphenation of word phrases such as "target specific" and "machine specific".
* ld.texi: Properly hyphenate the word "specific".
2019-04-26 15:23:59 +01:00
H.J. Lu 6fe014bcd3 LTO: Properly handle wrapper symbols in IR
When a wrapper symbol, __wrap_FOO, is defined in IR, its resolution
should be LDPR_PREVAILING_DEF, not PREVAILING_DEF_IRONLY, since LTO
doesn't know that __wrap_FOO provides definition of FOO.  And resolution
of FOO should be LDPR_RESOLVED_IR since it is resolved by __wrap_FOO in
IR.

	PR ld/24406
	* ld.texi: Remove LTO warning from --wrap.
	* plugin.c (get_symbols): Update resolution for wrapper and
	wrapped symbols.
	* testsuite/ld-plugin/lto.exp: Run ld/24406 tests.
	* testsuite/ld-plugin/pr24406-1.c: New file.
	* testsuite/ld-plugin/pr24406-2a.c: Likewise.
	* testsuite/ld-plugin/pr24406-2b.c: Likewise.
2019-04-25 07:54:00 -07:00
Sudakshina Das 68bb0359ee [BFD, AArch64] Improve bti/pac plts.
This patch aims to improve the definitions of BTI and PAC based PLTs.
The following changes are made:
   * PLT0 does not need PAC instructions since the PLTGOT[2] (and PLTGOT[1])
     are readonly so they cannot be corrupted at runtime. Thus both PAC plt0
     and BTI+PAC plt0 are removed and we can use basic plt0 and BTI plt0
     instead, respectively.
   * We can remove the extra padding nops when we add the new bti instructions.
     BTI plt0 and BTI TLSDESC plt are updated.
   * For better performance PLTn could be padded to 24bytes. Both BTI pltn and
     PAC pltn are updated.

*** bfd/ChangeLog ***

2019-04-25  Sudakshina Das  <sudi.das@arm.com>

	* elfnn-aarch64.c (PLT_BTI_ENTRY_SIZE): Remove.
	(PLT_BTI_TLSDESC_ENTRY_SIZE): Remove.
	(PLT_PAC_ENTRY_SIZE, PLT_BTI_PAC_ENTRY_SIZE): Remove.
	(PLT_BTI_SMALL_ENTRY_SIZE, PLT_PAC_SMALL_ENTRY_SIZE): Update.
	(elfNN_aarch64_small_plt0_pac_entry): Remove.
	(elfNN_aarch64_small_plt0_bti_pac_entry): Remove.
	(elfNN_aarch64_small_plt0_bti_entry): Update.
	(elfNN_aarch64_small_plt_bti_entry): Update.
	(elfNN_aarch64_small_plt_pac_entry): Update.
	(elfNN_aarch64_tlsdesc_small_plt_bti_entry): Update.
	(setup_plt_values): Setup new entries.
	(elfNN_aarch64_finish_dynamic_sections): Remove size change.
	(elfNN_aarch64_plt_sym_val): Likewise.

*** ld/ChangeLog ***

2019-04-25  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/ld-aarch64/bti-pac-plt-1.d: Update.
	* testsuite/ld-aarch64/bti-pac-plt-2.d: Update.
	* testsuite/ld-aarch64/bti-plt-1.d: Update.
	* testsuite/ld-aarch64/bti-plt-3.d: Update.
	* testsuite/ld-aarch64/bti-plt-5.d: Update.
	* testsuite/ld-aarch64/pac-plt-1.d: Update.
	* testsuite/ld-aarch64/pac-plt-2.d: Update.
2019-04-25 11:37:25 +01:00
Sandra Loosemore 44ed80923a Use better test for usable compiler in ld testsuite.
The ld testsuite includes numerous tests that depend on being able to
compile and link programs with the C compiler.  Some of these tests
use [which $CC] to check for the presence of the compiler before
proceeding with the test, but run_ld_link_exec_tests and run_cc_link_tests
give ERRORs if compilation fails.  Also, even if $CC is defined and present,
it may not be usable due to missing libraries, etc.

This patch adds a new procedure check_compiler_available that attempts
to build an empty program and caches the result.  Uses of [which $CC]
are replaced with calls to this procedure, and run_ld_link_exec_tests
and run_cc_link_tests now also guard attempts to use $CC.

2019-04-24  Sandra Loosemore  <sandra@codesourcery.com>

	ld/
	* testsuite/config/default.exp: Use [check_compiler_available]
	instead of [which $CC].
	* testsuite/ld-auto-import/auto-import.exp: Likewise.
	* testsuite/ld-cygwin/exe-export.exp: Likewise.
	* testsuite/ld-elf/audit.exp: Likewise.
	* testsuite/ld-elf/compress.exp: Likewise.
	* testsuite/ld-elf/dwarf.exp: Likewise.
	* testsuite/ld-elf/elf.exp: Likewise.
	* testsuite/ld-elf/indirect.exp: Likewise.
	* testsuite/ld-elf/linux-x86.exp: Likewise.
	* testsuite/ld-elf/shared.exp: Likewise.
	* testsuite/ld-elf/tls.exp: Likewise.
	* testsuite/ld-elf/wrap.exp: Likewise.
	* testsuite/ld-elfcomm/elfcomm.exp: Likewise.
	* testsuite/ld-elfvers/vers.exp: Likewise.
	* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
	* testsuite/ld-elfweak/elfweak.exp: Likewise.
	* testsuite/ld-gc/gc.exp: Likewise.
	* testsuite/ld-i386/i386.exp: Likewise.
	* testsuite/ld-i386/no-plt.exp: Likewise.
	* testsuite/ld-i386/tls.exp: Likewise.
	* testsuite/ld-ifunc/ifunc.exp: Likewise.
	* testsuite/ld-mn10300/mn10300.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-pie/pie.exp: Likewise.
	* testsuite/ld-plugin/lto.exp: Likewise.
	* testsuite/ld-plugin/plugin.exp: Likewise.
	* testsuite/ld-scripts/crossref.exp: Likewise.
	* testsuite/ld-sh/sh.exp: Likewise.
	* testsuite/ld-shared/shared.exp: Likewise.
	* testsuite/ld-size/size.exp: Likewise.
	* testsuite/ld-srec/srec.exp: Likewise.
	* testsuite/ld-undefined/undefined.exp: Likewise.
	* testsuite/ld-unique/unique.exp: Likewise.
	* testsuite/ld-x86-64/mpx.exp: Likewise.
	* testsuite/ld-x86-64/no-plt.exp: Likewise.
	* testsuite/ld-x86-64/tls.exp: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Call
	check_compiler_available before trying to use the compiler.
	(run_cc_link_tests): Likewise.
	(check_compiler_available): New.  Use it instead of [which $CC].
2019-04-24 12:14:56 -07:00
Alan Modra cc9519e7d6 Fix automatic makefile dependencies for generated ld/e*.c
Commit c40e31a121 broke --enable-dependency-tracking=no.

	* Makefile.am (GENDEPDIR): New var, used..
	(GENSCRIPTS): ..here.
	* Makefile.in: Regenerate.
	* genscripts.sh: Test for $DEPDIR set before every use.
2019-04-23 17:02:44 +09:30
Matthew Fortune 6f38008bb4 Fix M5100 flags test with interAptiv-MR2
ld/
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Fix expected ASEs
	for M5100.
2019-04-22 20:41:03 -07:00
Alan Modra fce9773608 s12z and h8300 no-print-map-discarded fails
This tidies the remaining --no-print-map-discarded fails.  h8300-elf
warns on a section without flags, and s12z doesn't support
--gc-sections.

bfd/
	* elf32-s12z.c (elf_backend_can_gc_sections): Don't define
ld/
	* testsuite/ld-gc/skip-map-discarded.s: Add section attributes.
	* testsuite/lib/ld-lib.exp (check_gc_sections_available): Add
	s12z to list of targets not supporting --gc-sections.
2019-04-19 12:41:58 +09:30
H.J. Lu 9a7f0679fd x86: Suggest -fPIE when not building shared object
When PIC is needed, linker should suggest -fPIE, instead of -fPIC, when
not building shared object.

bfd/

	* elf64-x86-64.c (elf_x86_64_need_pic): Suggest -fPIE when not
	building shared object.
	* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Likewise.

ld/

	* testsuite/ld-i386/i386.exp: Run pr18801a and pr18801b instead
	of pr18801.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr18801.d: Removed.
	* testsuite/ld-x86-64/pr18801.d: Likewise.
	* testsuite/ld-i386/pr18801a.d: New file.
	* testsuite/ld-i386/pr18801b.d: Likewise.
	* testsuite/ld-x86-64/pr18801a.d: Likewise.
	* testsuite/ld-x86-64/pr18801b.d: Likewise.
	* testsuite/ld-x86-64/pie2.d: Suggest -fPIE instead of -fPIC.
	* testsuite/ld-x86-64/pie2.d: Likewise.
	* testsuite/ld-x86-64/pr19719.d: Likewise.
	* testsuite/ld-x86-64/pr19807-2a.d: Likewise.
	* testsuite/ld-x86-64/pr19969.d: Likewise.
	* testsuite/ld-x86-64/pr21997-1a.err: Likewise.
	* testsuite/ld-x86-64/pr21997-1b.err: Likewise.
	* testsuite/ld-x86-64/pr22001-1a.err: Likewise.
	* testsuite/ld-x86-64/pr22001-1b.err: Likewise.
	* testsuite/ld-x86-64/pr22791-1.err: Likewise.
2019-04-17 10:25:28 -07:00
H.J. Lu 4e84a8f8bb x86: Also check x86 linker_def for non-shared definition
Since elf_x86_linker_defined sets linker_def in elf_x86_link_hash_entry
for linker defined symbols, SYMBOL_DEFINED_NON_SHARED_P should also check
linker_def in elf_x86_link_hash_entry.

bfd/

	PR ld/24458
	* elfxx-x86.h (SYMBOL_DEFINED_NON_SHARED_P): Also check x86
	linker_def.

ld/

	PR ld/24458
	* testsuite/ld-x86-64/x86-64.exp: Run PR ld/24458 tests.
	* testsuite/ld-x86-64/pr24458.s: New file.
	* testsuite/ld-x86-64/pr24458a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458a.d: Likewise.
	* testsuite/ld-x86-64/pr24458b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458b.d: Likewise.
	* testsuite/ld-x86-64/pr24458c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458c.d: Likewise.
2019-04-17 09:08:46 -07:00
Jozef Lawrynowicz e25de718de MSP430 Linker: Define __crt0_init_bss/__crt0_movedata symbols when .lower or .either prefixed sections are present.
ld	* config/tc-msp430.c (msp430_make_init_symbols): Define __crt0_init_bss
	symbol when .lower.bss or .either.bss sections exist.
	Define __crt0_movedata when .lower.data or .either.data sections exist.
	* testsuite/gas/msp430/either-data-bss-sym.d: New test.
	* testsuite/gas/msp430/low-data-bss-sym.d: New test.
	* testsuite/gas/msp430/either-data-bss-sym.s: New test source.
	* testsuite/gas/msp430/low-data-bss-sym.s: New test source.
	* testsuite/gas/msp430/msp430.exp: Run new tests.
	Enable large code model when running -mdata-region={upper,either}
	tests.
2019-04-17 15:05:08 +01:00
Alan Modra a0fb961508 ns32k testsuite tidy
Some of these tests were excluded for ns32k-netbsd, exclude for all
ns32k instead.

binutils/
	* testsuite/binutils-all/copy-2.d: Don't run for ns32k-*-*.
	* testsuite/binutils-all/copy-3.d: Likewise.
gas/
	* testsuite/gas/all/gas.exp: Remove ns32k xfails.
	* testsuite/gas/all/weakref1u.d: Don't run for ns32k-*-*.
ld/
	* testsuite/ld-scripts/pr20302.d: Don't run for ns32k-*-*.
	* testsuite/ld-scripts/section-match-1.d: Likewise.
	* testsuite/ld-undefined/require-defined.exp: Likewise.
2019-04-16 19:59:55 +09:30
Faraz Shahbazker 86333705ae Skip print-map-discarded test for non-ELF targets
ld/
	* testsuite/ld-gc/gc.exp: Skip print-map-discarded test
	for non-ELF targets.
2019-04-15 08:48:42 -07:00
Andre Vieira f6b2b12db8 [binutils, ARM, 11/16] New BFCSEL instruction for Armv8.1-M Mainline
s patch is part of a series of patches to add support for Armv8.1-M Mainline instructions to binutils.

This patch adds the BFCSEL instruction. It also adds a local relocation with a new bfd_reloc_code_real enum.

ChangeLog entries are as follows:

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* reloc.c (BFD_RELOC_THUMB_PCREL_BFCSEL): New relocation.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

*** gas/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>
             Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* config/tc-arm.c (T16_32_TAB): New entriy for bfcsel.
	(do_t_v8_1_branch): New switch case for bfcsel.
	(toU): Define.
	(insns): New instruction for bfcsel.
	(md_pcrel_from_section): New switch case
	for BFD_RELOC_THUMB_PCREL_BFCSEL.
	(md_appdy_fix): Likewise
	(tc_gen_reloc): Likewise.
	* testsuite/gas/arm/armv8_1-m-bfcsel.d: New.
	* testsuite/gas/arm/armv8_1-m-bfcsel.s: New.

*** ld/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/ld-arm/bfcsel.s: New.
	* testsuite/ld-arm/bfcsel.d: New.
	* testsuite/ld-arm/arm-elf.exp: Add above test.

*** opcodes/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* arm-dis.c (thumb32_opcodes): New instruction bfcsel.
	(print_insn_thumb32): Edit the switch case for %Z.
2019-04-15 12:31:42 +01:00
Andre Vieira 65d1bc05e8 [binutils, ARM, 9/16] New BFL instruction for Armv8.1-M Mainline
This patch is part of a series of patches to add support for Armv8.1-M Mainline
instructions to binutils.

This patch adds the BFL instruction.

*** gas/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>
             Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* config/tc-arm.c (T16_32_TAB): New entrie for bfl.
	(do_t_v8_1_branch): New switch case for bfl.
	(insns): New instruction for bfl.
	* testsuite/gas/arm/armv8_1-m-bfl.d: New.
	* testsuite/gas/arm/armv8_1-m-bfl.s: New.
	* testsuite/gas/arm/armv8_1-m-bfl-bad.s: New.
	* testsuite/gas/arm/armv8_1-m-bfl-bad.d: New.
	* testsuite/gas/arm/armv8_1-m-bfl-bad.l: New.
	* testsuite/gas/arm/armv8_1-m-bfl-rel.d: New.
	* testsuite/gas/arm/armv8_1-m-bfl-rel.s: New.

*** ld/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/ld-arm/bfl.s: New.
	* testsuite/ld-arm/bfl.d: New.
	* testsuite/ld-arm/arm-elf.exp: Add above test.

*** opcodes/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* arm-dis.c (thumb32_opcodes): New instruction bfl.
2019-04-15 12:30:33 +01:00
Andre Vieira 4389b29a5a [binutils, ARM, 6/16] New BF instruction for Armv8.1-M Mainline
This patch is part of a series of patches to add support for Armv8.1-M Mainline
instructions to binutils.

This patch adds the BF instruction.

ChangeLog entries are as follows:
*** gas/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>
             Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* config/tc-arm.c (T16_32_TAB): New entries for bf.
	(do_t_branch_future): New.
	(insns): New instruction for bf.
	* testsuite/gas/arm/armv8_1-m-bf.d: New.
	* testsuite/gas/arm/armv8_1-m-bf.s: New.
	* testsuite/gas/arm/armv8_1-m-bf-bad.s: New.
	* testsuite/gas/arm/armv8_1-m-bf-bad.l: New.
	* testsuite/gas/arm/armv8_1-m-bf-bad.d: New.
	* testsuite/gas/arm/armv8_1-m-bf-rel.d: New.
	* testsuite/gas/arm/armv8_1-m-bf-rel.s: New.

*** ld/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/ld-arm/bf.s: New.
	* testsuite/ld-arm/bf.d: New.
	* testsuite/ld-arm/arm-elf.exp: Add above test.

*** opcodes/ChangeLog ***

2019-04-15  Sudakshina Das  <sudi.das@arm.com>

	* arm-dis.c (thumb32_opcodes): New instructions for bf.
2019-04-15 12:30:33 +01:00
Andre Vieira 031254f211 [binutils, ARM, 1/16] Add support for Armv8.1-M Mainline CLI
The patch is straightforward, it does the following:

- support the new Tag_CPU_arch build attribute value, ie.:
   + declare the new value
   + update all the asserts forcing logic to be reviewed for new
     architectures
   + create a corresponding bfd_mach_arm_8_1M_MAIN enumerator in bfd and
     add mapping from Tag_CPU_arch to it
   + teach readelf about new Tag_CPU_arch value
- declare armv8.1-m.main as a supported architecture value
- define Armv8.1-M Mainline in terms of feature bits available
- tell objdump mapping from bfd_mach_arm_8_1M_MAIN enumerator to feature
   bits available
- update architecture-specific logic in gas and bfd guarded by the
   asserts mentioned above.
- tests for all the above

ChangeLog entries are as follows:

*** bfd/ChangeLog ***

2019-04-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* archures.c (bfd_mach_arm_8_1M_MAIN): Define.
	* bfd-in2.h: Regenerate.
	* cpu-arm.c (arch_info_struct): Add entry for Armv8.1-M Mainline.
	* elf32-arm.c (using_thumb_only): Return true for Armv8.1-M Mainline
	and update assert.
	(using_thumb2): Likewise.
	(using_thumb2_bl): Update assert.
	(arch_has_arm_nop): Likewise.
	(bfd_arm_get_mach_from_attributes): Add case for Armv8.1-M Mainline.
	(tag_cpu_arch_combine): Add logic for Armv8.1-M Mainline merging.

*** binutils/ChangeLog ***

2019-04-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* readelf.c (arm_attr_tag_CPU_arch): Add entry for Armv8.1-M Mainline.

*** gas/ChangeLog ***

2019-04-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* config/tc-arm.c (cpu_arch_ver): Add entry for Armv8.1-M Mainline
	Tag_CPU_arch build attribute value.  Reindent.
	(get_aeabi_cpu_arch_from_fset): Update assert.
	(aeabi_set_public_attributes): Update assert for Tag_DIV_use logic.
	* testsuite/gas/arm/attr-march-armv8_1-m.main.d: New test.

*** include/ChangeLog ***

2019-04-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* elf/arm.h (TAG_CPU_ARCH_V8_1M_MAIN): new macro.
	(MAX_TAG_CPU_ARCH): Set value to above macro.
	* opcode/arm.h (ARM_EXT2_V8_1M_MAIN): New macro.
	(ARM_AEXT_V8_1M_MAIN): Likewise.
	(ARM_AEXT2_V8_1M_MAIN): Likewise.
	(ARM_ARCH_V8_1M_MAIN): Likewise.

*** ld/ChangeLog ***

2019-04-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* testsuite/ld-arm/attr-merge-13.attr: New test.
	* testsuite/ld-arm/attr-merge-13a.s: New test.
	* testsuite/ld-arm/attr-merge-13b.s: New test.

*** opcodes/ChangeLog ***

2019-04-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* arm-dis.c (select_arm_features): Add logic for Armv8.1-M Mainline.
2019-04-15 10:54:42 +01:00
Alan Modra c40e31a121 Automatic makefile dependencies for generated ld/e*.c
This patch modifies genscripts.sh to emit dependency info along with
the generated emulation e*.c files.  This is done by a new source_sh
function that records its arg to a file (.deps/e*.Tc), using the
function whenever a shell script is sourced.  Entries in the file are
made unique and written to .deps/e*.Pc.  These files are then
included by the Makefile.

	* Makefile.am (GENSCRIPTS): Pass LIB_PATH as a parameter.  Add
	DEPDIR parameter.
	(ELF_DEPS, ELF_GEN_DEPS, ELF_X86_DEPS): Delete.
	(ALL_EMULATION_SOURCES, ALL_64_EMULATION_SOURCES): Depend on
	$GEN_DEPENDS.
	(e*.c): Delete all dependencies, instead include dependencies
	from $DEPDIR/*.Pc.
	* Makefile.in: Regenerate.
	* configure.ac (source_sh): Define and use function.
	* configure: Regenerate.
	* emulparams/aarch64cloudabib.sh, * emulparams/aarch64elf32b.sh,
	* emulparams/aarch64elfb.sh, * emulparams/aarch64fbsdb.sh,
	* emulparams/aarch64linux32b.sh, * emulparams/aarch64linuxb.sh,
	* emulparams/arcelf.sh, * emulparams/arcelf_prof.sh,
	* emulparams/arclinux.sh, * emulparams/arclinux_nps.sh,
	* emulparams/arclinux_prof.sh, * emulparams/arcv2elf.sh,
	* emulparams/arcv2elfx.sh, * emulparams/armelf_fbsd.sh,
	* emulparams/armelf_linux_eabi.sh,
	* emulparams/armelf_linux_fdpiceabi.sh,
	* emulparams/armelf_nacl.sh, * emulparams/armelf_nbsd.sh,
	* emulparams/armelf_vxworks.sh, * emulparams/armelfb.sh,
	* emulparams/armelfb_fbsd.sh, * emulparams/armelfb_fuchsia.sh,
	* emulparams/armelfb_linux.sh, * emulparams/armelfb_linux_eabi.sh,
	* emulparams/armelfb_linux_fdpiceabi.sh,
	* emulparams/armelfb_nacl.sh, * emulparams/armelfb_nbsd.sh,
	* emulparams/armsymbian.sh, * emulparams/cskyelf_linux.sh,
	* emulparams/elf32_sparc_sol2.sh,
	* emulparams/elf32_sparc_vxworks.sh, * emulparams/elf32_tic6x_be.sh,
	* emulparams/elf32_tic6x_elf_be.sh,
	* emulparams/elf32_tic6x_elf_le.sh,
	* emulparams/elf32_tic6x_linux_be.sh,
	* emulparams/elf32_tic6x_linux_le.sh,
	* emulparams/elf32_x86_64.sh, * emulparams/elf32_x86_64_nacl.sh,
	* emulparams/elf32b4300.sh, * emulparams/elf32bfinfd.sh,
	* emulparams/elf32bmipn32.sh, * emulparams/elf32bsmip.sh,
	* emulparams/elf32btsmip.sh, * emulparams/elf32btsmip_fbsd.sh,
	* emulparams/elf32btsmipn32.sh, * emulparams/elf32btsmipn32_fbsd.sh,
	* emulparams/elf32ebmip.sh, * emulparams/elf32ebmipvxworks.sh,
	* emulparams/elf32elmip.sh, * emulparams/elf32elmipvxworks.sh,
	* emulparams/elf32frvfd.sh, * emulparams/elf32l4300.sh,
	* emulparams/elf32lm32fd.sh, * emulparams/elf32lmip.sh,
	* emulparams/elf32lppc.sh, * emulparams/elf32lppclinux.sh,
	* emulparams/elf32lppcnto.sh, * emulparams/elf32lppcsim.sh,
	* emulparams/elf32lr5900.sh, * emulparams/elf32lr5900n32.sh,
	* emulparams/elf32lriscv.sh, * emulparams/elf32lriscv_ilp32.sh,
	* emulparams/elf32lriscv_ilp32f.sh, * emulparams/elf32lsmip.sh,
	* emulparams/elf32ltsmip.sh, * emulparams/elf32ltsmip_fbsd.sh,
	* emulparams/elf32ltsmipn32.sh, * emulparams/elf32ltsmipn32_fbsd.sh,
	* emulparams/elf32microblazeel.sh, * emulparams/elf32or1k_linux.sh,
	* emulparams/elf32ppc.sh, * emulparams/elf32ppc_fbsd.sh,
	* emulparams/elf32ppccommon.sh, * emulparams/elf32ppclinux.sh,
	* emulparams/elf32ppcnto.sh, * emulparams/elf32ppcsim.sh,
	* emulparams/elf32ppcvxworks.sh, * emulparams/elf32ppcwindiss.sh,
	* emulparams/elf32tilegx_be.sh, * emulparams/elf64_ia64_fbsd.sh,
	* emulparams/elf64_sparc_fbsd.sh, * emulparams/elf64_sparc_sol2.sh,
	* emulparams/elf64alpha_fbsd.sh, * emulparams/elf64alpha_nbsd.sh,
	* emulparams/elf64bmip-defs.sh, * emulparams/elf64bmip.sh,
	* emulparams/elf64btsmip.sh, * emulparams/elf64btsmip_fbsd.sh,
	* emulparams/elf64lppc.sh, * emulparams/elf64lriscv-defs.sh,
	* emulparams/elf64lriscv.sh, * emulparams/elf64lriscv_lp64.sh,
	* emulparams/elf64lriscv_lp64f.sh, * emulparams/elf64ltsmip.sh,
	* emulparams/elf64ltsmip_fbsd.sh, * emulparams/elf64ppc.sh,
	* emulparams/elf64ppc_fbsd.sh, * emulparams/elf64rdos.sh,
	* emulparams/elf64tilegx_be.sh, * emulparams/elf_i386.sh,
	* emulparams/elf_i386_be.sh, * emulparams/elf_i386_fbsd.sh,
	* emulparams/elf_i386_ldso.sh, * emulparams/elf_i386_nacl.sh,
	* emulparams/elf_i386_sol2.sh, * emulparams/elf_i386_vxworks.sh,
	* emulparams/elf_iamcu.sh, * emulparams/elf_k1om.sh,
	* emulparams/elf_k1om_fbsd.sh, * emulparams/elf_l1om.sh,
	* emulparams/elf_l1om_fbsd.sh, * emulparams/elf_x86_64.sh,
	* emulparams/elf_x86_64_cloudabi.sh,
	* emulparams/elf_x86_64_fbsd.sh, * emulparams/elf_x86_64_nacl.sh,
	* emulparams/elf_x86_64_sol2.sh, * emulparams/h8300helf.sh,
	* emulparams/h8300helf_linux.sh, * emulparams/h8300hnelf.sh,
	* emulparams/h8300self.sh, * emulparams/h8300self_linux.sh,
	* emulparams/h8300snelf.sh, * emulparams/h8300sxelf.sh,
	* emulparams/h8300sxelf_linux.sh, * emulparams/h8300sxnelf.sh,
	* emulparams/hppanbsd.sh, * emulparams/hppaobsd.sh,
	* emulparams/m32rlelf.sh, * emulparams/m32rlelf_linux.sh,
	* emulparams/m68kelfnbsd.sh, * emulparams/mn10300.sh,
	* emulparams/msp430X.sh, * emulparams/nds32belf.sh,
	* emulparams/nds32belf16m.sh, * emulparams/nds32belf_linux.sh,
	* emulparams/pjlelf.sh, * emulparams/ppclynx.sh,
	* emulparams/score7_elf.sh, * emulparams/shelf_fd.sh,
	* emulparams/shelf_linux.sh, * emulparams/shelf_nbsd.sh,
	* emulparams/shelf_uclinux.sh, * emulparams/shelf_vxworks.sh,
	* emulparams/shl.sh, * emulparams/shlelf.sh,
	* emulparams/shlelf_fd.sh, * emulparams/shlelf_nbsd.sh,
	* emulparams/shlelf_vxworks.sh: Use source_sh.
	* genscripts.sh: Adjust for changed parameters.  Emit dependencies
	for e*.c to .deps/*.Pc.
	(source_sh): New function, use it throughout to source scripts.
	* genscrba.sh (source_em): Use source_sh.
2019-04-13 12:13:22 +09:30
Alan Modra 50ff67e6cf ld TDIRS substitution
It is no longer true that autoconf/automake cannot substitute vars
with embedded new-lines.

	* configure.ac (TDIRS): Build up tdirs in this variable and
	AC_SUBST, also using AM_SUBST_NOTMAKE.
	* configure: Regenerate.
	* Makefile.am (DISTCLEANFILES): Remove tdirs.
	* Makefile.in: Regenerate.
2019-04-13 12:12:43 +09:30
Nick Clifton 3bbec4bd95 Fix thinko in linker documentation.
PR 24450
	* ld.texi (Output Section Attributes): Add ALIGN_WITH_INPUT to
	example of section attributes.
2019-04-12 13:15:21 +01:00
Faraz Shahbazker 035801cebe ld: Add --no-print-map-discarded option
Add a new option to disable the listing of discarded sections
in map file output.  The use case stems from a large application
built with -ffunction-sections --gc-sections where the list of
discarded sections blows up the map file output.  The default
behaviour remains to print discarded sections,  but the new option
allows us to disable it.

ld/
	* NEWS: Mention new option --no-print-map-discarded.
	* ld.h (ld_config_type) <print_map_discarded>: New field.
	* ldlang.c (lang_map): Conditionally output discarded sections
	in map files based on configuration option.
	* ldlex.h (option_values) <OPTION_PRINT_MAP_DISCARDED,
	OPTION_NO_PRINT_MAP_DISCARDED>: New.
	* ldmain.c (main): Enabled print_map_discarded by default.
	* lexsup.c (ld_options): Add new command-line options.
	(parse_args) <OPTION_NO_PRINT_MAP_DISCARDED,
	OPTION_PRINT_MAP_DISCARDED>: New cases.
	* ld.texi: Document new options.
	* testsuite/ld-gc/gc.exp: Add new test.
	* testsuite/ld-gc/skip-map-discarded.s: New file.
	* testsuite/ld-gc/skip-map-discarded.d: New file.
	* testsuite/ld-gc/skip-map-discarded.map: New file.
2019-04-11 10:16:31 -07:00
H.J. Lu 233a00833b x86: Add -z cet-report=[none|warning|error]
Add -z cet-report=[none|warning|error] to report the missing Intel
Indirect Branch Tracking (IBT) and Shadow Stack (SHSTK) properties
in input .note.gnu.property section.  -z cet-report=none, which is
the default, will make the linker not report missing properties in
input files.  -z cet-report=warning will make the linker issue a
warning for missing properties in input files.  -z cet-report=error
will make the linker issue an error for missing properties in input
files.  Note that -z ibt will turn off the missing IBT property report
and -z shstk will turn off the missing SHSTK property report.
Supported for Linux/i386 and Linux/x86_64.

bfd/

	* elf-linker-x86.h (elf_x86_cet_report): New.
	(elf_linker_x86_params): Add cet_report.
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Report
	missing IBT and SHSTK properties if needed.

ld/

	* ld.texi: Document -z cet-report=[none|warning|error].
	* emulparams/cet.sh: Add -z cet-report=[none|warning|error].
	* testsuite/ld-i386/i386.exp: Run -z cet-report=[warning|error]
	tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/property-x86-cet1.d: New file.
	* testsuite/ld-i386/property-x86-cet2a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet2b.d: Likewise.
	* testsuite/ld-i386/property-x86-cet3a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet3b.d: Likewise.
	* testsuite/ld-i386/property-x86-cet4a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet4b.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5b.d: Likewise.
	* testsuite/ld-i386/property-x86-cet6.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet.s: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet4a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet4a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet4b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet4b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet6-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet6.d: Likewise.
2019-04-11 08:21:30 -07:00
H.J. Lu b3d7a86748 ld: Add -static-pie tests
Add -static-pie tests for DT_INIT_ARRAY, DT_FINI_ARRAY, DT_PREINIT_ARRAY
and IFUNC.

	* testsuite/config/default.exp (STATIC_PIE_LDFLAGS): New.  Set
	to "-static-pie" if target compiler supports it.
	* testsuite/ld-elf/elf.exp: Run -static-pie tests if
	$STATIC_PIE_LDFLAGS isn't empty.
	* testsuite/ld-ifunc/ifunc.exp: Likewise.
2019-04-11 06:52:03 -07:00
Tamar Christina ce12121b63 AArch64: When DF_BIND_NOW don't use TLSDESC GOT value.
When using DF_BIND_NOW on AArch64 we don't reserve the GOT slot for a TLSDESC,
but we still emitted DT_TLSDESC_GOT and DT_TLSDESC_PLT.  This caused random
memory corruption as the "special" value of (bfd_vma)-1 would be set for
dt_tlsdesc_got.

Since we don't have a value of dt_tlsdesc_got I also don't emit DT_TLSDESC_PLT
now becuase it would point to an incomplete PLT. To be able to write the PLT
entry DT_TLSDESC_GOT is needed and since we don't have one we can't write the
PLT entry either.

It is my understanding that GLIBC doesn't need these two entries when not lazy
loading.  Conversely AArch32 does not reserve neither the GOT not the PLT slot
when doing DF_BIND_NOW.

AArch32 does not need these checks because these values are initialized to 0
and so the if (...) checks don't pass, but on AArch64 these are initialized
to (bfd_vma)-1 and thus we need some extra checks.

bfd/ChangeLog:

	PR ld/24302
	* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Don't emit
	DT_TLSDESC_GOT and DT_TLSDESC_PLT when DF_BIND_NOW.
	(elfNN_aarch64_finish_dynamic_sections): Don't write PLT if DF_BIND_NOW.

ld/ChangeLog:

	PR ld/24302
	* testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
	* testsuite/ld-aarch64/tls-relax-gdesc-le-now.d: New test.
2019-04-11 11:30:03 +01:00
H.J. Lu 795e3bb7de ld: Don't define __rel[a]_iplt_start/__rel[a]_iplt_end in PIE
__rel[a]_iplt_start and __rel[a]_iplt_end are defined to handle IFUNC in
static executables.  For PIE, since IFUNC is handled as the part of the
normal dynamic relocation processing, there is no need to define these
symbols in PIE.

	* scripttempl/elf.sc (CREATE_PIC): New.  Set for CREATE_SHLIB or
	CREATE_PIE.
	(__rel_iplt_start): Don't define for CREATE_PIC.
	(__rel_iplt_end): Likewise.
	(__rela_iplt_start): Likewise.
	(__rela_iplt_end): Likewise.
2019-04-10 18:36:22 -07:00
Alan Modra e6aded7c34 Re: XFAIL PR ld/20995 tests for lynxos and nto targets
* testsuite/ld-elf/shared.exp: Don't xfail PR ld/20995 for
	powerpc-nto.
2019-04-10 15:32:56 +09:30
Alan Modra 53b81c6de1 cskyelf.em branch stub handling
This fixes the csky-elf ld-elf/pr21884 and ld-unique/pr21529 failures,
by disabling branch stubs for binary (and other non-csky) output.
The csky-linux target gets branch stubs off by default because
presumably there are reasons why branch stubs were disabled, but
rather than killing the support completely it can be enabled by
--branch-stub.

	* emultempl/cskyelf.em (csk_elf_before_parse): New function,
	setting use_branch_stub false for linux.
	(csky_elf_create_output_section_statements): Do emit this
	function and all others in the file for linux, plus the branch
	option control.  Disable branch stubs when non-ELF.
2019-04-10 13:30:32 +09:30
Alan Modra c55b17b809 Fix some ld dependencies
In looking at the csky-elf vs. csky-linux differences, the first thing
I compared was csky_elf.sh and cskyelf_linux.sh.  Those files are
mostly the same but besides the real differences, annoyingly have some
lines ordered differently.  It's better in such cases to have one file
source the other, making differences plain.  This patch does that for
csky and microblaze, removes an unused variable defined in a few
places, and fixes ld makefile dependencies.

	* Makefile.am (eskyelf.c, eskyelf_linux.c): Depend on cskyelf.em.
	(ecskyelf_linux.c): Depend on cskyelf.sh.
	(eelf32microblazeel.c): Depend on elf32microblaze.sh.
	* Makefile.in: Regenerate.
	* emulparams/cskyelf.sh: Comment regarding cskelf_linux.sh.
	(PAGE_SIZE): Don't define.
	* emulparams/cskyelf_linux.sh: Source sckyelf.sh, leaving just
	the differing variable defs/undefs.
	* emulparams/elf32mcore.sh (PAGE_SIZE): Don't define.
	* emulparams/elf32microblaze.sh: Comment re. elf32microblazeel.sh.
	(OUTPUT_FORMAT): Use BIG_OUTPUT_FORMAT.
	(PAGE_SIZE): Don't define.
	* emulparams/elf32microblazeel.sh: Source elf32microblaze.sh,
	leaving just the differing OUTPUT_FORMAT.
2019-04-10 13:30:32 +09:30
Alan Modra 6feda62721 Regen BLD-POTFILES.in
* po/BLD-POTFILES.in: Regenerate.
2019-04-10 13:30:32 +09:30
H.J. Lu c93c0e7f3f XFAIL PR ld/20995 tests for lynxos and nto targets
lynxos and nto targets don't support RELRO.

	* testsuite/ld-elf/shared.exp: XFAIL PR ld/20995 tests for
	lynxos and nto targets.
2019-04-08 13:55:37 -07:00
H.J. Lu 3ae61bb67d x86: Remove i386-*-kaos* and i386-*-chaos targets
Remove i386-*-kaos* and i386-*-chaos targets since they are no longer
supported by config.sub:

$ .../config.sub i386-kaos
Invalid configuration `i386-kaos': system `kaos' not recognized
$ .../config.sub i386-chaos
Invalid configuration `i386-chaos': system `chaos' not recognized
$

bfd/

	* config.bfd: Remove i[3-7]86-*-kaos* and i[3-7]86-*-chaos targets.

gas/

	* configure.tgt: Remove i386-*-kaos* and i386-*-chaos targets.
	* testsuite/gas/i386/i386.exp: Remove *-*-caos* and "*-*-kaos*
	check.

ld/

	* Makefile.am (ALL_EMULATION_SOURCES): Remove eelf_i386_chaos.c.
	(eelf_i386_chaos.c): Removed.
	* Makefile.in: Regenerated.
	* configure.tgt: Remove i[3-7]86-*-kaos*.
	* emulparams/elf_i386_chaos.sh: Removed.
2019-04-08 11:58:51 -07:00
H.J. Lu da9b5f7be7 Use elf-x86.em for i386-moss and i386-beos
* emulparams/elf_i386_be.sh (EXTRA_EM_FILE): New.
	* emulparams/i386moss.sh (EXTRA_EM_FILE): Likewise.
2019-04-08 11:27:57 -07:00
Alan Modra d970ee2bae Fix i386-lynxos and other runtime linker fails
Segfaults due to htab->params being NULL.

	* emulparams/elf64rdos.sh (EXTRA_EM_FILE): Define.
	* emulparams/i386lynx.sh (EXTRA_EM_FILE): Define.
	* emulparams/i386nto.sh (EXTRA_EM_FILE): Define.
2019-04-08 14:11:57 +09:30
H.J. Lu 5b9c07b278 x86: Move x86-specific linker options to elf_linker_x86_params
Remove x86-specific linker options from bfd_link_info and put them in
elf_linker_x86_params.  Add _bfd_elf_linker_x86_set_options to pass
x86-specific linker options from ld to bfd.

bfd/

	* elf-linker-x86.h: New file.
	* elf32-i386.c (elf_i386_convert_load_reloc): Use htab->params
	to get x86-specific linker options.
	* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Likewise.
	(elf_x86_64_check_relocs): Likewise.
	(elf_x86_64_relocate_section): Likewise.
	(elf_x86_64_link_setup_gnu_properties): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Likewise.
	(_bfd_x86_elf_link_setup_gnu_properties): Likewise.
	(_bfd_elf_linker_x86_set_options): New function.
	* elfxx-x86.h: Include "elf-linker-x86.h".
	(elf_x86_link_hash_table): Add params.

include/

	* bfdlink.h (bfd_link_info): Remove x86-specific linker options.

ld/

	* Makefile.am (ELF_X86_DEPS): Add $(srcdir)/emultempl/elf-x86.em.
	(eelf_i386_sol2.c): Also depend on
	$(srcdir)/emultempl/solaris2-x86.em.
	(eelf_x86_64_sol2.c): Likewise.
	* Makefile.in: Regenerated.
	* emulparams/call_nop.sh: Set x86-specific linker options via
	params.
	* emulparams/cet.sh: Likewise.
	* emulparams/reloc_overflow.sh: Likewise.
	* emulparams/elf32_x86_64.sh (EXTRA_EM_FILE): New.  Set to
	"elf-x86".
	* emulparams/elf_i386.sh: Likewise.
	* emulparams/elf_i386_be.sh: Likewise.
	* emulparams/elf_i386_chaos.sh: Likewise.
	* emulparams/elf_i386_ldso.sh: Likewise.
	* emulparams/elf_i386_vxworks.sh: Likewise.
	* emulparams/elf_iamcu.sh: Likewise.
	* emulparams/elf_k1om.sh: Likewise.
	* emulparams/elf_l1om.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.
	* emulparams/elf_i386_sol2.sh (EXTRA_EM_FILE): Changed to
	"solaris2-x86".
	* emulparams/elf_x86_64_sol2.sh: Likewise.
	* emultempl/elf-x86.em: New file.
	* emultempl/solaris2-x86.em: Likewise.
	* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Don't
	set link_info.call_nop_byte.
2019-04-06 07:25:31 -07:00
Alan Modra c2b1c27545 PowerPC disassembler: Don't emit trailing spaces
When an instruction has operands, the PowerPC disassembler prints
spaces after the opcode so as to line up operands.  If the operands
are all optional and all default value, then no operands are printed,
leaving trailing spaces.  This patch fixes that.

opcodes/
	* ppc-dis.c (print_insn_powerpc): Delay printing spaces after
	opcode until first operand is output.
gas/
	* testsuite/gas/ppc/476.d: Remove trailing spaces.
	* testsuite/gas/ppc/a2.d: Likewise.
	* testsuite/gas/ppc/booke.d: Likewise.
	* testsuite/gas/ppc/booke_xcoff.d: Likewise.
	* testsuite/gas/ppc/e500.d: Likewise.
	* testsuite/gas/ppc/e500mc.d: Likewise.
	* testsuite/gas/ppc/e6500.d: Likewise.
	* testsuite/gas/ppc/htm.d: Likewise.
	* testsuite/gas/ppc/power6.d: Likewise.
	* testsuite/gas/ppc/power8.d: Likewise.
	* testsuite/gas/ppc/power9.d: Likewise.
	* testsuite/gas/ppc/vle.d: Likewise.
ld/
	* testsuite/ld-powerpc/tlsexe32.d: Remove trailing spaces.
	* testsuite/ld-powerpc/tlsopt5.d: Likewise.
	* testsuite/ld-powerpc/tlsopt5_32.d: Likewise.
2019-04-05 12:20:49 +10:30
Alan Modra 1c6aafe894 PR24411, Division is not accepted in MEMORY length expression
Let's hope no one has section names starting with '/' in scripts.  If
they do, this change to fix parsing of '/' in expressiongs will break
their project.

	PR 24411
	ldlex.l (SYMBOLNAMECHAR1): Don't match '/'.
	(<EXPRESSION>"/DISCARD/"): New.
2019-04-03 13:01:49 +10:30
Alan Modra 092da96ac4 ldlex.l tidy
Underscore was specified twice in all these patterns, and backslash
twice in some.  Flex warned about the $SYSROOT rule, which is covered
by earlier rules:  "ldlex.l:386: warning, rule cannot be matched".

	* ldlex.l: Formatting.
	(CMDFILENAMECHAR, CMDFILENAMECHAR1): Delete.
	(FILENAMECHAR1, SYMBOLNAMECHAR1, FILENAMECHAR, WILDCHAR),
	(NOCFILENAMECHAR): Remove duplicate chars.  Reorder.
	(SYMBOLCHARN): Likewise.  Rename to SYMBOLNAMECHAR.
	(<INPUTLIST>"$SYSROOT"..): Delete rule.
2019-04-03 13:01:32 +10:30
Max Filippov 2487ef07c2 bfd: xtensa: fix shrink_dynamic_reloc_sections for export-dynamic
shrink_dynamic_reloc_sections must remove PLT entry that was created for
an undefined weak symbol in the presence of --export-dynamic option when
relaxation coalesces literals pointing to that symbol. This fixes the
following assertion:

  ld: BFD (GNU Binutils) 2.31.1 internal error, aborting at
  elf32-xtensa.c:3292 in elf_xtensa_finish_dynamic_sections

2019-03-29  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* elf32-xtensa.c (shrink_dynamic_reloc_sections): Add
	info->export_dynamic to the conditional.

ld/
	* testsuite/ld-xtensa/relax-undef-weak-pie-export-dynamic.d: New
	test definition.
	* testsuite/ld-xtensa/xtensa.exp
	(relax-undef-weak-pie-export-dynamic): Add new test.
2019-03-29 10:02:10 -07:00
marxin 7ea79cb3af Provide string description of definition, visibility and resolution in LTO plug-in.
ld/ChangeLog:

2019-02-26  Martin Liska  <mliska@suse.cz>

	* plugin.c (get_symbols): Add lto_kind_str, lto_resolution_str,
	lto_visibility_str and use then to inform about plugin-symbols.
	* testsuite/ld-plugin/plugin-12.d: Adjust expected pattern.
2019-03-26 15:22:01 +01:00
Tamar Christina 796d6298bb Arm: Fix Arm disassembler mapping symbol search.
Similar to the AArch64 patches the Arm disassembler has the same issues with
out of order sections but also a few short comings.

For one thing there are multiple code blocks to determine mapping symbols, and
they all work slightly different, and neither fully correct.  The first thing
this patch does is centralise the mapping symbols search into one function
mapping_symbol_for_insn.  This function is then updated to perform a search in
a similar way as AArch64.

Their used to be a value has_mapping_symbols which was used to determine the
default disassembly for objects that have no mapping symbols.  The problem with
the approach was that it was determining this value in the same loop that needed
it, which is why this field could take on the states -1, 0, 1 where -1 means
"don't know".  However this means that until you actually find a mapping symbol
or reach the end of the disassembly glob, you don't know if you did the right
action or not, and if you didn't you can't correct it anymore.

This is why the two jump-reloc-veneers-* testcases end up disassembling some
insn as data when they shouldn't.

Out of order here refers to an object file where sections are not listed in a
monotonic increasing VMA order.

The ELF ABI for Arm [1] specifies the following for mapping symbols:

  1) A text section must always have a corresponding mapping symbol at it's
     start.
  2) Data sections do not require any mapping symbols.
  3) The range of a mapping symbol extends from the address it starts on up to
     the next mapping symbol (exclusive) or section end (inclusive).

However there is no defined order between a symbol and it's corresponding
mapping symbol in the symbol table.  This means that while in general we look
up for a corresponding mapping symbol, we have to make at least one check of
the symbol below the address being disassembled.

When disassembling different PCs within the same section, the search for mapping
symbol can be cached somewhat.  We know that the mapping symbol corresponding to
the current PC is either the previous one used, or one at the same address as
the current PC.

However this optimization and mapping symbol search must stop as soon as we
reach the end or start of the section.  Furthermore if we're only disassembling
a part of a section, the search is a allowed to search further than the current
chunk, but is not allowed to search past it (The mapping symbol if there, must
be at the same address, so in practice we usually stop at PC+4).

lastly, since only data sections don't require a mapping symbol the default
mapping type should be DATA and not INSN as previously defined, however if the
binary has had all its symbols stripped than this isn't very useful.  To fix
this we determine the default based on the section flags.  This will allow the
disassembler to be more useful on stripped binaries.  If there is no section
than we assume you to be disassembling INSN.

[1] https://developer.arm.com/docs/ihi0044/latest/elf-for-the-arm-architecture-abi-2018q4-documentation#aaelf32-table4-7

binutils/ChangeLog:

	* testsuite/binutils-all/arm/in-order-all.d: New test.
	* testsuite/binutils-all/arm/in-order.d: New test.
	* testsuite/binutils-all/arm/objdump.exp: Support .d tests.
	* testsuite/binutils-all/arm/out-of-order-all.d: New test.
	* testsuite/binutils-all/arm/out-of-order.T: New test.
	* testsuite/binutils-all/arm/out-of-order.d: New test.
	* testsuite/binutils-all/arm/out-of-order.s: New test.

ld/ChangeLog:

	* testsuite/ld-arm/jump-reloc-veneers-cond-long.d: Update disassembly.
	* testsuite/ld-arm/jump-reloc-veneers-long.d: Update disassembly.

opcodes/ChangeLog:

	* arm-dis.c (struct arm_private_data): Remove has_mapping_symbols.
	(mapping_symbol_for_insn): Implement new algorithm.
	(print_insn): Remove duplicate code.
2019-03-25 15:05:53 +00:00
Sudakshina Das 4e5391148d [BFD, AArch64, x86] Improve warning for --force-bti
The AArch64 linker option to turn on BTI (--force-bti) warns in case there are
input objects which have a missing GNU NOTE section for BTI. This patch is trying
to improve the warnings that come out.

In order to do so, I propose adding a new argument to elf_merge_gnu_properties
and the backend function merge_gnu_properties. This new argument makes sure
that we now pass both the objects along with the properties to which they
belong to. The x86 backend function has also been updated to match this
change.

*** bfd/ChangeLog ***

2019-03-21  Sudakshina Das  <sudi.das@arm.com>

	* elf-bfd.h (struct elf_backend_data): Add argument to
	merge_gnu_properties.
	* elf-properties.c (elf_merge_gnu_properties): Add argument to
	itself and while calling bed->merge_gnu_properties.
	(elf_merge_gnu_property_list): Update the calls for
	elf_merge_gnu_properties.
	* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update handling
	of --force-bti warning and add argument.
	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add
	warning.
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument.
	* elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in
	declaration.

*** ld/ChangeLog ***

2019-03-21  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
	* testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note section.
	* testsuite/ld-aarch64/bti-plt-6.d: Update warning.
	* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
	* testsuite/ld-aarch64/bti-warn.d: New test.
2019-03-21 16:20:21 +00:00
Alan Modra f84bd4655c Adjust pr14156 test for m68hc1*
The test section alignment is unnecessarily high, overflowing the
m68hc11 page used by .init code.

	* testsuite/ld-elf/fini2.s: Reduce alignment.
	* testsuite/ld-elf/fini3.s: Likewise.
	* testsuite/ld-elf/finin.s: Likewise.
	* testsuite/ld-elf/init2.s: Likewise.
	* testsuite/ld-elf/init3.s: Likewise.
	* testsuite/ld-elf/initn.s: Likewise.
	* testsuite/ld-elf/pr14156a.d: Don't xfail m68hc1*-* or xgate-*.
	* testsuite/ld-elf/pr14156b.d: Don't xfail xgate-*.
2019-03-21 22:19:51 +10:30
Alan Modra 2d3181c7c4 Add SORT_NONE to .init and .fini in scripts
The special case for .init and .fini in update_wild_statements is
ineffective for .init or .fini wildcards inside other output sections.
The special case needs to be on the wildcard, not the output section.
This patch is belt and braces, both fixing update_wild_statements and
the scripts.

	* scripttempl/alpha.sc, * scripttempl/armbpabi.sc,
	* scripttempl/crisaout.sc, * scripttempl/elf32cr16.sc,
	* scripttempl/elf32crx.sc, * scripttempl/elf32xc16x.sc,
	* scripttempl/elf32xc16xl.sc, * scripttempl/elf32xc16xs.sc,
	* scripttempl/elf64hppa.sc, * scripttempl/elf_chaos.sc,
	* scripttempl/elfarc.sc, * scripttempl/elfarcv2.sc,
	* scripttempl/elfd30v.sc, * scripttempl/elfm68hc11.sc,
	* scripttempl/elfm68hc12.sc, * scripttempl/elfm9s12z.sc,
	* scripttempl/elfmicroblaze.sc, * scripttempl/elfxgate.sc,
	* scripttempl/elfxtensa.sc, * scripttempl/epiphany_4x4.sc,
	* scripttempl/ft32.sc, * scripttempl/i386beos.sc,
	* scripttempl/iq2000.sc, * scripttempl/mcorepe.sc,
	* scripttempl/mep.sc, * scripttempl/mips.sc, * scripttempl/moxie.sc,
	* scripttempl/pe.sc, * scripttempl/pep.sc, * scripttempl/ppcpe.sc,
	* scripttempl/tic4xcoff.sc, * scripttempl/tic80coff.sc,
	* scripttempl/v850.sc, * scripttempl/v850_rh850.sc,
	* scripttempl/visium.sc, * scripttempl/xstormy16.sc: Add KEEP and
	SORT_NONE to .init and .fini wildcards.
	* scripttempl/elf32xc16x.sc,
	* scripttempl/elf32xc16xl.sc,
	* scripttempl/elf32xc16xs.sc: Add .fini wildcard.
	* scripttempl/elf_chaos.sc: Add .init output section.
	* scripttempl/elfd30v.sc: Remove duplicate .init.
	* scripttempl/elfm68hc11.sc, * scripttempl/elfm68hc12.sc,
	* scripttempl/elfm9s12z.sc, * scripttempl/elfxgate.sc: Remove
	duplicate .init, and add .fini wildcard.
	* scripttempl/ppcpe.sc (INIT, FINI): Delete.
	* ldlang.c (update_wild_statements): Special case .init and
	.fini in the wildcard, not the output section.
2019-03-21 22:19:20 +10:30
Alan Modra 980a2e42f7 lm32-linux ld testsuite fails
A number of the fails are due to ld supporting the creation of shared
libraries but not allowing linking against them without using an
option like -Bdynamic.
FAIL: Symbol export class test (final shared object)
FAIL: PROVIDE_HIDDEN test 4
FAIL: PROVIDE_HIDDEN test 6
FAIL: PROVIDE_HIDDEN test 10
FAIL: PROVIDE_HIDDEN test 12
FAIL: Build pr22471b.so
FAIL: Build pr22649-2b.so
FAIL: Build pr22649-2d.so
FAIL: PR ld/20828 dynamic symbols with section GC (plain)
FAIL: PR ld/20828 dynamic symbols with section GC (version script)
FAIL: PR ld/20828 dynamic symbols with section GC (versioned)
FAIL: PR ld/21233 dynamic symbols with section GC (--undefined)
FAIL: PR ld/21233 dynamic symbols with section GC (--require-defined)
FAIL: PR ld/21233 dynamic symbols with section GC (EXTERN)
FAIL: Build pr22150
FAIL: PR ld/14170
FAIL: Link using broken linker script
FAIL: pr17068 link --as-needed lib in group
FAIL: ld-gc/pr20022

	* emulparams/elf32lm32fd.sh (DYNAMIC_LINK): Undef.
2019-03-21 08:57:30 +10:30
Alan Modra 3b6c196682 Fix some dlx fails
Generic linker ELF targets using CREATE_OBJECT_SYMBOLS in their
scripts run into a problem.  The file symbols are created by
_bfd_generic_link_output_symbols in each object file, in the section
corresponding to the CREATE_OBJECT_SYMBOLS section, typically .text.
If it so happens that the output .text section is stripped due to
being empty, then elf.c:assign_section_numbers won't assign an ELF
section number and swap_out_syms will report "unable to find
equivalent output section" for the object symbols.  Fix this by
always keeping an output section with CREATE_OBJECT_SYMBOLS.

	* ldlang.c (lang_size_sections_1): Set SEC_KEEP on
	create_object_symbols_section.
	* testsuite/ld-elf/pr22319.d: Don't xfail dlx.
2019-03-21 08:45:28 +10:30
Alan Modra 28a66f07f0 csky ld testsuite fixes
* testsuite/ld-elf/merge.d: Remove csky from xfails, add moxie.
	* testsuite/ld-elf/pr21884.d: Remove csky from xfails.
	* testsuite/ld-elf/shared.exp: Add csky to list not xfailing pr22374.
	* testsuite/ld-unique/pr21529.d: Remove csky from xfails
2019-03-18 22:37:26 +10:30
Nick Clifton 1c82ed745b Update the documentation describing where the linker will attempt to locate plugins.
PR 24262
	* ld.texi (-plugin): Correct the path used to locate linker
	plugins.
2019-03-15 12:08:56 +00:00
Sudakshina Das 1dbade7441 [BFD, LD, AArch64, 3/3] Add --pac-plt to enable PLTs protected with PAC.
This is part of the patch series to add support for BTI and
PAC in AArch64 linker.

1) This patch adds new definitions of PAC enabled PLTs
and both BTI and PAC enabled PLTs.
2) It also defines the new dynamic tag DT_AARCH64_PAC_PLT
for the PAC enabled PLTs.
3) This patch adds a new ld command line option: --pac-plt.
In the presence of this option, the linker uses the PAC
enabled PLTs and marks with DT_AARCH64_PAC_PLT.
4) In case both BTI and PAC are enabled the linker should
pick PLTs enabled with both and also use dynamic tags for both.
All these are made according to the new AArch64 ELF ABI
https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4

*** bfd/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* elfnn-aarch64.c (PLT_PAC_ENTRY_SIZE, PLT_PAC_SMALL_ENTRY_SIZE): New.
	(PLT_BTI_PAC_ENTRY_SIZE, PLT_BTI_PAC_SMALL_ENTRY_SIZE): New.
	(setup_plt_values): Account for PAC or PAC and BTI enabled PLTs.
	(elfNN_aarch64_size_dynamic_sections): Add checks for PLT_BTI_PAC
	and PLT_PAC_PLT.
	(elfNN_aarch64_finish_dynamic_sections): Account for PLT_BTI_PAC.
	(get_plt_type): Add case for DT_AARCH64_PAC_PLT.
	(elfNN_aarch64_plt_sym_val): Add cases for PLT_BTI_PAC and PLT_PAC.

*** binutils/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* readelf.c (get_aarch64_dynamic_type): Add case for
	DT_AARCH64_PAC_PLT.
	(dynamic_section_aarch64_val): Likewise.

*** include/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* elf/aarch64.h (DT_AARCH64_PAC_PLT): New.

*** ld/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* NEWS: Document --pac-plt.
	* emultempl/aarch64elf.em (OPTION_PAC_PLT): New.
	(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add pac-plt.
	(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_PAC_PLT.
	* testsuite/ld-aarch64/aarch64-elf.exp: Add the following tests.
	* testsuite/ld-aarch64/bti-pac-plt-1.d: New test.
	* testsuite/ld-aarch64/bti-pac-plt-2.d: New test.
	* testsuite/ld-aarch64/pac-plt-1.d: New test.
	* testsuite/ld-aarch64/pac-plt-2.d: New test.
	* testsuite/ld-aarch64/bti-plt-1.s: Add .ifndef directive.
2019-03-13 11:47:33 +00:00
Sudakshina Das 37c18eedff [BFD, LD, AArch64, 2/3] Add --force-bti to enable BTI and to select BTI enabled PLTs
This is part of the patch series to add support for BTI and
PAC in AArch64 linker.

1) This patch adds a new ld command line option: --force-bti.
In the presence of this option, the linker enables BTI with the
GNU_PROPERTY_AARCH64_FEATURE_1_BTI feature. This gives out warning
in case of missing gnu notes for BTI in inputs.
2) It also defines a new set of BTI enabled PLTs. These are used either
when all the inputs are marked with GNU_PROPERTY_AARCH64_FEATURE_1_BTI
or when the new --force-bti option is used. This required adding new
fields in elf_aarch64_link_hash_table so that we could make the PLT
related information more generic.
3) It also defines a dynamic tag DT_AARCH64_BTI_PLT. The linker uses
this whenever it picks BTI enabled PLTs.
All these are made according to the new AArch64 ELF ABI
https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4

*** bfd/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* bfd-in.h (aarch64_plt_type, aarch64_enable_bti_type): New.
	(aarch64_bti_pac_info): New.
	(bfd_elf64_aarch64_set_options): Add aarch64_bti_pac_info argument.
	(bfd_elf32_aarch64_set_options): Likewise.
	* bfd-in2.h: Regenerate
	* elfnn-aarch64.c (PLT_BTI_ENTRY_SIZE): New.
	(PLT_BTI_SMALL_ENTRY_SIZE, PLT_BTI_TLSDESC_ENTRY_SIZE): New.
	(elfNN_aarch64_small_plt0_bti_entry): New.
	(elfNN_aarch64_small_plt_bti_entry): New.
	(elfNN_aarch64_tlsdesc_small_plt_bti_entry): New.
	(elf_aarch64_obj_tdata): Add no_bti_warn and plt_type fields.
	(elf_aarch64_link_hash_table): Add plt0_entry, plt_entry and
	tlsdesc_plt_entry_size fields.
	(elfNN_aarch64_link_hash_table_create): Initialise the new fields.
	(setup_plt_values): New helper function.
	(bfd_elfNN_aarch64_set_options): Use new bp_info to set plt sizes and
	bti enable type.
	(elfNN_aarch64_allocate_dynrelocs): Use new size members instead of
	fixed macros.
	(elfNN_aarch64_size_dynamic_sections): Likewise and add checks.
	(elfNN_aarch64_create_small_pltn_entry): Use new generic pointers
	to plt stubs instead of fixed ones and update filling them according
	to the need for bti.
	(elfNN_aarch64_init_small_plt0_entry): Likewise.
	(elfNN_aarch64_finish_dynamic_sections): Likewise.
	(get_plt_type, elfNN_aarch64_get_synthetic_symtab): New.
	(elfNN_aarch64_plt_sym_val): Update size accordingly.
	(elfNN_aarch64_link_setup_gnu_properties): Set up plts if BTI GNU NOTE
	is set.
	(bfd_elfNN_get_synthetic_symtab): Define.
	(elfNN_aarch64_merge_gnu_properties): Give out warning with --force-bti
	and mising BTI NOTE SECTION.

*** binutils/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* readelf.c (get_aarch64_dynamic_type): New.
	(get_dynamic_type): Use above for EM_AARCH64.
	(dynamic_section_aarch64_val): New.
	(process_dynamic_section): Use above for EM_AARCH64.

*** include/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* elf/aarch64.h (DT_AARCH64_BTI_PLT): New.

*** ld/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>
	    Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* NEWS: Document --force-bti.
	* emultempl/aarch64elf.em (plt_type, bti_type, OPTION_FORCE_BTI): New.
	(PARSE_AND_LIST_SHORTOPTS, PARSE_AND_LIST_OPTIONS): Add force-bti.
	(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_FORCE_BTI.
	* testsuite/ld-aarch64/aarch64-elf.exp: Add all the tests below.
	* testsuite/ld-aarch64/bti-plt-1.d: New test.
	* testsuite/ld-aarch64/bti-plt-1.s: New test.
	* testsuite/ld-aarch64/bti-plt-2.s: New test.
	* testsuite/ld-aarch64/bti-plt-2.d: New test.
	* testsuite/ld-aarch64/bti-plt-3.d: New test.
	* testsuite/ld-aarch64/bti-plt-4.d: New test.
	* testsuite/ld-aarch64/bti-plt-5.d: New test.
	* testsuite/ld-aarch64/bti-plt-6.d: New test.
	* testsuite/ld-aarch64/bti-plt-7.d: New test.
	* testsuite/ld-aarch64/bti-plt-so.s: New test.
	* testsuite/ld-aarch64/bti-plt.ld: New test.
2019-03-13 11:47:07 +00:00
Sudakshina Das cd702818c6 [BFD, LD, AArch64, 1/3] Add support for GNU PROPERTIES in AArch64 for BTI and PAC
This is part of the patch series to add support for BTI and
PAC in AArch64 linker.

This patch implements the following:
1) This extends in the gnu property support in the linker for
AArch64 by defining backend hooks for elf_backend_setup_gnu_properties,
elf_backend_merge_gnu_properties and elf_backend_parse_gnu_properties.
2) It defines AArch64 specific GNU property
GNU_PROPERTY_AARCH64_FEATURE_1_AND and 2 bit for BTI and PAC in it.
3) It also adds support in readelf.c to read and print these new
GNU properties in AArch64.
All these are made according to the new AArch64 ELF ABI
https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4

*** bfd/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Exclude
	linker created inputs from merge.
	* elfnn-aarch64.c (struct elf_aarch64_obj_tdata): Add field for
	GNU_PROPERTY_AARCH64_FEATURE_1_AND properties.
	(elfNN_aarch64_link_setup_gnu_properties): New.
	(elfNN_aarch64_merge_gnu_properties): New.
	(elf_backend_setup_gnu_properties): Define for AArch64.
	(elf_backend_merge_gnu_properties): Likewise.
	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Define.
	(_bfd_aarch64_elf_parse_gnu_properties): Define.
	(_bfd_aarch64_elf_merge_gnu_properties): Define.
	* elfxx-aarch64.h (_bfd_aarch64_elf_link_setup_gnu_properties): Declare.
	(_bfd_aarch64_elf_parse_gnu_properties): Declare.
	(_bfd_aarch64_elf_merge_gnu_properties): Declare.
	(elf_backend_parse_gnu_properties): Define for AArch64.

*** binutils/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* readelf.c (decode_aarch64_feature_1_and): New.
	(print_gnu_property_note): Add case for AArch64 gnu notes.

*** include/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* elf/common.h (GNU_PROPERTY_AARCH64_FEATURE_1_AND): New.
	(GNU_PROPERTY_AARCH64_FEATURE_1_BTI): New.
	(GNU_PROPERTY_AARCH64_FEATURE_1_PAC): New.

*** ld/ChangeLog ***

2019-03-13  Sudakshina Das  <sudi.das@arm.com>

	* NEWS: Document GNU_PROPERTY_AARCH64_FEATURE_1_BTI and
	GNU_PROPERTY_AARCH64_FEATURE_1_PAC.
	* testsuite/ld-aarch64/aarch64-elf.exp: Add run commands for new tests.
	* testsuite/ld-aarch64/property-bti-pac1.d: New test.
	* testsuite/ld-aarch64/property-bti-pac1.s: New test.
	* testsuite/ld-aarch64/property-bti-pac2.d: New test.
	* testsuite/ld-aarch64/property-bti-pac2.s: New test.
	* testsuite/ld-aarch64/property-bti-pac3.d: New test.
2019-03-13 11:47:00 +00:00
H.J. Lu 44b27f959a x86: Properly set IBT and SHSTK properties for -z ibt/shstk
There should be no AND properties if some input doesn't have them.  We
should set IBT and SHSTK properties for -z ibt and -z shstk if needed.

bfd/

	PR ld/24322
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Properly
	merge GNU_PROPERTY_X86_FEATURE_1_[IBT|SHSTK].

ld/

	PR ld/24322
	* testsuite/ld-i386/i386.exp: Run PR ld/24322 tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr24322a.d: New file.
	* testsuite/ld-i386/pr24322b.d: Likewise.
	* testsuite/ld-x86-64/pr24322a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24322a.d: Likewise.
	* testsuite/ld-x86-64/pr24322b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24322b.d: Likewise.
	* testsuite/ld-x86-64/pr24322a.s: Likewise.
	* testsuite/ld-x86-64/pr24322b.s: Likewise.
	* testsuite/ld-x86-64/pr24322c.s: Likewise.
2019-03-13 14:38:29 +08:00
Nick Bowler 912ebfa0d7 Allow the use of the ORIGIN and LENGTH attributes in expressions inside MEMORY regions.
PR 24289
	* ldexp.c (fold_name): Allow lookups of the LENGTH and ORIGIN
	attributes during the first phase.
2019-03-06 15:20:29 +00:00
Andreas Krebbel 24801b1576 Revert "Add support to GNU ld to separate got related plt entries"
bfd/ChangeLog:

2019-03-01  Andreas Krebbel  <krebbel@linux.ibm.com>

	This reverts commit 5a12586d44.
	2019-01-14  Maamoun Tarsha  <maamountk@hotmail.com>

	PR 20113
	* elf32-s390.c (allocate_dynrelocs): Update comment.

ld/ChangeLog:

2019-03-01  Andreas Krebbel  <krebbel@linux.ibm.com>

	This reverts commit 5a12586d44.
	2019-01-14  Maamoun Tarsha  <maamountk@hotmail.com>

	PR 20113
	* 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-03-01 15:35:00 +01:00
H.J. Lu 5cfe428cd1 x86-64: Skip protected check on symbol defined by linker
Skip symbol defined by linker when checking copy reloc on protected
symbol.

bfd/

	PR ld/24276
	* elf64-x86-64.c (elf_x86_64_check_relocs): Skip symbol defined
	by linker when checking copy reloc on protected symbol.

ld/

	PR ld/24276
	* testsuite/ld-i386/i386.exp: Run PR ld/24276 test.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr24276.dso: New file.
	* testsuite/ld-i386/pr24276.warn: Likewise.
	* testsuite/ld-x86-64/pr24276.dso: Likewise.
	* testsuite/ld-x86-64/pr24276.warn: Likewise.
2019-02-27 11:53:27 -08:00
Max Filippov eed62915fd bfd: xtensa: fix callx relaxation
Big section alignment requirements between source and destination of a
long call can result in making call range bigger than what's reachable
by the call opcode. Add biggest section alignment of sections between
the call site and call destination to the call distance when making
long call relaxation decision.

2019-02-20  Eric Tsai  <erictsai@cadence.com>
bfd/
	* elf32-xtensa.c (is_resolvable_asm_expansion): Scan output
	sections between the call site and call destination and adjust
	call distance by the largest alignment.

ld/
	* testsuite/ld-xtensa/call_overflow.d: New test definition.
	* testsuite/ld-xtensa/call_overflow1.s: New test source.
	* testsuite/ld-xtensa/call_overflow2.s: New test source.
	* testsuite/ld-xtensa/call_overflow3.s: New test source.
	* testsuite/ld-xtensa/xtensa.exp: Add call_overflow test.
2019-02-20 02:51:01 -08:00
Thomas Schwinge abc163a464 [ld, hurd] Remove 'ld-elf/elf.exp' XFAILs
... as a follow-up to commit d981640286 "Run more
ld tests when not native", which replaced by a proper solution the following
mess before present in 'ld/configure.host':

    -*-*-gnu*)
    -  # When creating static executables, we ought to use crt0.o instead of crt1.o,
    -  # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static>,
    -  # but the testing infrastructure is not prepared for that.  This is not
    -  # relevant for most tests, and the few remaining ones have been XFAILed.
    -  HOSTING_CRT0='[...]'
    -  HOSTING_LIBS='[...]'

	ld/
	* testsuite/ld-elf/elf.exp: Remove Hurd XFAILs.
2019-02-14 17:51:22 +01:00
Nick Clifton e486594504 Updated French translation for ld/ and gold/ subdirectories 2019-02-12 13:22:42 +00:00
Claudiu Zissulescu a0e90a73f0 [ARC] don't force _init/_fini as DT_INIT/DT_FINI.
Recent gcc commit b4371b277f1e ("[ARC] Enable init_array support")
inhibits DT_"INIT,FINI} in favor of DT_{INIT,FINI}ARRAY.

Even prior to that, it seems ARC port is the only one with this
special DT_INIT/FINI handling in linker emulation. Removing it
doesn't seem to change any uClibc/glibc testsuite results,
so this can RIP anyways.

bfd/
    2019-02-01  Vineet Gupta <vgupta@synopsys.com>

           * elf32-arc.c: Delete init_str, fini_str

ld/
    2019-02-01  Vineet Gupta <vgupta@synopsys.com>

           * emultempl/arclinux.em : Delete special INIT/FINI handling.
2019-02-09 11:07:42 +01:00
Nick Clifton 5d3db3e297 Fix typo in description of --start-group/--end-group options.
PR 24175
	* ld.texi (Options): Add missing word to the description of the
	--start-group option.
2019-02-07 14:54:58 +00:00
Alan Modra 4249a53cce Fix some ldscripts/pr24008 fails
These targets were all failing due to extra symbols.
pdp11-dec-aout  +FAIL: ld-scripts/pr24008
powerpc-aix5.1  +FAIL: ld-scripts/pr24008
powerpc-aix5.2  +FAIL: ld-scripts/pr24008
rs6000-aix4.3.3  +FAIL: ld-scripts/pr24008
rs6000-aix5.1  +FAIL: ld-scripts/pr24008
rs6000-aix5.2  +FAIL: ld-scripts/pr24008

Some fails remain, those I saw were segfaults or assertion fails that
indicate target bugs.

	PR ld/24008
	* testsuite/ld-scripts/pr24008.d: Pass with extra target
	defined symbols.
2019-02-06 17:33:54 +10:30
H.J. Lu 83924b3846 x86-64: Restore PIC check for PCREL reloc against protected symbol
commit bd7ab16b45
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Feb 13 07:34:22 2018 -0800

    x86-64: Generate branch with PLT32 relocation

removed check R_X86_64_PC32 relocation against protected symbols in
shared objects.  Since elf_x86_64_check_relocs is called after we
have seen all input files, we can check for PC-relative relocations in
elf_x86_64_check_relocs.  We should not allow PC-relative relocations
against protected symbols since address of protected function and
location of protected data may not be in the shared object.

bfd/

	PR ld/24151
	* elf64-x86-64.c (elf_x86_64_need_pic): Check
	SYMBOL_DEFINED_NON_SHARED_P instead of def_regular.
	(elf_x86_64_relocate_section): Move PIC check for PC-relative
	relocations to ...
	(elf_x86_64_check_relocs): Here.
	(elf_x86_64_finish_dynamic_symbol): Use SYMBOL_DEFINED_NON_SHARED_P
	to check if a symbol is defined in a non-shared object.
	* elfxx-x86.h (SYMBOL_DEFINED_NON_SHARED_P): New.

ld/

	PR ld/24151
	* testsuite/ld-x86-64/pr24151a-x32.d: New file.
	* testsuite/ld-x86-64/pr24151a.d: Likewise.
	* testsuite/ld-x86-64/pr24151a.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr24151a and pr24151a-x32.
2019-02-05 18:45:34 -08:00
Alan Modra 4f4690cd42 Document ld -t behaviour
* NEWS: Mention -t change.
	* ld.texi (--trace/-t): Expand documentation a little.
2019-01-31 11:37:44 +10:30
H.J. Lu ad0f979c9d Add a testcase for PR ld/24008
PR ld/24008
	* testsuite/ld-scripts/defined.exp: Run pr24008.
	* testsuite/ld-scripts/pr24008.d: New file.
	* testsuite/ld-scripts/pr24008.map: Likewise.
	* testsuite/ld-scripts/pr24008.s: Likewise.
	* testsuite/ld-scripts/pr24008.t: Likewise.
2019-01-29 06:07:42 -08:00
Eric Botcazou c49829c3c3 Skip ld/pr23169 on SPARC.
The test is already skipped on PowerPC and Aarch64 because it's invalid.

	* testsuite/ld-ifunc/ifunc.exp: Skip pr23169 on SPARC.
2019-01-29 10:11:01 +01:00
Alan Modra 6a84624340 PR24008, Wrong value of ternary expression in map file
PR 24008
	* ldexp.h (lang_phase_type): Add lang_fixed_phase_enum.
	* ldexp.c (fold_name): Move expld.assign_name check later to
	avoid an extra lookup.
	(exp_fold_tree_1): When lang_fixed_phase_enum, don't change symbol
	values, and don't clear expld.assign_name.
	* ldlang.c (lang_map): Set expld.phase to lang_fixed_phase_enum.
	(print_assignment): Resolve entire assignment expression.
	Don't access symbol u.def unless symbol is defined.
2019-01-28 09:59:29 +10:30
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