Commit Graph

13731 Commits

Author SHA1 Message Date
H.J. Lu 2980ccad59 Move common symbol check after bed->common_definition
bfd/

	* elflink.c (elf_link_add_object_symbols): Move common symbol
	check after bed->common_definition.

ld/

	* testsuite/ld-elf/pr21903.s (start): Removed.
	(_start): Likewise.
	(__start): Likewise.
	(main): Likewise.
	(bar): New.
2017-08-07 08:02:29 -07:00
Alan Modra b3293efaf8 PR21910, segfault in common symbol override test when hash-style=gnu
PR 21910
	* elflink.c (bfd_elf_final_link): Don't segfault when sections
	needed to define various dynamic tags have been discarded.
2017-08-07 21:26:09 +09:30
Nick Clifton b7a18930e3 Do not choose a non-ELF format input file to hold the linker created GOT sections.
PR 21884
	* elf32-i386.c (elf_i386_link_setup_gnu_properties): If the dynobj
	has not been set then use the bfd returned by
	_bfd_elf_link_setup_gnu_properties.  If that is null then search
	through all the input bfds selecting the first normal, ELF format
	one.
	* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Likewise.
2017-08-07 10:09:51 +01:00
GDB Administrator 2010d1a3f8 Automatic date update in version.in 2017-08-07 00:01:03 +00:00
H.J. Lu 1d4af308ae x86: Lookup __tls_get_addr or ___tls_get_addr once
Instead of checking if a symbol is __tls_get_addr or ___tls_get_addr,
we check if there is a reference to __tls_get_addr or ___tls_get_addr
before starting relocation check.

	* elf32-i386.c (elf_i386_link_hash_entry): Change tls_get_addr
	to 1 bit.
	(elf_i386_link_hash_newfunc): Initialize tls_get_addr to 0.
	(elf_i386_check_tls_transition): Check tls_get_addr directly.
	(elf_i386_convert_load_reloc): Update tls_get_addr check.
	(elf_i386_link_check_relocs): New function.
	(bfd_elf32_bfd_link_check_relocs): New.
	* elf64-x86-64.c (elf_x86_64_link_hash_entry): Change tls_get_addr
	to 1 bit.
	(elf_x86_64_link_hash_newfunc): Initialize tls_get_addr to 0.
	(elf_x86_64_check_tls_transition): Check tls_get_addr directly.
	(elf_x86_64_convert_load_reloc): Update tls_get_addr check.
	(elf_x86_64_link_check_relocs): New function.
	(bfd_elf64_bfd_link_check_relocs): New.
	(bfd_elf32_bfd_link_check_relocs): Likewise.
2017-08-06 08:41:07 -07:00
H.J. Lu a4819f54c0 Treat common symbol as undefined for --no-define-common
When --no-define-common is used to build shared library, treat common
symbol as undefined so that common symbols that are referenced from a
shared library to be assigned addresses only in the main program.  This
eliminates the unused duplicate space in the shared library, and also
prevents any possible confusion over resolving to the wrong duplicate
when there are many dynamic modules with specialized search paths for
runtime symbol resolution.

--no-define-common is only allowed when building a shared library.

bfd/

	PR ld/21903:
	* elflink.c (elf_link_add_object_symbols): Treat common symbol
	as undefined for --no-define-common.

include/

	PR ld/21903:
	* bfdlink.h (bfd_link_info): Add inhibit_common_definition.

ld/

	PR ld/21903:
	* ld.h (command_line): Remove inhibit_common_definition.
	* ldgram.y: Replace command_line.inhibit_common_definition with
	link_info.inhibit_common_definition.
	* ldlang.c (lang_common): Likewise.
	* lexsup.c (parse_args): Likewise.
	* ldmain.c (main): Only allow --no-define-common with -shared.
	* testsuite/ld-elf/pr21903.s: New file.
	* testsuite/ld-elf/pr21903a.d: Likewise.
	* testsuite/ld-elf/pr21903b.d: Likewise.
	* testsuite/ld-elf/pr21903c.d: Likewise.
	* testsuite/ld-elf/pr21903d.d: Likewise.
	* testsuite/ld-elf/pr21903e.d: Likewise.
2017-08-06 08:19:04 -07:00
GDB Administrator e2a084f2c1 Automatic date update in version.in 2017-08-06 00:00:44 +00:00
Alan Modra 55ef6584ca Don't fail in elf32_hppa_set_gp
The base bfd_link_hash_table works fine here, the only thing to watch
out for is to only set elf_gp if the output is ELF.

bfd/
	* elf32-hppa.c (elf32_hppa_set_gp): Don't require an
	hppa_link_hash_table.
ld/
	* testsuite/ld-unique/pr21529.d: Don't xfail hppa.
2017-08-05 23:28:21 +09:30
GDB Administrator a66930b357 Automatic date update in version.in 2017-08-05 00:00:19 +00:00
GDB Administrator a30d3a7990 Automatic date update in version.in 2017-08-04 00:00:52 +00:00
GDB Administrator 5f66bad45b Automatic date update in version.in 2017-08-03 00:01:14 +00:00
Max Filippov d84ed528d4 Fix potential illegal memory access in Xtensa port.
* xtensa-isa.c (xtensa_isa_init): Don't update lookup table
	entries for sysregs with negative indices.
2017-08-02 10:38:09 +01:00
GDB Administrator a5be90a4d9 Automatic date update in version.in 2017-08-02 00:00:53 +00:00
Andreas Krebbel 1ef692ea23 S/390: Fix claimfile failures
This fixes a segfault when trying to access the local_plt field in the
s390 specific elf data althoug the underlaying object is a generic elf
object.

This fixes the following testsuite failures:

< FAIL: plugin claimfile replace symbol with source
< FAIL: plugin claimfile resolve symbol with source
< FAIL: plugin claimfile replace file with source
< FAIL: plugin set symbol visibility with source
< FAIL: plugin ignore lib with source
< FAIL: plugin claimfile replace lib with source
< FAIL: plugin 2 with source lib
< FAIL: load plugin 2 with source
< FAIL: plugin 3 with source lib
< FAIL: load plugin 3 with source

bfd/ChangeLog:

2017-08-01  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

	* elf32-s390.c (elf_s390_finish_dynamic_sections): Skip if it
	isn't the S/390 specific elf data.
	* elf64-s390.c (elf_s390_finish_dynamic_sections): Likewise.
2017-08-01 15:13:40 +02:00
GDB Administrator 51b69c74c6 Automatic date update in version.in 2017-08-01 00:00:54 +00:00
Kuan-Lin Chen 5759343685 Improve handling of ADD and SUB relocations on the RISCV target.
* elfxx-riscv.c (riscv_elf_add_sub_reloc): New function.
	* (howto_table) [R_RISCV_ADD8]: Use riscv_elf_add_sub_reloc.
	[R_RISCV_ADD16]: Likewise.
	[R_RISCV_ADD32]: Likewise.
	[R_RISCV_ADD64]: Likewise.
	[R_RISCV_SUB6]: Likewise.
	[R_RISCV_SUB8]: Likewise.
	[R_RISCV_SUB16]: Likewise.
	[R_RISCV_SUB32]: Likewise.
	[R_RISCV_SUB64]: Likewise.
2017-07-31 15:33:48 +01:00
Alan Modra d44c746aed PR 21847, PowerPC64 --plt-localentry again
This makes ld warn about --plt-localentry if a version of glibc
without the necessary ld.so checks is detected, and revises the
documentation.

bfd/
	* elf64-ppc.c (ppc64_elf_tls_setup): Warn on --plt-localentry
	without ld.so checks.
gold/
	* powerpc.cc (Target_powerpc::scan_relocs): Warn on --plt-localentry
	without ld.so checks.
ld/
	* ld.texinfo (plt-localentry): Revise.
2017-07-31 13:20:44 +09:30
GDB Administrator 93e0a1eab1 Automatic date update in version.in 2017-07-31 00:00:25 +00:00
GDB Administrator 10683b8d11 Automatic date update in version.in 2017-07-30 00:00:45 +00:00
Alan Modra 8b5f1ed877 PR 21847, Don't default PowerPC64 to --plt-localentry
The big comment in ppc64_elf_tls_setup says why.  I've also added some
code to the bfd linker that catches the -lpthread -lc symbol
differences and disable generation of optimized call stubs even when
--plt-localentry is activated.  Gold doesn't yet have that.

	PR 21847
bfd/
	* elf64-ppc.c (struct ppc_link_hash_entry): Add non_zero_localentry.
	(ppc64_elf_merge_symbol): Set non_zero_localentry.
	(is_elfv2_localentry0): Test non_zero_localentry.
	(ppc64_elf_tls_setup): Default to --no-plt-localentry.
gold/
	* powerpc.cc (Target_powerpc::scan_relocs): Default to
	--no-plt-localentry.
ld/
	* ld.texinfo (plt-localentry): Document.
2017-07-29 13:02:27 +09:30
GDB Administrator ef080e7ed4 Automatic date update in version.in 2017-07-29 00:01:03 +00:00
Andreas Krebbel 894dde0ba7 Add missing changelog 2017-07-28 18:34:34 +02:00
Andreas Krebbel 79c12faeea S/390: Fix segfault when linking -shared -nostartfiles
Regression-tested on s390x.

bfd/ChangeLog:

2017-07-28  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

	* elf32-s390.c (elf_s390_finish_dynamic_sections): Add NULL
	pointer check for htab->elf.irelplt.
	* elf64-s390.c (elf_s390_finish_dynamic_sections): Likewise.
2017-07-28 18:26:25 +02:00
GDB Administrator 242f30e67c Automatic date update in version.in 2017-07-28 00:00:46 +00:00
Nick Clifton 8bdf0be19d Fix address violation issues encountered when parsing corrupt binaries.
PR 21840
	* mach-o.c (bfd_mach_o_read_symtab_strtab): Fail if the symtab
	size is -1.
	* nlmcode.h (nlm_swap_auxiliary_headers_in): Replace assertion
	with error return.
	* section.c (bfd_make_section_with_flags): Fail if the name or bfd
	are NULL.
	* vms-alpha.c (bfd_make_section_with_flags): Correct computation
	of end pointer.
	(evax_bfd_print_emh): Check for invalid string lengths.
2017-07-27 12:04:50 +01:00
GDB Administrator 63d4980d60 Automatic date update in version.in 2017-07-27 00:00:47 +00:00
GDB Administrator 11f1093690 Automatic date update in version.in 2017-07-26 00:00:31 +00:00
Nick Clifton 133193b8ae Fix thinko in previous change to elf32-msp430.c 2017-07-25 12:47:46 +01:00
Nick Clifton c26bb06769 Updated French translation for the BFD library. 2017-07-25 09:46:14 +01:00
Benjamin Green cfe7b9bd58 Add a linker branch optimization for the MSP430.
PR 21824
	* elf32-msp430.c (msp430_elf_relax_section): Allow conversion of
	16-bit absolute branches into 10-bit pc-relative branches on the
	MSP430 as well as the MSP430X.
2017-07-25 09:41:23 +01:00
Alan Modra d4aaa2a074 __tls_get_addr_opt stub eh_frame info
Since the __tls_get_addr_opt stub saves LR and makes a call, eh_frame
info should be generated to describe how to unwind through the stub.

The patch also changes the way the backend iterates over stubs, from
looking at all sections in stub_bfd to which all dynamic sections are
attached as well, to iterating over the group list, which gets just
the stub sections.  Most binaries will have just one or two stub
groups, so this is a little faster.

bfd/
	* elf64-ppc.c (struct map_stub): Add tls_get_addr_opt_bctrl.
	(stub_eh_frame_size): New function.
	(ppc_size_one_stub): Set group tls_get_addr_opt_bctrl.
	(group_sections): Init group tls_get_addr_opt_bctrl.
	(ppc64_elf_size_stubs): Update sizing and initialization of
	.eh_frame.  Iteration over stubs via group list.
	(ppc64_elf_build_stubs): Iterate over stubs via group list.
	(ppc64_elf_finish_dynamic_sections): Update finalization of
	.eh_frame.
ld/
	* testsuite/ld-powerpc/tlsopt5.s: Add cfi.
	* testsuite/ld-powerpc/tlsopt5.d: Update.
	* testsuite/ld-powerpc/tlsopt5.wf: New file.
	* testsuite/ld-powerpc/powerpc.exp: Perform new tlsopt5 test.
2017-07-25 15:14:39 +09:30
GDB Administrator aafd38357a Automatic date update in version.in 2017-07-25 00:01:08 +00:00
Nick Clifton 8a2df5e2df Fix another memory access error triggered by attempting to parse a corrupt binary.
PR 21813
	(alpha_vms_object_p): Check for a truncated record.
2017-07-24 14:04:04 +01:00
Nick Clifton ca4cf9b9c6 Fix address violation errors parsing corrupt binary files.
PR 21813
binutils* rddbg.c (read_symbol_stabs_debugging_info): Check for an empty
	string whilst concatenating symbol names.

bfd	* mach-o.c (bfd_mach_o_canonicalize_relocs): Pass the base address
	of the relocs to the canonicalize_one_reloc routine.
	* mach-o.h (struct bfd_mach_o_backend_data): Update the prototype
	for the _bfd_mach_o_canonicalize_one_reloc field.
	* mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Add
	res_base parameter.  Use to check for corrupt pair relocs.
	* mach-o-aarch64.c (bfd_mach_o_arm64_canonicalize_one_reloc):
	Likewise.
	* mach-o-i386.c (bfd_mach_o_i386_canonicalize_one_reloc):
	Likewise.
	* mach-o-x86-64.c (bfd_mach_o_x86_64_canonicalize_one_reloc):
	Likewise.

	* vms-alpha.c (_bfd_vms_slurp_eihd): Make sure that there is
	enough data in the record before attempting to parse it.
	(_bfd_vms_slurp_eeom): Likewise.

	(_bfd_vms_slurp_egsd): Check for an invalid section index.
	(image_set_ptr): Likewise.
	(alpha_vms_slurp_relocs): Likewise.
2017-07-24 13:49:22 +01:00
Nick Clifton 47aeb64c10 Improve "unrecognized relocation" error messages to add the suggestion that the linker might be out of date.
PR 21803
	* reloc.c (_bfd_unrecognized_reloc): New function.  Reports
	an unrecognized reloc and sets the bfd_error value.
	* libbfd.h: Regenerate.
	* elf32-arm.c (elf32_arm_final_link_relocate): Use the new
	function.
	* elf32-i386.c (elf_i386_relocate_section): Likewise.
	* elf32-tilepro.c (tilepro_elf_relocate_section): Likewise.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Likewise.
	* elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise.
2017-07-24 11:27:33 +01:00
GDB Administrator 8ca02f6a21 Automatic date update in version.in 2017-07-24 00:00:58 +00:00
Alan Modra 15a3a14fdd Correct eh_frame info for __glink_PLTresolve
My PPC64_OPT_LOCALENTRY patch of June 1, git commit f378ab099d, and
the later gold change, git commit 7ee7ff7015, added an insn in
__glink_PLTresolve which needs a corresponding adjustment in the
eh_frame info for asynchronous exceptions to unwind correctly.

It would have been OK for both ABIs to use +5 for the advance before
restore of LR, since we can put the DW_CFA_restore_extended on any
insn after the actual restore and before the r12/r0 copy is clobbered,
but it's slightly better to delay as much as possible.  There are
then more addresses where fewer CFA program insns are executed.

bfd/
	* elf64-ppc.c (ppc64_elf_size_stubs): Correct advance to
	restore of LR.
gold/
	* powerpc.cc (glink_eh_frame_fde_64v2): Correct advance to
	restore of LR.
	(glink_eh_frame_fde_64v1): Advance to restore of LR at latest
	possible insn.
2017-07-23 20:40:39 +09:30
GDB Administrator 5c2c0020fb Automatic date update in version.in 2017-07-23 00:00:36 +00:00
GDB Administrator dbdda973f3 Automatic date update in version.in 2017-07-22 00:00:45 +00:00
GDB Administrator 33d69f8727 Automatic date update in version.in 2017-07-21 00:00:33 +00:00
GDB Administrator 8e8f892f70 Automatic date update in version.in 2017-07-20 00:00:34 +00:00
Szabolcs Nagy f2e6a8430e [AArch64] Fix PR18841 ifunc relocation ordering
In order to get the ifunc relocs properly sorted the correct class
needs to be returned.  The code mimics what has been done for x86.

Fixes
FAIL: Run pr18841 with libpr18841c.so

bfd/
	PR ld/18841
	* elfnn-aarch64.c (elfNN_aarch64_reloc_type_class): Return
	reloc_class_ifunc for ifunc symbols.
2017-07-19 18:47:22 +01:00
Nick Clifton 6c4e7b6bfb Extend previous fix to coff-rs6000.c to coff64-rs6000.c
PR 21786
	* coff64-rs6000.c (_bfd_strntol): New function.
	(_bfd_strntoll): New function.
	(GET_VALUE_IN_FIELD): New macro.
	(xcoff64_slurp_armap): Use new macros.
2017-07-19 16:14:02 +01:00
Nick Clifton 909e4e716c Fix use-after-free error when parsing a corrupt nested archive.
PR 21787
	* archive.c (bfd_generic_archive_p): If the bfd does not have the
	correct magic bytes at the start, set the error to wrong format
	and clear the format selector before returning NULL.
2017-07-19 14:49:12 +01:00
Nick Clifton 29866fa186 Fix address violation when attempting to read a corrupt field in a COFF archive header structure.
PR 21786
	* coff-rs6000.c (_bfd_strntol): New function.
	(_bfd_strntoll): New function.
	(GET_VALUE_IN_FIELD): New macro.
	(EQ_VALUE_IN_FIELD): new macro.
	(_bfd_xcoff_slurp_armap): Use new macros.
	(_bfd_xcoff_archive_p): Likewise.
	(_bfd_xcoff_read_ar_hdr): Likewise.
	(_bfd_xcoff_openr_next_archived_file): Likewise.
	(_bfd_xcoff_stat_arch_elt): Likewise.
2017-07-19 11:07:43 +01:00
John Eric Martin 684d5a10b1 [ARC] Add JLI support.
The following relocation types were added to GCC/binutils:

ARC_JLI_SECTOFF is a relocation type in Metaware that is now used by
GCC as well to adjust the index of function calls to functions with
attribute jli_call_always.

bfd/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
	    John Eric Martin  <John.Martin@emmicro-us.com>

	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* elf32-arc.c (JLI): Define.
	* reloc.c: Add JLI relocations.

gas/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>

	* testsuite/gas/arc/jli-1.d: New file.
	* testsuite/gas/arc/jli-1.s: Likewise.
	* testsuite/gas/arc/taux.d: Update for jli_base.

include/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
	    John Eric Martin  <John.Martin@emmicro-us.com>

	* elf/arc-reloc.def: Add JLI relocs howto.
	* opcode/arc-func.h (replace_jli): New function.

ld/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
	    John Eric Martin  <John.Martin@emmicro-us.com>

	* emulparams/arcelf.sh (JLI_START_TABLE): Define.
	* scripttempl/elfarc.sc: Handle jlitab section.
	* scripttempl/elfarcv2.sc: Likewise.
	* testsuite/ld-arc/arc.exp: Add JLI test.
	* testsuite/ld-arc/jli-script.ld: New file.
	* testsuite/ld-arc/jli-simple.dd: Likewise.
	* testsuite/ld-arc/jli-simple.rd: Likewise.
	* testsuite/ld-arc/jli-simple.s: Likewise.
	* testsuite/ld/testsuite/ld-arc/jli-overflow.s: Likewise.
	* testsuite/ld/testsuite/ld-arc/jli-overflow.d: Likewise.
	* testsuite/ld/testsuite/ld-arc/jli-overflow.err: Likewise.

opcode/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
	    John Eric Martin  <John.Martin@emmicro-us.com>

	* arc-opc.c (UIMM10_6_S_JLIOFF): Define.
	(UIMM3_23): Adjust accordingly.
	* arc-regs.h: Add/correct jli_base register.
	* arc-tbl.h (jli_s): Likewise.
2017-07-19 09:56:55 +02:00
GDB Administrator 801f648cfc Automatic date update in version.in 2017-07-19 00:00:59 +00:00
Yuri Chornovian de194d8575 Fix spelling typos. 2017-07-18 16:58:14 +01:00
Nick Clifton e4e21d9ed1 Fix runtime failure triggered by a corrupt ecoff input file.
PR binutils/21781
	* coffcode.h (handle_COMDAT): Replace abort with an error message
	and return.
2017-07-18 15:46:13 +01:00
GDB Administrator 25bda061bf Automatic date update in version.in 2017-07-18 00:00:50 +00:00