Commit Graph

7322 Commits

Author SHA1 Message Date
Alan Modra 8941017bc0 ppc apuinfo for spe parsed incorrectly
apuinfo saying SPE resulted in mach = bfd_mach_ppc_vle due to a
missing break.

	PR 20531
	* elf32-ppc.c (_bfd_elf_ppc_set_arch): Add missing "break".
2016-08-30 21:04:44 +09:30
H.J. Lu 74437ea28f i386: Issue an error on non-PIC call to IFUNC in PIC object
On i386, IFUNC function must be called via PLT.  Since PLT in PIC
object uses EBX register, R_386_PLT32 relocation must be used to
call IFUNC function even when IFUNC function is defined locally.
Linker should issue an error when R_386_PC32 relocation is used
to call IFUNC function.

Since PR ld/19784 tests doesn't use PLT relocation to local IFUNC
function, they are moved to the x86-64 test directory.

bfd/

	PR ld/14961
	PR ld/20515
	* elf32-i386.c (elf_i386_check_relocs): Issue an error when
	R_386_PC32 relocation is used to call IFUNC function in PIC
	object.

ld/

	PR ld/14961
	PR ld/20515
	* testsuite/ld-i386/i386.exp: Run pr20515.
	* testsuite/ld-i386/pr20515.d: New file.
	* testsuite/ld-i386/pr20515.s: Likewise.
	* testsuite/ld-ifunc/ifunc-14a.s: Use R_386_PLT32 to call IFUNC
	function.
	* testsuite/ld-ifunc/ifunc-14c.s: Likewise.
	* testsuite/ld-ifunc/ifunc-2-i386.s: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-i386.s: Likewise.
	* testsuite/ld-ifunc/ifunc.exp: Move PR ld/19784 tests to ...
	* testsuite/ld-x86-64/x86-64.exp: Here.
	* testsuite/ld-ifunc/pr19784a.c: Moved to ...
	* testsuite/ld-x86-64/pr19784a.c: Here.
	* testsuite/ld-ifunc/pr19784b.c: Moved to ...
	* testsuite/ld-x86-64/pr19784b.c: Here.
	* testsuite/ld-ifunc/pr19784c.c: Moved to ...
	* testsuite/ld-x86-64/pr19784c.c: Here.
2016-08-29 08:14:45 -07:00
Alan Modra 53720c495c Lack of SHF_GROUP sections result in ld segfault
PR 20520
	* elf.c (_bfd_elf_setup_sections): Check that SHT_GROUP sections
	have corresponding SHF_GROUP sections.
	(bfd_elf_set_group_contents): Comment.
2016-08-27 09:44:22 +09:30
Alan Modra 8a9e8e72fe Fix commit 980aa3e6
Commit 980aa3e6 was supposed to cure dyn_reloc counting problems, but
did the opposite.  For PIC we count two types of dyn_reloc, those on
pc-relative relocs, and the total.  If a sym needs pc-relative dyn
relocs then all the relocs are dynamic.  If not, then only those that
are must_be_dyn_reloc are dynamic.

	PR 20519
	* elf64-ppc.c (pc_dynrelocs): New function.
	(ppc64_elf_relocate_section): Use it and must_be_dyn_reloc to
	handle pic dynamic relocs.
2016-08-27 09:42:09 +09:30
Thomas Preud'homme 68c3989217 Reduce parameter list in bfd_elf32_arm_target_relocs
2016-08-26  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* bfd-in.h (struct elf32_arm_params): Define.
	(bfd_elf32_arm_set_target_relocs): Rename into ...
	(bfd_elf32_arm_set_target_params): This.  Use a struct
	elf32_arm_params to pass all parameters but the bfd and bfd_link_info.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (bfd_elf32_arm_set_target_relocs): Rename into ...
	(bfd_elf32_arm_set_target_params): This.  Pass all values via a struct
	elf32_arm_params rather than as individual parameters.

ld/
	* emultempl/armelf.em (params): New static variable.
	(thumb_entry_symbol, byteswap_code, target1_is_rel, target2_type,
	fix_v4bx, use_blx, vfp11_denorm_fix, stm32l4xx_fix, fix_cortex_a8,
	no_enum_size_warning, no_wchar_size_warning, pic_veneer,
	merge_exidx_entries, fix_arm1176, cmse_implib): move as part of the
	above new structure.
	(arm_elf_before_allocation): Access static variable from the params
	structure.
	(gld${EMULATION_NAME}_finish): Likewise.
	(arm_elf_create_output_section_statements): Likewise and pass the
	address of that structure to bfd_elf32_arm_set_target_relocs instead
	of the static variables.
	(PARSE_AND_LIST_ARGS_CASES): Access static variable from the params
	structure.
2016-08-26 14:00:39 +01:00
Thomas Preud'homme c2abbbebcc 2016-08-26 Thomas Preud'homme <thomas.preudhomme@arm.com>
bfd/
	* elf32-arm.c (elf32_arm_get_stub_entry): Assert that we don't access
	passed the end of htab->stub_group array.
	(elf32_arm_create_or_find_stub_sec): Likewise.
	(elf32_arm_create_stub): Likewise.
2016-08-26 12:01:47 +01:00
Cupertino Miranda 980aa3e6df Dynamic TLS GOT entries would not be relocated.
Forgot to set should_relocate to TRUE in case of GOT and TLS relocations of
undefined symbols for shared libraries.
In dynamic libraries if symbol is not known the instruction relocation would
not be resolved to point to the respective .got entry.
A test was created to detect similar future mistakes.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* elf32-arc.c (elf_arc_relocate_section): Changed. Set should_relocate
	to TRUE for GOT and TLS relocs.

ld/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* ld/testsuite/ld-arc/tls_gd-01.s: Added a testcase for this patch.
	* ld/testsuite/ld-arc/tls_gd-01.d: Likewise.
2016-08-26 12:09:17 +02:00
Cupertino Miranda 65b94e9097 Fixed -init, -fini linker options.
ARC was overloading this options by forcing DT_INIT AND DT_FINI
to always point to _init and _fini, respectively.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synospsys.com>

	* elf32-arc.c (elf_arc_finish_dynamic_sections): Changed.
2016-08-26 12:09:17 +02:00
Cupertino Miranda 8a36df4dcf Several fixes related to ARC PIE support.
Fixed conditions related to dynamic relocs relative offset patching.
Added arc_link_hash_table to be able to always generate and track
.rela.bss section.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* elf-bfd.h: Added ARC_ELF_DATA to enum elf_target_id.
	* elf32-arc.c (struct elf_arc_link_hash_entry): Added.
	(struct elf_arc_link_hash_table): Likewise.
	(elf_arc_link_hash_newfunc): Likewise.
	(elf_arc_link_hash_table_free): Likewise.
	(arc_elf_link_hash_table_create): Likewise.
	(elf_arc_relocate_section): Fixed conditions related to dynamic
	(elf_arc_check_relocs): Likewise.
	(arc_elf_create_dynamic_sections): Added
	(elf_arc_adjust_dynamic_symbol): Changed access to .rela.bss to be done
	through the hash table.
2016-08-26 12:09:17 +02:00
Cupertino Miranda 4dd72ffdfe Content for TLS_IE_GOT not written to .got.
When no dynamic relocation was generated the .got content would not be
updated for the TLS_IE_GOT relocation addresses.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* arc-got.h (relocate_fix_got_relocs_for_got_info): Fixed addresses in
	debug comments. Fixed address in .got related to TLS_IE_GOT dynamic
	relocation.

ld/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>

	* testsuite/ld-arc/tls_ie-01.s: Added to verify associated fix.
	* testsuite/ld-arc/tls_ie-01.d: Likewise
2016-08-26 12:09:17 +02:00
Cupertino Miranda a87aa054a6 Fixes to legacy ARC relocations.
Added support for ARC_SDA_12 reloc.
Fixed ARC_N32_ME.
Added ME (middle-endian) to ARC_SDA_12 reloc.

bfd/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>
	* reloc.c: Fixed type in ARC_SECTOFF relocations. Added ARC_SDA_12
	relocation.
	* bfd-in2.h: Regenerated from the previous changes.
	* libbfd.h: Regenerated from the previous changes.

include/ChangeLog:

Cupertino Miranda  <cmiranda@synopsys.com>
	* elf/arc-reloc.def: Fixed relocation formula for N*, SDA, SDA_12,
	SDA_16_LD*, S13_PCREL, N32_ME, SECTOFF_* relocations.
	* opcode/arc-func.h (replace_disp12s): Added. Used for SDA_12 relocation.
2016-08-26 12:09:17 +02:00
Thomas Preud'homme 0955507f6e Add support for stable secure gateway veneers addresses
2016-08-26  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* bfd-in.h (bfd_elf32_arm_set_target_relocs): Add a new parameter for
	the input import library bfd.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (struct elf32_arm_link_hash_table): New in_implib_bfd
	and new_cmse_stub_offset fields.
	(stub_hash_newfunc): Initialize stub_offset and stub_template_size to
	-1.
	(elf32_arm_add_stub): Likewise for stub_offset.
	(arm_new_stubs_start_offset_ptr): New function.
	(arm_build_one_stub): Only allocate a stub_offset if it is -1.  Allow
	empty SG veneers to have zero relocations.
	(arm_size_one_stub): Only initialize stub size and template
	information for non empty veneers.  Do not update veneer section size
	if veneer already has an offset.
	(elf32_arm_create_stub): Return the stub entry pointer or NULL instead
	of a boolean indicating success or failure.
	(cmse_scan): Change stub_changed parameter into an integer pointer
	parameter cmse_stub_created to count the number of stub created and
	adapt to change of return value in elf32_arm_create_stub.
	(cmse_entry_fct_p): New function.
	(arm_list_new_cmse_stub): Likewise.
	(set_cmse_veneer_addr_from_implib): Likewise.
	(elf32_arm_size_stubs): Define cmse_stub_created, pass its address to
	cmse_scan instead of that of cmse_stub_changed to compute the number
	of stub created and use it to initialize stub_changed.  Call
	set_cmse_veneer_addr_from_implib after all cmse_scan.  Adapt to change
	of return value in elf32_arm_create_stub.  Use
	arm_stub_section_start_offset () if not NULL to initialize size of
	secure gateway veneers section.  Initialize stub_offset of Cortex-A8
	erratum fix to -1.  Use ret to hold return value.
	(elf32_arm_build_stubs): Use arm_stub_section_start_offset () if not
	NULL to initialize size of secure gateway veneers section.  Adapt
	comment to stress the importance of zeroing veneer section content.
	(bfd_elf32_arm_set_target_relocs): Add new in_implib_bfd parameter to
	initialize eponymous field in struct elf32_arm_link_hash_table.

ld/
	* emultempl/armelf.em (in_implib_filename): Declare and initialize new
	variable.
	(arm_elf_create_output_section_statements): Open import input library
	file for writing and pass resulting in_implib_bfd to
	bfd_elf32_arm_set_target_relocs.
	(PARSE_AND_LIST_PROLOGUE): Define OPTION_IN_IMPLIB option.
	(PARSE_AND_LIST_LONGOPTS): Define --in-implib option.
	(PARSE_AND_LIST_OPTIONS): Add help message for --in-implib option.
	(PARSE_AND_LIST_ARGS_CASES): Handle new OPTION_IN_IMPLIB case.
	* ld.texinfo (--cmse-implib): Update to mention --in-implib.
	(--in-implib): Document new option.
	* NEWS: Likewise.
	* testsuite/ld-arm/arm-elf.exp
	(Secure gateway import library generation): add --defsym VER=1 to gas
	CLI.
	(Secure gateway import library generation: errors): Likewise.
	(Input secure gateway import library): New test.
	(Input secure gateway import library: no output import library):
	Likewise.
	(Input secure gateway import library: not an SG input import library):
	Likewise.
	(Input secure gateway import library: earlier stub section base):
	Likewise.
	(Input secure gateway import library: later stub section base):
	Likewise.
	(Input secure gateway import library: veneer comeback): Likewise.
	(Input secure gateway import library: entry function change):
	Likewise.
	* testsuite/ld-arm/cmse-implib.s: Add input import library testing.
	* testsuite/ld-arm/cmse-implib.rd: Update accordingly.
	* testsuite/ld-arm/cmse-new-implib.out: New file.
	* testsuite/ld-arm/cmse-new-implib.rd: Likewise.
	* testsuite/ld-arm/cmse-new-implib-no-output.out: Likewise.
	* testsuite/ld-arm/cmse-new-implib-not-sg-in-implib.out: Likewise.
	* testsuite/ld-arm/cmse-new-earlier-later-implib.out: Likewise.
	* testsuite/ld-arm/cmse-new-comeback-implib.rd: Likewise.
	* testsuite/ld-arm/cmse-new-wrong-implib.out: Likewise.
2016-08-26 11:00:36 +01:00
Andreas Arnez e3e9290d6c S390: Add support for core dump NOTE sections
This enhances the 32-bit and 64-bit s390 ELF backends with support for
reading and writing the core dump note sections NT_PRSTATUS and
NT_PRPSINFO.  Byte swapping is done as appropriate, such that core files
can now be processed correctly on non-s390 platforms.

bfd/ChangeLog:

	* elf32-s390.c (stdarg.h): New include.
	(elf_s390_grok_psinfo): New function.
	(elf_s390_write_core_note): New function.
	(elf_backend_grok_psinfo): Declare backend hook.
	(elf_backend_write_core_note): Likewise.
	* elf64-s390.c (stdarg.h): New include.
	(elf_s390_grok_prstatus): New function.
	(elf_s390_grok_psinfo): New function.
	(elf_s390_write_core_note): New function.
	(elf_backend_grok_prstatus): Declare backend hook.
	(elf_backend_grok_psinfo): Likewise.
	(elf_backend_write_core_note): Likewise.
2016-08-25 19:13:57 +02:00
Andreas Arnez ceada89664 S390: Indentation fixes in elf32/64-s390.c
Some indentation fixes in elf32-s390.c and elf64-s390.c.  Whitespace
changes only.

bfd/ChangeLog:

	* elf32-s390.c (allocate_dynrelocs): Fix indentation.
	(elf_s390_finish_ifunc_symbol): Likewise.
	(elf_s390_finish_dynamic_symbol): Likewise.
	(elf_s390_finish_dynamic_sections): Likewise.
	(elf_s390_grok_prstatus): Likewise.
	* elf64-s390.c (elf_s390_hash_table): Fix indentation.
	(elf_s390_finish_dynamic_symbol): Likewise.
2016-08-25 19:13:57 +02:00
Anton Kolesov 47f7f636bc [ARC] Parse NOTE section in core dump files
This patch adds function elf32_arc_grok_parse to parse NOTE section of core
dump files. GDB requires this to work properly with core dumps.

bfd/
2016-08-24  Anton Kolesov  <Anton.Kolesov@synopsys.com>

	* elf32-arc.c (elf32_arc_grok_prstatus): New function.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2016-08-24 13:56:32 +02:00
Nick Clifton 6342be709e Fix seg-fault in ARM linker when trying to parse a binary file.
* elf32-arm.c (elf32_arm_count_additional_relocs): Return zero if
	there is no arm data associated with the section.
2016-08-23 09:46:36 +01:00
Alan Modra eacfca90f1 R_OR1K_GOTOFF_* relocations
PR 20475
	* elf32-or1k.c (or1k_elf_relocate_section): Offset from
	_GLOBAL_OFFSET_TABLE_, not start of .got section.
2016-08-23 12:21:25 +09:30
Nick Clifton 5fbe0d878a Free the string buffer used by the chew program to hold each file it parses.
* doc/chew.c (main): Free the string buffer used to files as they
	are parsed.
2016-08-22 14:23:19 +01:00
Alan Modra 888a7fc366 Error on unsupported PowerPC ifuncs
The pr19784 tests fail on ppc32 due to a gcc bug.  The failure should
be noticed when building both libpr19784a.so and libpr19784b.so,
rather than ld building a buggy libpr19784a.so that fails at run time.
This patch fixes that by moving the @local ifunc check out of
check_relocs, where a call destination may not yet be known to be
ifunc.  The patch also adds a related error for -mbss-plt code.

	* elf32-ppc.c (ppc_elf_check_relocs): Move error for @local ifunc..
	(ppc_elf_relocate_section): ..to here.  Comment.  Error on
	detecting -mbss-plt -fPIC local ifuncs too.
	(ppc_elf_size_dynamic_sections): Comment on unnecessary glink
	branch table entries.
2016-08-22 10:55:08 +09:30
Nick Clifton dd90581873 Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets.
bfd
  * elf.c (assign_section_numbers): Assign number for the .shstrtab
  section after the symbol table and string table sections.

binutils
  * testsuite/binutils-all/readelf.s: Adjust expected ordering of
  sections.
  * testsuite/binutils-all/readelf.s-64: Likewise.

gas
  * testsuite/gas/i386/ilp32/x86-64-unwind.d: Adjust expected ordering
  of sections.
  * testsuite/gas/i386/x86-64-unwind.d: Likewise.
  * testsuite/gas/ia64/alias-ilp32.d: Likewise.
  * testsuite/gas/ia64/alias.d: Likewise.
  * testsuite/gas/ia64/group-1.d: Likewise.
  * testsuite/gas/ia64/group-2.d: Likewise.
  * testsuite/gas/ia64/secname-ilp32.d: Likewise.
  * testsuite/gas/ia64/secname.d: Likewise.
  * testsuite/gas/ia64/unwind-ilp32.d: Likewise.
  * testsuite/gas/ia64/unwind.d: Likewise.
  * testsuite/gas/ia64/xdata-ilp32.d: Likewise.
  * testsuite/gas/ia64/xdata.d: Likewise.
  * testsuite/gas/mmix/bspec-1.d: Likewise.
  * testsuite/gas/mmix/bspec-2.d: Likewise.
  * testsuite/gas/mmix/byte-1.d: Likewise.
  * testsuite/gas/mmix/loc-1.d: Likewise.
  * testsuite/gas/mmix/loc-2.d: Likewise.
  * testsuite/gas/mmix/loc-3.d: Likewise.
  * testsuite/gas/mmix/loc-4.d: Likewise.
  * testsuite/gas/mmix/loc-5.d: Likewise.
  * testsuite/gas/tic6x/scomm-directive-4.d: Likewise.

ld
  * testsuite/ld-alpha/tlsbin.rd: Adjust expected ordering of sections.
  * testsuite/ld-alpha/tlsbinr.rd: Likewise.
  * testsuite/ld-alpha/tlspic.rd: Likewise.
  * testsuite/ld-cris/libdso-2.d: Likewise.
  * testsuite/ld-i386/nogot1.d: Likewise.
  * testsuite/ld-i386/pr12718.d: Likewise.
  * testsuite/ld-i386/pr12921.d: Likewise.
  * testsuite/ld-i386/tlsbin-nacl.rd: Likewise.
  * testsuite/ld-i386/tlsbin.rd: Likewise.
  * testsuite/ld-i386/tlsbin2-nacl.rd: Likewise.
  * testsuite/ld-i386/tlsbin2.rd: Likewise.
  * testsuite/ld-i386/tlsbindesc-nacl.rd: Likewise.
  * testsuite/ld-i386/tlsbindesc.rd: Likewise.
  * testsuite/ld-i386/tlsdesc-nacl.rd: Likewise.
  * testsuite/ld-i386/tlsdesc.rd: Likewise.
  * testsuite/ld-i386/tlsgdesc-nacl.rd: Likewise.
  * testsuite/ld-i386/tlsgdesc.rd: Likewise.
  * testsuite/ld-i386/tlsnopic-nacl.rd: Likewise.
  * testsuite/ld-i386/tlsnopic.rd: Likewise.
  * testsuite/ld-i386/tlspic-nacl.rd: Likewise.
  * testsuite/ld-i386/tlspic.rd: Likewise.
  * testsuite/ld-i386/tlspic2-nacl.rd: Likewise.
  * testsuite/ld-i386/tlspic2.rd: Likewise.
  * testsuite/ld-ia64/tlsbin.rd: Likewise.
  * testsuite/ld-ia64/tlspic.rd: Likewise.
  * testsuite/ld-mips-elf/attr-gnu-4-10.d: Likewise.
  * testsuite/ld-mips-elf/attr-gnu-4-50.d: Likewise.
  * testsuite/ld-mips-elf/attr-gnu-4-60.d: Likewise.
  * testsuite/ld-mips-elf/attr-gnu-4-70.d: Likewise.
  * testsuite/ld-mmix/bspec1.d: Likewise.
  * testsuite/ld-mmix/bspec2.d: Likewise.
  * testsuite/ld-mmix/local1.d: Likewise.
  * testsuite/ld-mmix/local3.d: Likewise.
  * testsuite/ld-mmix/local5.d: Likewise.
  * testsuite/ld-mmix/local7.d: Likewise.
  * testsuite/ld-mmix/undef-3.d: Likewise.
  * testsuite/ld-powerpc/tlsexe.r: Likewise.
  * testsuite/ld-powerpc/tlsexe32.r: Likewise.
  * testsuite/ld-powerpc/tlsexetoc.r: Likewise.
  * testsuite/ld-powerpc/tlsso.r: Likewise.
  * testsuite/ld-powerpc/tlsso32.r: Likewise.
  * testsuite/ld-powerpc/tlstocso.r: Likewise.
  * testsuite/ld-s390/tlsbin.rd: Likewise.
  * testsuite/ld-s390/tlsbin_64.rd: Likewise.
  * testsuite/ld-s390/tlspic.rd: Likewise.
  * testsuite/ld-s390/tlspic_64.rd: Likewise.
  * testsuite/ld-sh/sh64/crange1.rd: Likewise.
  * testsuite/ld-sh/sh64/crange2.rd: Likewise.
  * testsuite/ld-sh/sh64/crange3-cmpct.rd: Likewise.
  * testsuite/ld-sh/sh64/crange3-media.rd: Likewise.
  * testsuite/ld-sh/sh64/crange3.rd: Likewise.
  * testsuite/ld-sh/sh64/crangerel1.rd: Likewise.
  * testsuite/ld-sh/sh64/crangerel2.rd: Likewise.
  * testsuite/ld-sh/tlsbin-2.d: Likewise.
  * testsuite/ld-sh/tlspic-2.d: Likewise.
  * testsuite/ld-sparc/gotop32.rd: Likewise.
  * testsuite/ld-sparc/gotop64.rd: Likewise.
  * testsuite/ld-sparc/tlssunbin32.rd: Likewise.
  * testsuite/ld-sparc/tlssunbin64.rd: Likewise.
  * testsuite/ld-sparc/tlssunnopic32.rd: Likewise.
  * testsuite/ld-sparc/tlssunnopic64.rd: Likewise.
  * testsuite/ld-sparc/tlssunpic32.rd: Likewise.
  * testsuite/ld-sparc/tlssunpic64.rd: Likewise.
  * testsuite/ld-tic6x/common.d: Likewise.
  * testsuite/ld-tic6x/shlib-1.rd: Likewise.
  * testsuite/ld-tic6x/shlib-1b.rd: Likewise.
  * testsuite/ld-tic6x/shlib-1r.rd: Likewise.
  * testsuite/ld-tic6x/shlib-1rb.rd: Likewise.
  * testsuite/ld-tic6x/shlib-app-1.rd: Likewise.
  * testsuite/ld-tic6x/shlib-app-1b.rd: Likewise.
  * testsuite/ld-tic6x/shlib-app-1r.rd: Likewise.
  * testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise.
  * testsuite/ld-tic6x/shlib-noindex.rd: Likewise.
  * testsuite/ld-tic6x/static-app-1.rd: Likewise.
  * testsuite/ld-tic6x/static-app-1b.rd: Likewise.
  * testsuite/ld-tic6x/static-app-1r.rd: Likewise.
  * testsuite/ld-tic6x/static-app-1rb.rd: Likewise.
  * testsuite/ld-x86-64/ilp32-4-nacl.d: Likewise.
  * testsuite/ld-x86-64/ilp32-4.d: Likewise.
  * testsuite/ld-x86-64/nogot1.d: Likewise.
  * testsuite/ld-x86-64/pr12718.d: Likewise.
  * testsuite/ld-x86-64/pr12921.d: Likewise.
  * testsuite/ld-x86-64/split-by-file-nacl.rd: Likewise.
  * testsuite/ld-x86-64/split-by-file.rd: Likewise.
  * testsuite/ld-x86-64/tlsbin-nacl.rd: Likewise.
  * testsuite/ld-x86-64/tlsbin.rd: Likewise.
  * testsuite/ld-x86-64/tlsbin2-nacl.rd: Likewise.
  * testsuite/ld-x86-64/tlsbin2.rd: Likewise.
  * testsuite/ld-x86-64/tlsbindesc-nacl.rd: Likewise.
  * testsuite/ld-x86-64/tlsbindesc.rd: Likewise.
  * testsuite/ld-x86-64/tlsdesc-nacl.rd: Likewise.
  * testsuite/ld-x86-64/tlsdesc.rd: Likewise.
  * testsuite/ld-x86-64/tlsgdesc-nacl.rd: Likewise.
  * testsuite/ld-x86-64/tlsgdesc.rd: Likewise.
  * testsuite/ld-x86-64/tlspic-nacl.rd: Likewise.
  * testsuite/ld-x86-64/tlspic.rd: Likewise.
  * testsuite/ld-x86-64/tlspic2-nacl.rd: Likewise.
  * testsuite/ld-x86-64/tlspic2.rd: Likewise.
  * testsuite/ld-xtensa/tlsbin.rd: Likewise.
  * testsuite/ld-xtensa/tlspic.rd: Likewise.
2016-08-19 09:16:30 +01:00
Alan Modra d311bc8bf8 PowerPC64, Don't copy weak symbol dyn_relocs to weakdef.
At the cost of an extra field in the symbol table hash entries, this
simplification to the relocate_section dynamic reloc test should help
maintainability.

	* elf64-ppc.c (struct ppc_link_hash_entry): Add weakref.
	(ppc64_elf_copy_indirect_symbol): Set weakref.  Don't merge
	dyn_relocs for weakdefs.
	(alias_readonly_dynrelocs): New function.
	(ppc64_elf_adjust_dynamic_symbol): Use alias_readonly_dynrelocs.
	(ppc64_elf_relocate_section): Simplify condition under which
	dyn_relocs are emitted.
2016-08-19 11:06:53 +09:30
Alan Modra 8a2058b5e3 PR 20472, PowerPC64 ifunc confusion
This patch fixes quite a lot of confusion in allocate_dynrelocs over
ifuncs.  Function descriptors make ELFv1 quite different to ELFv2.

	PR 20472
	* elf64-ppc.c (ppc64_elf_before_check_relocs): Tweak abiversion test.
	(readonly_dynrelocs): Comment fix.
	(global_entry_stub): New function.
	(ppc64_elf_adjust_dynamic_symbol): Tweak abiversion test.  Match
	ELFv2 code deciding on dynamic relocs vs. global entry stubs to
	that in size_global_entry_stubs, handling ifunc too.  Delete dead
	weak sym code.
	(allocate_dynrelocs): Ensure dyn_relocs field is cleared when no
	dyn_relocs are needed.  Correct handling of ifunc dyn_relocs.
	Tidy ELIMINATE_COPY_RELOCS code, only setting dynindx for
	undefweak syms.  Expand and correct comments.
	(size_global_entry_stubs): Ensure symbol is defined.
	(ppc64_elf_relocate_section): Match condition under which
	dyn_relocs are emitted to that in allocate_dynrelocs.
2016-08-19 11:06:41 +09:30
Alan Modra 90ac242072 Correct .dynsym sh_info
bfd/
	* elf-bfd.h (struct elf_link_hash_table): Add local_dynsymcount.
	* elflink.c (_bfd_elf_link_renumber_dynsyms): Set local_dynsymcount.
	(bfd_elf_final_link): Set .dynsym sh_info from local_dynsymcount.
ld/
	* testsuite/ld-tic6x/shlib-1.rd: Correct expected .dynsym sh_info.
	* testsuite/ld-tic6x/shlib-1b.rd: Likewise.
	* testsuite/ld-tic6x/shlib-1r.rd: Likewise.
	* testsuite/ld-tic6x/shlib-1rb.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1b.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1r.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise.
	* testsuite/ld-tic6x/shlib-noindex.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1b.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1r.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1rb.rd: Likewise.
2016-08-13 00:07:20 +09:30
Alan Modra d93d1c80b3 PowerPC64 ELFv1 undefined weak functions
Undefined weak functions, like __gmon_start__, were not being made
dynamic or emitting plt call code.  While the behaviour of undefined
weak symbols is not defined in the ELF standard, the intention on
powerpc64 was to make it possible to link without a definition of such
symbols and at run time behave the same as if a definition was found
at link time in a shared library.

	* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Don't exit with
	non_got_ref true in any case where we could have generated dynbss
	copies but decide not to do so.
2016-08-11 13:00:40 +09:30
Maciej W. Rozycki fe152e64f6 MIPS/BFD: Actually produce short microMIPS LA25 stubs
For the case where a function which requires an LA25 stub is at the
beginning of a section we use a short sequence comprised of a LUI/ADDIU
instruction pair only and prepended to the associated function rather
than using a trailing jump to reach the function.  This works by
checking for the offset into section of the function symbol being 0.

This is however never the case for microMIPS function symbols, which
have the ISA bit set.  Consequently the short LA25 sequence is never
produced for microMIPS functions, like with the following example:

$ cat la25a.s
	.abicalls

	.global	f1
	.ent	f1
f1:
	.set	noreorder
	.cpload	$25
	.set	reorder
	.option	pic0
	jal	f2
	.option	pic2
	jr	$31
	.end	f1

	.global	f2
	.ent	f2
f2:
	jr	$31
	.end	f2
$ cat la25b.s
	.abicalls
	.option	pic0

	.global	__start
	.ent	__start
__start:
	jal	f1
	jal	f2
	.end	__start
$ as -mmicromips -32 -EB -o la25a.o la25a.s
$ as -mmicromips -32 -EB -o la25b.o la25b.s
$ ld -melf32btsmip -o la25 la25a.o la25b.o
$ objdump -d la25

la25:     file format elf32-tradbigmips

Disassembly of section .text:

004000d0 <.pic.f2>:
  4000d0:	41b9 0040 	lui	t9,0x40
  4000d4:	d420 0083 	j	400106 <f2>
  4000d8:	3339 0107 	addiu	t9,t9,263
  4000dc:	0000 0000 	nop

004000e0 <.pic.f1>:
  4000e0:	41b9 0040 	lui	t9,0x40
  4000e4:	d420 0078 	j	4000f0 <f1>
  4000e8:	3339 00f1 	addiu	t9,t9,241
  4000ec:	0000 0000 	nop

004000f0 <f1>:
  4000f0:	41bc 0002 	lui	gp,0x2
  4000f4:	339c 801f 	addiu	gp,gp,-32737
  4000f8:	033c e150 	addu	gp,gp,t9
  4000fc:	f420 0083 	jal	400106 <f2>
  400100:	0000 0000 	nop
  400104:	45bf      	jrc	ra

00400106 <f2>:
  400106:	45bf      	jrc	ra
	...

00400110 <__start>:
  400110:	f420 0070 	jal	4000e0 <.pic.f1>
  400114:	0000 0000 	nop
  400118:	f420 0068 	jal	4000d0 <.pic.f2>
  40011c:	0000 0000 	nop
$

where `.pic.f1' could omit the trailing jump and the filler NOP and just
fall through to `f1'.

Correct the problem by masking out the ISA bit from microMIPS functions,
which fixes the earlier example:

$ objdump -d la25

la25:     file format elf32-tradbigmips

Disassembly of section .text:

004000d0 <.pic.f2>:
  4000d0:	41b9 0040 	lui	t9,0x40
  4000d4:	d420 0083 	j	400106 <f2>
  4000d8:	3339 0107 	addiu	t9,t9,263
	...

004000e8 <.pic.f1>:
  4000e8:	41b9 0040 	lui	t9,0x40
  4000ec:	3339 00f1 	addiu	t9,t9,241

004000f0 <f1>:
  4000f0:	41bc 0002 	lui	gp,0x2
  4000f4:	339c 801f 	addiu	gp,gp,-32737
  4000f8:	033c e150 	addu	gp,gp,t9
  4000fc:	f420 0083 	jal	400106 <f2>
  400100:	0000 0000 	nop
  400104:	45bf      	jrc	ra

00400106 <f2>:
  400106:	45bf      	jrc	ra
	...

00400110 <__start>:
  400110:	f420 0074 	jal	4000e8 <.pic.f1>
  400114:	0000 0000 	nop
  400118:	f420 0068 	jal	4000d0 <.pic.f2>
  40011c:	0000 0000 	nop
$

There is no need to do anything for MIPS16 functions, because if any
LA25 stub has been generated for such a function, then it is only
required for an associated call thunk only, which is regular MIPS code
and the address of which, with the ISA bit clear, is returned by
`mips_elf_get_la25_target'.

This problem has been there since the beginning of microMIPS support:

commit df58fc944d
Author: Richard Sandiford <rdsandiford@googlemail.com>
Date:   Sun Jul 24 14:20:15 2011 +0000

<https://sourceware.org/ml/binutils/2011-07/msg00198.html>, ("MIPS:
microMIPS ASE support").

	bfd/
	* elfxx-mips.c (mips_elf_add_la25_stub): Clear the ISA bit of
	the stub address retrieved if associated with a microMIPS
	function.
2016-08-10 22:22:50 +01:00
Maciej W. Rozycki a848a2271b MIPS/BFD: Add microMIPS annotation to LA25 stub symbols
Fix a problem with missing microMIPS symbol annotation with microMIPS
LA25 stub symbols.  The consequence of the issue is these symbols appear
in the symbol table as regular MIPS symbols with the ISA bit set, as
shown with the example below:

$ cat la25a.s
	.abicalls

	.global	f1
	.ent	f1
f1:
	.set	noreorder
	.cpload	$25
	.set	reorder
	.option	pic0
	jal	f2
	.option	pic2
	jr	$31
	.end	f1

	.global	f2
	.ent	f2
f2:
	jr	$31
	.end	f2
$ cat la25b.s
	.abicalls
	.option	pic0

	.global	__start
	.ent	__start
__start:
	jal	f1
	jal	f2
	.end	__start
$ as -mmicromips -32 -EB -o la25a.o la25a.s
$ as -mmicromips -32 -EB -o la25b.o la25b.s
$ ld -melf32btsmip -o la25 la25a.o la25b.o
$ readelf -s la25

Symbol table '.symtab' contains 18 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00400098     0 SECTION LOCAL  DEFAULT    1
     2: 004000b0     0 SECTION LOCAL  DEFAULT    2
     3: 004000d0     0 SECTION LOCAL  DEFAULT    3
     4: 00000000     0 SECTION LOCAL  DEFAULT    4
     5: 00000000     0 SECTION LOCAL  DEFAULT    5
     6: 00418110     0 NOTYPE  LOCAL  DEFAULT    3 _gp
     7: 004000e1    16 FUNC    LOCAL  DEFAULT    3 .pic.f1
     8: 004000d1    16 FUNC    LOCAL  DEFAULT    3 .pic.f2
     9: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _fdata
    10: 00400110    16 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 __start
    11: 00400106     2 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 f2
    12: 004000d0     0 NOTYPE  GLOBAL DEFAULT    3 _ftext
    13: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 __bss_start
    14: 004000f0    22 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 f1
    15: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _edata
    16: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _end
    17: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _fbss
$

where microMIPS annotation is missing for `.pic.f1' and `.pic.f2' even
though these stubs are associated with microMIPS functions `f1' and `f2'
respectively.

Add the missing annotation then, by copying it from the function symbol
an LA25 stub is associated with, correcting the example above:

$ readelf -s la25

Symbol table '.symtab' contains 18 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00400098     0 SECTION LOCAL  DEFAULT    1
     2: 004000b0     0 SECTION LOCAL  DEFAULT    2
     3: 004000d0     0 SECTION LOCAL  DEFAULT    3
     4: 00000000     0 SECTION LOCAL  DEFAULT    4
     5: 00000000     0 SECTION LOCAL  DEFAULT    5
     6: 00418110     0 NOTYPE  LOCAL  DEFAULT    3 _gp
     7: 004000e0    16 FUNC    LOCAL  DEFAULT [MICROMIPS]     3 .pic.f1
     8: 004000d0    16 FUNC    LOCAL  DEFAULT [MICROMIPS]     3 .pic.f2
     9: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _fdata
    10: 00400110    16 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 __start
    11: 00400106     2 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 f2
    12: 004000d0     0 NOTYPE  GLOBAL DEFAULT    3 _ftext
    13: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 __bss_start
    14: 004000f0    22 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 f1
    15: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _edata
    16: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _end
    17: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _fbss
$

This problem has been there since the beginning of microMIPS support:

commit df58fc944d
Author: Richard Sandiford <rdsandiford@googlemail.com>
Date:   Sun Jul 24 14:20:15 2011 +0000

<https://sourceware.org/ml/binutils/2011-07/msg00198.html>, ("MIPS:
microMIPS ASE support").

	bfd/
	* elfxx-mips.c (mips_elf_create_stub_symbol): For a microMIPS
	stub also add STO_MICROMIPS annotation.
2016-08-10 22:21:15 +01:00
Maciej W. Rozycki c7318def0c MIPS/BFD: Set the ISA bit in microMIPS LA25 stub references
Fix a linker regression introduced with commit 9d862524f6 ("MIPS:
Verify the ISA mode and alignment of branch and jump targets") causing a
build failure in microMIPS glibc where the `zdump' tool fails to link:

.../timezone/zdump.o: In function `yeartot':
.../timezone/zdump.c:758:(.text+0x62): Jump to a non-instruction-aligned address
.../timezone/zdump.c:758:(.text+0x76): Jump to a non-instruction-aligned address
.../timezone/zdump.c:768:(.text+0x112): Jump to a non-instruction-aligned address
.../timezone/zdump.c:774:(.text+0x1b8): Jump to a non-instruction-aligned address
.../timezone/zdump.c:774:(.text+0x1cc): Jump to a non-instruction-aligned address
collect2: error: ld returned 1 exit status
make[2]: *** [.../timezone/zdump] Error 1

The cause of the failure is the stricter check introduced with the said
change for jump and branch targets tripping on the address of microMIPS
LA25 stubs.  Despite being microMIPS code these stubs do not have the
ISA bit set throughout the relocation calculation process, because they
have their address set to the memory offset into the stub section they
are placed in.

The `mips_elf_la25_stub' structure does not carry ISA mode information,
but there is no need to extend it, because the ISA mode can be inferred
from the original symbol, which will have STO_MICROMIPS annotation, so
use that instead to set the ISA bit appropriately.  Also only LA25 stubs
associated with microMIPS symbols need to have the ISA bit set, because
other LA25 stubs are made with regular MIPS code, even if associated
with a MIPS16 symbol (in which case they are needed by a call thunk only
rather than the MIPS16 function proper).

	bfd/
	* elfxx-mips.c (mips_elf_calculate_relocation): Set the ISA bit
	in microMIPS LA25 stub references.
2016-08-10 22:19:33 +01:00
Jiaming Wei 68994ca2c0 Correct the calculation of the use_counts of merged .got entries.
* elf64-alpha.c (elf64_alpha_copy_indirect_symbol): Fix thinko
	adjusting the use_count of merged .got entries.
2016-08-09 16:18:42 +01:00
Nick Clifton 8a286b6345 Fix memory leaks in chew program.
* doc/chew.c (delete_string): Only free the string buffer if it is
	there.  Mark the buffer as NULL after freeing.
	(drop): Free the dropped string.
	(free_words): New function: Frees the memory allocated to the
	dictionary.
	(add_instrinsic): Duplicate the name string, so that it can be
	freed later on.
	(compile): Free unused words.
	(main): Free the dictionary and top level string buffers at the
	end.
2016-08-08 12:19:29 +01:00
Thomas Preud'homme 54ddd295b5 2016-08-04 Thomas Preud'homme <thomas.preudhomme@arm.com>
bfd/
	* bfd-in.h (bfd_elf32_arm_set_target_relocs): Add one parameter.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (struct elf32_arm_link_hash_table): Declare new
	cmse_implib field.
	(bfd_elf32_arm_set_target_relocs): Add new parameter to initialize
	cmse_implib field in struct elf32_arm_link_hash_table.
	(elf32_arm_filter_cmse_symbols): New function.
	(elf32_arm_filter_implib_symbols): Likewise.
	(elf_backend_filter_implib_symbols): Define to
	elf32_arm_filter_implib_symbols.

ld/
	* emultempl/armelf.em (cmse_implib): Declare and define this new
	static variable.
	(arm_elf_create_output_section_statements): Add new cmse_implib
	parameter.
	(OPTION_CMSE_IMPLIB): Define macro.
	(PARSE_AND_LIST_LONGOPTS): Add entry for new --cmse-implib switch.
	(PARSE_AND_LIST_OPTIONS): Likewise.
	(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_CMSE_IMPLIB case.
	* ld.texinfo (--cmse-implib): Document new option.
	* testsuite/ld-arm/arm-elf.exp
	(Secure gateway import library generation): New test.
	(Secure gateway import library generation: errors): Likewise.
	* testsuite/ld-arm/cmse-implib.s: New file.
	* testsuite/ld-arm/cmse-implib-errors.out: Likewise.
	* testsuite/ld-arm/cmse-implib.rd: Likewise.
2016-08-04 15:54:57 +01:00
Thomas Preud'homme 4ba2ef8fbe 2016-08-04 Thomas Preud'homme <thomas.preudhomme@arm.com>
bfd/
	* elf32-arm.c (CMSE_PREFIX): Define macro.
	(elf32_arm_stub_cmse_branch_thumb_only): Define stub sequence.
	(cmse_branch_thumb_only): Declare stub.
	(struct elf32_arm_link_hash_table): Define cmse_stub_sec field.
	(elf32_arm_get_plt_info): Add globals parameter.  Use it to return
	FALSE if there is no PLT.
	(arm_type_of_stub): Adapt to new elf32_arm_get_plt_info signature.
	(elf32_arm_final_link_relocate): Likewise.
	(elf32_arm_gc_sweep_hook): Likewise.
	(elf32_arm_gc_mark_extra_sections): Mark sections holding ARMv8-M
	secure entry functions.
	(arm_stub_is_thumb): Add case for arm_stub_cmse_branch_thumb_only.
	(arm_dedicated_stub_output_section_required): Change to a switch case
	and add a case for arm_stub_cmse_branch_thumb_only.
	(arm_dedicated_stub_output_section_required_alignment): Likewise.
	(arm_stub_dedicated_output_section_name): Likewise.
	(arm_stub_dedicated_input_section_ptr): Likewise and remove
	ATTRIBUTE_UNUSED for htab parameter.
	(arm_stub_required_alignment): Likewise.
	(arm_stub_sym_claimed): Likewise.
	(arm_dedicated_stub_section_padding): Likewise.
	(cmse_scan): New function.
	(elf32_arm_size_stubs): Call cmse_scan for ARM M profile targets.
	Set stub_changed to TRUE if such veneers were created.
	(elf32_arm_swap_symbol_in): Add detection code for CMSE special
	symbols.

include/
	* arm.h (ARM_GET_SYM_CMSE_SPCL): Define macro.
	(ARM_SET_SYM_CMSE_SPCL): Likewise.

ld/
	* ld.texinfo (Placement of SG veneers): New concept entry.
	* testsuite/ld-arm/arm-elf.exp
	(Secure gateway veneers: no .gnu.sgstubs section): New test.
	(Secure gateway veneers: wrong entry functions): Likewise.
	(Secure gateway veneers (ARMv8-M Baseline)): Likewise.
	(Secure gateway veneers (ARMv8-M Mainline)): Likewise.
	* testsuite/ld-arm/cmse-veneers.s: New file.
	* testsuite/ld-arm/cmse-veneers.d: Likewise.
	* testsuite/ld-arm/cmse-veneers.rd: Likewise.
	* testsuite/ld-arm/cmse-veneers.sd: Likewise.
	* testsuite/ld-arm/cmse-veneers-no-gnu_sgstubs.out: Likewise.
	* testsuite/ld-arm/cmse-veneers-wrong-entryfct.out: Likewise.
2016-08-04 15:36:52 +01:00
Alan Modra 89d77b8a52 PowerPC64 ld segfault with code in non-executable sections
PR ld/20428
	* elf64-ppc.c (ppc_get_stub_entry): Don't segfault on NULL group.
2016-08-02 23:39:09 +09:30
Nick Clifton a94d834c9d Fix SH GOT allocation in the presence of linker garbage collection.
PR ld/17739
ld	* emulparams/shelf.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Define with
	valye 'yes'.
	* emulparams/shelf32.sh: Likewise.
	* emulparams/shelf32.sh: Likewise.
	* emulparams/shelf_nto.sh: Likewise.
	* emulparams/shelf_nto.sh: Likewise.
	* emulparams/shelf_vxworks.sh: Likewise.
	* emulparams/shelf_vxworks.sh: Likewise.
	* emulparams/shlelf32_linux.sh: Likewise.
	* emulparams/shlelf32_linux.sh: Likewise.
	* emulparams/shlelf_linux.sh: Likewise.
	* emulparams/shlelf_linux.sh: Likewise.
	* emulparams/shlelf_nto.sh: Likewise.
	* emulparams/shlelf_nto.sh: Likewise.

bfd	* elf32-sh.c (sh_elf_gc_sweep_hook): Delete.
	(elf_backend_sweep_hook): Delete.
2016-08-02 11:56:55 +01:00
Andrew Jenner dfdaec14b0 Fix some PowerPC VLE BFD issues and add some PowerPC VLE instructions.
bfd/
        * elf32-ppc.c (is_branch_reloc): Recognise VLE branch relocations.
        (ppc_elf_howto_raw): Fix dst_mask of R_PPC_VLE_REL15.
        (ppc_elf_vle_split16): Clear field before inserting.

        opcodes/
        * ppc-opc.c (vle_opcodes): Alias 'e_cmpwi' to 'e_cmpi' and
        'e_cmplwi' to 'e_cmpli' instead.
        (OPVUPRT, OPVUPRT_MASK): Define.
        (powerpc_opcodes): Add E200Z4 insns.
        (vle_opcodes): Add context save/restore insns.

        include/
        * opcode/ppc.h (PPC_OPCODE_E200Z4): New define.
2016-08-01 09:42:31 -07:00
Nick Clifton 781bf64d24 Update Swedish translation in bfd directory. 2016-08-01 09:59:04 +01:00
Nick Clifton 147d994bcd Fix seg-fault when running garbage collection on coff binaries.
PR ld/20401
	* coffgen.c (fini_reloc_cookie_rels): Check for the extistence
	of the coff_section_data before using it.
2016-07-27 10:50:52 +01:00
Maciej W. Rozycki 54806ffa85 MIPS/BFD: Handle branches in PLT compression selection
Complement:

commit 1bbce13264
Author: Maciej W. Rozycki <macro@linux-mips.org>
Date:   Mon Jun 24 23:55:46 2013 +0000

<https://sourceware.org/ml/binutils/2013-06/msg00077.html>, ("MIPS:
Compressed PLT/stubs support"), and also choose between regular and
compressed PLT entries as appropriate for any branches referring.

	bfd/
	* elfxx-mips.c (mips_elf_calculate_relocation): Handle branches
	in PLT compression selection.
	(_bfd_mips_elf_check_relocs): Likewise.

	ld/
	* testsuite/ld-mips-elf/compressed-plt-1.s: Add branch support.
	* testsuite/ld-mips-elf/compressed-plt-1a.s: Likewise.
	* testsuite/ld-mips-elf/compressed-plt-1b.s: Likewise.
	* testsuite/ld-mips-elf/compressed-plt-1-o32-branch.od: New
	test.
	* testsuite/ld-mips-elf/compressed-plt-1-o32-branch.rd: New
	test.
	* testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-bronly.od:
	New test.
	* testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-bronly.rd:
	New test.
	* testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-branch.od:
	New test.
	* testsuite/ld-mips-elf/compressed-plt-1-o32-mips16-branch.rd:
	New test.
	* testsuite/ld-mips-elf/compressed-plt-1-o32-umips-bronly.od:
	New test.
	* testsuite/ld-mips-elf/compressed-plt-1-o32-umips-bronly.rd:
	New test.
	* testsuite/ld-mips-elf/compressed-plt-1-o32-umips-branch.od:
	New test.
	* testsuite/ld-mips-elf/compressed-plt-1-o32-umips-branch.rd:
	New test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2016-07-26 20:00:48 +01:00
Cupertino Miranda c02d11a585 Fix segfault in ARC linker when generating got entries for local symbols.
bfd	* arc-got.h (relocate_fix_got_relocs_for_got_info): Handle the case
	where there's no elf_link_hash_entry while processing GOT_NORMAL got
	entries.

ld	* testsuite/ld-arc/got-01.d: New file.
	* testsuite/ld-arc/got-01.s: New file.
2016-07-22 15:10:31 +01:00
H.J. Lu fecd57f9f1 Set BFD_VERSION to 2.27.51
bfd/

	* version.m4 (BFD_VERSION): Set to 2.27.51.
	* configure: Regenerated.

binutils/

	* configure: Regenerated.

gas/

	* configure: Regenerated.

gprof/

	* configure: Regenerated.

ld/

	* configure: Regenerated.

opcodes/

	* configure: Regenerated.
2016-07-21 15:22:13 -07:00
H.J. Lu 89b829a8b3 Move ChangeLog entry for PR ld/20376 2016-07-21 15:17:37 -07:00
Alan Modra 5df1bc570f Fix implib test failures
bfd/
	* elf.c (_bfd_elf_filter_global_symbols): Skip local symbols.
	(swap_out_syms): Return an error when not finding ELF output
	section rather than asserting.
	* elflink.c (elf_output_implib): Call bfd_set_error on no symbols.
ld/
	* testsuite/lib/ld-lib.exp (run_ld_link_tests): Add optional
	parameter to pass list of xfails.
	* testsuite/ld-elf/elf.exp: Add xfails for implib tests.  Tidy
	implib test formatting.  Don't set .data start address.
	* testsuite/ld-elf/implib.s: Remove first .bss directive and
	replace second one with equivalent .section directive.
	* testsuite/ld-elf/empty-implib.out: Add expected final error.
	* testsuite/ld-elf/implib.rd: Update.
2016-07-21 11:30:34 +09:30
John Baldwin 0064d22386 Handle version 1a of FreeBSD's NT_PRSINFO.
Version 1a adds a pr_pid member containing the process ID of the
terminating process.  The presence of pr_pid is inferred from the
note's size.

bfd/ChangeLog:

	* elf.c (elfcore_grok_freebsd_psinfo): Check for minimum note size
	and handle pr_pid if present.
2016-07-20 08:43:54 -07:00
Alan Modra 3ce512885b Mark some more powerpc relocs as not handled by generic linker
* elf64-ppc.c (ppc64_elf_howto_raw <R_PPC64_PLTREL32>): Put
	ppc64_elf_unhandled_reloc for special_function.
	* elf32-ppc.c (ppc_elf_howto_raw): Similarly for lots of relocs.
2016-07-20 10:55:04 +09:30
Maciej W. Rozycki a6ebf6169a MIPS: Convert cross-mode BAL to JALX
Convert cross-mode regular MIPS and microMIPS BAL instructions to JALX,
similarly to how JAL instructions are converted.

	bfd/
	* elfxx-mips.c (mips_elf_perform_relocation): Convert cross-mode
	BAL to JALX.
	(_bfd_mips_elf_relocate_section) <bfd_reloc_outofrange>: Add a
	corresponding error message.

	gas/
	* config/tc-mips.c (mips_force_relocation, mips_fix_adjustable):
	Adjust comments for BAL to JALX linker conversion.
	(fix_bad_cross_mode_branch_p): Accept cross-mode BAL.
	* testsuite/gas/mips/unaligned-branch-1.l: Update error messages
	expected.
	* testsuite/gas/mips/unaligned-branch-micromips-1.l: Likewise.
	* testsuite/gas/mips/branch-local-4.d: New test.
	* testsuite/gas/mips/branch-local-n32-4.d: New test.
	* testsuite/gas/mips/branch-local-n64-4.d: New test.
	* testsuite/gas/mips/branch-addend.d: New test.
	* testsuite/gas/mips/branch-addend-n32.d: New test.
	* testsuite/gas/mips/branch-addend-n64.d: New test.
	* testsuite/gas/mips/branch-local-4.s: New test source.
	* testsuite/gas/mips/branch-addend.s: New test source.
	* testsuite/gas/mips/mips.exp: Run the new tests.

	ld/
	* testsuite/ld-mips-elf/unaligned-branch-2.d: Update error
	messages expected.
	* testsuite/ld-mips-elf/unaligned-branch-r6-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-mips16.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-branch-micromips.d: Likewise.
	* testsuite/ld-mips-elf/bal-jalx-addend.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-local.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-pic.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-addend-n32.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-local-n32.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-pic-n32.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-addend-n64.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-local-n64.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-pic-n64.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-2.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-3.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-2.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-3.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-2.s: New test source.
	* testsuite/ld-mips-elf/unaligned-jalx-3.s: New test source.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-2.s: New test
	source.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-3.s: New test
	source.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2016-07-19 16:22:53 +01:00
Maciej W. Rozycki 9d862524f6 MIPS: Verify the ISA mode and alignment of branch and jump targets
Verify that the ISA mode of branch targets is the same as the referring
relocation, so that an attempt to produce a branch between instructions
encoded in different ISA modes each causes an error rather than silently
producing non-functional code.  Make sure that no symbol or addend bits
are silently truncated: terminate with an error if the relocation value
calculated cannot be encoded in the relocatable field of a branch; for
REL targets also applying to any intermediate addend.

Also make jump target's alignment verification consistent with that for
branches.

This change will require an update to some obscure handcoded assembly
sources which make branches to labels placed at data objects, however
for microMIPS code only.  These labels will have to be updated with the
`.insn' directive for containing code to assemble and link successfully.
Such code is broken as any such labels have always been required by the
microMIPS architecture specification[1][2] to be annotated this way for
correct interpretation, and with our old code missing `.insn' directives
caused labels to present different semantics depending on whether they
were referred with branch (ISA bit ignored) or other relocations (ISA
bit respected).

Enforcing these checks however will ensure errors in building software,
like mixed regular MIPS and microMIPS code links with branches between,
will be diagnosed at the build time rather than causing odd run-time
errors such as intermittent crashes.  It will also let cross-mode BAL
instructions be converted to JALX instructions, with a separate change.

References:

[1] "MIPS Architecture for Programmers, Volume II-B: The microMIPS32
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00582,
    Revision 5.04, January 15, 2014, Section 7.1 "Assembly-Level
    Compatibility", p. 533

[2] "MIPS Architecture for Programmers, Volume II-B: The microMIPS64
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00594,
    Revision 5.04, January 15, 2014, Section 8.1 "Assembly-Level
    Compatibility", p. 623

	bfd/
	* elfxx-mips.c (b_reloc_p): Add R_MICROMIPS_PC16_S1,
	R_MICROMIPS_PC10_S1 and R_MICROMIPS_PC7_S1.
	(branch_reloc_p): New function.
	(mips_elf_calculate_relocation): Handle ISA mode determination
	for relocations against section symbols, against absolute
	symbols and absolute relocations.  Also set `*cross_mode_jump_p'
	for branches.
	<R_MIPS16_26, R_MIPS_26, R_MICROMIPS_26_S1>: Suppress alignment
	checks for weak undefined symbols.  Also check target alignment
	within the same ISA mode.
	<R_MIPS_PC16, R_MIPS_GNU_REL16_S2>: Handle cross-mode branches
	in the alignment check.
	<R_MICROMIPS_PC7_S1>: Add an alignment check.
	<R_MICROMIPS_PC10_S1>: Likewise.
	<R_MICROMIPS_PC16_S1>: Likewise.
	(mips_elf_perform_relocation): Report a failure for unsupported
	same-mode JALX instructions and cross-mode branches.
	(_bfd_mips_elf_relocate_section) <bfd_reloc_outofrange>: Add
	error messages for jumps to misaligned addresses.

	gas/
	* config/tc-mips.c (mips_force_relocation): Also retain branch
	relocations against MIPS16 and microMIPS symbols.
	(fix_bad_cross_mode_jump_p): New function.
	(fix_bad_same_mode_jalx_p): Likewise.
	(fix_bad_misaligned_jump_p): Likewise.
	(fix_bad_cross_mode_branch_p): Likewise.
	(fix_bad_misaligned_branch_p): Likewise.
	(fix_validate_branch): Likewise.
	(md_apply_fix) <BFD_RELOC_MIPS_JMP, BFD_RELOC_MIPS16_JMP>
	<BFD_RELOC_MICROMIPS_JMP>: Separate from BFD_RELOC_MIPS_SHIFT5,
	etc.  Verify the ISA mode and alignment of the jump target.
	<BFD_RELOC_MIPS_21_PCREL_S2>: Replace the inline alignment check
	with a call to `fix_validate_branch'.
	<BFD_RELOC_MIPS_26_PCREL_S2>: Likewise.
	<BFD_RELOC_16_PCREL_S2>: Likewise.
	<BFD_RELOC_MICROMIPS_7_PCREL_S1, BFD_RELOC_MICROMIPS_10_PCREL_S1>
	<BFD_RELOC_MICROMIPS_16_PCREL_S1>: Retain the original addend.
	Verify the ISA mode and alignment of the branch target.
	(md_convert_frag): Verify the ISA mode and alignment of resolved
	MIPS16 branch targets.
	* testsuite/gas/mips/branch-misc-1.s: Annotate non-instruction
	branch targets with `.insn'.
	* testsuite/gas/mips/branch-misc-5.s: Likewise.
	* testsuite/gas/mips/micromips@branch-misc-5-64.d: Update
	accordingly.
	* testsuite/gas/mips/micromips@branch-misc-5pic-64.d: Likewise.
	* testsuite/gas/mips/micromips-branch-relax.s: Annotate
	non-instruction branch target with `.insn'.
	* testsuite/gas/mips/micromips.s: Replace microMIPS JALX targets
	with external symbols.
	* testsuite/gas/mips/micromips-insn32.d: Update accordingly.
	* testsuite/gas/mips/micromips-noinsn32.d: Likewise.
	* testsuite/gas/mips/micromips-trap.d: Likewise.
	* testsuite/gas/mips/micromips.d: Likewise.
	* testsuite/gas/mips/mips16.s: Annotate non-instruction branch
	targets with `.insn'.
	* testsuite/gas/mips/mips16.d: Update accordingly.
	* testsuite/gas/mips/mips16-64.d: Likewise.
	* testsuite/gas/mips/mips16-dwarf2.s: Annotate non-instruction
	branch target with `.insn'.
	* testsuite/gas/mips/relax-swap3.s: Likewise.
	* testsuite/gas/mips/branch-local-2.l: New list test.
	* testsuite/gas/mips/branch-local-3.l: New list test.
	* testsuite/gas/mips/branch-local-n32-2.l: New list test.
	* testsuite/gas/mips/branch-local-n32-3.l: New list test.
	* testsuite/gas/mips/branch-local-n64-2.l: New list test.
	* testsuite/gas/mips/branch-local-n64-3.l: New list test.
	* testsuite/gas/mips/unaligned-jump-1.l: New list test.
	* testsuite/gas/mips/unaligned-jump-2.l: New list test.
	* testsuite/gas/mips/unaligned-jump-3.d: New test.
	* testsuite/gas/mips/unaligned-jump-mips16-1.l: New list test.
	* testsuite/gas/mips/unaligned-jump-mips16-2.l: New list test.
	* testsuite/gas/mips/unaligned-jump-mips16-3.d: New test.
	* testsuite/gas/mips/unaligned-jump-micromips-1.l: New list
	test.
	* testsuite/gas/mips/unaligned-jump-micromips-2.l: New list
	test.
	* testsuite/gas/mips/unaligned-jump-micromips-3.d: New test.
	* testsuite/gas/mips/unaligned-branch-1.l: New list test.
	* testsuite/gas/mips/unaligned-branch-2.l: New list test.
	* testsuite/gas/mips/unaligned-branch-3.d: New test.
	* testsuite/gas/mips/unaligned-branch-r6-1.l: New list test.
	* testsuite/gas/mips/unaligned-branch-r6-2.l: New list test.
	* testsuite/gas/mips/unaligned-branch-r6-3.l: New list test.
	* testsuite/gas/mips/unaligned-branch-r6-4.l: New list test.
	* testsuite/gas/mips/unaligned-branch-r6-5.d: New test.
	* testsuite/gas/mips/unaligned-branch-r6-6.d: New test.
	* testsuite/gas/mips/unaligned-branch-mips16-1.l: New list test.
	* testsuite/gas/mips/unaligned-branch-mips16-2.l: New list test.
	* testsuite/gas/mips/unaligned-branch-mips16-3.d: New test.
	* testsuite/gas/mips/unaligned-branch-micromips-1.l: New list
	test.
	* testsuite/gas/mips/unaligned-branch-micromips-2.l: New list
	test.
	* testsuite/gas/mips/unaligned-branch-micromips-3.d: New test.
	* testsuite/gas/mips/branch-local-2.s: New test source.
	* testsuite/gas/mips/branch-local-3.s: New test source.
	* testsuite/gas/mips/branch-local-n32-2.s: New test source.
	* testsuite/gas/mips/branch-local-n32-3.s: New test source.
	* testsuite/gas/mips/branch-local-n64-2.s: New test source.
	* testsuite/gas/mips/branch-local-n64-3.s: New test source.
	* testsuite/gas/mips/unaligned-jump-1.s: New test source.
	* testsuite/gas/mips/unaligned-jump-2.s: New test source.
	* testsuite/gas/mips/unaligned-jump-mips16-1.s: New test source.
	* testsuite/gas/mips/unaligned-jump-mips16-2.s: New test source.
	* testsuite/gas/mips/unaligned-jump-micromips-1.s: New test
	source.
	* testsuite/gas/mips/unaligned-jump-micromips-2.s: New test
	source.
	* testsuite/gas/mips/unaligned-branch-1.s: New test source.
	* testsuite/gas/mips/unaligned-branch-2.s: New test source.
	* testsuite/gas/mips/unaligned-branch-r6-1.s: New test source.
	* testsuite/gas/mips/unaligned-branch-r6-2.s: New test source.
	* testsuite/gas/mips/unaligned-branch-r6-3.s: New test source.
	* testsuite/gas/mips/unaligned-branch-r6-4.s: New test source.
	* testsuite/gas/mips/unaligned-branch-mips16-1.s: New test
	source.
	* testsuite/gas/mips/unaligned-branch-mips16-2.s: New test
	source.
	* testsuite/gas/mips/unaligned-branch-micromips-1.s: New test
	source.
	* testsuite/gas/mips/unaligned-branch-micromips-2.s: New test
	source.
	* testsuite/gas/mips/mips.exp: Run the new tests.

	ld/
	* testsuite/ld-mips-elf/unaligned-jalx-1.d: Update error message
	expected.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-mips16-1.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-addend-micromips-1.d:
	Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d: Likewise.
	* testsuite/ld-mips-elf/undefweak-overflow.s: Add jumps,
	microMIPS BAL and MIPS16 instructions.
	* testsuite/ld-mips-elf/undefweak-overflow.d: Update
	accordingly.
	* testsuite/ld-mips-elf/unaligned-branch-2.d: New test.
	* testsuite/ld-mips-elf/unaligned-branch-r6-1.d: New test.
	* testsuite/ld-mips-elf/unaligned-branch-r6-2.d: New test.
	* testsuite/ld-mips-elf/unaligned-branch-mips16.d: New test.
	* testsuite/ld-mips-elf/unaligned-branch-micromips.d: New test.
	* testsuite/ld-mips-elf/unaligned-jump-mips16.d: New test.
	* testsuite/ld-mips-elf/unaligned-jump-micromips.d: New test.
	* testsuite/ld-mips-elf/unaligned-jump.d: New test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2016-07-19 14:46:30 +01:00
Alan Modra 7d0b9ebc1e Don't include libbfd.h outside of bfd, part 6
Some messing with plugin code in order to not need arelt_size in
ld code.  File descriptor handling in ld/plugin.c is tidied too,
simply duping the open fd rather than opening the file again.

bfd/
	* elflink.c: Include plugin-api.h.
	* plugin.c (bfd_plugin_open_input): New function, extracted from..
	(try_claim): ..here.
	* plugin.h: Don't include bfd.h.
	(bfd_plugin_open_input): Declare.
binutils/
	* ar.c: Include plugin-api.h.
	* nm.c: Likewise.
ld/
	* plugin.c: Don't include libbfd.h.  Include plugin-api.h
	before bfd/plugin.h.
	(plugin_object_p): Use bfd_plugin_open_input.
2016-07-16 19:09:00 +09:30
Alan Modra 4212b42d79 Don't include libbfd.h outside of bfd, part 4
Not much to see here, just renaming a function.

bfd/
	* targets.c (bfd_seach_for_target): Rename to..
	(bfd_iterate_over_targets): ..this.  Rewrite doc.
	* bfd-in2.h: Regenerate.
ld/
	* ldlang.c (open_output): Replace bfd_search_for_target with
	bfd_iterate_over_targets.  Localize vars.
2016-07-16 13:29:35 +09:30
Alan Modra 00dad9a491 Don't include libbfd.h outside of bfd, part 2
Make bfd_default_set_arch_mach available to a bunch of gas backend
files.

bfd/
	* archures.c (bfd_default_set_arch_mach): Make available in bfd.h.
	* libbfd.h: Regenerate.
	* bfd-in2.h: Regenerate.
gas/
	* config/tc-epiphany.c: Don't include libbfd.h.
	* config/tc-frv.c: Likewise.
	* config/tc-ip2k.c: Likewise.
	* config/tc-iq2000.c: Likewise.
	* config/tc-m32c.c: Likewise.
	* config/tc-mep.c: Likewise.
	* config/tc-mt.c: Likewise.
	* config/tc-nios2.c: Likewise.
2016-07-16 13:27:30 +09:30
Alan Modra 76e7a75123 Don't include libbfd.h outside of bfd, part 1
Make BFD_ALIGN available to objcopy.  Fix assertions.  Don't use
bfd_log2 in ppc32elf.em or bfd_malloc in xtensaelf.em and bucomm.c.

bfd/
	* libbfd-in.h (BFD_ALIGN): Move to..
	* bfd-in.h: ..here.
	* elf32-ppc.h (struct ppc_elf_params): Add pagesize.
	* elf32-ppc.c (default_params): Adjust init.
	(ppc_elf_link_params): Set pagesize_p2.
	* libbfd.h: Regenerate.
	* bfd-in2.h: Regenerate.
binutils/
	* ar.c: Don't include libbfd.h.
	* objcopy.c: Likewise.
	* bucomm.c (bfd_get_archive_filename): Use xmalloc rather than
	bfd_malloc.
gas/
	* config/bfin-parse.y: Don't include libbfd.h.
	* config/tc-bfin.c: Likewise.
	* config/tc-rl78.c: Likewise.
	* config/tc-rx.c: Likewise.
	* config/tc-metag.c: Likewise.
	(create_dspreg_htabs, create_scond_htab): Use gas_assert not BFD_ASSERT.
	* Makefile.am: Update dependencies.
	* Makefile.in: Regenerate.
ld/
	* ldlang.c: Don't include libbfd.h.
	* emultempl/nds32elf.em: Likewise.
	* emultempl/ppc64elf.em: Likewise.
	* emultempl/ppc32elf.em: Likewise.
	(pagesize): Delete.
	(params): Update init.
	(ppc_after_open_output): Use params.pagesize.  Don't call bfd_log2.
	(PARSE_AND_LIST_ARGS_CASES): Use params.pagesize.
	* emultempl/sh64elf.em: Don't include libbfd.h.
	(after_allocation): Use ASSERT, not BFD_ASSERT.
	* emultempl/xtensaelf.em: Don't include libbfd.h.
	(replace_insn_sec_with_prop_sec): Use xmalloc, not bfd_malloc.
	* Makefile.am: Update dependencies.
	* Makefile.in: Regenerate.
2016-07-16 13:25:11 +09:30
Thomas Preud'homme 7635954182 Add support for creating ELF import libraries
2016-07-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

bfd/
	* elf-bfd.h (elf_backend_filter_implib_symbols): Declare backend hook.
	(_bfd_elf_filter_global_symbols): Declare.
	* elf.c (_bfd_elf_filter_global_symbols): New function.
	* elflink.c (elf_filter_global_symbols): Likewise.
	(elf_output_implib): Likewise.
	(bfd_elf_final_link): Call above function, failing if it does.
	* elfxx-target.h (elf_backend_filter_implib_symbols): Define macro and
	default it to NULL.
	(elf_backend_copy_indirect_symbol): Fix spacing.
	(elf_backend_hide_symbol): Likewise.
	(elfNN_bed): Initialize elf_backend_filter_implib_symbols backend hook.

include/
	* bfdlink.h (struct bfd_link_info): Declare new ldscript_def and
	out_implib_bfd fields.

2016-07-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>
	    Nick Clifton  <nickc@redhat.com>

ld/
	* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Open import
	library file for writing and initialize implib_bfd field of link_info
	structure.
	* emultempl/pe.em (pe_implib_filename): Remove variable declaration.
	(OPTION_IMPLIB_FILENAME): Remove macro definition.
	(gld${EMULATION_NAME}_add_options): Remove --out-implib option.
	(gld_${EMULATION_NAME}_list_options): Likewise.
	(gld${EMULATION_NAME}_handle_option): Likewise.
	(gld_${EMULATION_NAME}_finish): Use command_line.out_implib_filename
	instead of pe_implib_filename.
	* emultempl/pep.em (pep_implib_filename): Remove variable declaration.
	(OPTION_IMPLIB_FILENAME): Remove enumerator.
	(gld${EMULATION_NAME}_add_options): Remove --out-implib option.
	(gld_${EMULATION_NAME}_list_options): Likewise.
	(gld${EMULATION_NAME}_handle_option): Likewise.
	(gld_${EMULATION_NAME}_finish): Use command_line.out_implib_filename
	instead of pep_implib_filename.
	* ld.h (args_type): Declare new out_implib_filename field.
	* ld.texinfo (--out-implib): Move documentation to arch-independent
	part and rephrase to apply to ELF targets.
	* ldexp.c (exp_fold_tree_1): Set ldscript_def field to 1 for symbols
	defined in linker scripts.
	* ldlex.h (enum option_values): Declare new OPTION_OUT_IMPLIB
	enumerator.
	* lexsup.c (ld_options): Add entry for new --out-implib switch.
	(parse_args): Handle OPTION_OUT_IMPLIB case.
	* testsuite/ld-elf/elf.exp (Generate empty import library): New test.
	(Generate import library): Likewise.
	* testsuite/ld-elf/implib.s: Likewise.
	* testsuite/ld-elf/implib.rd: New file.
	* testsuite/ld-elf/empty-implib.out: Likewise
2016-07-15 17:50:48 +01:00