Commit Graph

13983 Commits

Author SHA1 Message Date
GDB Administrator 639257e981 Automatic date update in version.in 2017-09-07 00:00:25 +00:00
H.J. Lu 78984959cb x86-64: Add R_X86_64_converted_reloc_bit
Add R_X86_64_converted_reloc_bit to relocation type to indicate if a
relocation is converted from a GOTPCREL relocation.  Linker now generates

failed to convert GOTPCREL relocation; relink with --no-relax

for all cases, including relocations against local symbols.

bfd/

	* elf64-x86-64.c (R_X86_64_converted_reloc_bit): New.
	(elf_x86_64_info_to_howto): Get the real relocation type by
	masking out R_X86_64_converted_reloc_bit.
	(elf_x86_64_check_tls_transition): Get the real relocation type
	by masking out R_X86_64_converted_reloc_bit.
	(elf_x86_64_convert_load_reloc): Set R_X86_64_converted_reloc_bit
	instead of setting converted_reloc.
	(elf_x86_64_relocate_section): Check R_X86_64_converted_reloc_bit
	instead of converted_reloc. Get the real relocation type by
	masking out R_X86_64_converted_reloc_bit.
	(elf_x86_64_link_setup_gnu_properties): Verify that the value of
	R_X86_64_converted_reloc_bit is valid.
	* elfxx-x86.h (converted_reloc): Removed.

ld/

	* testsuite/ld-x86-64/pr19609-2a.d: Updated.
	* testsuite/ld-x86-64/pr19609-2b.d: Likewise.
	* testsuite/ld-x86-64/pr19609-4a.d: Likewise.
	* testsuite/ld-x86-64/pr19609-4c.d: Likewise.
2017-09-06 05:06:35 -07:00
H.J. Lu 419414eafc x86: Don't change r_type when performing TLS transitions
Don't change r_type when performing TLS transitions to avoid getting
the relocation type with ELF32_R_TYPE again.

	* elf32-i386.c (elf_i386_relocate_section): Don't change r_type
	when calling elf_i386_tls_transition.  Don't use ELF32_R_TYPE
	to get the relocation type again.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Don't change
	r_type when calling elf_x86_64_tls_transition.  Don't use
	ELF32_R_TYPE to get the relocation type again.
2017-09-06 04:53:59 -07:00
GDB Administrator 39250b0a1c Automatic date update in version.in 2017-09-06 00:00:18 +00:00
H.J. Lu dc08907213 x86-64: Properly set converted_reloc
Linker now generates

failed to convert GOTPCREL relocation; relink with --no-relax

for more cases.

bfd/

	* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Properly set
	converted_reloc.

ld/

	* testsuite/ld-x86-64/pr19609-5d.d: Updated.
	* testsuite/ld-x86-64/pr19609-7a.d: Likewise.
	* testsuite/ld-x86-64/pr19609-7c.d: Likewise.
2017-09-05 13:43:02 -07:00
H.J. Lu 8b43e45688 x86-64: Improve GOTPCREL relocation conversion
When GOTPCREL relocation conversion leads to relocation overflow, we
may get a mysterious linker message, like

relocation truncated to fit: R_X86_64_32S against symbol `foo'

This patch changes the linker message to

failed to convert GOTPCREL relocation; relink with --no-relax

bfd/

	* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Remove the sec
	argument.  Don't check relocation overflow.  Avoid relocation
	overflow if --no-relax is used.  Set converted_reloc on symbol
	if a GOTPCREL relocation is converted.
	(elf_x86_64_relocate_section): Issue a fatal error and suggest
	--no-relax if GOTPCREL relocation conversion leads to relocation
	overflow.
	* elfxx-x86.h (elf_x86_link_hash_entry): Add converted_reloc.

ld/

	* testsuite/ld-x86-64/pr19609-4e.d: Updated.
	* testsuite/ld-x86-64/pr19609-6a.d: Likewise.
2017-09-05 11:24:14 -07:00
GDB Administrator 0097251b8a Automatic date update in version.in 2017-09-05 00:00:18 +00:00
Alexander Fedotov-B55613 83eef88358 Missing relocation R_PPC_VLE_ADDR20 and add VLE flag to details in readelf
include/
	* elf/ppc.h (R_PPC_VLE_ADDR20): New relocation.
bfd/
	* elf32-ppc.c (ppc_elf_howto_raw): Add R_PPC_VLE_ADDR20.
	(ppc_elf_check_relocs): Handle it.
	(ppc_elf_vle_split20): New function.
	(ppc_elf_relocate_section): Handle R_PPC_VLE_ADDR20.
binutils/
	* readelf.c (get_elf_section_flags): Add VLE.
	(process_section_headers): Add VLE key to details.
gas/
	* config/tc-ppc.c (md_parse_option): Handle "mno-vle" flag.
	(ppc_elf_section_letter): New function.
	* config/tc-ppc.h (md_elf_section_letter): New.
	* testsuite/gas/elf/section10.d: Adjust for VLE.
2017-09-05 08:42:27 +09:30
GDB Administrator a826403eb6 Automatic date update in version.in 2017-09-04 00:00:29 +00:00
H.J. Lu 0e30d99180 x86-64: Set tlsdesc_plt if GOT_TLS_GDESC_P is true
We need to set tlsdesc_plt for x86-64 if GOT_TLS_GDESC_P is true when
allocating dynamic relocations so that _bfd_x86_elf_size_dynamic_sections
will generate TLSDESC_PLT and TLSDESC_GOT in x86-64 output.

bfd/

	PR ld/22071
	* elfxx-x86.c (elf_x86_allocate_dynrelocs): Set tlsdesc_plt
	for x86-64 if GOT_TLS_GDESC_P is true.

ld/

	PR ld/22071
	* testsuite/ld-x86-64/pr22071.d: New file.
	* testsuite/ld-x86-64/pr22071.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr22071.
2017-09-03 10:18:38 -07:00
Alan Modra 1cf58434bf PR22067, x86 check_relocs invalid read
PR 22067
	* elfxx-x86.h (elf_x86_hash_table): Check is_elf_hash_table first.
2017-09-03 22:09:38 +09:30
H.J. Lu f04bdfa7b2 Initialize tls_get_addr for x86-64 in one place
* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
	tls_get_addr for x86-64 in one place.
2017-09-02 22:14:58 -07:00
H.J. Lu d47a80260c Add missing ChangeLog entries 2017-09-02 22:10:39 -07:00
H.J. Lu 2ac3a7f5ce Add elf64-x86-64.lo together with elfxx-x86.lo for 64-bit BFD
Since elfxx-x86.lo needs elf64-x86-64.lo with 64-bit BFD now, add
elf64-x86-64.lo together with elfxx-x86.lo to bfd_backends for 64-bit
BFD.

	* configure.ac (bfd_backends): Add elf64-x86-64.lo together
	with elfxx-x86.lo for 64-bit BFD.
	* configure: Regenerated.
2017-09-02 22:04:27 -07:00
GDB Administrator aed02419fb Automatic date update in version.in 2017-09-03 00:00:30 +00:00
H.J. Lu 5e2ac45d56 x86: Add _bfd_x86_elf_size_dynamic_sections
elf_i386_size_dynamic_sections and elf_x86_64_size_dynamic_sections are
very similar, except for the followings:

1. elf_i386_size_dynamic_sections checks GOT_TLS_IE and GOT_TLS_IE_BOTH.
elf_x86_64_size_dynamic_sections checks only GOT_TLS_IE.  Since
GOT_TLS_IE_BOTH is never true for x86-64, it is OK to check GOT_TLS_IE
for both i386 and x86-64.
2, x86-64 sets tlsdesc_plt, but i386 doesn't.  We set tlsdesc_plt only
if target_id == X86_64_ELF_DATA.
3. x86-64 has

	  if (s != htab->elf.srelplt)
	    s->reloc_count = 0;

and i386 has

	  s->reloc_count = 0;

i386 did have

	  if (s != htab->srelplt)
	    s->reloc_count = 0;

in the original commit:

commit 67a4f2b710
Author: Alexandre Oliva <aoliva@redhat.com>
Date:   Wed Jan 18 21:07:51 2006 +0000

But it was removed by

commit 5ae0bfb60a
Author: Richard Sandiford <rdsandiford@googlemail.com>
Date:   Tue Feb 28 07:16:12 2006 +0000

    bfd/
            * elf32-i386.c (elf_i386_link_hash_table): Add next_tls_desc_index.
            (elf_i386_link_hash_table_create): Initialize it.
            (elf_i386_compute_jump_table_size): Use it instead of
            srelplt->reloc_count.
            (allocate_dynrelocs): Likewise.
            (elf_i386_size_dynamic_sections): Likewise.
            (elf_i386_relocate_section): Likewise.

A later commit:

commit e1f987424b
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Oct 21 15:13:37 2011 +0000

    Put IRELATIVE relocations after JUMP_SLOT.

    bfd/

    2011-10-21  H.J. Lu  <hongjiu.lu@intel.com>

            PR ld/13302
            * elf32-i386.c (elf_i386_link_hash_table): Add next_jump_slot_index
            and next_irelative_index.
            (elf_i386_link_hash_table_create): Initialize next_jump_slot_index
            and next_irelative_index.
            (elf_i386_allocate_dynrelocs): Increment reloc_count instead of
            next_tls_desc_index.
            (elf_i386_size_dynamic_sections): Set next_tls_desc_index and
            next_irelative_index from reloc_count.
            (elf_i386_finish_dynamic_symbol): Put R_386_IRELATIVE after
            R_386_JUMP_SLOT.

changed it back to use reloc_count again. So it is correct to use

	  if (s != htab->elf.srelplt)
	    s->reloc_count = 0;

for both i386 and x86-64 now.
4. i386 and x86-64 use different DT_XXXs.  They are handled by adding
them to elf_x86_link_hash_table.

With these changes, we can share _bfd_x86_elf_size_dynamic_sections in
elf32-i386.c and elf64-x86-64.c.

	* elf32-i386.c (elf_i386_convert_load): Renamed to ...
	(_bfd_i386_elf_convert_load): This.  Remove static.
	(elf_i386_size_dynamic_sections): Removed.
	(elf_backend_size_dynamic_sections): Likewise.
	* elf64-x86-64.c (elf_x86_64_convert_load): Renamed to ...
	(_bfd_x86_64_elf_convert_load): This.  Remove static.
	(elf_x86_64_size_dynamic_sections): Removed.
	(elf_backend_size_dynamic_sections): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_allocate_dynrelocs): Renamed to ...
	(elf_x86_allocate_dynrelocs): This.  Make it static.
	(_bfd_x86_elf_allocate_local_dynrelocs): Renamed to ...
	(elf_x86_allocate_local_dynreloc): This.  Make it static.
	(elf_i386_is_reloc_section): New function.
	(elf_x86_64_is_reloc_section): Likewise.
	(_bfd_x86_elf_link_hash_table_create): Initialize convert_load,
	is_reloc_section, dt_reloc, dt_reloc_sz and dt_reloc_ent.
	Rearrange got_entry_size initialization.
	(_bfd_x86_elf_size_dynamic_sections): New function.
	* elfxx-x86.h (elf_x86_link_hash_table): Add convert_load,
	is_reloc_section, dt_reloc, dt_reloc_sz and dt_reloc_ent.
	(_bfd_i386_elf_convert_load): New.
	(_bfd_x86_64_elf_convert_load): Likewise.
	(_bfd_x86_elf_size_dynamic_sections): Likewise.
	(elf_backend_size_dynamic_sections): Likewise.
	(_bfd_x86_elf_allocate_dynrelocs): Removed.
	(_bfd_x86_elf_allocate_local_dynrelocs): Likewise.
2017-09-02 15:12:04 -07:00
H.J. Lu 2926eb2c32 x86: Rearrange fields and update comments
* elfxx-x86.h (elf_x86_link_hash_table): Rearrange fields and
	update comments.
2017-09-02 13:05:49 -07:00
H.J. Lu 92c10f5f61 i386: Update sgotplt_jump_table_size setting
elf_i386_size_dynamic_sections has

      htab->next_tls_desc_index = htab->elf.srelplt->reloc_count;
      htab->sgotplt_jump_table_size = htab->next_tls_desc_index * 4;

This patch changes it to

      htab->sgotplt_jump_table_size
	= elf_x86_compute_jump_table_size (htab)

Since elf_x86_compute_jump_table_size is defined as

  ((htab)->elf.srelplt->reloc_count * (htab)->got_entry_size)

there is no change in output.  It makes elf_i386_size_dynamic_sections
the same as elf_x86_64_size_dynamic_sections.

	* elf32-i386.c (elf_i386_size_dynamic_sections): Set
	sgotplt_jump_table_size with elf_x86_compute_jump_table_size.
2017-09-02 11:18:30 -07:00
H.J. Lu aa595247af x86: Define PLT_CIE_LENGTH and PLT_FDE_* in elfxx-x86.h
Since PLT_CIE_LENGTH, PLT_FDE_LENGTH, PLT_FDE_START_OFFSET and
PLT_FDE_LEN_OFFSET are identical in elf32-i386.c and elf64-x86-64.c,
they can be defined in elfxx-x86.h.

	* elf32-i386.c (PLT_CIE_LENGTH, PLT_FDE_LENGTH,
	PLT_FDE_START_OFFSET, PLT_FDE_LEN_OFFSET): Moved to ...
	* elfxx-x86.h (PLT_CIE_LENGTH, PLT_FDE_LENGTH,
	PLT_FDE_START_OFFSET, PLT_FDE_LEN_OFFSET): Here.
	* elf64-x86-64.c (PLT_CIE_LENGTH, PLT_FDE_LENGTH,
	PLT_FDE_START_OFFSET, PLT_FDE_LEN_OFFSET): Removed.
2017-09-02 11:10:51 -07:00
H.J. Lu b9ce864ca8 x86: Add _bfd_x86_elf_allocate_dynrelocs
Share _bfd_x86_elf_allocate_dynrelocs in elf32-i386.c and elf64-x86-64.c.

	* elf32-i386.c (elf_i386_allocate_dynrelocs): Removed.
	(elf_i386_allocate_local_dynrelocs): Likewise.
	(elf_i386_size_dynamic_sections): Replace
	elf_i386_allocate_dynrelocs/elf_i386_allocate_local_dynrelocs
	with _bfd_x86_elf_allocate_dynrelocs and
	_bfd_x86_elf_allocate_local_dynrelocs.
	* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Removed.
	(elf_x86_64_allocate_local_dynrelocs): Likewise.
	(elf_x86_64_size_dynamic_sections): Replace
	elf_x86_64_allocate_dynrelocs/elf_x86_64_allocate_local_dynrelocs
	with _bfd_x86_elf_allocate_dynrelocs and
	_bfd_x86_elf_allocate_local_dynrelocs.
	* elfxx-x86.c (_bfd_x86_elf_allocate_dynrelocs): New function.
	(_bfd_x86_elf_allocate_local_dynrelocs): Likewise.
	* elfxx-x86.h (_bfd_x86_elf_allocate_dynrelocs): New prototype.
	(_bfd_x86_elf_allocate_local_dynrelocs): Likewise.
2017-09-02 07:27:40 -07:00
H.J. Lu fe53b4a4c4 x86: Add is_x86_elf
Share is_x86_elf in elf32-i386.c and elf64-x86-64.c.

	* elf32-i386.c (is_i386_elf): Removed.
	(elf_i386_check_relocs): Replace is_i386_elf with is_x86_elf.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	* elf64-x86-64.c (is_x86_64_elf): Removed.
	(elf_x86_64_check_relocs): Replace is_x86_64_elf with
	is_x86_elf.
	(elf_x86_64_size_dynamic_sections): Likewise.
	(elf_x86_64_relocate_section): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
	target_id.
	* elfxx-x86.h (elf_x86_link_hash_table): Add target_id.
	(is_x86_elf): New.
2017-09-02 07:24:42 -07:00
H.J. Lu 9ff114ca5d x86: Add elf_x86_compute_jump_table_size
Share elf_x86_compute_jump_table_size in elf32-i386.c and
elf64-x86-64.c.

	* elf32-i386.c (elf_i386_compute_jump_table_size): Removed.
	(elf_i386_allocate_dynrelocs): Replace
	elf_i386_compute_jump_table_size with
	elf_x86_compute_jump_table_size.
	(elf_i386_size_dynamic_sections): Likewise.
	* elf64-x86-64.c (elf_x86_64_compute_jump_table_size): Removed.
	(elf_x86_64_allocate_dynrelocs): Replace
	elf_x86_64_compute_jump_table_size with
	elf_x86_compute_jump_table_size.
	(elf_x86_64_size_dynamic_sections): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
	got_entry_size.
	* elfxx-x86.h (elf_x86_link_hash_table): Add got_entry_size.
	(elf_x86_compute_jump_table_size): New.
2017-09-02 07:18:55 -07:00
H.J. Lu 503294e755 x86: Add sizeof_reloc to elf_x86_link_hash_table
Initialize htab->sizeof_reloc once, instead of computing it every time.

	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
	sizeof_reloc.
	(_bfd_x86_elf_adjust_dynamic_symbol): Use sizeof_reloc.
	* elfxx-x86.h (elf_x86_link_hash_table): Add sizeof_reloc.
2017-09-02 05:55:25 -07:00
H.J. Lu 9a742a902f i386: Check VxWorks with htab->is_vxworks
* elf32-i386.c (elf_i386_allocate_dynrelocs): Check VxWorks
	with htab->is_vxworks.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_finish_dynamic_symbol): Likewise.
	(elf_i386_finish_dynamic_sections): Likewise.
2017-09-02 05:05:30 -07:00
H.J. Lu 6b9553e2a5 x86: Move GOT_TLS_* in elf32-i386.c to elfxx-x86.h
elf64-x86-64.c can use GOT_TLS_* definitions in elf32-i386.c with
GOT_TLS_IE_POS, GOT_TLS_IE_NEG and GOT_TLS_IE_BOTH unused.

	* elf32-i386.c (GOT_TLS_IE, GOT_TLS_IE_POS, GOT_TLS_IE_NEG,
	GOT_TLS_IE_BOTH, GOT_TLS_GDESC, GOT_TLS_GD_BOTH_P,
	GOT_TLS_GD_P, GOT_TLS_GDESC_P, GOT_TLS_GD_ANY_P): Moved to ...
	* elfxx-x86.h (GOT_TLS_IE, GOT_TLS_IE_POS, GOT_TLS_IE_NEG,
	GOT_TLS_IE_BOTH, GOT_TLS_GDESC, GOT_TLS_GD_BOTH_P,
	GOT_TLS_GD_P, GOT_TLS_GDESC_P, GOT_TLS_GD_ANY_P): Here.
	* elf64-x86-64.c (GOT_TLS_IE, GOT_TLS_GDESC, GOT_TLS_GD_BOTH_P,
	GOT_TLS_GD_P, GOT_TLS_GDESC_P, GOT_TLS_GD_ANY_P): Removed.
2017-09-02 04:52:15 -07:00
H.J. Lu ad71ce8de7 x86-64: Check ELF_COMMON_DEF_P for common symbols
bfd/

	PR ld/22064
	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Check
	ELF_COMMON_DEF_P for common symbols.

ld/

	PR ld/22064
	* testsuite/ld-x86-64/pr22064a.S: New file.
	* testsuite/ld-x86-64/pr22064b.c: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run PR ld/22064 test.
2017-09-01 18:55:55 -07:00
Alan Modra 96d01d93c4 -Og warning fixes
Found when building with gcc 4.9.4 using -Og.

bfd/
	* elf-eh-frame.c (offset_adjust): Avoid false positive gcc warning.
	* elflink.c (bfd_elf_size_dynsym_hash_dynstr): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise.
ld/
	* emultempl/msp430.em (eval_upper_either_sections): Make base_sec_name
	a const char*.
	(eval_lower_either_sections): Likewise.
	(msp430_elf_after_allocation): Likewise, and don't needlessly concat
	and free.  Warning fix.
2017-09-02 11:00:02 +09:30
GDB Administrator 96fbe52eaa Automatic date update in version.in 2017-09-02 00:00:25 +00:00
H.J. Lu 4f501a245f x86: Add _bfd_x86_elf_gc_mark_hook
Since R_X86_64_GNU_VTINHERIT == R_386_GNU_VTINHERIT and
R_X86_64_GNU_VTENTRY == R_386_GNU_VTENTRY, we can share
_bfd_x86_elf_gc_mark_hook in elf32-i386.c and elf64-x86-64.c.

	* elf32-i386.c (elf_i386_gc_mark_hook): Removed.
	(elf_backend_gc_mark_hook): Likewise.
	* elf64-x86-64.c (elf_x86_64_gc_mark_hook): Likewise.
	(elf_backend_gc_mark_hook): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_gc_mark_hook): New function.
	* elfxx-x86.h (_bfd_x86_elf_gc_mark_hook): New.
	(elf_backend_gc_mark_hook): Likewise.
2017-09-01 14:51:58 -07:00
H.J. Lu eeb2f20a76 x86: Add _bfd_x86_elf_adjust_dynamic_symbol
Share _bfd_x86_elf_adjust_dynamic_symbol in elf32-i386.c and
elf64-x86-64.c.

	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Removed.
	(elf_backend_adjust_dynamic_symbol): Likewise.
	* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.
	(elf_backend_adjust_dynamic_symbol): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_adjust_dynamic_symbol): New function.
	(_bfd_x86_elf_link_setup_gnu_properties): Copy is_vxworks.
	* elfxx-x86.h (elf_x86_link_hash_table): Add is_vxworks.
	(_bfd_x86_elf_adjust_dynamic_symbol): New.
	(elf_backend_adjust_dynamic_symbol): Likewise.
2017-09-01 13:03:40 -07:00
H.J. Lu 18da07cd12 Correct ChangeLog entry 2017-09-01 13:01:23 -07:00
H.J. Lu c6295c2290 elfxx-x86.h: Fix a typo in comments
* elfxx-x86.h (elf_x86_plt_layout_table): Fix a typo in
	comments.
2017-09-01 12:39:38 -07:00
H.J. Lu 39946cc227 x86: Add _bfd_x86_elf_mkobject
Share _bfd_x86_elf_mkobject in elf32-i386.c and elf64-x86-64.c.

	* elf32-i386.c (elf_i386_mkobject): Removed.
	(bfd_elf32_mkobject): Likewise.
	* elf64-x86-64.c (elf_x86_64_mkobject): Likewise.
	(bfd_elf64_mkobject): Likewise.
	(bfd_elf32_mkobject): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_mkobject): New function.
	(_bfd_x86_elf_mkobject): New.
	(bfd_elf64_mkobject): Likewise.
	(bfd_elf32_mkobject): Likewise.
2017-09-01 12:09:03 -07:00
H.J. Lu a6798baba2 x86: Add _bfd_x86_elf_link_setup_gnu_properties
Extract the common parts of elf_i386_link_setup_gnu_properties and
elf_x86_64_link_setup_gnu_properties into a new function.

For x86-64, since PIC PLT layouts are the same as non-PIC PLT layouts,
initialize pic_plt0_entry and pic_plt_entry fields in PLT layouts with
the non-PIC PLT entries.

	* elf32-i386.c (elf_i386_link_setup_gnu_properties): Updated.
	Call _bfd_x86_elf_link_setup_gnu_properties.
	* elf64-x86-64.c (elf_x86_lazy_plt_layout): Initialize
	pic_plt0_entry and pic_plt_entry fields with the non-PIC PLT
	entries.
	(elf_x86_64_non_lazy_plt): Likewise.
	(elf_x86_64_lazy_bnd_plt): Likewise.
	(elf_x86_64_non_lazy_bnd_plt): Likewise.
	(elf_x86_64_lazy_ibt_plt): Likewise.
	(elf_x32_lazy_ibt_plt): Likewise.
	(elf_x86_64_non_lazy_ibt_plt): Likewise.
	(elf_x32_non_lazy_ibt_plt): Likewise.
	(elf_x86_64_nacl_plt): Likewise.
	(elf_x86_64_link_setup_gnu_properties): Updated.  Call
	_bfd_x86_elf_link_setup_gnu_properties.
	* elfxx-x86.c: Include elf-vxworks.h".
	(_bfd_x86_elf_link_setup_gnu_properties): New function.
	* elfxx-x86.h (elf_x86_lazy_plt_layout): Remove "for i386 only"
	comments for pic_plt0_entry and pic_plt_entry.
	(elf_x86_non_lazy_plt_layout): Likewise.
	(elf_x86_plt_layout_table): New.
	(_bfd_x86_elf_link_setup_gnu_properties): Likewise.
2017-09-01 08:00:51 -07:00
H.J. Lu e10c9c620c x86: Correct unwind information for the second PLT
For i386, generate unwind information for the second PLT.  For x32,
correct alignment of .eh_frame section for the second PLT.

bfd/

	PR ld/22061
	* elf32-i386.c (elf_i386_link_setup_gnu_properties): Create
	.eh_frame section for the second PLT.
	* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Correct
	alignment of .eh_frame section for the second PLT.

ld/

	PR ld/22061
	* testsuite/ld-i386/ibt-plt-1.d: Updated.
	* testsuite/ld-i386/ibt-plt-2a.d: Likewise.
	* testsuite/ld-i386/ibt-plt-2c.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3a.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3c.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise.
	* testsuite/ld-i386/ibt-plt-2b.d: Pass --hash-style=sysv to ld
	and dump unwind information.
	* testsuite/ld-i386/ibt-plt-2d.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3b.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3d.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2b-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2b.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-3b-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3b.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d.d: Likewise.
2017-09-01 06:12:06 -07:00
Nick Clifton 7e8b60085e Prevent an address violation parsing corrupt DWARF information by fixing the test for an overlong debug line info structure.
PR 22059
	* dwarf2.c (decode_line_info): Fix test for an overlong line info
	structure.
2017-09-01 11:20:51 +01:00
Nick Clifton 2a143b99fc Fix buffer overrun when parsing an ELF attribute string that is not NUL terminated.
PR 22058
	* elf-attrs.c (_bfd_elf_parse_attributes): Ensure that the
	attribute buffer is NUL terminated.
2017-09-01 09:57:44 +01:00
GDB Administrator 1f0c13579f Automatic date update in version.in 2017-09-01 00:00:25 +00:00
Nick Clifton e4f2723003 Fix buffer read overrun by ensuring that DWARF sections containing strings always end in a NUL byte.
PR 22047
	* dwarf2.c (read_section): If necessary add a terminating NUL byte
	to dwarf string sections.
2017-08-31 17:03:23 +01:00
Alan Modra 686335cd3c Regen SRC-POTFILES.in
* po/SRC-POTFILES.in: Regenerate.
2017-08-31 20:07:13 +09:30
Alan Modra 9866ffe25a Remove .eh_frame zero terminators
The machinery to do this was there, but not enabled if the terminator
was the only thing in the section.

bfd/
	* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Don't exit early
	for a section containing just a terminator.  Allow multiple
	terminators at end of section.
	* elflink.c (bfd_elf_discard_info): Iterate over .eh_frame
	sections when not adding alignment.  Assert on terminator in
	the middle of FDEs.
ld/
	* testsuite/ld-elf/eh3.d: Update.
	* testsuite/ld-elf/eh4.d: Update.
2017-08-31 19:40:35 +09:30
Alan Modra af471f828c PR22048, Incorrect .eh_frame section in libc.so
PR 21441
	PR 22048
	* elflink.c (bfd_elf_discard_info): Don't pad embedded zero
	terminators.
2017-08-31 13:18:16 +09:30
H.J. Lu 3321e42bf2 Add elf64.lo together with elfxx-x86.lo for 64-bit BFD
Since elfxx-x86.lo needs elf64.lo with 64-bit BFD, add elf64.lo together
with elfxx-x86.lo to bfd_backends for 64-bit BFD.

	* configure.ac (bfd_backends): Add elf64.lo together with
	elfxx-x86.lo for 64-bit BFD.
	* configure: Regenerated.
2017-08-30 19:55:45 -07:00
James Bowman ef32532f22 FT32: Permit R_FT32_18 overflow
The howto for R_FT32_18 was using complain_overflow_signed. But some
valid address calculations exceed the range of this reloc.  Changing it
to complain_overflow_dont allows them.

bfd/ChangeLog:

	* elf32-ft32.c (ft32_elf_howto_table): Use
	complain_overflow_dont for R_FT32_18.
2017-08-30 19:44:58 -07:00
Alan Modra e234de6be5 bfd_close_all_done calling _close_and_cleanup
elf64_vms_close_and_cleanup calls bfd_get_size, which calls
iovec->bstat.  cache_bstat ends up adding the bfd to the cache lru
list, negating the bfd_cache_close call in bfd_close_all_done.  So
there is a dangling pointer into the freed and then reused bfd.  Thus,
bfd_cache_close must be called after _close_and_cleanup, or better,
via iovec->bclose.

	PR binutils/22032
	* opncls.c (bfd_close_all_done): Don't call bfd_cache_close
	before _close_and_cleanup.  Call iovec->bclose after.
	(bfd_close): Remove code common to, and call, bfd_close_all_done.
2017-08-31 10:30:07 +09:30
GDB Administrator e69f32654a Automatic date update in version.in 2017-08-31 00:00:22 +00:00
H.J. Lu f493882dab x86: Add _bfd_x86_elf_get_synthetic_symtab
Move the common codes in elf_i386_get_synthetic_symtab and
elf_x86_64_get_synthetic_symtab to _bfd_x86_elf_get_synthetic_symtab.

	* elf32-i386.c (elf_i386_plt_type): Removed.
	(elf_i386_plt): Likewise.
	(elf_i386_get_synthetic_symtab): Updated.   Call
	_bfd_x86_elf_get_synthetic_symtab.
	* elf64-x86-64.c (elf_x86_64_plt_type): Removed.
	(elf_x86_64_plt): Likewise.
	(elf_x86_64_get_synthetic_symtab): Updated.  Call
	_bfd_x86_elf_get_synthetic_symtab.
	* elfxx-x86.c (elf_i386_get_plt_got_vma): New function.
	(elf_x86_64_get_plt_got_vma): Likewise.
	(elf_i386_valid_plt_reloc_p): Likewise.
	(elf_x86_64_valid_plt_reloc_p): Likewise.
	(_bfd_x86_elf_get_synthetic_symtab): Likewise.
	* elfxx-x86.h (elf_x86_plt_type): New.
	(elf_x86_plt): Likewise.
	(_bfd_x86_elf_get_synthetic_symtab): Likewise.
2017-08-30 12:27:30 -07:00
H.J. Lu 5b86dbf454 x86: Check target_id instead of elf_machine_code
Since both elf32-i386.c and elf64-x86-64.c support targets with
different ELF_MACHINE_CODEs, _bfd_x86_elf_link_hash_table_create
should check target_id instead of elf_machine_code.

	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Check
	target_id instead of elf_machine_code.
2017-08-30 11:13:32 -07:00
H.J. Lu 765e526c75 x86: Add _bfd_x86_elf_link_hash_table_create
Share _bfd_x86_elf_link_hash_table_create in elf32-i386.c and
elf64-x86-64.c by:

1. Replace elf_i386_lazy_plt_layout, elf_i386_non_lazy_plt_layout,
elf_i386_plt_layout, elf_x86_64_lazy_plt_layout,
elf_x86_64_non_lazy_plt_layout and elf_x86_64_plt_layout with
elf_x86_lazy_plt_layout, elf_x86_non_lazy_plt_layout and
elf_x86_plt_layout.
2. Move plt, lazy_plt, non_lazy_plt, srelplt2 and next_tls_desc_index
from elf_i386_link_hash_table to elf_x86_link_hash_table.
3. Remove elf_i386_link_hash_table and elf_x86_64_link_hash_table.

	* elf32-i386.c (ELF_DYNAMIC_INTERPRETER): Removed.
	(elf_i386_lazy_plt_layout): Likewise.
	(elf_i386_non_lazy_plt_layout): Likewise.
	(elf_i386_plt_layout): Likewise.
	(elf_i386_link_hash_table): Likewise.
	(elf_i386_next_tls_desc_index): Likewise.
	(elf_i386_srelplt2): Likewise.
	(elf_i386_plt): Likewise.
	(elf_i386_lazy_plt): Likewise.
	(elf_i386_non_lazy_plt): Likewise.
	(elf_i386_link_hash_table_create): Likewise.
	(bfd_elf32_bfd_link_hash_table_create): Likewise.
	(elf_i386_lazy_plt): Updated.
	(elf_i386_non_lazy_plt): Likewise.
	(elf_i386_lazy_ibt_plt): Likewise.
	(elf_i386_non_lazy_ibt_plt): Likewise.
	(elf_i386_allocate_dynrelocs): Likewise.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_finish_dynamic_symbol): Likewise.
	(elf_i386_finish_dynamic_sections): Likewise.
	(elf_i386_get_synthetic_symtab): Likewise.
	(elf_i386_link_setup_gnu_properties): Likewise.
	(elf_i386_nacl_plt): Likewise.
	* elf64-x86-64.c (ABI_64_P): Removed.
	(ELF64_DYNAMIC_INTERPRETER): Likewise.
	(ELF32_DYNAMIC_INTERPRETER): Likewise.
	(elf_x86_64_lazy_plt_layout): Likewise.
	(elf_x86_64_non_lazy_plt_layout): Likewise.
	(elf_x86_64_plt_layout): Likewise.
	(elf_x86_64_link_hash_table): Likewise.
	(elf_x86_64_plt): Likewise.
	(elf_x86_64_lazy_plt): Likewise.
	(elf_x86_64_non_lazy_plt): Likewise.
	(elf_x86_64_link_hash_table_create): Likewise.
	(bfd_elf64_bfd_link_hash_table_create): Likewise.
	(bfd_elf32_bfd_link_hash_table_create): Likewise.
	(elf_x86_64_lazy_plt): Updated.
	(elf_x86_64_non_lazy_plt): Likewise.
	(elf_x86_64_lazy_bnd_plt): Likewise.
	(elf_x86_64_non_lazy_bnd_plt): Likewise.
	(elf_x86_64_lazy_ibt_plt): Likewise.
	(elf_x32_lazy_ibt_plt): Likewise.
	(elf_x86_64_non_lazy_ibt_plt): Likewise.
	(elf_x32_non_lazy_ibt_plt): Likewise.
	(elf_x86_64_allocate_dynrelocs): Likewise.
	(elf_x86_64_size_dynamic_sections): Likewise.
	(elf_x86_64_relocate_section): Likewise.
	(elf_x86_64_finish_dynamic_symbol): Likewise.
	(elf_x86_64_finish_dynamic_sections): Likewise.
	(elf_x86_64_get_synthetic_symtab): Likewise.
	(elf_x86_64_link_setup_gnu_properties): Likewise.
	(elf_x86_64_nacl_plt): Likewise.
	* elfxx-x86.c: Include "objalloc.h", "elf/i386.h" and
	"elf/x86-64.h".
	(ELF32_DYNAMIC_INTERPRETER): New.
	(ELF64_DYNAMIC_INTERPRETER): Likewise.
	(ELFX32_DYNAMIC_INTERPRETER): Likewise.
	(_bfd_x86_elf_link_hash_table_create): Likewise.
	(_bfd_x86_elf_link_hash_table_free): Renamed to ...
	(elf_x86_link_hash_table_free): This.  Make it static.
	* elfxx-x86.h: Don't include "objalloc.h".
	(ABI_64_P): New.
	(elf_x86_lazy_plt_layout): Likewise.
	(elf_x86_non_lazy_plt_layout): Likewise.
	(elf_x86_plt_layout): Likewise.
	(_bfd_x86_elf_link_hash_table_create): Likewise.
	(bfd_elf64_bfd_link_hash_table_create): Likewise.
	(bfd_elf32_bfd_link_hash_table_create): Likewise.
	(elf_x86_link_hash_table): Add plt, lazy_plt, non_lazy_plt,
	srelplt2 and next_tls_desc_index.
	(_bfd_x86_elf_link_hash_table_free): Removed.
2017-08-30 09:10:24 -07:00
Maciej W. Rozycki 70e65ca8e5 MIPS/BFD: Correct microMIPS cross-mode BAL to JALX relaxation
Fix a bug in commit a6ebf6169a ("MIPS: Convert cross-mode BAL to
JALX") and in BFD linker relaxation correct the microMIPS interpretation
of the branch offset, which is supposed to be shifted by 1 bit, rather
than 2 as in the regular MIPS case.

	bfd/
	* elfxx-mips.c (mips_elf_perform_relocation): Correct microMIPS
	branch offset interpretation.

	gas/
	* testsuite/gas/mips/branch-addend-micromips.d: New test.
	* testsuite/gas/mips/branch-addend-micromips-n32.d: New test.
	* testsuite/gas/mips/branch-addend-micromips-n64.d: New test.
	* testsuite/gas/mips/branch-addend-micromips.s: New test source.
	* testsuite/gas/mips/mips.exp: Run the new tests.

	ld/
	* testsuite/ld-mips-elf/bal-jalx-addend-micromips.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-addend-micromips-n32.d: New
	test.
	* testsuite/ld-mips-elf/bal-jalx-addend-micromips-n64.d: New
	test.
	* testsuite/ld-mips-elf/bal-jalx-local-micromips.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-local-micromips-n32.d: New
	test.
	* testsuite/ld-mips-elf/bal-jalx-local-micromips-n64.d: New
	test.
	* testsuite/ld-mips-elf/bal-jalx-pic-micromips.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-pic-micromips-n32.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-pic-micromips-n64.d: New test.
	* testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips.d: New
	test.
	* testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n32.d: New
	test.
	* testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n64.d: New
	test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2017-08-30 16:07:45 +01:00
H.J. Lu 7c0ed39626 Call _close_and_cleanup in bfd_close_all_done
PR binutils/22032
	* opncls.c (bfd_close_all_done): Call _close_and_cleanup.
2017-08-30 06:22:52 -07:00
H.J. Lu 0f2425c4c8 Remove elf_x86_64_next_tls_desc_index/elf_x86_64_srelplt2
They are unused.

	* elf64-x86-64.c (elf_x86_64_next_tls_desc_index): Removed.
	(elf_x86_64_srelplt2): Likewise.
2017-08-30 05:29:22 -07:00
H.J. Lu 443701f509 Add missing ChangeLog entries 2017-08-30 05:28:10 -07:00
Alan Modra 9a23f96e91 PowerPC TPREL16_HA/LO reloc optimization
In the TLS GD/LD to LE optimization, ld replaces a sequence like

 addi 3,2,x@got@tlsgd		R_PPC64_GOT_TLSGD16	x
 bl __tls_get_addr(x@tlsgd)	R_PPC64_TLSGD		x
				R_PPC64_REL24		__tls_get_addr
 nop

with

 addis 3,13,x@tprel@ha		R_PPC64_TPREL16_HA	x
 addi 3,3,x@tprel@l		R_PPC64_TPREL16_LO	x
 nop

When the tprel offset is small, this can be further optimized to

 nop
 addi 3,13,x@tprel
 nop

bfd/
	* elf64-ppc.c (struct ppc_link_hash_table): Add do_tls_opt.
	(ppc64_elf_tls_optimize): Set it.
	(ppc64_elf_relocate_section): Nop addis on TPREL16_HA, and convert
	insn on TPREL16_LO and TPREL16_LO_DS relocs to use r13 when
	addis would add zero.
	* elf32-ppc.c (struct ppc_elf_link_hash_table): Add do_tls_opt.
	(ppc_elf_tls_optimize): Set it.
	(ppc_elf_relocate_section): Nop addis on TPREL16_HA, and convert
	insn on TPREL16_LO relocs to use r2 when addis would add zero.
gold/
	* powerpc.cc (Target_powerpc::Relocate::relocate): Nop addis on
	TPREL16_HA, and convert insn on TPREL16_LO and TPREL16_LO_DS
	relocs to use r2/r13 when addis would add zero.
ld/
	* testsuite/ld-powerpc/tls.s: Add calls with tls markers.
	* testsuite/ld-powerpc/tls32.s: Likewise.
	* testsuite/ld-powerpc/powerpc.exp: Run tls marker tests.
	* testsuite/ld-powerpc/tls.d: Adjust for TPREL16_HA/LO optimization.
	* testsuite/ld-powerpc/tlsexe.d: Likewise.
	* testsuite/ld-powerpc/tlsexetoc.d: Likewise.
	* testsuite/ld-powerpc/tlsld.d: Likewise.
	* testsuite/ld-powerpc/tlsmark.d: Likewise.
	* testsuite/ld-powerpc/tlsopt4.d: Likewise.
	* testsuite/ld-powerpc/tlstoc.d: Likewise.
2017-08-30 20:43:31 +09:30
Alan Modra b9f04fe0df PowerPC64 __tls_get_addr sequence optimization
There isn't a good reason for ld.bfd to behave differently from gold
in the code generated by TLS GD/LD to LE optimization.

bfd/
	* elf64-ppc.c (ppc64_elf_relocate_section): When optimizing
	__tls_get_addr call sequences to LE, don't move the addi down
	to the nop.  Replace the bl with addi and leave the nop alone.
ld/
	* testsuite/ld-powerpc/tls.d: Update.
	* testsuite/ld-powerpc/tlsexe.d: Update.
	* testsuite/ld-powerpc/tlsexetoc.d: Update.
	* testsuite/ld-powerpc/tlsld.d: Update.
	* testsuite/ld-powerpc/tlsmark.d: Update.
	* testsuite/ld-powerpc/tlsopt4.d: Update.
	* testsuite/ld-powerpc/tlstoc.d: Update.
2017-08-30 20:35:09 +09:30
GDB Administrator 22e5c8027a Automatic date update in version.in 2017-08-30 00:00:21 +00:00
H.J. Lu 5f0f0847e2 x86: Re-indent elf32-i386.c/elf64-x86-64.c
* elf32-i386.c (elf_i386_pie_finish_undefweak_symbol):
	Re-indent.
	* elf64-x86-64.c (elf_x86_64_finish_local_dynamic_symbol):
	Likewise.
	(elf_x86_64_pie_finish_undefweak_symbol): Likewise.
2017-08-29 14:44:40 -07:00
H.J. Lu 0afcef5384 Add elfxx-x86.h and elfxx-x86.c
Move common codes in elf32-i386.c and elf64-x86-64.c to elfxx-x86.c.

	* Makefile.am (BFD32_BACKENDS): Add elfxx-x86.lo.
	(BFD64_BACKENDS): Likewise.
	(BFD32_BACKENDS_CFILES): Add elfxx-x86.c.
	(BFD64_BACKENDS_CFILES): Likewise.
	* Makefile.in: Regenerated.
	* configure.ac (bfd_backends): Add elfxx-x86.lo together with
	elf32-i386.lo and elf64-x86-64.lo.
	* configure: Regenerated.
	* elf32-i386.c: Include "elfxx-x86.h" instead of "sysdep.h",
	"bfd.h", "bfdlink.h", "libbfd.h", "elf-bfd.h", "bfd_stdint.h",
	"objalloc.h" and "hashtab.h".
	(ELIMINATE_COPY_RELOCS): Removed.
	(UNDEFINED_WEAK_RESOLVED_TO_ZERO):Likewise.
	(SYMBOL_NO_COPYRELOC): Likewise.
	(elf_i386_link_hash_entry): Likewise.
	(GOT_UNKNOWN): Likewise.
	(GOT_NORMAL): Likewise.
	(GOT_TLS_GD): Likewise.
	(elf_i386_hash_entry): Likewise.
	(elf_i386_obj_tdata): Likewise.
	(elf_i386_tdata): Likewise.
	(elf_i386_local_got_tls_type): Likewise.
	(elf_i386_local_tlsdesc_gotent): Likewise.
	(elf_i386_hash_table): Likewise.
	(elf_i386_link_hash_newfunc): Likewise.
	(elf_i386_local_htab_hash): Likewise.
	(elf_i386_local_htab_eq): Likewise.
	(elf_i386_get_local_sym_hash): Likewise.
	(elf_i386_link_hash_table_free): Likewise.
	(elf_i386_copy_indirect_symbol): Likewise.
	(elf_i386_fixup_symbol): Likewise.
	(elf_i386_readonly_dynrelocs): Likewise.
	(elf_i386_always_size_sections): Likewise.
	(elf_i386_set_tls_module_base): Likewise.
	(elf_i386_dtpoff_base): Likewise.
	(compare_relocs): Likewise.
	(elf_i386_hash_symbol): Likewise.
	(elf_i386_parse_gnu_properties): Likewise.
	(elf_i386_merge_gnu_properties): Likewise.
	(elf_i386_link_check_relocs): Likewise.
	(elf_i386_merge_symbol_attribute): Likewise.
	(bfd_elf32_bfd_link_check_relocs): Likewise.
	(elf_backend_copy_indirect_symbol): Likewise.
	(elf_backend_always_size_sections): Likewise.
	(elf_backend_omit_section_dynsym): Likewise.
	(elf_backend_hash_symbol): Likewise.
	(elf_backend_fixup_symbol): Likewise.
	(elf_backend_parse_gnu_properties): Likewise.
	(elf_backend_merge_gnu_properties): Likewise.
	(elf_backend_merge_symbol_attribute): Likewise.
	(elf_i386_mkobject): Updated.
	(elf_i386_link_hash_table_create): Likewise.
	(elf_i386_check_tls_transition): Likewise.
	(elf_i386_tls_transition): Likewise.
	(elf_i386_convert_load_reloc): Likewise.
	(elf_i386_check_relocs): Likewise.
	(elf_i386_adjust_dynamic_symbol): Likewise.
	(elf_i386_allocate_dynrelocs): Likewise.
	(elf_i386_convert_load): Likewise.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_finish_dynamic_symbol ): Likewise.
	(elf_i386_finish_dynamic_sections): Likewise.
	(elf_i386_output_arch_local_syms): Likewise.
	(elf_i386_get_synthetic_symtab): Likewise.
	(elf_i386_link_setup_gnu_properties): Likewise.
	(elf_i386_link_hash_table): Use elf_x86_link_hash_table, instead
	of elf_link_hash_table, as base.
	(elf_i386_next_tls_desc_index): New.
	(elf_i386_srelplt2): Likewise.
	(elf_i386_plt): Likewise.
	(elf_i386_lazy_plt): Likewise.
	(elf_i386_non_lazy_plt): Likewise.
	* elf32-x86-64.c: Include "elfxx-x86.h" instead of "sysdep.h",
	"bfd.h", "bfdlink.h", "libbfd.h", "elf-bfd.h", "bfd_stdint.h",
	"objalloc.h" and "hashtab.h".
	(ELIMINATE_COPY_RELOCS): Removed.
	(UNDEFINED_WEAK_RESOLVED_TO_ZERO):Likewise.
	(SYMBOL_NO_COPYRELOC): Likewise.
	(elf_x86_64_link_hash_entry): Likewise.
	(GOT_UNKNOWN): Likewise.
	(GOT_NORMAL): Likewise.
	(GOT_TLS_GD): Likewise.
	(elf_x86_64_hash_entry): Likewise.
	(elf_x86_64_obj_tdata): Likewise.
	(elf_x86_64_tdata): Likewise.
	(elf_x86_64_local_got_tls_type): Likewise.
	(elf_x86_64_local_tlsdesc_gotent): Likewise.
	(elf_x86_64_hash_table): Likewise.
	(elf_x86_64_link_hash_newfunc): Likewise.
	(elf_x86_64_local_htab_hash): Likewise.
	(elf_x86_64_local_htab_eq): Likewise.
	(elf_x86_64_get_local_sym_hash): Likewise.
	(elf_x86_64_link_hash_table_free): Likewise.
	(elf_x86_64_copy_indirect_symbol): Likewise.
	(elf_x86_64_fixup_symbol): Likewise.
	(elf_x86_64_readonly_dynrelocs): Likewise.
	(elf_x86_64_always_size_sections): Likewise.
	(elf_x86_64_set_tls_module_base): Likewise.
	(elf_x86_64_dtpoff_base): Likewise.
	(compare_relocs): Likewise.
	(elf_x86_64_merge_symbol_attribute): Likewise.
	(elf_x86_64_hash_symbol): Likewise.
	(elf_x86_64_parse_gnu_properties): Likewise.
	(elf_x86_64_merge_gnu_properties): Likewise.
	(elf_x86_64_link_check_relocs): Likewise.
	(elf_backend_copy_indirect_symbol): Likewise.
	(elf_backend_always_size_sections): Likewise.
	(bfd_elf64_bfd_link_check_relocs): Likewise.
	(elf_backend_merge_symbol_attribute): Likewise.
	(elf_backend_hash_symbol): Likewise.
	(elf_backend_omit_section_dynsym): Likewise.
	(elf_backend_fixup_symbol): Likewise.
	(elf_backend_parse_gnu_properties): Likewise.
	(elf_backend_merge_gnu_properties): Likewise.
	(bfd_elf32_bfd_link_check_relocs): Likewise.
	(elf_x86_64_mkobject): Updated.
	(elf_x86_64_link_hash_table_create): Likewise.
	(elf_x86_64_check_tls_transition): Likewise.
	(elf_x86_64_tls_transition): Likewise.
	(elf_x86_64_convert_load_reloc): Likewise.
	(elf_x86_64_check_relocs): Likewise.
	(elf_x86_64_adjust_dynamic_symbol): Likewise.
	(elf_x86_64_allocate_dynrelocs): Likewise.
	(elf_x86_64_convert_load): Likewise.
	(elf_x86_64_size_dynamic_sections): Likewise.
	(elf_x86_64_relocate_section): Likewise.
	(elf_x86_64_finish_dynamic_symbol ): Likewise.
	(elf_x86_64_finish_dynamic_sections): Likewise.
	(elf_x86_64_output_arch_local_syms): Likewise.
	(elf_x86_64_get_synthetic_symtab): Likewise.
	(elf_x86_64_link_setup_gnu_properties): Likewise.
	(elf_x86_64_link_hash_table): Use elf_x86_link_hash_table,
	instead of elf_link_hash_table, as base.
	(elf_x86_64_next_tls_desc_index): New.
	(elf_x86_64_srelplt2): Likewise.
	(elf_x86_64_plt): Likewise.
	(elf_x86_64_lazy_plt): Likewise.
	(elf_x86_64_non_lazy_plt): Likewise.
	* elfxx-x86.c: New file.
	* elfxx-x86.h: Likewise.
2017-08-29 12:58:51 -07:00
H.J. Lu 823cb06774 x86: Simplify bad return in get_synthetic_symtab
* elf32-i386.c (elf_i386_get_synthetic_symtab): Simplify bad
	return.
	* elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise.
2017-08-29 11:28:10 -07:00
H.J. Lu 37c0b6ee65 x86: Check valid PLT sections before checking dynamic relocations
Update x86 get_synthetic_symtab to check valid PLT sections before
checking dynamic relocations and free invalid PLT section contents.

	* elf32-i386.c (elf_i386_get_synthetic_symtab): Check valid PLT
	sections before checking dynamic relocations and free invalid
	PLT section contents.
	* elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise.
2017-08-29 10:40:03 -07:00
GDB Administrator f2d394fce1 Automatic date update in version.in 2017-08-29 00:01:09 +00:00
H.J. Lu 0fb0a76778 Remove unused _bfd_elf_ifunc_get_synthetic_symtab
Since _bfd_elf_ifunc_get_synthetic_symtab is no longer called by x86
get_synthetic_symtab, it is now unused.  This patch removes it.

	* elf-bfd.h (_bfd_elf_ifunc_get_synthetic_symtab): Removed.
	* elf-ifunc.c (_bfd_elf_ifunc_get_synthetic_symtab): Likewise.
2017-08-28 15:40:00 -07:00
H.J. Lu 90efb64229 x86: Check for valid PLT section size
Update x86 get_synthetic_symtab to check for valid PLT section size
before examining PLT section contents.

	PR binutils/22018
	* elf32-i386.c (elf_i386_get_synthetic_symtab): Check for valid
	PLT section size.
	* elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise.
2017-08-28 11:25:58 -07:00
GDB Administrator 41e5237748 Automatic date update in version.in 2017-08-28 00:00:46 +00:00
H.J. Lu 596dc58f33 x86: Initialize def_protected
* elf32-i386.c (elf_i386_link_hash_newfunc): Initialize
	def_protected.
	* elf64-x86-64.c (elf_x86_64_link_hash_newfunc): Likewise.
2017-08-27 07:23:40 -07:00
H.J. Lu a5b4ee9451 Disallow copy relocation against protected data symbol
We shpouldn't generate copy relocation to resolve reference to protected
data symbol defined in shared object with the NO_COPY_ON_PROTECTED
property.  This patch adds a bit to elf_obj_tdata as well as
elf_i386_link_hash_entry and elf_x86_64_link_hash_entry to track the bfd
with the NO_COPY_ON_PROTECTED property as well as protected symbol
defined in shared object.  extern_protected_data is set to FALSE if any
input relocatable file contains the NO_COPY_ON_PROTECTED property.

bfd/

	PR ld/21997
	* elf-bfd.h (elf_obj_tdata): Use ENUM_BITFIELD on object_id,
	dyn_lib_class and has_gnu_symbols.  Change bad_symtab to bitfield.
	Add a has_no_copy_on_protected bitfield.
	(elf_has_no_copy_on_protected): New.
	* elf-properties.c (_bfd_elf_parse_gnu_properties): Set
	elf_has_no_copy_on_protected for GNU_PROPERTY_NO_COPY_ON_PROTECTED.
	(elf_merge_gnu_property_list): Likewise.
	(_bfd_elf_link_setup_gnu_properties): Set extern_protected_data
	to FALSE for elf_has_no_copy_on_protected.
	* elf32-i386.c (SYMBOL_NO_COPYRELOC): New.
	(elf_i386_link_hash_entry): Add def_protected.
	(elf_i386_adjust_dynamic_symbol): Also check SYMBOL_NO_COPYRELOC
	when checking info->nocopyreloc.
	(elf_i386_link_setup_gnu_properties): Don't set
	extern_protected_data here.
	(elf_i386_merge_symbol_attribute): New function.
	(elf_backend_merge_symbol_attribute): New.
	* elf64-x86-64.c (SYMBOL_NO_COPYRELOC): New.
	(elf_x86_64_link_hash_entry): Add def_protected.
	(elf_x86_64_need_pic): Report protected symbol for def_protected.
	(elf_x86_64_adjust_dynamic_symbol): Also check SYMBOL_NO_COPYRELOC
	when checking info->nocopyreloc.
	(elf_x86_64_relocate_section): Also check for R_X86_64_PC32
	relocation run-time overflow and unresolvable R_X86_64_32S
	relocation against protected data symbol defined in shared object
	with GNU_PROPERTY_NO_COPY_ON_PROTECTED.
	(elf_x86_64_link_setup_gnu_properties): Don't set
	extern_protected_data here.
	(elf_x86_64_merge_symbol_attribute): New function.
	(elf_backend_merge_symbol_attribute): New.

ld/

	PR ld/21997
	* testsuite/ld-i386/i386.exp: Run PR ld/21997 tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr21997-1a.S: New file.
	* testsuite/ld-i386/pr21997-1b.c: Likewise.
	* testsuite/ld-i386/pr21997-1c.S: Likewise.
	* testsuite/ld-x86-64/pr21997-1a.S: Likewise.
	* testsuite/ld-x86-64/pr21997-1a.err: Likewise.
	* testsuite/ld-x86-64/pr21997-1b.c: Likewise.
	* testsuite/ld-x86-64/pr21997-1b.err: Likewise.
	* testsuite/ld-x86-64/pr21997-1c.c: Likewise.
2017-08-26 19:26:21 -07:00
GDB Administrator aecbb010f9 Automatic date update in version.in 2017-08-27 00:00:52 +00:00
Alan Modra 7c8bbca5e6 PowerPC TPREL reloc handling
Tidy how these are handled in PIEs.

	* elf32-ppc.c (must_be_dyn_reloc): Use bfd_link_dll.  Comment.
	(ppc_elf_check_relocs): Only set DF_STATIC_TLS in shared libs.
	(ppc_elf_relocate_section): Comment fix.
	* elf64-ppc.c (must_be_dyn_reloc): Use bfd_link_dll.  Comment.
	(ppc64_elf_check_relocs): Only set DF_STATIC_TLS in shared libs.
	Support dynamic relocs for TPREL16 when non-pic too.
	(dec_dynrel_count): Adjust TPREL16 handling as per check_relocs.
	(ppc64_elf_relocate_section): Support dynamic relocs for TPREL16
	when non-pic too.
2017-08-26 20:52:07 +09:30
H.J. Lu 5fdda9d6a4 x86: Remove redundant "symbol" in comments
* elf32-i386.c (elf_i386_link_hash_entry): Remove redundant
	"symbol" in comments.
	* elf64-x86-64.c (elf_x86_64_link_hash_entry): Likewise.
2017-08-25 17:13:58 -07:00
GDB Administrator 7d5b8b81d3 Automatic date update in version.in 2017-08-26 00:01:04 +00:00
GDB Administrator a2d64ef20b Automatic date update in version.in 2017-08-25 00:01:00 +00:00
H.J. Lu 7073b5b9ed x86-64: Check relocations with -z nocopyreloc
On x86-64, when -z nocopyreloc is used to build executable, relocations
may overflow at run-time or may not be resolved without PIC.  This patch
checks these conditions and issues an error with suggestion for -fPIC.

bfd/

	PR ld/22001
	* elf64-x86-64.c (elf_x86_64_relocate_section): Check for
	R_X86_64_PC32 relocation run-time overflow and unresolvable
	R_X86_64_32S relocation with -z nocopyreloc.

ld/

	PR ld/22001
	* testsuite/ld-i386/i386.exp: Run -z nocopyreloc tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* ld/testsuite/ld-i386/pr22001-1a.c: New file.
	* ld/testsuite/ld-i386/pr22001-1b.c: Likewise.
	* ld/testsuite/ld-i386/pr22001-1c.S: Likewise.
	* ld/testsuite/ld-x86-64/pr22001-1a.c: Likewise.
	* ld/testsuite/ld-x86-64/pr22001-1a.err: Likewise.
	* ld/testsuite/ld-x86-64/pr22001-1b.c: Likewise.
	* ld/testsuite/ld-x86-64/pr22001-1b.err: Likewise.
	* ld/testsuite/ld-x86-64/pr22001-1c.c: Likewise.
2017-08-24 06:34:38 -07:00
H.J. Lu 34bb2571d4 Revert commit aab921adcb
* elf32-i386.c (elf_i386_check_relocs): Revert the last change.
	Undefined symbols may not have a type.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
2017-08-24 03:35:44 -07:00
GDB Administrator f8d31560e1 Automatic date update in version.in 2017-08-24 00:00:38 +00:00
H.J. Lu aab921adcb x86-64: Properly report output type when PIC is needed
-fPIC may be needed to compile PIE or PDE objects, not just shared
object.

bfd/

	* elf64-x86-64.c (elf_x86_64_need_pic): Add an argument for
	bfd_link_info.  Report shared, PIE or PDE object based on
	bfd_link_info.
	(elf_x86_64_check_relocs): Update elf_x86_64_need_pic call.
	(elf_x86_64_relocate_section): Likewise.

ld/

	* testsuite/ld-x86-64/pie2.d: Updated.
	* testsuite/ld-x86-64/pr19719.d: Likewise.
	* testsuite/ld-x86-64/pr19807-2a.d: Likewise.
	* testsuite/ld-x86-64/pr19969.d: Likewise.
2017-08-23 13:43:45 -07:00
H.J. Lu b1bb697ea1 x86: Increment PLT count only for function symbols
Since PLT entry is needed only for function symbols, increment PLT count
only for function symbols.

	* elf32-i386.c (elf_i386_check_relocs): Increment PLT count only
	for function symbols.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
2017-08-23 13:12:04 -07:00
H.J. Lu 73784fa565 x86: Clear extern_protected_data for GNU_PROPERTY_NO_COPY_ON_PROTECTED
When GNU_PROPERTY_NO_COPY_ON_PROTECTED is set, it indicates that there
are no copy relocations against protected data symbols.  When linker
sees GNU_PROPERTY_NO_COPY_ON_PROTECTED on any input relocatable file,
it sets extern_protected_data to FALSE.

bfd/

	* elf32-i386.c (elf_i386_link_setup_gnu_properties): Set
	extern_protected_data to FALSE if GNU_PROPERTY_NO_COPY_ON_PROTECTED
	is set on any input relocatable file.
	* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Likewise.

ld/

	* testsuite/ld-i386/i386.exp: Run protected7.
	* testsuite/ld-i386/protected7.d: New file.
	* testsuite/ld-i386/protected7.s: Likewise.
	* testsuite/ld-x86-64/protected8.d: Likewise.
	* testsuite/ld-x86-64/protected8.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run protected8.
2017-08-23 10:15:58 -07:00
GDB Administrator 98973784dc Automatic date update in version.in 2017-08-23 00:00:48 +00:00
Alan Modra 46434633f9 Make undefined symbols in allocate_dynrelocs dynamic
..if they have dynamic relocs.  An undefined symbol in a PIC object
that finds no definition ought to become dynamic in order to support
--allow-shlib-undefined, but there is nothing in the generic ELF
linker code to do this if the reference isn't via the GOT or PLT.  (An
initialized function pointer is an example.)  So it falls to backend
code to ensure the symbol is made dynamic.

	PR 21988
	* elf64-ppc.c (ensure_undef_dynamic): Rename from
	ensure_undefweak_dynamic.  Handle undefined too.
	* elf32-ppc.c (ensure_undef_dynamic): Likewise.
	* elf32-hppa.c (ensure_undef_dynamic): Likewise.
	(allocate_dynrelocs): Discard undefined non-default visibility
	relocs first.  Make undefined syms dynamic.  Tidy goto.
2017-08-23 08:58:08 +09:30
Alan Modra 487b6440da Make __start/__stop symbols protected visibility
They can't be hidden visibility since apparently people use dlsym to
look them up.

bfd/
	PR ld/21964
	* elf-bfd.h (SYMBOLIC_BIND): Return TRUE for __start/__stop symbols.
	* elflink.c (bfd_elf_define_start_stop): Rewrite.
ld/
	PR ld/21964
	* testsuite/ld-elf/pr21562a.d: Update for changed start/stop symbols.
	* testsuite/ld-elf/pr21562b.d: Likewise.
	* testsuite/ld-elf/pr21562c.d: Likewise.
	* testsuite/ld-elf/pr21562d.d: Likewise.
	* testsuite/ld-elf/pr21562e.d: Likewise.
	* testsuite/ld-elf/pr21562f.d: Likewise.
	* testsuite/ld-elf/pr21562g.d: Likewise.
	* testsuite/ld-elf/pr21562h.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/sizeofa.d: Likewise.
	* testsuite/ld-elf/sizeofb.d: Likewise.
	* testsuite/ld-elf/startofa.d: Likewise.
	* testsuite/ld-elf/startofb.d: Likewise.
	* testsuite/ld-gc/pr20022.d: Likewise.
	* testsuite/ld-gc/start.d: Likewise.
	* testsuite/ld-elf/pr21964-1a.c: New file.
	* testsuite/ld-elf/pr21964-1b.c: New file.
	* testsuite/ld-elf/pr21964-2a.c: New file.
	* testsuite/ld-elf/pr21964-2b.c: New file.
	* testsuite/ld-elf/shared.exp: Run PR ld/21964 tests.
2017-08-21 23:29:29 +09:30
Hans-Peter Nilsson 284d826d9f PR ld/20125, MMIX weak symbols
Weak undefineds with PUSHJ relocs were "lost", causing internal
inconsistencies and an abort.
2017-08-21 03:43:35 +02:00
GDB Administrator 454c9bb956 Automatic date update in version.in 2017-08-21 00:00:41 +00:00
GDB Administrator 45aee2da6b Automatic date update in version.in 2017-08-20 00:00:47 +00:00
GDB Administrator d7dec582d1 Automatic date update in version.in 2017-08-19 00:00:44 +00:00
Nick Clifton de25939739 Fix buffer overrun parsing a corrupt tekhex binary.
PR binutils/21962
	* tekhex.c (getsym): Fix check for source pointer walking off the
	end of the input buffer.
2017-08-18 08:45:12 +01:00
GDB Administrator dd66b39984 Automatic date update in version.in 2017-08-18 00:00:54 +00:00
Szabolcs Nagy 545bc2b377 [AArch64] Skip IFUNC relocations in debug sections
Skip IFUNC relocations in debug sections ignored by ld.so.
Fixes the following ld test failures on aarch64:

FAIL: Build libpr18808.so
FAIL: Build libpr18808.so_2
FAIL: Run pr18808

aborting at bfd/elfnn-aarch64.c:4986 in elf64_aarch64_final_link_relocate.

bfd/
	PR ld/18808
	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Skip IFUNC
	relocations in debug sections, change abort to _bfd_error_handler.
2017-08-17 14:48:03 +01:00
GDB Administrator 8c1d4b8799 Automatic date update in version.in 2017-08-17 00:01:00 +00:00
GDB Administrator 1a457753cf Automatic date update in version.in 2017-08-16 00:13:28 +00:00
Nick Clifton 0c54f69295 Fix null pointer dereference when parsing a corrupt ELF binary.
PR 21957
	* elf.c (setup_group): Check for an empty or very small group
	section.
	* po/bfd.pot: Regenerate.
2017-08-14 12:09:36 +01:00
GDB Administrator d7f00f429a Automatic date update in version.in 2017-08-14 00:01:33 +00:00
Alan Modra 79a94a2ad1 PR21441, Unnecessary padding of .eh_frame section
Until all .eh_frame sections have been edited we don't know their
sizes.  So it isn't possible to properly decide whether a non-empty
.eh_frame section follows a given section until editing is complete.

bfd/
	PR 21441
	* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't add
	alignment padding here.
	* elflink.c (bfd_elf_discard_info): Add .eh_frame padding here
	in a reverse pass over sections.
ld/
	PR 21441
	* testsuite/ld-x86-64/pr21038a.d: Adjust.
	* testsuite/ld-x86-64/pr21038a-now.d: Adjust.
2017-08-14 09:25:17 +09:30
GDB Administrator 9ba349b544 Automatic date update in version.in 2017-08-13 00:00:56 +00:00
GDB Administrator 1a682d061c Automatic date update in version.in 2017-08-12 00:00:57 +00:00
H.J. Lu 98c5dfc994 x86: Allocate space for symbol names with symbol table
When synthesizing symbols for PLT entries, allocate space for symbol
names with @plt suffixes together with symbol table so that all memory
is returned when symbol table is freed.

	PR binutils/21943
	* elf32-i386.c (elf_i386_get_synthetic_symtab): Allocate space
	for @plt suffixes first.
	* elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise.
2017-08-11 09:40:39 -07:00
GDB Administrator 5af3691c75 Automatic date update in version.in 2017-08-11 00:01:26 +00:00
Nick Clifton 957e1fc1c5 Fix out of bounds memory access when trying to allocate space for a note of size -1.
PR 21933
	* elf.c (elf_read_notes): Check for a note size of -1.
2017-08-10 09:37:36 +01:00
GDB Administrator 3ecaa9fd72 Automatic date update in version.in 2017-08-10 00:01:40 +00:00
GDB Administrator a26c49b78a Automatic date update in version.in 2017-08-09 00:00:58 +00:00
Nick Clifton 24d3e51bf0 Fix address violation problems when parsing corrupt ELF binaries.
PR 21916
	* elf-attrs.c (_bfd_elf_parse_attributes): Complain about very
	small section lengths.
	* elf.c (_bfd_elf_setup_sections): Skip empty entries in the group
	table.
	(elfcore_grok_freebsd_prstatus): Add checks to make sure that
	there is enough data present in the note.
2017-08-08 13:20:02 +01:00
Alan Modra 206c9c79ee PR21017, microblaze missing _GLOBAL_OFFSET_TABLE_ symbol
PR 21017
	* elf32-microblaze.c (microblaze_elf_check_relocs): Don't bump
	got.refcount for GOTOFF relocs, just create .got section.
2017-08-08 14:08:43 +09:30
GDB Administrator 5d1ceb0b87 Automatic date update in version.in 2017-08-08 00:00:54 +00:00
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
H.J. Lu 8e85f840e1 Add missing ChangeLog entries for PR ld/21782 fix 2017-07-17 12:40:57 -07:00
H.J. Lu c5bb8910e8 x86-64: Limit PIC check to shared library build
When building an executable, undefined symbols are error and undefined
weak symbols are resolved to zero.  We only need to check PIC for
building a shared library.

bfd/

	PR ld/21782
	* elf64-x86-64.c (elf_x86_64_relocate_section): Limit PIC check
	to shared library.

ld/

	PR ld/21782
	* testsuite/ld-x86-64/pie3-nacl.d: New file.
	* testsuite/ld-x86-64/pie3.d: Likewise.
	* testsuite/ld-x86-64/pie3.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pie3 and pie3-nacl.
2017-07-17 12:17:59 -07:00
H.J. Lu dd57c19c1a Re-indent elf_x86_64_relocate_section
* elf64-x86-64.c (elf_x86_64_relocate_section): Re-indent.
2017-07-17 10:40:18 -07:00
GDB Administrator caa74962b6 Automatic date update in version.in 2017-07-17 00:00:58 +00:00
Alan Modra 676ee2b5fa __tls_get_addr_opt GOT entries
My 2017-01-24 patch (commit f0158f44) wrongly applied an optimization
of GOT entries for the __tls_get_addr_opt stub, to shared libraries.

When the TLS segment layout is known, as it is for the executable and
shared libraries loaded at initial program start, powerpc supports a
__tls_get_addr optimization.  On the first call to __tls_get_addr for
a given __tls_index GOT entry, the DTPMOD word is set to zero and the
DTPREL word to the thread pointer offset to the thread variable.  This
allows the __tls_get_addr_opt stub to return that value immediately
without making a call into glibc for any subsequent __tls_get_addr
calls using that __tls_index GOT entry.

That's all fine, but I thought I'd be clever and when the thread
variable is local, set up the GOT entry as if __tls_get_addr had
already been called.  Which is good only for the executable, since ld
cannot know the TLS layout for shared libraries.

Of course, if this only applies to executables there isn't much point
to the optimization.  Normally, GD and LD code in an executable will
be converted to IE or LE, losing the __tls_get_addr call.  So the only
time it will trigger is with --no-tls-optimize.  Thus, revert all
support.

	* elf64-ppc.c (ppc64_elf_relocate_section): Don't optimize
	__tls_index GOT entries when using __tls_get_addr_opt stub.
	* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
2017-07-16 21:31:38 +09:30
GDB Administrator 046c08c44b Automatic date update in version.in 2017-07-16 00:00:55 +00:00
GDB Administrator 71d01ca93b Automatic date update in version.in 2017-07-15 00:00:42 +00:00
GDB Administrator ee77ed019f Automatic date update in version.in 2017-07-14 00:00:47 +00:00
GDB Administrator bbe7ef6699 Automatic date update in version.in 2017-07-13 00:00:50 +00:00
Alan Modra 429d795d50 Update PO files
bfd/
	* po/es.po: Update from translationproject.org/latest/bfd/.
	* po/fi.po: Likewise.
	* po/fr.po: Likewise.
	* po/id.po: Likewise.
	* po/ja.po: Likewise.
	* po/ro.po: Likewise.
	* po/ru.po: Likewise.
	* po/sr.po: Likewise.
	* po/sv.po: Likewise.
	* po/tr.po: Likewise.
	* po/uk.po: Likewise.
	* po/vi.po: Likewise.
	* po/zh_CN.po: Likewise.
	* po/hr.po: New file from translationproject.org.
	* configure.ac (ALL_LINGUAS): Add hr.  Sort.
	* configure: Regenerate.

binutils/
	* po/bg.po: Update from translationproject.org/latest/binutils/.
	* po/ca.po: Likewise.
	* po/da.po: Likewise.
	* po/es.po: Likewise.
	* po/fi.po: Likewise.
	* po/fr.po: Likewise.
	* po/hr.po: Likewise.
	* po/id.po: Likewise.
	* po/it.po: Likewise.
	* po/ja.po: Likewise.
	* po/ro.po: Likewise.
	* po/ru.po: Likewise.
	* po/sk.po: Likewise.
	* po/sr.po: Likewise.
	* po/sv.po: Likewise.
	* po/tr.po: Likewise.
	* po/uk.po: Likewise.
	* po/vi.po: Likewise.
	* po/zh_CN.po: Likewise.
	* po/zh_TW.po: Likewise.

gas/
	* po/es.po: Update from translationproject.org/latest/gas/.
	* po/fi.po: Likewise.
	* po/fr.po: Likewise.
	* po/id.po: Likewise.
	* po/ja.po: Likewise.
	* po/ru.po: Likewise.
	* po/sv.po: Likewise.
	* po/tr.po: Likewise.
	* po/uk.po: Likewise.
	* po/zh_CN.po: Likewise.

gold/
	* po/es.po: Update from translationproject.org/latest/gold/.
	* po/fi.po: Likewise.
	* po/fr.po: Likewise.
	* po/id.po: Likewise.
	* po/it.po: Likewise.
	* po/vi.po: Likewise.
	* po/zh_CN.po: Likewise.
	* po/ja.po: New file from translationproject.org.
	* po/sv.po: Likewise.
	* po/uk.po: Likewise.

gprof/
	* po/bg.po: Update from translationproject.org/latest/gprof/.
	* po/da.po: Likewise.
	* po/de.po: Likewise.
	* po/eo.po: Likewise.
	* po/es.po: Likewise.
	* po/fi.po: Likewise.
	* po/fr.po: Likewise.
	* po/ga.po: Likewise.
	* po/hu.po: Likewise.
	* po/id.po: Likewise.
	* po/it.po: Likewise.
	* po/ja.po: Likewise.
	* po/ms.po: Likewise.
	* po/nl.po: Likewise.
	* po/pt_BR.po: Likewise.
	* po/ro.po: Likewise.
	* po/ru.po: Likewise.
	* po/sr.po: Likewise.
	* po/sv.po: Likewise.
	* po/tr.po: Likewise.
	* po/uk.po: Likewise.
	* po/vi.po: Likewise.

ld/
	* po/bg.po: Update from translationproject.org/latest/ld/.
	* po/da.po: Likewise.
	* po/es.po: Likewise.
	* po/fi.po: Likewise.
	* po/fr.po: Likewise.
	* po/id.po: Likewise.
	* po/it.po: Likewise.
	* po/ja.po: Likewise.
	* po/tr.po: Likewise.
	* po/uk.po: Likewise.
	* po/vi.po: Likewise.
	* po/zh_CN.po: Likewise.
	* po/zh_TW.po: Likewise.
	* po/de.po: New file from translationproject.org.
	* po/ru.po: Likewise.
	* configure.ac (ALL_LINGUAS): Add de, ru.  Sort.
	* configure: Regenerate.

opcodes/
	* po/da.po: Update from translationproject.org/latest/opcodes/.
	* po/de.po: Likewise.
	* po/es.po: Likewise.
	* po/fi.po: Likewise.
	* po/fr.po: Likewise.
	* po/id.po: Likewise.
	* po/it.po: Likewise.
	* po/nl.po: Likewise.
	* po/pt_BR.po: Likewise.
	* po/ro.po: Likewise.
	* po/sv.po: Likewise.
	* po/tr.po: Likewise.
	* po/uk.po: Likewise.
	* po/vi.po: Likewise.
	* po/zh_CN.po: Likewise.
2017-07-12 23:08:59 +09:30
Nick Clifton 0bae9e9ec5 Fix compile time warnings building the binutils with gcc 7.1.1.
bfd	* elf32-xtensa.c (elf_xtensa_get_plt_section): Increase length of
	plt_name buffer.
	(elf_xtensa_get_gotplt_section): Increase length of got_name
	buffer.
	* mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Add a
	default return of FALSE.
	* mach-o-i386.c (bfd_mach_o_i386_canonicalize_one_reloc): Add a
	default return of FALSE.

binutils * dwarf.c (dwarf_vmatoa_1): Do not pass a NULL string pointer to
	sprintf.
	* srconv.c (walk_tree_type): Initialise the spare field of the
	IT_dty structure.

gas	* config/tc-pru.c (md_assemble): Add continue statement after
	handling 'E' operand character.
	* config/tc-v850.c (md_assemble): Initialise the 'insn' variable.
2017-07-12 12:17:02 +01:00
Alan Modra d42c267e9b bfd_error_handler bfd_vma and bfd_size_type args
This patch uses the new %L _bfd_error_handler support for printing
bfd_vma arguments, and fixes a many other format and/or argument
errors in error messages.

bfd/
	* binary.c (binary_set_section_contents): Don't print filepos in
	error message.
	(coff_write_object_contents): Cast size_t for error message.
	(coff_slurp_line_table): Don't use bfd_vma symndx.
	(coff_slurp_reloc_table): Remove unneeded cast.
	* dwarf2.c (read_section): Cast bfd_int64_t to long long for
	error message.
	(find_abstract_instance_name): Likewise.
	* elf32-arm.c (arm_type_of_stub): Correct error arg order.
	(bfd_elf32_arm_stm32l4xx_erratum_scan): Don't cast error arg.
	(elf32_arm_check_relocs): Make r_symndx an int.
	* elf32-cris.c (cris_elf_check_relocs): Delete extraneous %s in
	format string.
	* elf32-metag.c (elf_metag_relocate_section): Delete extra error
	message arg.
	* elf32-nds32.c (nds32_elf_ex9_build_hash_table): Rewrite bogus
	error message.
	* elf32-i386.c (elf_i386_check_relocs): Make r_symndx an int.
	* elf32-s390.c (elf_s390_check_relocs): Likewise.
	* elf32-tic6x.c (elf32_tic6x_check_relocs): Likewise.
	* elf32-tilepro.c (tilepro_elf_check_relocs): Likewise.
	* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
	* elf64-s390.c (elf_s390_check_relocs): Likewise.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Likewise.
	* elfnn-riscv.c (riscv_elf_check_relocs): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
	* elfxx-tilegx.c (tilegx_elf_check_relocs): Likewise.
	* elf64-mmix.c (_bfd_mmix_after_linker_allocation): Cast size_t args
	and use %lu for error message.
	* elflink.c (elf_link_adjust_relocs): Delete extra error message arg.
	* mmo.c (mmo_scan): Make stab_loc a file_ptr.  Cast expression for
	error message.

	* elf32-arm.c (elf32_arm_tls_relax): Correct format string and args
	in error message.
	(elf32_arm_final_link_relocate): Likewise.
	* coff-arm.c (bfd_arm_process_before_allocation): Likewise.
	* coffcode.h (styp_to_sec_flags): Likewise.
	* cofflink.c (_bfd_coff_write_global_sym): Likewise.
	* ecoff.c (_bfd_ecoff_slurp_symbol_table): Likewise.
	* elf32-arc.c (arc_elf_merge_private_bfd_data): Likewise.
	* elf32-bfin.c (bfinfdpic_check_relocs): Likewise.
	(elf32_bfin_merge_private_bfd_data): Likewise.
	* elf32-cris.c (cris_elf_relocate_section): Likewise.
	* elf32-frv.c (frv_elf_merge_private_bfd_data): Likewise.
	* elf32-i370.c (i370_elf_merge_private_bfd_data): Likewise.
	(i370_elf_relocate_section): Likewise.
	* elf32-iq2000.c (iq2000_elf_merge_private_bfd_data): Likewise.
	* elf32-m32c.c (m32c_elf_merge_private_bfd_data): Likewise.
	* elf32-m68hc1x.c (_bfd_m68hc11_elf_merge_private_bfd_data): Likewise.
	* elf32-mcore.c (mcore_elf_relocate_section): Likewise.
	* elf32-mep.c (mep_elf_merge_private_bfd_data): Likewise.
	* elf32-mt.c (mt_elf_merge_private_bfd_data): Likewise.
	* elf64-sparc.c (elf64_sparc_merge_private_bfd_data): Likewise.
	* elfxx-mips.c (mips_elf_merge_obj_e_flags): Likewise.
	(_bfd_mips_elf_merge_private_bfd_data): Likewise.
	* ieee.c (ieee_write_id, read_id): Likewise.
	* mach-o.c (bfd_mach_o_write_contents): Likewise.
	(bfd_mach_o_layout_commands, bfd_mach_o_read_section_32): Likewise.
	(bfd_mach_o_read_section_64, bfd_mach_o_read_symtab_symbol): Likewise.
	(bfd_mach_o_read_command, bfd_mach_o_header_p): Likewise.
	* peXXigen.c (_bfd_XXi_swap_aouthdr_in): Likewise.
	* stabs.c (_bfd_link_section_stabs): Likewise.

	* coff-arm.c (coff_arm_relocate_section): Use L modifier in error
	format.
	* coff-mcore.c (coff_mcore_relocate_section): Likewise.
	* coff-ppc.c (coff_ppc_relocate_section): Likewise.
	* coff-rs6000.c (xcoff_reloc_type_toc): Likewise.
	* coff-sh.c (sh_relax_section): Likewise.
	(sh_relax_delete_bytes, sh_swap_insns): Likewise.
	* coff-tic80.c (coff_tic80_relocate_section): Likewise.
	* coffcode.h (coff_slurp_reloc_table): Likewise.
	* coffgen.c (_bfd_coff_get_external_symbols): Likewise.
	(_bfd_coff_read_string_table): Likewise.
	* cofflink.c (_bfd_coff_generic_relocate_section): Likewise.
	* compress.c (bfd_get_full_section_contents): Likewise.
	* dwarf2.c (read_formatted_entries, decode_line_info): Likewise.
	* elf-m10300.c (mn10300_elf_relocate_section): Likewise.
	* elf.c (bfd_elf_string_from_elf_section): Likewise.
	* elf32-arc.c (arc_special_overflow_checks): Likewise.
	* elf32-arm.c (elf32_arm_tls_relax): Likewise.
	(elf32_arm_final_link_relocate, elf32_arm_relocate_section): Likewise.
	(elf32_arm_write_section): Likewise.
	* elf32-bfin.c (bfin_relocate_section): Likewise.
	(bfinfdpic_relocate_section): Likewise.
	* elf32-hppa.c (hppa_build_one_stub): Likewise.
	(final_link_relocate, elf32_hppa_relocate_section): Likewise.
	* elf32-i386.c (elf_i386_tls_transition): Likewise.
	(elf_i386_relocate_section): Likewise.
	* elf32-ip2k.c (ip2k_final_link_relocate): Likewise.
	* elf32-lm32.c (lm32_elf_finish_dynamic_sections): Likewise.
	* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
	* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
	* elf32-metag.c (elf_metag_relocate_section): Likewise.
	* elf32-nds32.c (unrecognized_reloc_msg): Likewise.
	(nds32_elf_relax_longcall1, nds32_elf_relax_longcall2): Likewise.
	(nds32_elf_relax_longcall3, nds32_elf_relax_longjump1): Likewise.
	(nds32_elf_relax_longjump2, nds32_elf_relax_longjump3): Likewise.
	(nds32_elf_relax_longcall4, nds32_elf_relax_longcall5): Likewise.
	(nds32_elf_relax_longcall6, nds32_elf_relax_longjump4): Likewise.
	(nds32_elf_relax_longjump5, nds32_elf_relax_longjump6): Likewise.
	(nds32_elf_relax_longjump7, nds32_elf_relax_loadstore): Likewise.
	(nds32_elf_relax_ptr, nds32_elf_ex9_build_hash_table): Likewise.
	* elf32-nios2.c (nios2_elf32_relocate_section): Likewise.
	* elf32-rx.c (UNSAFE_FOR_PID): Likewise.
	* elf32-s390.c (invalid_tls_insn, elf_s390_relocate_section): Likewise.
	* elf32-score.c (s3_bfd_score_elf_check_relocs): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_check_relocs): Likewise.
	* elf32-sh.c (sh_elf_relax_section): Likewise.
	(sh_elf_relax_delete_bytes, sh_elf_swap_insns): Likewise.
	(sh_elf_relocate_section): Likewise.
	* elf32-sh64.c (shmedia_prepare_reloc): Likewise.
	* elf32-spu.c (spu_elf_relocate_section): Likewise.
	* elf32-tic6x.c (elf32_tic6x_relocate_section): Likewise.
	* elf32-tilepro.c (tilepro_elf_relocate_section): Likewise.
	* elf32-v850.c (v850_elf_relax_section): Likewise.
	* elf32-vax.c (elf_vax_check_relocs): Likewise.
	(elf_vax_relocate_section): Likewise.
	* elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
	(extend_ebb_bounds_forward, extend_ebb_bounds_backward): Likewise.
	(compute_text_actions, compute_ebb_proposed_actions): Likewise.
	(do_fix_for_relocatable_link): Likewise.
	* elf64-alpha.c (elf64_alpha_relax_got_load): Likewise.
	(elf64_alpha_relax_with_lituse): Likewise.
	* elf64-hppa.c (elf64_hppa_finish_dynamic_symbol): Likewise.
	(elf_hppa_final_link_relocate): Likewise.
	* elf64-ia64-vms.c (elf64_ia64_relax_section): Likewise.
	(elf64_ia64_choose_gp, elf64_ia64_relocate_section): Likewise.
	(elf64_vms_link_add_object_symbols): Likewise.
	* elf64-mmix.c (mmix_elf_perform_relocation): Likewise.
	(mmix_final_link_relocate): Likewise.
	* elf64-s390.c (invalid_tls_insn): Likewise.
	(elf_s390_relocate_section): Likewise.
	* elf64-sh64.c (sh_elf64_relocate_section): Likewise.
	* elf64-x86-64.c (elf_x86_64_tls_transition): Likewise.
	(elf_x86_64_relocate_section): Likewise.
	* elfcode.h (elf_slurp_symbol_table): Likewise.
	* elfcore.h (elf_core_file_p): Likewise.
	* elflink.c (elf_link_read_relocs_from_section): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise.
	(elfNN_aarch64_relocate_section): Likewise.
	* elfnn-ia64.c (elfNN_ia64_relax_section): Likewise.
	(elfNN_ia64_choose_gp, elfNN_ia64_relocate_section): Likewise.
	* elfnn-riscv.c (riscv_elf_relocate_section): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
	(_bfd_mips_elf_relocate_section): Likewise.
	(_bfd_mips_elf_finish_dynamic_symbol, mips_finish_exec_plt): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.
	* elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise.
	* ieee.c (ieee_slurp_external_symbols): Likewise.
	* ihex.c (ihex_write_object_content): Likewise.
	* mach-o.c (bfd_mach_o_build_exec_seg_command): Likewise.
	* merge.c (_bfd_merged_section_offset): Likewise.
	* mmo.c (mmo_write_loc_chunk): Likewise.
	(mmo_write_object_contents): Likewise.
	* peXXigen.c (_bfd_XX_bfd_copy_private_bfd_data_common): Likewise.
	* stabs.c (_bfd_link_section_stabs): Likewise.
	* xcofflink.c (xcoff_link_add_symbols, xcoff_find_tc0): Likewise.
ld/
	* testsuite/ld-arc/nps-1b.err: Update.
	* testsuite/ld-x86-64/ilp32-11.d: Update.
2017-07-12 14:03:48 +09:30
GDB Administrator bd6a8c1905 Automatic date update in version.in 2017-07-12 00:00:47 +00:00
Alan Modra e3fbc3da13 ppc32 use of %x in einfo format, typo fix
* elf32-ppc.c (ppc_elf_relocate_section): Fix typo.
2017-07-11 22:42:43 +09:30
Alan Modra 2c4d9cbe51 ppc32 use of %x in einfo format
einfo doesn't support %x.

	* elf32-ppc.c (ppc_elf_relocate_section): Emit "unexpected
	instruction" error using _bfd_error_handler, not einfo.
2017-07-11 19:18:47 +09:30
GDB Administrator 36cebdda80 Automatic date update in version.in 2017-07-11 00:00:41 +00:00
Nick Clifton adce5b398d Fix compile time warning about duplicate case values for powerpc-aix target.
* coffcode.h (coff_slurp_symbol_table): Do not include an entry
	for C_AIX_WEAKEXT if it has the same value as C_WEAKEXT.
2017-07-10 13:18:05 +01:00
GDB Administrator a074796714 Automatic date update in version.in 2017-07-10 00:00:41 +00:00
GDB Administrator f4db828807 Automatic date update in version.in 2017-07-09 00:00:41 +00:00
GDB Administrator 12c1f20d6f Automatic date update in version.in 2017-07-08 00:00:40 +00:00
John Baldwin e6f3b9c319 Create pseudo sections for FreeBSD NT_PTLWPINFO core notes.
bfd/ChangeLog:

	* elf.c (elfcore_grok_freebsd_note): Handle NT_FREEBSD_PTLWPINFO.
2017-07-07 16:11:42 -07:00
Alan Modra 532cc31305 Add some missing xcoff support
* coffcode.h (coff_slurp_symbol_table): Handle C_AIX_WEAKEXT.
2017-07-07 10:35:31 +09:30
Alan Modra 1cf9552bf1 Another _doprnt fix for %L handling
* bfd.c (_doprnt): Replace "L" with "ll" when printing bfd_vma
	as long long.  Move code replacing "ll" with "I64", and simplify.
2017-07-07 10:35:31 +09:30
GDB Administrator 9691e722c6 Automatic date update in version.in 2017-07-07 00:00:35 +00:00
H.J. Lu a0b7b10523 Convert 'L' to 'l' when setting wide_width to 1
When setting wide_width to 1, convert 'L' to 'l'.  Otherwise, %Lx/%Lu/%Ld
will be passed to fprintf which will treat the argument as long long.

	* bfd.c (_doprnt): Convert 'L' to 'l' when setting wide_width
	to 1.
2017-07-06 06:52:13 -07:00
GDB Administrator 4b617f5235 Automatic date update in version.in 2017-07-06 00:00:56 +00:00
H.J. Lu 1d827a720c Fix build with GCC 4.2
Fix GCC 4.2 warnings like:

cc1: warnings being treated as errors
binutils-gdb/bfd/dwarf2.c:1844: warning: declaration of ‘time’ shadows a global declaration
/usr/include/time.h:187: warning: shadowed declaration is here
binutils-gdb/bfd/dwarf2.c: In function ‘line_info_add_file_name’:
binutils-gdb/bfd/dwarf2.c:1854: warning: declaration of ‘time’ shadows a global declaration
/usr/include/time.h:187: warning: shadowed declaration is here

bfd/

	* dwarf2.c (line_info_add_include_dir_stub): Replace time with
	xtime.
	(line_info_add_file_name): Likewise.
	(decode_line_info): Likewise.

binutils/

	* dwarf.c (display_debug_names): Replace index with xindex.
2017-07-05 09:05:05 -07:00
GDB Administrator 033ea118c0 Automatic date update in version.in 2017-07-05 00:00:31 +00:00
Tristan Gingold 0d702cfe5d Regenerate configure.
bfd/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

	* version.m4: Bump version to 2.29.51
	* configure: Regenerate.

binutils/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

	* configure: Regenerate.

gas/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

	* configure: Regenerate.

gprof/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

	* configure: Regenerate.

ld/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

	* configure: Regenerate.

opcodes/
2017-07-04  Tristan Gingold  <gingold@adacore.com>

	* configure: Regenerate.
2017-07-04 11:15:33 +02:00
Jiong Wang 564e46b795 [AArch64] Remove useless and incorrect assertion
The outer caller elf_link_output_extsym in elflink.c is a traverse function on
all external symbol, and it will only call *finish_dynamic_symbol if some
conditions is meet.  It is executed conditionally.

If the condition to trigger that assertion is satisified, it then won't satify
the outer check in finish_dynamic_symbol, so *finish_dynamic_symbol won't be
called that the assertion is expected to be dead code.

If elf_link_output_extsym is a traverse function that unconditionally called
on external symbols decided to be exported, then an assertion to make sure these
symbols are in sane status might make sense.

bfd/
        * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): Remove the
        sanity check at the head of this function.
2017-07-04 09:24:10 +01:00
Jan Kratochvil 0041f7df74 [binutils patch] DWARF-5: Extend bfd/dwarf2.c parse_comp_unit()
bfd/
2017-07-04  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2.c (struct dwarf2_debug): Add fields dwarf_line_str_buffer and
	dwarf_line_str_size.
	(struct attr_abbrev): Add field implicit_const.
	(dwarf_debug_sections): Add .debug_line_str.
	(enum dwarf_debug_section_enum): Add debug_line_str and debug_max.
	(dwarf_debug_section_assert): Add static assertion.
	(read_indirect_line_string): New.
	(read_abbrevs): Support DW_FORM_implicit_const.
	(is_str_attr): Support DW_FORM_line_strp.
	(read_attribute_value): Support DW_FORM_line_strp and
	DW_FORM_implicit_const.
	(read_attribute): Support DW_FORM_implicit_const.
	(line_info_add_include_dir, line_info_add_include_dir_stub):
	(line_info_add_file_name, read_formatted_entries): New.
	(decode_line_info, parse_comp_unit): Support DWARF 5.
	(_bfd_dwarf2_cleanup_debug_info): Free dwarf_line_str_buffer.
2017-07-04 10:09:27 +02:00
GDB Administrator 568fc4f4f8 Automatic date update in version.in 2017-07-04 00:00:43 +00:00
Egeyar Bagcioglu d8cd8c1f48 bfd: partial revert commit EC1ACAB (prevent all but undef weak symbols to become dynamic in sparc).
bfd/ChangeLog:

2017-07-03  Egeyar Bagcioglu  <egeyar.bagcioglu@oracle.com>

        * elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_symbol): Remove the
        abort statement that was put for symbols that are not dynamic.
2017-07-03 20:06:35 +02:00
Tristan Gingold 15e6ed8cbf Regenerate pot files. 2017-07-03 17:02:01 +02:00
Alan Modra 76cfced5ad Support %Lx, %Lu, %Ld in _bfd_error_handler format
One way to print 64-bit bfd_vma or bfd_size_type values on 32-bit
hosts is to cast the value to long long and use the 'll' modifier in
printf format strings.  However, that's awkward because we also
support the Microsoft C library printf that uses 'I64' as a modifier
instead, and having variants of translated strings would not endear us
to the translation project.  So, rewrite the 'll' modifier in
_doprint for Microsoft.  Even with that capability it's not so nice
for 32-bit code to need casts to long long, so this patch makes 'L' a
modifier for bfd_vma rather than an alias for 'll'.

I've then used the new 'L' modifier to fix selected format strings.

	* bfd.c (_doprnt): Rewrite "ll" and "L" modifiers to "I64" for
	__MSVCRT__.  Support "L" modifier for bfd_vma.  Formatting.
	* elf.c (setup_group): Use "Lx" to print sh_size.
	(_bfd_elf_setup_sections): Remove unnecessary cast and print
	unknown section type in hex.
	(copy_special_section_fields): Style fix.
	(bfd_section_from_shdr): Correct format for sh_link.  Use a
	common error message for all the variants of unrecognized
	section types.
	(assign_file_positions_for_load_sections): Use "Lx" for lma
	adjust error message.
	(assign_file_positions_for_non_load_sections): Formatting.
	(rewrite_elf_program_header): Formatting.  Use "Lx" for
	bfd_vma values in error messages.
	* elfcode.h (elf_slurp_reloc_table_from_section): Cast
	ELF_R_SYM value to type expected by format.
	* elflink.c (elf_link_read_relocs_from_section): Use "Lx"
	in error messages.
	(elf_link_add_object_symbols): Use "Lu" for symbol sizes.
	(elf_link_input_bfd): Use "Lx" for r_info.
	(bfd_elf_gc_record_vtinherit): Use "Lx" for offset.
2017-07-03 22:03:49 +09:30
Alan Modra ce9116fdbf BFD long long cleanup
long long isn't supposed to be used without a configure test, to
support ancient compilers.  Probably not terribly important nowadays.

	* bfd.c (bfd_scan_vma): Don't use long long unless HAVE_LONG_LONG.
	* coff-rs6000.c (FMT20): Handle hosts with 64-bit long and
	Microsoft C library variant of long long format specifier.
	(PRINT20): Cast value to bfd_uint64_t not long long.
	* coffcode.h (coff_print_aux): Use BFD_VMA_FMT.
	* coff-x86_64.c (coff_amd64_reloc): Use bfd_uint64_t rather than
	long long.  Don't cast to bfd_vma.
	* elf32-score.c (score3_bfd_getl48): Likewise.
	* vms-alpha.c (_bfd_vms_slurp_eisd): Likewise.
2017-07-03 22:03:48 +09:30
Alan Modra cd9af601e6 Miscellaneous format string fixes
* elf.c (_bfd_elf_print_private_bfd_data): Use BFD_VMA_FMT to
	print d_tag.
	(bfd_elf_print_symbol): Don't cast symbol->flags.
	(_bfd_elf_symbol_from_bfd_symbol): Likewise.
	* elf32-ppc.c (ppc_elf_begin_write_processing): Correct
	_bfd_error_handler argument order.
	(ppc_elf_merge_private_bfd_data): Don't cast flags.
2017-07-03 22:03:28 +09:30
Alan Modra 33c734b2f8 Missing config for bfd.c:_doprnt
This function uses HAVE_LONG_LONG and HAVE_LONG_DOUBLE

	* configure.ac: Invoke AC_CHECK_TYPES for long long.  Invoke
	AC_TYPE_LONG_DOUBLE.
	* configure: Regenerate.
	* config.in: Regenerate.
2017-07-03 21:55:57 +09:30
GDB Administrator 2040444f33 Automatic date update in version.in 2017-07-03 00:00:39 +00:00
GDB Administrator c6eb149dfa Automatic date update in version.in 2017-07-02 00:00:47 +00:00
GDB Administrator 3c465ea0ff Automatic date update in version.in 2017-07-01 00:00:41 +00:00
GDB Administrator 8d011e87df Automatic date update in version.in 2017-06-30 00:00:30 +00:00
Andrew Waterman 3df5cd1394 RISC-V: Fix TLS copy relocs
The dynrelro introduction wasn't implemented quite right for RISC-V,
as it didn't consider TLS copy relocs.

bfd/ChangeLog

2017-06-29  Andrew Waterman  <andrew@sifive.com>

        * elfnn-riscv.c (riscv_elf_adjust_dynamic_symbol): Fix TLS copy
        relocs.
2017-06-29 09:38:50 -07:00
Egeyar Bagcioglu ec1acaba13 bfd: prevent all but undef weak syms from becoming dynamic in sparc.
Prevent sparc backend making symbols dynamic unless they are undefined
weak. Use R_SPARC_RELATIVE for the symbols which are not dynamic in PIC.

This patch is tested on sparc64-unknown-linux-gnu, no regressions are
found.

bfd/ChangeLog:

2017-06-29  Egeyar Bagcioglu  <egeyar.bagcioglu@oracle.com>

	* elfxx-sparc.c (allocate_dynrelocs): Don't make a symbol dynamic
	unless it is undefined weak.
	* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Set the flag
	relative_reloc to direct non-dynamic symbols to R_SPARC_RELATIVE
	relocation.
	* elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_symbol): If symbol
        is not dynamic in PIC, abort.
2017-06-29 04:28:27 -07:00
Jiong Wang ff07562f1e [AArch64] Only override the symbol dynamic decision on undefined weak symbol
This fix is an adaption of the x86-64 PR ld/21402 fix to AArch64.

After the generic code deciding one symbol is not dynamic, AArch64 backend
only overrides the decision on undefined weak symbols.

bfd/
	PR ld/21402
	* elfnn-aarch64.c (elfNN_aarch64_allocate_dynrelocs): Only make
	undefined weak symbols into dynamic.
	(elfNN_aarch64_final_link_relocate): Generate runtime RELATIVE
	relocation for non-dynamic symbols.
	(elfNN_aarch64_finish_dynamic_symbol): Add sanity check.
2017-06-29 11:47:43 +01:00
Jiong Wang 2aff25ba76 [AArch64] Remove duplicated code when handling some GOT relocations types
There are quite a few duplicated code supporting several GP based
relocation types.  They are:

  BFD_RELOC_AARCH64_LD64_GOTOFF_LO15
  BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC
  BFD_RELOC_AARCH64_MOVW_GOTOFF_G1

These relocation types are supposed to be used for large memory model PIC/pic
mode under which we will have an initialized GP register points to the base of
GOT table, then these relocations are supposed to put the distance between GOT
entry and GOT table base address into the related instructions.

So, the parameters required to calculate the relocation should be the same as
BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15 etc, all of them are require the GOT entry
address and GOT table base address to perform the relocation.

This patch has removed those duplicated code when handling above listed
relocation types,  grouped them with others as relocation types that are
require GOT table base address during performing relocation, reused the
existed GOT handling code.

The relocation calculation for these types before and after this patch should be
identical.

bfd/
	* elfnn-aarch64.c (aarch64_relocation_aginst_gp_p): New function.
	(elfNN_aarch64_final_link_relocate): Delete duplicated code for
	BFD_RELOC_AARCH64_LD64_GOTOFF_LO15, BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC,
	BFD_RELOC_AARCH64_MOVW_GOTOFF_G1.
	* elfxx-aarch64.c (_bfd_aarch64_elf_resolve_relocation): Optimize the
	support for them.
2017-06-29 11:45:24 +01:00
Andreas Arnez 88ab90e860 S390: Support guarded-storage core note sections
Newer Linux kernel versions offer two new register sets in support of the
z/Architecture's guarded storage facility: NT_S390_GS_CB, the
"guarded-storage registers", and NT_S390_GS_BC, the "guarded-storage
broadcast control block".  This patch adds support for the respective core
notes sections to binutils.

bfd/ChangeLog:
	* elf-bfd.h (elfcore_write_s390_gs_cb): Add prototype.
	(elfcore_write_s390_gs_bc): Likewise.
	* elf.c (elfcore_grok_s390_gs_cb): New function.
	(elfcore_grok_s390_gs_bc): New function.
	(elfcore_grok_note): Call them.
	(elfcore_write_s390_gs_cb): New function.
	(elfcore_write_s390_gs_bc): New function.
	(elfcore_write_register_note): Call them.

binutils/ChangeLog:
	* readelf.c (get_note_type): Add NT_S390_GS_CB and NT_S390_GS_BC.

include/ChangeLog:
	* elf/common.h (NT_S390_GS_CB): New macro.
	(NT_S390_GS_BC): Likewise.
2017-06-29 10:30:09 +02:00
GDB Administrator 1b19ec9710 Automatic date update in version.in 2017-06-29 00:01:02 +00:00