Commit Graph

12319 Commits

Author SHA1 Message Date
GDB Administrator 25f004c8dd Automatic date update in version.in 2015-09-20 00:00:10 +00:00
Doug Evans 015d2e7e49 default_read_var_value <LOC_UNRESOLVED>: Include minsym kind in error message.
bfd/ChangeLog:

	* targets.c (enum bfd_flavour): Add comment.
	(bfd_flavour_name): New function.
	* bfd-in2.h: Regenerate.

gdb/ChangeLog:

	* findvar.c (default_read_var_value) <LOC_UNRESOLVED>: Include the
	kind of minimal symbol in the error message.
	* objfiles.c (objfile_flavour_name): New function.
	* objfiles.h (objfile_flavour_name): Declare.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/dw2-bad-unresolved.c: New file.
	* gdb.dwarf2/dw2-bad-unresolved.exp: New file.
2015-09-18 21:43:38 -07:00
GDB Administrator d96c806b92 Automatic date update in version.in 2015-09-19 00:00:08 +00:00
Alan Modra 7c9cf41584 Add PowerPC64 ld --tls-get-addr-optimize.
Sometimes it may be of benefit to force use of the __tls_get_addr_opt
call stub even when the glibc being used during linking does not
advertise __tls_get_addr_opt.

bfd/
	* elf64-ppc.h (struct ppc64_elf_params <tls_get_addr_opt>): Rename
	from no_tls_get_addr_opt.
	* elf64-ppc.c: Update for rename and inversion of tls_get_addr_opt.
	(ppc64_elf_tls_setup): Set tls_get_addr_opt to 0 only when at
	default of -1.
ld/
	* emultempl/ppc64elf.em (params): Init tls_get_addr_opt field to -1.
	(OPTION_TLS_GET_ADDR_OPT): Define.
	(PARSE_AND_LIST_LONGOPTS): Handle --tls-get-addr-opt.
	(PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Likewise.
	* ld.texinfo: Document --tls-get-addr-optimize and
	--no-tls-get-addr-optimize.
2015-09-18 16:38:03 +09:30
Alan Modra b29b8669ad Remove one unnecessary iteration in insertion sort
PR 18867
	* elflink.c (elf_link_adjust_relocs): Correct start of insertion
	sort main loop.
2015-09-18 12:39:16 +09:30
GDB Administrator a8aa551e5a Automatic date update in version.in 2015-09-18 00:00:08 +00:00
GDB Administrator c785244dd4 Automatic date update in version.in 2015-09-17 00:00:08 +00:00
Alan Modra bca6d0e319 Fix slowdown in ld -r for most common case of out-of-order relocs
I chose insertion sort since relocs are mostly sorted, but there is a
common case we can handle better;  A run of relocs put out of order
due to not linking input files in order.

	PR 18867
	* elflink.c (elf_link_adjust_relocs): Modify insertion sort to
	insert a run.  Return status in case of malloc failure.
	Adjust callers.
2015-09-16 21:53:21 +09:30
GDB Administrator 25bc8a24e4 Automatic date update in version.in 2015-09-16 00:00:07 +00:00
Max Filippov 92b3f00826 xtensa: generate PLT entries for call0 ABI
2015-09-15  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* elf32-xtensa.c (elf_xtensa_be_plt_entry)
	(elf_xtensa_le_plt_entry): Emit 'entry' instruction only for
	windowed ABI.
	(elf_xtensa_create_plt_entry): Generate 'l32r' offsets and fix
	up instructions according to ABI.
2015-09-15 22:18:51 +03:00
GDB Administrator afa18d267a Automatic date update in version.in 2015-09-15 00:00:09 +00:00
Rich Felker fbedb42d07 Fix the SH behavior for EF_SH_PIC flag in FDPIC ABI
Fix it so that it's compatible with the kernel and other FDPIC targets.

* elf32-sh.c (sh_elf_relocate_section): Set EF_SH_PIC flag
instead of clearing it on cross-section relocations.
(sh_elf_merge_private_data): Clear EF_SH_PIC flag by default.
2015-09-15 08:34:12 +09:00
GDB Administrator 1090ebbf87 Automatic date update in version.in 2015-09-14 00:00:09 +00:00
GDB Administrator 1ba8250461 Automatic date update in version.in 2015-09-13 00:00:11 +00:00
John David Anglin f3c3938c1c Set .plt entry size to 0 in elf32-hppa.c 2015-09-12 12:50:55 -04:00
GDB Administrator d8f16f3e9f Automatic date update in version.in 2015-09-12 00:00:08 +00:00
GDB Administrator 9ed2dcc401 Automatic date update in version.in 2015-09-11 00:00:08 +00:00
GDB Administrator 3f263e4b5a Automatic date update in version.in 2015-09-10 00:00:08 +00:00
Jiong Wang 4af68b9c78 [AArch64] Sort IS_AARCH64_TLS_RELAX_RELOC in alphabetic order
This can also speedup the check as TLSDESC is the default model for
global/local dynamic that the big "||" check can finish more quickly
than putting them at the bottom.

2015-09-09  Jiong. Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELAX_RELOC): Sort alphabetically.
2015-09-09 14:25:33 +01:00
Jiong Wang 259364adb8 [AArch64] Relax TLS local dynamic traditional into local executable
The linker relaxation logic will be:

Code sequence I (tiny):

    0x00 adr  x0, :tlsldm:x
    0x04 bl   __tls_get_addr
         |
         V
    0x00 mrs  x0, tpidr_el0
    0x04 add  x0, x0, TCB_SIZE

Code sequence II (small):

    0x00 adrp a0, :tlsldm:x
    0x04 add  a0, #:tlsldm_lo12:x
    0x08 bl   __tls_get_addr
         |
         V
    0x00 mrs  x0, tpidr_el0
    0x04 add  x0, x0, TCB_SIZE
    0x08 nop

2015-09-09  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (aarch64_tls_transition_without_check): Support
  three TLS local dynamic traditional relocations types.
  (elfNN_aarch64_tls_relax): Support TLS local dynamic traditional to
  local executable relaxation.

ld/testsuite/
  * ld-aarch64/tls-relax-ld-le-tiny.s: New testcase.
  * ld-aarch64/tls-relax-ld-le-small.s: Likewise.
  * ld-aarch64/tls-relax-ld-le-tiny.d: New expectation file.
  * ld-aarch64/tls-relax-ld-le-small.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new testcases.
2015-09-09 14:19:28 +01:00
GDB Administrator a79762eef0 Automatic date update in version.in 2015-09-09 00:00:08 +00:00
GDB Administrator 4e0753f6a5 Automatic date update in version.in 2015-09-08 00:00:08 +00:00
GDB Administrator b31103ae77 Automatic date update in version.in 2015-09-07 00:00:07 +00:00
GDB Administrator 7d8316e58e Automatic date update in version.in 2015-09-06 00:00:08 +00:00
GDB Administrator 53db1aba3c Automatic date update in version.in 2015-09-05 00:00:08 +00:00
GDB Administrator 096abbeb31 Automatic date update in version.in 2015-09-04 00:00:09 +00:00
H.J. Lu 77697d411e Remove convert_mov_to_lea
* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Remove
	convert_mov_to_lea.
2015-09-03 04:17:05 -07:00
GDB Administrator 8cbebaac8f Automatic date update in version.in 2015-09-03 00:00:11 +00:00
H.J. Lu c74be520ba Rename R_386_irelative to R_386_ext2
* elf32-i386.c (R_386_irelative): Renamed to ...
	(R_386_ext2): This.
	(R_386_vt_offset): Updated.
	(elf_i386_rtype_to_howto): Likewise.
	(elf_i386_relocate_section): Likewise.
2015-09-02 05:13:08 -07:00
GDB Administrator 700190e776 Automatic date update in version.in 2015-09-02 00:00:08 +00:00
H.J. Lu 04ebc307f9 Skip PLT for function pointer initialization
We use its PLT entry to initialize function pointer at run-time.  If
there is no other usage for the PLT entry, we can generate run-time
function pointer relocations in read-write section, which can be
resolved by dynamic linker, to initialize function pointers.  It avoids
the extra indirect branch overhead in PLT.

bfd/

	PR ld/18900
	* elf32-i386.c (elf_i386_link_hash_entry): Add
	func_pointer_refcount.
	(elf_i386_link_hash_newfunc): Clear func_pointer_refcount.
	(elf_i386_get_local_sym_hash): Likewise.
	(elf_i386_copy_indirect_symbol): Also copy
	func_pointer_refcount.
	(elf_i386_check_relocs): Increment func_pointer_refcount.
	(elf_i386_gc_sweep_hook): Decrement func_pointer_refcount.
	(elf_i386_allocate_dynrelocs): Don't create the PLT entry if
	there are only function pointer relocations which can be
	resolved at run-time.  Keep dynanamic relocations for run-time
	function pointer initialization.
	(elf_i386_relocate_section): Copy dynamic function pointer
	relocations.
	* elf64-x86-64.c (elf_x86_64_link_hash_entry): Add
	func_pointer_refcount.
	(elf_x86_64_link_hash_newfunc): Clear func_pointer_refcount.
	(elf_x86_64_get_local_sym_hash): Likewise.
	(elf_x86_64_copy_indirect_symbol): Also copy
	func_pointer_refcount.
	(elf_x86_64_check_relocs): Increment func_pointer_refcount.
	(elf_x86_64_gc_sweep_hook): Decrement func_pointer_refcount.
	(elf_x86_64_allocate_dynrelocs): Don't create the PLT entry if
	there are only function pointer relocations which can be
	resolved at run-time.  Keep dynanamic relocations for run-time
	function pointer initialization.
	(elf_x86_64_relocate_section): Copy dynamic function pointer
	relocations.

ld/testsuite/

	PR ld/18900
	* ld-i386/i386.exp: Run tests for PR ld/18900.
	* ld-x86-64/x86-64.exp: Likewise.
	* ld-i386/pr18900.out: New file.
	* ld-i386/pr18900a.c: Likewise.
	* ld-i386/pr18900a.c: Likewise.
	* ld-i386/pr18900a.rd: Likewise.
	* ld-i386/pr18900b.c: Likewise.
	* ld-i386/pr18900b.rd: Likewise.
	* ld-i386/pr18900c.c: Likewise.
	* ld-x86-64/pr18900.out: Likewise.
	* ld-x86-64/pr18900a.c: Likewise.
	* ld-x86-64/pr18900a.rd: Likewise.
	* ld-x86-64/pr18900b.c: Likewise.
	* ld-x86-64/pr18900b.rd: Likewise.
	* ld-x86-64/pr18900c.c: Likewise.
	* ld-x86-64/mpx3.dd: Updated.
2015-09-01 05:06:33 -07:00
Alan Modra b07bca4ecd Wrong function reported for linker error message
OPD lookup goes awry when .opd has been shuffled to remove unused
functions.

	* elf64-ppc.c (ppc64_elf_maybe_function_sym): Adjust symbol value
	if .opd section has been edited.
2015-09-01 17:44:33 +09:30
Alan Modra a4b6fadd50 ppc64 out-of-line register save/restore functions
Don't emit long branch or plt branch stubs to save/restore functions.
Copy them instead.  The problem is that plt branch stubs currently
trash r12, one of the parameters to some of the save/restore
functions, and there is no free register available to use instead of
r12.

6f20ed8a is prerequisite for this patch.

	PR 18878
	* elf64-ppc.c (ARRAY_SIZE): Define.  Use throughout.
	(enum ppc_stub_type): Add ppc_stub_save_res.
	(struct map_stub): Add "next" and "needs_save_res".
	(struct ppc_link_hash_entry): Add "save_res" flag.
	(struct ppc_link_hash_table): Add "group".
	(sfpr_define): Add stub_sec param.  Define symbol in stub_sec if
	stub_sec is non-null.  Set "save_res".
	(save_res_funcs): Make file scope, rename from funcs.  Adjust uses.
	(ppc64_elf_adjust_dynamic_symbol): Prohibit plt call to save_res syms.
	(ppc_build_one_stub): Handle ppc_stub_save_res.
	(ppc_size_one_stub): Set stub type to ppc_size_one_stub on finding
	stub for linker defined save_res sym.
	(group_sections): Init new fields of struct map_stub.
	(ppc64_elf_size_stubs): Reserve space for save/restore func copy.
	(ppc64_elf_build_stubs): Copy save/restore funcs to groups.  Emit
	alias syms too.
	(ppc64_elf_relocate_section): Set destination for ppc_stub_save_res.
2015-09-01 17:42:32 +09:30
GDB Administrator 76b20b99f7 Automatic date update in version.in 2015-09-01 00:00:08 +00:00
Alan Modra a7c4979727 Optimise PowerPC64 r2 adjusting stubs
Sometimes these stubs don't need to change the low 16-bits of r2, so in
that case omit a useless addi r2,r2,0 insn.  Also, change the get_r2off
error return from 0 to -1 since 0 is a valid return for ELFv2 -R objects.

	* elf64-ppc.c (get_r2off): Return -1 on error.
	(ppc_build_one_stub): Adjust for get_r2off change.  Don't emit
	addi r2,r2,0 on r2off stubs when the low 16-bit delta is zero.
	(ppc_size_one_stub): Corresponding size changes for r2off stubs.
	Add condition in test for -R objects.
2015-08-31 22:54:23 +09:30
Alan Modra 6f20ed8a6b ppc64 section group handling
Two organizational changes to the array of additional info kept for
sections.
1) Move group info into a per-group allocated struct, in preparation
for future changes that need per-group accounting.
2) Expand the array to include output sections, which simplifies
sizing and removes the need for a separate output section array.

	* section.c (section_id): Make file scope.
	(bfd_get_next_section_id): New function.
	* elf64-ppc.c (struct map_stub): Remove toc_off field.  Move decl.
	(struct ppc_stub_hash_entry): Delete stub_sec and id_sec.  Add
	group.  Update all uses.
	(struct ppc_link_hash_table): Delete top_id, top_index, and
	input_list.  Add sec_info_arr_size.  Rename stub_group to
	sec_info, and make group info indirect.  Update stub_group refs
	throughout file.
	(ppc_add_stub): Don't look for stub_sec on link_sec stub_group
	entry.
	(ppc_build_one_stub): Delete FIXME.
	(ppc64_elf_setup_section_lists): Size htab->sec_info for all
	sections, not just input sections.  Don't create htab->input_list.
	(ppc64_elf_next_input_section): Update to use sec_info union as
	list pointer.
	(PREV_SEC): Delete.
	(group_sections): Pass "info" param rather than "htab".  Iterate
	over output sections rather than input_list.  Use sec_info union
	as list pointers.  Alloc atruct map_stub, and return fail status.
	* bfd-in2.h: Regenerate.
2015-08-31 22:54:06 +09:30
Alan Modra d3435ae8dd More "Make asection->id and asection->index unsigned"
Fixes regressions introduced by 7292b3ac.

	* elflink.c (elf_sort_symbol): Use correctly sized type for
	calculating signed section->id difference.
	(elf_link_add_object_symbols): Likewise.
	* pef.c (bfd_pef_scan_start_address): Warning fix.
	* vms-alpha.c (vms_new_section_hook): Likewise.
2015-08-31 16:26:10 +09:30
Alan Modra 6cae483a9d NDS32 build fixes
* elf32-nds32.c (nds32_convert_32_to_16_alu1): Warning fix.
	(find_relocs_at_address_addr): Make "reloc_type" an enum.
	(nds32_elf_relax_delete_blanks): Warning fix.
	(nds32_elf_relax_loadstore): Correct loop bound.
2015-08-31 13:01:59 +09:30
Alan Modra 7292b3ac74 Make asection->id and asection->index unsigned
These int vars are really unsigned, so make them so.

	* section.c (struct bfd_section): Make "id" and "index" unsigned.
	* coff-rs6000.c (_bfd_xcoff_sizeof_headers): Adjust local var to suit.
	* elf.c (elf_map_symbols): Likewise.
	* elf64-ppc.c (sym_exists_at): Make "id" param unsigned.
	(struct ppc_link_hash_table): Make "top_id" and "top_index" unsigned.
	(ppc64_elf_setup_section_lists): Ditto for local vars.
	* elf32-arm.c: Similarly to elf64-ppc.c.
	* elf32-avr.c: Likewise.
	* elf32-hppa.c: Likewise.
	* elf32-m68hc1x.c: Likewise.
	* elf32-metag.c: Likewise.
	* elf32-nios2.c: Likewise.
	* elfnn-aarch64.c: Likewise.
	* simple.c (struct saved_offsets): Make "section_count" unsigned.
	* bfd-in2.h: Regenerate.
2015-08-31 12:37:36 +09:30
GDB Administrator 56e3225bfb Automatic date update in version.in 2015-08-31 00:00:08 +00:00
GDB Administrator c6ef89f56b Automatic date update in version.in 2015-08-30 00:00:08 +00:00
GDB Administrator 4df0419386 Automatic date update in version.in 2015-08-29 00:00:08 +00:00
GDB Administrator 9cb64d222c Automatic date update in version.in 2015-08-28 00:00:08 +00:00
Alan Modra a40d44c44e Add missing pr reference 2015-08-27 11:00:01 +09:30
Alan Modra 6fc5bb5718 Don't sort ld -r output relocs on alpha
LITERAL/LITUSE relocs must be kept together.

	* elf64-alpha.c (elf64_alpha_sort_relocs_p): New function.
	(elf_backend_sort_relocs_p): Define.
2015-08-27 10:56:51 +09:30
GDB Administrator 60f02a58bf Automatic date update in version.in 2015-08-27 00:00:08 +00:00
Alan Modra 0e28778672 Use stable sort for ld -r relocs
A number of targets emit multiple relocs at a given r_offset, and
depend on those relocs staying in their original order.

	PR 18867
	* elflink.c (cmp_ext32l_r_offset, cmp_ext32b_r_offset): Delete.
	(cmp_ext64l_r_offset, cmp_ext64b_r_offset): Delete.
	(ext32l_r_offset, ext32b_r_offset, ext64l_r_offset, ext64b_r_offset):
	New functions.
	(elf_link_adjust_relocs): Use an insertion sort to sort relocs.
2015-08-26 23:34:10 +09:30
Matthew Fortune c97c330ba8 Select MIPS ABi based upon abiflags rather than e_flags.
bfd	PR ld/18401
	* elfxx-mips.c (bfd_mips_isa_ext_mach): New function: Converts an
	ISA value to a bfd machine number.
	(bfd_mips_isa_ext): Update the ISA level and revision if
	necessary.  Use mips_mach_extends_p to decide if the ISA extension
	needs to be set.
	(_bfd_mips_elf_merge_private_bfd_data): Allow the ISA extension to
	be inferred from the ABI setting.  Set the ISA level from the
	maximum of the incoming and outgoing ISA levels.

tests
	* ld-mips-elf/mips-elf-flags.exp: Add more ISA conflict tests.
2015-08-26 14:42:56 +01:00
GDB Administrator dc72bf948a Automatic date update in version.in 2015-08-26 00:00:07 +00:00
Nick Clifton 16ad13eca4 Replace assertions with warning messages about ELF binaries containing multiple symbol tables.
PR binutils/18854
	* elf.c (bfd_section_from_shdr): Replace assertions with warnings
	about multiple symbol tables.
2015-08-25 17:48:20 +01:00
Renlin Li 7c2bea1ad1 [AArch64] Fix a typo in the comment for BFD_RELOC_AARCH64_LD64_GOT_LO12_NC
2015-08-25  Renlin Li  <renlin.li@arm.com>

bfd/
  * reloc.c (BFD_RELOC_AARCH64_LD64_GOTOFF_LO15): Use LP64 instead of
  ILP64.
  * bfd-in2.h: Regenerate.
2015-08-25 12:37:21 +01:00
GDB Administrator 9a11754213 Automatic date update in version.in 2015-08-25 00:00:08 +00:00
GDB Administrator b83035f1f6 Automatic date update in version.in 2015-08-24 00:00:07 +00:00
GDB Administrator d579c450dd Automatic date update in version.in 2015-08-23 00:00:07 +00:00
Alan Modra 595bce7595 Uninitialized vd_nodename
Belt and braces fix.  Either of the changes here is sufficient to
ensure vd_nodename is initialized properly.

	* elf.c (_bfd_elf_slurp_version_tables): Always init vd_nodename.
	Don't copy fields not set by _bfd_elf_swap_verdef_in.
2015-08-22 16:24:52 +09:30
GDB Administrator 0d6b12851b Automatic date update in version.in 2015-08-22 00:00:09 +00:00
GDB Administrator 8e804db96b Automatic date update in version.in 2015-08-21 00:00:07 +00:00
GDB Administrator 9d1f512094 Automatic date update in version.in 2015-08-20 00:00:10 +00:00
Jiong Wang 07c9aa07cd [AArch64][6/6] LD support TLSLD load/store relocation types
2015-08-19  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize new relocation
  types, including BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC.
  (elfNN_aarch64_final_link_relocate): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/emit-relocs-531.s: New testcase.
  * ld-aarch64/emit-relocs-531-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-532.s: Likewise.
  * ld-aarch64/emit-relocs-533.s: Likewise.
  * ld-aarch64/emit-relocs-533-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-534.s: Likewise.
  * ld-aarch64/emit-relocs-535.s: Likewise.
  * ld-aarch64/emit-relocs-535-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-536.s: Likewise.
  * ld-aarch64/emit-relocs-537.s: Likewise.
  * ld-aarch64/emit-relocs-537-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-538.s: Likewise.
  * ld-aarch64/emit-relocs-531.d: New expectation file.
  * ld-aarch64/emit-relocs-531-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-532.d: Likewise.
  * ld-aarch64/emit-relocs-533.d: Likewise.
  * ld-aarch64/emit-relocs-533-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-534.d: Likewise.
  * ld-aarch64/emit-relocs-535.d: Likewise.
  * ld-aarch64/emit-relocs-535-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-536.d: Likewise.
  * ld-aarch64/emit-relocs-537.d: Likewise.
  * ld-aarch64/emit-relocs-537-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-538.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new testcases.
2015-08-19 16:57:38 +01:00
Jiong Wang 4c5625238c [AArch64][5/6] GAS support TLSLD load/store relocation types
2015-08-19  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * reloc.c: New entries, including
  BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC.
  BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC.
  * elfnn-aarch64.c (elfNN_aarch64_howto_table): Likewise.
  * bfd-in2.h: Regenerate.
  * libbfd.h: Regenerate.

gas/
  * config/tc-aarch64.c (reloc_table): New relocation types support for
  dtprel_lo12.
  (ldst_lo12_determine_real_reloc_type): Support
  BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC,
  BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12,
  BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC.
  (parse_operands): Likewise.
  (md_apply_fix): Likewise
  (aarch64_force_relocation): Likewise.
  (process_movw_reloc_info): Likewise.

gas/testsuite/
  * gas/aarch64/reloc-dtprel_lo12-ldst8.s: New testcase.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldstc.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-ldst16.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst16.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-ldst32.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst32.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-ldst64.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst64.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-ldst8.d: New expectation file.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst8.d: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-ldst16.d: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst16.d: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-ldst32.d: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst32.d: Likewise.
  * gas/aarch64/reloc-dtprel-lo12-ldst64.d: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc-ldst64.d: Likewise.
2015-08-19 16:54:39 +01:00
Jiong Wang 6ffe9a1ba3 [AArch64][4/6] LD support TLSLD move/add relocation types
2015-08-19  Jiong Wang  <jiong.wang@arm.com>

bfd/
  PR ld/18276
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize new relocation
  types, including BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2.
  (elfNN_aarch64_final_link_relocate): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/emit-relocs-87.s: New testcase.
  * ld-aarch64/emit-relocs-88.s: Likewise.
  * ld-aarch64/emit-relocs-88-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-89.s: Likewise.
  * ld-aarch64/emit-relocs-90.s: Likewise.
  * ld-aarch64/emit-relocs-90-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-523.s: Likewise.
  * ld-aarch64/emit-relocs-524.s: Likewise.
  * ld-aarch64/emit-relocs-525.s: Likewise.
  * ld-aarch64/emit-relocs-527.s: Likewise.
  * ld-aarch64/emit-relocs-526.s: Likewise.
  * ld-aarch64/emit-relocs-528.s: Likewise.
  * ld-aarch64/emit-relocs-528-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-87.d: New expectation file.
  * ld-aarch64/emit-relocs-88.d: Likewise.
  * ld-aarch64/emit-relocs-88-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-89.d: Likewise.
  * ld-aarch64/emit-relocs-90.d: Likewise.
  * ld-aarch64/emit-relocs-90-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-91.d: Likewise.
  * ld-aarch64/emit-relocs-523.d: Likewise.
  * ld-aarch64/emit-relocs-524.d: Likewise.
  * ld-aarch64/emit-relocs-525.d: Likewise.
  * ld-aarch64/emit-relocs-526.d: Likewise.
  * ld-aarch64/emit-relocs-527.d: Likewise.
  * ld-aarch64/emit-relocs-528.d: Likewise.
  * ld-aarch64/emit-relocs-528-overflow.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new testcases.
2015-08-19 16:40:18 +01:00
Jiong Wang 49df5539f9 [AArch64][3/6] GAS support TLSLD move/add relocation types
2015-08-19  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * reloc.c (BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC,
  BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2): New entries.
  * elfnn-aarch64.c (elfNN_aarch64_howto_table): Likewise.
  * bfd-in2.h: Regenerate.
  * libbfd.h: Regenerate.

gas/
  * config/tc-aarch64.c (reloc_table): New relocation modifiers,
  "dtprel_hi12", "dtprel_g0", "dtprel_g0_nc", "dtprel_g1",
  "dtprel_g1_nc", "dtprel_g2".
  (md_apply_fix): Support new relocation types.
  (aarch64_force_relocation): Likewise.
  (process_movw_reloc_info): Likewise.

gas/testsuite/
  * gas/aarch64/reloc-dtprel_g0.s: New testcase.
  * gas/aarch64/reloc-dtprel_g0-ilp32.s: Likewise.
  * gas/aarch64/reloc-dtprel_g0_nc.s: Likewise.
  * gas/aarch64/reloc-dtprel_g0_nc-ilp32.s: Likewise.
  * gas/aarch64/reloc-dtprel_g1.s: Likewise.
  * gas/aarch64/reloc-dtprel_g1-ilp32.s: Likewise.
  * gas/aarch64/reloc-dtprel_g1_nc.s: Likewise.
  * gas/aarch64/reloc-dtprel_g2.s: Likewise.
  * gas/aarch64/reloc-dtprel_hi12.s: Likewise.
  * gas/aarch64/reloc-dtprel_hi12-ilp32.s: Likewise.
  * gas/aarch64/reloc-dtprel_g0.d: New expectation file.
  * gas/aarch64/reloc-dtprel_g0-ilp32.d: Likewise.
  * gas/aarch64/reloc-dtprel_g0_nc.d: Likewise.
  * gas/aarch64/reloc-dtprel_g0_nc-ilp32.d: Likewise.
  * gas/aarch64/reloc-dtprel_g1.d: Likewise.
  * gas/aarch64/reloc-dtprel_g1-ilp32.d: Likewise.
  * gas/aarch64/reloc-dtprel_g1_nc.d: Likewise.
  * gas/aarch64/reloc-dtprel_g2.d: Likewise.
  * gas/aarch64/reloc-dtprel_hi12.d: Likewise.
  * gas/aarch64/reloc-dtprel_hi12-ilp32.d: Likewise.
2015-08-19 16:36:22 +01:00
Jiong Wang 753999c1ec [AArch64][2/6] LD support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC
2015-08-19  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize
  BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC.
  (aarch64_reloc_got_type): Likewise.
  (elfNN_aarch64_final_link_relocate): Likewise.
  (elfNN_aarch64_relocate_section): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/emit-relocs-530.s: New testcase.
  * ld-aarch64/emit-relocs-92.s: Likewise.
  * ld-aarch64/emit-relocs-530.d: New expectation file.
  * ld-aarch64/emit-relocs-92.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new testcases.
2015-08-19 16:30:47 +01:00
Jiong Wang 13289c10e2 [AArch64][1/6] GAS support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC
2015-08-19  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * reloc.c (BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC): New entry.
  * bfd-in2.h: Regenerate.
  * libbfd.h: Regenerate.
  * elfnn-aarch64.c (elfNN_aarch64_howto_table): New entry for
  BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC.

gas/
  * config/tc-aarch64.c (reloc_table): New relocation modifiers.
  (md_apply_fix): Support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC.
  (aarch64_force_relocation): Likewise.

gas/testsuite/
  * gas/aarch64/reloc-dtprel_lo12_nc.s: New testcase.
  * gas/aarch64/reloc-dtprel_lo12_nc-ilp32.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12_nc.d: New expectation file.
  * gas/aarch64/reloc-dtprel_lo12_nc-ilp32.d: Likewise.
2015-08-19 16:28:08 +01:00
Alan Modra 3cbc1e5e68 Add bfd_link_pde, and simplify some tests of link_info.type
include/
	* bfdlink.h (bfd_link_pde): Define.
bfd/
	* elf-s390-common.c: Simplify expressions using
	bfd_linke_executable, bfd_link_pie and bfd_link_pic.
	* elf32-arm.c: Likewise.
	* elf32-bfin.c: Likewise.
	* elf32-frv.c: Likewise.
	* elf32-m68k.c: Likewise.
	* elf32-nios2.c: Likewise.
	* elf32-ppc.c: Likewise.
	* elf32-s390.c: Likewise.
	* elf32-sh.c: Likewise.
	* elf64-alpha.c: Likewise.
	* elf64-ppc.c: Likewise.
	* elf64-s390.c: Likewise.
	* elflink.c: Likewise.
2015-08-19 12:51:06 +09:30
GDB Administrator e49433d22d Automatic date update in version.in 2015-08-19 00:00:08 +00:00
H.J. Lu cae1fbbb7e Return reloc_class_ifunc for reloc against IFUNC
elf_XXX_reloc_type_class should return reloc_class_ifunc for relocation
against STT_GNU_IFUNC symbol.

bfd/

	PR ld/18841
	* elf-bfd.h (elf_link_hash_table): Add dynsym.
	* elf32-i386.c (elf_i386_reloc_type_class): Return
	reloc_class_ifunc for relocation against STT_GNU_IFUNC symbol.
	* elf64-x86-64.c (elf_x86_64_reloc_type_class): Likewise.
	* elflink.c (_bfd_elf_link_create_dynamic_sections): Set dynsym.
	(bfd_elf_size_dynsym_hash_dynstr): Use dynsym.
	(elf_final_link_info): Remove dynsym_sec.
	(elf_link_output_extsym): Replace dynsym_sec with dynsym.
	(bfd_elf_final_link): Remove reference to dynsym_sec.  Replace
	dynsym_sec with dynsym.

ld/testsuite/

	PR ld/18841
	* ld-ifunc/ifunc.exp: Add a test for PR ld/18841.
	* ld-ifunc/pr18841.out: New file.
	* ld-ifunc/pr18841a.c: Likewise.
	* ld-ifunc/pr18841b.c: Likewise.
2015-08-18 09:50:08 -07:00
Jiong Wang 44b4145b72 [AArch64] Cleanup TLS relocation types which don't go through GOT table
This patch done two types of cleanup:

  * in aarch64_reloc_got_type and elfNN_aarch64_relocate_section

    We don't need those redundant "case" check, as they can be merged
    with the "default" which just "break".

  * in elfNN_aarch64_gc_sweep_hook and elfNN_aarch64_check_relocs

    All TLS local executable relocations and some local dynamic
    relocations (those calculate module offset) actually don't need GOT
    entry, so remove them from GOT entry counting.

2015-08-18  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (aarch64_reloc_got_type): Delete useless check.
  (elfNN_aarch64_relocate_section): Likewise.
  (elfNN_aarch64_gc_sweep_hook): Likewise.
  (elfNN_aarch64_check_relocs): Likewise.
2015-08-18 16:50:56 +01:00
H.J. Lu 0e1862bb40 Add output_type to bfd_link_info
The "shared" field in bfd_link_info is set for both DSO and and PIE.
There are separate fields for executable and relocatable outputs.  This
patch adds an "output_type" field:

enum output_type
{
  type_unknown = 0,
  type_executable,
  type_dll,
  type_relocatable
};

and a "pic" field to bfd_link_info to replace shared, executable and
relocatable fields so that we can use the "output_type" field to check
for output type and the "pic" field check if output is PIC.  Macros,
bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic
and bfd_link_pie, are provided to check for output features.

bfd/

	* bfd/aoutx.h: Replace shared, executable, relocatable and pie
	fields with bfd_link_executable, bfd_link_dll,
	bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
	* bfd/bout.c: Likewise.
	* bfd/coff-alpha.c: Likewise.
	* bfd/coff-arm.c: Likewise.
	* bfd/coff-i386.c: Likewise.
	* bfd/coff-i960.c: Likewise.
	* bfd/coff-m68k.c: Likewise.
	* bfd/coff-mcore.c: Likewise.
	* bfd/coff-mips.c: Likewise.
	* bfd/coff-ppc.c: Likewise.
	* bfd/coff-rs6000.c: Likewise.
	* bfd/coff-sh.c: Likewise.
	* bfd/coff-tic80.c: Likewise.
	* bfd/coff-x86_64.c: Likewise.
	* bfd/coff64-rs6000.c: Likewise.
	* bfd/coffgen.c: Likewise.
	* bfd/cofflink.c: Likewise.
	* bfd/ecoff.c: Likewise.
	* bfd/ecofflink.c: Likewise.
	* bfd/elf-bfd.h: Likewise.
	* bfd/elf-eh-frame.c: Likewise.
	* bfd/elf-ifunc.c: Likewise.
	* bfd/elf-m10200.c: Likewise.
	* bfd/elf-m10300.c: Likewise.
	* bfd/elf-s390-common.c: Likewise.
	* bfd/elf-vxworks.c: Likewise.
	* bfd/elf.c: Likewise.
	* bfd/elf32-arm.c: Likewise.
	* bfd/elf32-avr.c: Likewise.
	* bfd/elf32-bfin.c: Likewise.
	* bfd/elf32-cr16.c: Likewise.
	* bfd/elf32-cr16c.c: Likewise.
	* bfd/elf32-cris.c: Likewise.
	* bfd/elf32-crx.c: Likewise.
	* bfd/elf32-d10v.c: Likewise.
	* bfd/elf32-dlx.c: Likewise.
	* bfd/elf32-epiphany.c: Likewise.
	* bfd/elf32-fr30.c: Likewise.
	* bfd/elf32-frv.c: Likewise.
	* bfd/elf32-ft32.c: Likewise.
	* bfd/elf32-h8300.c: Likewise.
	* bfd/elf32-hppa.c: Likewise.
	* bfd/elf32-i370.c: Likewise.
	* bfd/elf32-i386.c: Likewise.
	* bfd/elf32-i860.c: Likewise.
	* bfd/elf32-ip2k.c: Likewise.
	* bfd/elf32-iq2000.c: Likewise.
	* bfd/elf32-lm32.c: Likewise.
	* bfd/elf32-m32c.c: Likewise.
	* bfd/elf32-m32r.c: Likewise.
	* bfd/elf32-m68hc11.c: Likewise.
	* bfd/elf32-m68hc1x.c: Likewise.
	* bfd/elf32-m68k.c: Likewise.
	* bfd/elf32-mcore.c: Likewise.
	* bfd/elf32-mep.c: Likewise.
	* bfd/elf32-metag.c: Likewise.
	* bfd/elf32-microblaze.c: Likewise.
	* bfd/elf32-moxie.c: Likewise.
	* bfd/elf32-msp430.c: Likewise.
	* bfd/elf32-mt.c: Likewise.
	* bfd/elf32-nds32.c: Likewise.
	* bfd/elf32-nios2.c: Likewise.
	* bfd/elf32-or1k.c: Likewise.
	* bfd/elf32-ppc.c: Likewise.
	* bfd/elf32-rl78.c: Likewise.
	* bfd/elf32-rx.c: Likewise.
	* bfd/elf32-s390.c: Likewise.
	* bfd/elf32-score.c: Likewise.
	* bfd/elf32-score7.c: Likewise.
	* bfd/elf32-sh-symbian.c: Likewise.
	* bfd/elf32-sh.c: Likewise.
	* bfd/elf32-sh64.c: Likewise.
	* bfd/elf32-spu.c: Likewise.
	* bfd/elf32-tic6x.c: Likewise.
	* bfd/elf32-tilepro.c: Likewise.
	* bfd/elf32-v850.c: Likewise.
	* bfd/elf32-vax.c: Likewise.
	* bfd/elf32-visium.c: Likewise.
	* bfd/elf32-xc16x.c: Likewise.
	* bfd/elf32-xstormy16.c: Likewise.
	* bfd/elf32-xtensa.c: Likewise.
	* bfd/elf64-alpha.c: Likewise.
	* bfd/elf64-hppa.c: Likewise.
	* bfd/elf64-ia64-vms.c: Likewise.
	* bfd/elf64-mmix.c: Likewise.
	* bfd/elf64-ppc.c: Likewise.
	* bfd/elf64-s390.c: Likewise.
	* bfd/elf64-sh64.c: Likewise.
	* bfd/elf64-x86-64.c: Likewise.
	* bfd/elflink.c: Likewise.
	* bfd/elfnn-aarch64.c: Likewise.
	* bfd/elfnn-ia64.c: Likewise.
	* bfd/elfxx-mips.c: Likewise.
	* bfd/elfxx-sparc.c: Likewise.
	* bfd/elfxx-tilegx.c: Likewise.
	* bfd/i386linux.c: Likewise.
	* bfd/linker.c: Likewise.
	* bfd/m68klinux.c: Likewise.
	* bfd/pdp11.c: Likewise.
	* bfd/pe-mips.c: Likewise.
	* bfd/peXXigen.c: Likewise.
	* bfd/reloc.c: Likewise.
	* bfd/reloc16.c: Likewise.
	* bfd/sparclinux.c: Likewise.
	* bfd/sunos.c: Likewise.
	* bfd/vms-alpha.c: Likewise.
	* bfd/xcofflink.c: Likewise.

include/

	* include/bfdlink.h (output_type): New enum.
	(bfd_link_executable): New macro.
	(bfd_link_dll): Likewise.
	(bfd_link_relocatable): Likewise.
	(bfd_link_pic): Likewise.
	(bfd_link_pie): Likewise.
	(bfd_link_info): Remove shared, executable, pie and relocatable.
	Add output_type and pic.

ld/

	* ld/ldctor.c: Replace shared, executable, relocatable and pie
	fields with bfd_link_executable, bfd_link_dll,
	bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
	* ld/ldemul.c: Likewise.
	* ld/ldfile.c: Likewise.
	* ld/ldlang.c: Likewise.
	* ld/ldmain.c: Likewise.
	* ld/ldwrite.c: Likewise.
	* ld/lexsup.c: Likewise.
	* ld/pe-dll.c: Likewise.
	* ld/plugin.c: Likewise.
	* ld/emultempl/aarch64elf.em: Likewise.
	* ld/emultempl/aix.em: Likewise.
	* ld/emultempl/alphaelf.em: Likewise.
	* ld/emultempl/armcoff.em: Likewise.
	* ld/emultempl/armelf.em: Likewise.
	* ld/emultempl/avrelf.em: Likewise.
	* ld/emultempl/beos.em: Likewise.
	* ld/emultempl/cr16elf.em: Likewise.
	* ld/emultempl/elf-generic.em: Likewise.
	* ld/emultempl/elf32.em: Likewise.
	* ld/emultempl/genelf.em: Likewise.
	* ld/emultempl/generic.em: Likewise.
	* ld/emultempl/gld960.em: Likewise.
	* ld/emultempl/gld960c.em: Likewise.
	* ld/emultempl/hppaelf.em: Likewise.
	* ld/emultempl/irix.em: Likewise.
	* ld/emultempl/linux.em: Likewise.
	* ld/emultempl/lnk960.em: Likewise.
	* ld/emultempl/m68hc1xelf.em: Likewise.
	* ld/emultempl/m68kcoff.em: Likewise.
	* ld/emultempl/m68kelf.em: Likewise.
	* ld/emultempl/metagelf.em: Likewise.
	* ld/emultempl/mipself.em: Likewise.
	* ld/emultempl/mmo.em: Likewise.
	* ld/emultempl/msp430.em: Likewise.
	* ld/emultempl/nds32elf.em: Likewise.
	* ld/emultempl/needrelax.em: Likewise.
	* ld/emultempl/nios2elf.em: Likewise.
	* ld/emultempl/pe.em: Likewise.
	* ld/emultempl/pep.em: Likewise.
	* ld/emultempl/ppc32elf.em: Likewise.
	* ld/emultempl/ppc64elf.em: Likewise.
	* ld/emultempl/sh64elf.em: Likewise.
	* ld/emultempl/solaris2.em: Likewise.
	* ld/emultempl/spuelf.em: Likewise.
	* ld/emultempl/sunos.em: Likewise.
	* ld/emultempl/tic6xdsbt.em: Likewise.
	* ld/emultempl/ticoff.em: Likewise.
	* ld/emultempl/v850elf.em: Likewise.
	* ld/emultempl/vms.em: Likewise.
	* ld/emultempl/vxworks.em: Likewise.
2015-08-18 05:51:19 -07:00
Alan Modra fe875424a0 Use $SED in bfd Makefile
PR 18667
	* Makefile.am: Use $(SED) in place of sed throughout.
	* Makefile.in: Regenerate.
2015-08-18 16:44:48 +09:30
Alan Modra 43417696fe PPC64: Allow .TOC. in linker script to override backend calculated value
bfd/
	* elf64-ppc.c (ppc64_elf_func_desc_adjust): Don't redefine .TOC.
	if already defined, and set linker_def.
	(ppc64_elf_set_toc): Use .TOC. value if defined other than by
	the backend.
ld/
	* ldexp.c (exp_fold_tree_1): Clear linker_def on symbol assignment.
2015-08-18 16:43:18 +09:30
GDB Administrator f6721e4955 Automatic date update in version.in 2015-08-18 00:00:08 +00:00
GDB Administrator 26a4b92c91 Automatic date update in version.in 2015-08-17 00:00:08 +00:00
GDB Administrator a40f728f5c Automatic date update in version.in 2015-08-16 00:00:08 +00:00
GDB Administrator a057aa3c45 Automatic date update in version.in 2015-08-15 00:00:07 +00:00
Alan Modra 9b57267f4f Revert "Fix encoding or OpenRisk1000 PC relative relocations."
This reverts commit dbac553d28.

	PR ld/18759
	* elf32-or1k.c: Revert 2015-08-11 change.
2015-08-14 11:02:59 +09:30
GDB Administrator 92019596ba Automatic date update in version.in 2015-08-14 00:00:08 +00:00
H.J. Lu 8efa2874ab Issue an error for read-only segment with dynamic IFUNC relocations
To load an ELF binary with DT_TEXTREL tag, the dynamic linker calls
__mprotect on the read-only segment with PROT_READ|PROT_WRITE before
applying dynamic relocation.  It leads to segfault when performing
IFUNC relocations since the read-only segment has no execute permission.
This patch changes x86 linker to issue an error for read-only segment
with dynamic IFUNC relocations.  Other backends with IFUNC support
may need a similar change.

bfd/

	PR ld/18801
	* elf32-i386.c (elf_i386_size_dynamic_sections): Issue an error
	for read-only segment with dynamic IFUNC relocations.
	* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise.

ld/testsuite/

	PR ld/18801
	* ld-i386/i386.exp: Run pr18801.
	* ld-x86-64/x86-64.exp: Likewise.
	* ld-i386/pr18801.d: New file.
	* ld-i386/pr18801.s: Likewise.
	* ld-x86-64/pr18801.d: Likewise.
	* ld-x86-64/pr18801.s: Likewise.
2015-08-13 04:31:38 -07:00
GDB Administrator c74e78b36c Automatic date update in version.in 2015-08-13 00:00:08 +00:00
H.J. Lu 13a2df29c9 Set EI_OSABI to ELFOSABI_GNU for local IFUNC symbols
Since the backend elf_add_symbol_hook isn't called on local symbols,
the EI_OSABI field isn't to ELFOSABI_GNU where are local IFUNC symbols.
This patch changes the x86 backends to set has_gnu_symbols if there are
relocations against IFUNC symbols.  Other backends with IFUNC support
may need a similar change.

This patch also changes the type of has_gnu_symbols from bfd_boolean to
enum elf_gnu_symbols.

bfd/

	PR ld/18815
	* elf-bfd.h (elf_gnu_symbols): New enum.
	(elf_obj_tdata): Use elf_gnu_symbols on has_gnu_symbols.
	* elf-s390-common.c (elf_s390_add_symbol_hook): Set
	has_gnu_symbols to elf_gnu_symbol_any.
	* elf32-arm.c (elf32_arm_add_symbol_hook): Likewise.
	* elf32-m68k.c (elf_m68k_add_symbol_hook): Likewise.
	* elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
	* elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise.
	* elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise.
	* elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise.
	* lfxx-aarch64.c (_bfd_aarch64_elf_add_symbol_hook): Likewise.
	* elf32-i386.c (elf_i386_check_relocs): Update has_gnu_symbols
	if there are relocations against IFUNC symbols.
	(elf_i386_add_symbol_hook): Don't check STT_GNU_IFUNC here.
	* elf64-x86-64. (elf_x86_64_check_relocs): Update has_gnu_symbols
	if there are relocations against IFUNC symbols.
	(elf_x86_64_add_symbol_hook): Don't check STT_GNU_IFUNC here.

ld/testsuite/

	PR ld/18815
	* ld-i386/i386.exp: Run pr18815.
	* ld-x86-64/x86-64.exp: Likewise.
	* ld-i386/pr18815.d: New file.
	* ld-i386/pr18815.s: Likewise.
	* ld-x86-64/pr18815.d: Likewise.
	* ld-x86-64/pr18815.s: Likewise.
2015-08-12 13:47:41 -07:00
Simon Dardis 40fc1451c6 [MIPS] Map 'move' to 'or'.
The MIPS assembly idiom 'move' now maps to the 'or' machine instruction. This
change affects microMIPS, MIPS32, MIPS64.

2015-08-12  Simon Dardis  <simon.dardis@imgtec.com>

opcodes/

	* micromips-opc.c (micromips_opcodes): Re-order table so that move
	based on 'or' is first.
	* mips-opc.c (mips_builtin_opcodes): Ditto.

bfd/

	* elfxx-mips.c (STUB_MOVE): Change to use 'or' only.
	(mips_o32_exec_plt0_entry, mips_n32_exec_plt0_entry,
	mips_n64_exec_plt0_entry, micromips_insn32_o32_exec_plt0_entry):
	Update to use 'or' instead of 'addu/daddu'.
	(_bfd_mips_elf_finish_dynamic_symbol): Update usage of STUB_MOVE.
	(move_insns_32): Reorder table.

gas/

	* config/tc-mips.c (move_register): Change to use 'or' only.
	(s_cpload, s_cpsetup, s_cprestore, s_cpreturn): Update to
	use or for move.

gas/testsuite/

	* gas/mips/elf-rel23.d: Update test.
	* gas/mips/elf-rel23.d: Ditto.
	* gas/mips/elf-rel23a.d: Ditto.
	* gas/mips/elf-rel23b.d: Ditto.
	* gas/mips/elf_e_flags1.d: Ditto.
	* gas/mips/elf_e_flags2.d: Ditto.
	* gas/mips/elf_e_flags3.d: Ditto.
	* gas/mips/elf_e_flags4.d: Ditto.
	* gas/mips/loc-swap-dis.d: Ditto.
	* gas/mips/micromips-insn32.d: Ditto.
	* gas/mips/micromips-noinsn32.d: Ditto.
	* gas/mips/micromips-trap.d: Ditto.
	* gas/mips/micromips.d: Ditto.
	* gas/mips/mips-abi32-pic.d: Ditto.
	* gas/mips/mips-abi32.d: Ditto.
	* gas/mips/mips-gp32-fp32-pic.d: Ditto.
	* gas/mips/mips-gp32-fp32.d: Ditto.
	* gas/mips/mips-gp32-fp64-pic.d: Ditto.
	* gas/mips/mips-gp32-fp64.d: Ditto.
	* gas/mips/mips-gp64-fp32-pic.d: Ditto.
	* gas/mips/mips-gp64-fp32.d: Ditto.
	* gas/mips/mips-gp64-fp64-pic.d: Ditto.
	* gas/mips/mips-gp64-fp64.d: Ditto.
	* gas/mips/mipsr6@loc-swap-dis.d: Ditto.
	* gas/mips/tls-o32.d: Ditto.
	* gas/mips/uld2-eb.d: Ditto.
	* gas/mips/uld2-el.d: Ditto.
	* gas/mips/ulw2-eb-ilocks.d: Ditto.
	* gas/mips/ulw2-eb.d: Ditto.
	* gas/mips/ulw2-el-ilocks.d: Ditto.
	* gas/mips/ulw2-el.d: Ditto.
	* gas/mips/move.d: New test.
	* gas/mips/move.s: Ditto.
	* gas/mips/micromips32-move.d: Ditto.
	* gas/mips/micromips32-move.s: Ditto.
	* gas/mips/mips.exp: Run the new tests.

gold/

	* mips.cc (plt0_entry_o32, plt0_entry_n32, plt0_entry_n64,
	lazy_stub_normal_1, lazy_stub_normal_1_n64,
	lazy_stub_normal_2, lazy_stub_normal_2_n64, lazy_stub_big,
	lazy_stub_big_n64, lazy_stub_micromips32_normal_1_n64,
	lazy_stub_micromips32_normal_2_n64, lazy_stub_micromips32_big,
	lazy_stub_micromips32_big_n64): Update to use 'or' for move instead
	of 'addu/daddu'.

ld/testsuite/

	* ld-mips-elf/compressed-plt-1-n32-mips16.od: Update test.
	* ld-mips-elf/compressed-plt-1-n32-umips.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-mips16-got.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-mips16-only.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-mips16-word.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-mips16.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-se.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-umips-got.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-umips-word.od: Ditto.
	* ld-mips-elf/compressed-plt-1-o32-umips.od: Ditto.
	* ld-mips-elf/jalx-2.dd: Ditto.
	* ld-mips-elf/mips16-pic-3.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-3a.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-3b.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-5b.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-6-n32.dd: Ditto.
	* ld-mips-elf/pic-and-nonpic-6-o32.dd: Ditto.
	* ld-mips-elf/stub-dynsym-1-10000.d: Ditto.
	* ld-mips-elf/stub-dynsym-1-2fe80.d: Ditto.
	* ld-mips-elf/stub-dynsym-1-7fff.d: Ditto.
	* ld-mips-elf/stub-dynsym-1-8000.d: Ditto.
	* ld-mips-elf/stub-dynsym-1-fff0.d: Ditto.
	* ld-mips-elf/tlsbin-o32.d: Ditto.
	* ld-mips-elf/tlsdyn-o32-1.d: Ditto.
	* ld-mips-elf/tlsdyn-o32-2.d: Ditto.
	* ld-mips-elf/tlsdyn-o32-3.d: Ditto.
	* ld-mips-elf/tlsdyn-o32.d: Ditto.
	* ld-mips-elf/tlslib-o32.d: Ditto.
2015-08-12 17:10:22 +01:00
H.J. Lu 1b7868733d Remove trailing spaces in bfd 2015-08-12 04:32:43 -07:00
H.J. Lu 0eace2105d Properly skip IFUNC relocations in debug sections
Use "continue" instead of "break" to skip IFUNC relocations in debug
sections.

	* elf32-i386.c (elf_i386_relocate_section): Properly skip IFUNC
	relocations in debug sections.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
2015-08-11 19:04:38 -07:00
GDB Administrator a12a06d74a Automatic date update in version.in 2015-08-12 00:00:07 +00:00
Jiong Wang c674f5cd3f [AArch64] Improve BFD overflow warning message for -fpic
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (elfNN_aarch64_relocate_section): Improve warning
  message for R_AARCH64_LD64_GOTPAGE_LO15/R_AARCH64_LD32_GOTPAGE_LO14.
2015-08-11 22:12:41 +01:00
Jiong Wang 9331eea1f8 [AArch64]Speed up linking speed by skipping unncessary TLS reloc type check
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
   * elfnn-aarch64.c (IS_AARCH64_TLS_RELAX_RELOC): New.
  (aarch64_can_relax_tls): Use the new IS_AARCH64_TLS_RELAX_RELOC.
2015-08-11 22:05:39 +01:00
Jiong Wang f678ded748 [AArch64] Long branch veneer support far symbol defined by --defsym
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * bfd/elfnn-aarch64.c (aarch64_type_of_stub): New parameter "sym_sec".
  Loose the check for symbol from ABS section.
  (elfNN_aarch64_size_stubs): Pass sym_sec.

ld/testsuite/
  * ld-aarch64/farcall-b-defsym.s: New test.
  * ld-aarch64/farcall-bl-defsym.s: Likewise.
  * ld-aarch64/farcall-b-defsym.d: New expectation.
  * ld-aarch64/farcall-bl-defsym.d: Likewise.
2015-08-11 21:55:52 +01:00
Jiong Wang 07f9ddfeba [AArch64] PR18668, repair long branch veneer for plt stub
2015-08-11  Jiong Wang  <jiong.wang@arm.com>
bfd/
   PR ld/18668
   * elfnn-aarch64.c (aarch64_type_of_stub): Update destination for
   calls go through plt stub.
   (elfNN_aarch64_final_link_relocate): Adjust code logic for CALL26,
   JUMP26 relocation to support inserting veneer for call to plt stub.

ld/testsuite/
   * ld-aarch64/farcall-b-gsym.s: New test.
   * ld-aarch64/farcall-b-plt.s: Likewise.
   * ld-aarch64/farcall-bl-plt.s: Likewise.
   * ld-aarch64/farcall-b-gsym.d: New expect file.
   * ld-aarch64/farcall-b-plt.d: Likewise.
   * ld-aarch64/farcall-bl-plt.d: Likewise.
2015-08-11 21:44:31 +01:00
Jiong Wang 40fbed8481 [AArch64][8/8] LD support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize
  BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12.
  (aarch64_reloc_got_type): Likewise.
  (elfNN_aarch64_final_link_relocate): Likewise.
  (elfNN_aarch64_relocate_section): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/emit-relocs-529.s: New testcase.
  * ld-aarch64/emit-relocs-529-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-86.s: Likewise.
  * ld-aarch64/emit-relocs-86-overflow.s: Likewise.
  * ld-aarch64/emit-relocs-529.d: New expectation file.
  * ld-aarch64/emit-relocs-529-overflow.d: Likewise.
  * ld-aarch64/emit-relocs-86.d: Likewise.
  * ld-aarch64/emit-relocs-86-overflow.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new testcases.
2015-08-11 21:26:41 +01:00
Jiong Wang 70151fb54a [AArch64][7/8] GAS support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

include/elf/
  * aarch64.h (R_AARCH64_P32_TLSLD_ADD_DTPREL_LO12): Define.

bfd/
  * reloc.c (BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12): New entry.
  * bfd-in2.h: Regenerate.
  * libbfd.h: Regenerate.
  * elfnn-aarch64.c (elfNN_aarch64_howto_table): New entry for
  BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12.

gas/
  * config/tc-aarch64.c (reloc_table): New relocation modifiers
  "dtprel_lo12".
  (md_apply_fix): Support BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12.
  (aarch64_force_relocation): Likewise.

gas/testsuite/
  * gas/aarch64/reloc-dtprel_lo12-1.s: New testcase.
  * gas/aarch64/reloc-dtprel_lo12-ilp32-1.s: Likewise.
  * gas/aarch64/reloc-dtprel_lo12-1.d: New expectation file.
  * gas/aarch64/reloc-dtprel_lo12-ilp32-1.d: Likewise.
2015-08-11 21:26:31 +01:00
Jiong Wang 73f925cc20 [AArch64][6/8] LD support BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize
  BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC.
  (aarch64_reloc_got_type): Likewise.
  (elfNN_aarch64_final_link_relocate): Likewise.
  (elfNN_aarch64_relocate_section): Likewise.
  (elfNN_aarch64_gc_sweep_hook): Likewise.
  (elfNN_aarch64_check_relocs): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/tls-small-ld.s: Update testcase.
2015-08-11 21:26:13 +01:00
Jiong Wang a12fad50d2 [AArch64][5/8] GAS support BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * reloc.c (BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC): New entry.
  * bfd-in2.h: Regenerate.
  * libbfd.h: Regenerate.
  * elfnn-aarch64.c (elfNN_aarch64_howto_table): New entry for
  BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC.

gas/
  * config/tc-aarch64.c (reloc_table): New relocation modifiers.
  (md_apply_fix): Support BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC.
  (aarch64_force_relocation): Likewise.

gas/testsuite/
  * gas/aarch64/reloc-tlsldm_lo12_nc-1.s: New testcase.
  * gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.s: Likewise.
  * gas/aarch64/reloc-tlsldm_lo12_nc-1.d: New expectation file.
  * gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.d: Likewise.
2015-08-11 21:25:51 +01:00
Jiong Wang f69e49203b [AArch64][3/8] LD support BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize
  BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21.
  (aarch64_reloc_got_type): Likewise.
  (elfNN_aarch64_final_link_relocate): Likewise.
  (elfNN_aarch64_relocate_section): Likewise.
  (elfNN_aarch64_gc_sweep_hook): Likewise.
  (elfNN_aarch64_check_relocs): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/tls-small-ld.s: New file.
  * ld-aarch64/tls-small-ld.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new test.
2015-08-11 21:25:04 +01:00
Jiong Wang 1107e076cf [AArch64][2/8] GAS support BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * reloc.c (BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21): New entry.
  * bfd-in2.h: Regenerate.
  * libbfd.h: Regenerate.
  * elfnn-aarch64.c (elfNN_aarch64_howto_table): New entry for
  BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21.

gas/
  * config/tc-aarch64.c (reloc_table): New relocation modifiers.
  (md_apply_fix): Support BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21.
  (aarch64_force_relocation): Likewise.

gas/testsuite/
  * gas/aarch64/reloc-tlsldm-page-1.s: New testcase.
  * gas/aarch64/reloc-tlsldm-page-ilp32-1.s: Likewise.
  * gas/aarch64/reloc-tlsldm-page-1.d: New expectation file.
  * gas/aarch64/reloc-tlsldm-page-ilp32-1.d: Likewise.
2015-08-11 21:24:38 +01:00
H.J. Lu 97dc35c88d Skip IFUNC relocations in debug sections
Skip IFUNC relocations in debug sections ignored by ld.so.

bfd/

	PR ld/18808
	* elf32-i386.c (elf_i386_relocate_section): Skip IFUNC
	relocations in debug sections.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.

ld/testsuite/

	PR ld/18808
	* ld-ifunc/ifunc.exp: Add a test for PR ld/18808.
	* ld-ifunc/pr18808.out: New file.
	* ld-ifunc/pr18808a.c: Likewise.
	* ld-ifunc/pr18808b.c: Likewise.
2015-08-11 12:59:11 -07:00
Peter Zotov dbac553d28 Fix encoding or OpenRisk1000 PC relative relocations.
PR ld/18759
	* elf32-or1k.c (R_OR1K_32_PCREL): Set pcrel_offset to TRUE.
	(R_OR1K_16_PCREL): Likewise.
	(R_OR1K_8_PCREL): Likewise.
2015-08-11 17:12:21 +01:00
Nick Clifton 4c0160b8e2 Fix typo in coff-sh.c.
PR binutils/18747
	* coff-sh.c (_bfd_sh_align_load_span): Fix typo when setting
	opcode count.
2015-08-11 17:02:25 +01:00
Nick Clifton 4b0e8a5f80 Fix memory access problems discovered when running some binary tools on corrupt files.
PR binutils/18758
	* elf.c (_bfd_elf_setup_sections): Add checks for corrupt section
	group information.
	* peicode.h (pe_ILF_make_a_section): Ensure alignment of the
	used_by_bfd pointer.
	(pe_ILF_build_a_bfd): Ensure alignment of vars.data pointer.
2015-08-11 11:57:09 +01:00
H.J. Lu 64140f86ab Fix a typo in _bfd_elf_copy_private_bfd_data
* elf.c (_bfd_elf_copy_private_bfd_data): Fix a typo.
2015-08-11 03:50:17 -07:00
GDB Administrator 125453567f Automatic date update in version.in 2015-08-11 00:00:08 +00:00
H.J. Lu 422f11824b Replace hidden with versioned in elf_link_hash_entry
This patch replaces the "hidden" field with the "versioned" field in
elf_link_hash_entry so that we can avoid calling strchr and strrchr if
the symbol is unversioned.

	* elf-bfd.h (elf_symbol_version): New enum.
	(elf_link_hash_entry): Replace hidden with versioned.
	* elflink.c (_bfd_elf_merge_symbol): Don't look for symbol
	version if the symbol is unversioned.  Initialize versioned.
	(_bfd_elf_add_default_symbol): Don't look for symbol version
	if the symbol is unversioned or hidden.  Initialize versioned.
	(elf_collect_hash_codes): Don't look for symbol version if the
	symbol is unversioned.
	(elf_collect_gnu_hash_codes): Likewise.
	(bfd_elf_gc_mark_dynamic_ref_symbol): Likewise.
	(_bfd_elf_link_hash_copy_indirect): Check versioned instead of
	hidden.
	(elf_link_output_extsym): Likewise.
2015-08-10 07:57:57 -07:00
GDB Administrator 2bc6d61bf3 Automatic date update in version.in 2015-08-10 00:00:08 +00:00
GDB Administrator 662a7b62c4 Automatic date update in version.in 2015-08-09 00:00:07 +00:00
GDB Administrator e44bf850df Automatic date update in version.in 2015-08-08 00:00:08 +00:00
H.J. Lu d4ac1f878e Check sh_type/sh_flags/sh_addralign/sh_entsize when copying sh_link/sh_info
When copying the sh_link and sh_info fields in stripped section headers,
we also check if the sh_type, sh_flags, /sh_addralign and sh_entsize
fields of the output section match the output.  Since --only-keep-debug
turns all non-debug sections into SHT_NOBITS sections, the output
SHT_NOBITS type matches any input type.

bfd/

	PR binutils/18785
	* elf.c (_bfd_elf_copy_private_bfd_data): When copying the
	sh_link and sh_info fields in stripped section headers, we also
	check if the sh_type, sh_flags, /sh_addralign and sh_entsize
	fields of the output section match the output.  Since
	--only-keep-debug turns all non-debug sections into SHT_NOBITS
	sections, the output SHT_NOBITS type matches any input type.

binutils/testsuite/

	PR binutils/18785
	* binutils-all/objcopy.exp: Run strip-12.
	* binutils-all/strip-12.d: New file.
	* binutils-all/strip-12.s: Likewise.
2015-08-07 10:35:58 -07:00
H.J. Lu 6e33951edc Properly merge hidden versioned symbol
The hidden versioned symbol can only be merged with the versioned
symbol with the same symbol version.  _bfd_elf_merge_symbol should
check the symbol version before merging the new hidden versioned
symbol with the existing symbol.  _bfd_elf_link_hash_copy_indirect can't
copy any references to the hidden versioned symbol.   We need to
bind a symbol locally when linking executable if it is locally defined,
hidden versioned, not referenced by shared library and not exported.

bfd/

	PR ld/18720
	* elflink.c (_bfd_elf_merge_symbol): Add a parameter to indicate
	if the new symbol matches the existing one.  The new hidden
	versioned symbol matches the existing symbol if they have the
	same symbol version. Update the existing symbol only if they
	match.
	(_bfd_elf_add_default_symbol): Update call to
	_bfd_elf_merge_symbol.
	(_bfd_elf_link_assign_sym_version): Don't set the hidden field
	here.
	(elf_link_add_object_symbols): Override a definition only if the
	new symbol matches the existing one.
	(_bfd_elf_link_hash_copy_indirect): Don't copy any references to
	the hidden versioned symbol.
	(elf_link_output_extsym): Bind a symbol locally when linking
	executable if it is locally defined, hidden versioned, not
	referenced by shared library and not exported.  Turn on
	VERSYM_HIDDEN only if the hidden vesioned symbol is defined
	locally.

ld/testsuite/

	PR ld/18720
	* ld-elf/indirect.exp: Run tests for PR ld/18720.
	* ld-elf/pr18720.out: New file.
	* ld-elf/pr18720a.c: Likewise.
	* ld-elf/pr18720b.c: Likewise.
	* ld-elf/pr18720c.c: Likewise.
2015-08-07 05:04:35 -07:00
GDB Administrator 308d9764e1 Automatic date update in version.in 2015-08-07 00:00:07 +00:00
GDB Administrator 0cf003f49e Automatic date update in version.in 2015-08-06 00:00:10 +00:00
Nick Clifton 63b9bbb7d7 Change the behaviour of the --only-keep-debug option to objcopy and strip so that the sh_link and sh_info fields in stripped section headers are preserved.
bfd	* elf.c (_bfd_elf_copy_private_bfd_data): Copy the sh_link and
	sh_info fields of sections whose type has been changed to
	SHT_NOBITS.

bin	* doc/binutils.texi: Document that the --only-keep-debug option
	to strip and objcopy preserves the section headers of stripped
	sections.

tests	* binutils-all/objcopy.exp (keep_debug_symbols_and_check_links):
	New proc.  Checks that debug-info-only binaries retain the
	sh_link field in stripped sections.
2015-08-05 16:16:39 +01:00
GDB Administrator ea546fbb60 Automatic date update in version.in 2015-08-05 00:00:08 +00:00
Yuriy M. Kaminskiy 7e27a9d5f2 Fix stack buffer overflows when parsing corrupt ihex files.
PR binutils/18750
	* ihex.c (ihex_scan): Fixes incorrect escape sequence in error message
	and stack overflow when char is signed and \200-\376 was in place of hex
	digit; also fixes \377 was handled as EOF instead of "incorrect character".
	(ihex_read_section): Changed for consistency.
	(ihex_bad_byte): Prevent (now impossible to trigger) stack
	overflow and incorrect escape sequence handling.
	* srec.c (srec_bad_byte): Likewise.

	* readelf.c (process_mips_specific): Fix incorrect escape
	sequence handling.
2015-08-04 16:51:53 +01:00
GDB Administrator a26b73ed2d Automatic date update in version.in 2015-08-04 00:00:08 +00:00
Hans-Peter Nilsson 4122b41366 Fix ChangeLog for "FAIL: -Bsymbolic-functions" for cris-linux in ld
It's bfd_link_info, not elf_link_hash_entry, for the old reference:

	* elf32-cris.c (cris_elf_relocate_section)
	(elf_cris_finish_dynamic_symbol, cris_elf_check_relocs)
	(elf_cris_discard_excess_dso_dynamics): Use SYMBOLIC_BIND, not
	just bfd_link_info->symbolic, to check if a symbol should be bound
	symbolically.
2015-08-03 20:44:05 +02:00
Hans-Peter Nilsson cb1c8103f1 Fix "FAIL: -Bsymbolic-functions" for cris-linux in ld
* elf32-cris.c (cris_elf_relocate_section)
	(elf_cris_finish_dynamic_symbol, cris_elf_check_relocs)
	(elf_cris_discard_excess_dso_dynamics): Use SYMBOLIC_BIND, not
	just h->symbolic, to check if a symbol should be bound
	symbolically.
2015-08-03 20:34:51 +02:00
GDB Administrator 17c42309df Automatic date update in version.in 2015-08-03 00:00:08 +00:00
GDB Administrator 5e99d4b301 Automatic date update in version.in 2015-08-02 00:00:08 +00:00
GDB Administrator 5efafabf7b Automatic date update in version.in 2015-08-01 00:00:08 +00:00
GDB Administrator 22d31b1192 Automatic date update in version.in 2015-07-31 00:00:08 +00:00
H.J. Lu c6e8a9a802 Don't change the default symbol for relocatable link
We should change the default symbol for the versioned symbol only when
not performing a relocatable link.

bfd/

	PR ld/18735
	* elflink.c (_bfd_elf_add_default_symbol): Add the default
	symbol if not performing a relocatable link.
	(elf_link_add_object_symbols): Adjust the default symbol if
	not performing a relocatable link.

ld/testsuite/

	PR ld/18735
	* ld-elf/pr18735.d: New file.
	* ld-elf/pr18735.s: Likewise.
2015-07-30 03:28:00 -07:00
GDB Administrator 13be649613 Automatic date update in version.in 2015-07-30 00:00:08 +00:00
H.J. Lu e77e648e93 Don't set link_info.executable for "ld -r"
This patch changes "ld -r" not to set link_info.executable.  It
removes !info->relocatable check for info->executable and adds it
for !info->executable in elflink.c.

bfd/

	* elflink.c (elf_link_add_object_symbols): Remove
	!info->relocatable check for info->executable.  Add
	!info->relocatable check for !info->executable.
	(elf_link_output_extsym): Remove
	!info->relocatable check for info->executable.

ld/

	* lexsup.c (parse_args): Don't set link_info.executable to
	TRUE for link_info.relocatable.
2015-07-29 09:14:05 -07:00
Hans-Peter Nilsson 11509220a0 bfd/mmo.c (MMIX): Fix massive gcc LTO testsuite failures.
* mmo.c (mmo_write_symbols_and_terminator): Skip symbol-type
	assignment loop for bfd plugin objects.
2015-07-29 05:40:30 +02:00
GDB Administrator a66f09dd91 Automatic date update in version.in 2015-07-29 00:00:09 +00:00
Alan Modra e5654c0f84 Fallout from "Reorder more powerpc64 sections for -z relro"
Commit 23283c1b changed the layout of some bss style sections on
powerpc64, but neglected to add a page gap before the third PT_LOAD
segment created by this reording.  Without a page gap we get two
PT_LOAD headers that overlap by one page in memory.  That shouldn't be
allowed because the dynamic loader will load garbage from the first
page of the last segment over the last page of the previous segment.

bfd/
	* elf.c (_bfd_elf_map_sections_to_segments): Do not make a new
	segment for loaded sections after nonloaded sections if the
	sections are on the same page.
ld/testsuite/
	* ld-powerpc/elfv2so.d: Update
2015-07-28 18:42:43 +09:30
Iain Buclaw d6f1bafa2c Check for asprintf and vasprintf during configure stage.
This should fix some build errors seen on AIX, MinGW, and possibly other
non-GNU systems too due to missing asprintf().

bfd/

	* configure.in: Add asprintf and vasprintf to AC_CHECK_DECLS.
	* config.in, configure: Regenerate.
2015-07-28 09:57:32 +02:00
GDB Administrator 671c4e31fb Automatic date update in version.in 2015-07-28 00:00:08 +00:00
H.J. Lu 37a42ee9ad Regenerate configure files
bfd/

	* configure: Regenerated.

binutils/

	* configure: Regenerated.

gas/

	* configure: Regenerated.

gold/

	* configure: Regenerated.

gprof/

	* configure: Regenerated.

ld/

	* configure: Regenerated.

opcodes/

	* configure: Regenerated.
2015-07-27 07:56:32 -07:00
Nick Clifton 79559014b2 Fix the address size computation for the MSP430 port.
* elf32-msp430.c (uses_large_model): New function.
	(msp430_elf_eh_frame_address_size): New function.
	(elf_backend_eh_frame_address_size): Define.
2015-07-27 15:15:28 +01:00
Szabolcs Nagy 32f573bcb3 [AArch64] Fix extern protected data handling
Emit *GLOB_DAT instead of *RELATIVE relocs for protected data
in shared objects.

This is needed for the fix of glibc bug 17711:
https://sourceware.org/bugzilla/show_bug.cgi?id=17711

bfd:
	PR ld/18705
	* elfnn-aarch64.c (elf_backend_extern_protected_data): Define.

ld/testsuite:
	PR ld/18705
	* ld-aarch64/protected-data.d: New.
	* ld-aarch64/protected-data.s: New.
	* ld-aarch64/aarch64-elf.exp: Add new test.
2015-07-27 11:48:48 +01:00
Szabolcs Nagy b68a20d667 [ARM] Fix extern protected data handling
Emit *GLOB_DAT instead of *RELATIVE relocs for protected data
in shared objects.

This is needed for the fix of glibc bug 17711:
https://sourceware.org/bugzilla/show_bug.cgi?id=17711

bfd:
	PR ld/18705
	* elf32-arm.c (elf_backend_extern_protected_data): Define.

ld/testsuite:
	PR ld/18705
	* ld-arm/protected-data.d: New.
	* ld-arm/protected-data.s: New.
	* ld-arm/arm-elf.exp: Add new test.
2015-07-27 11:45:27 +01:00
GDB Administrator 0c096ed760 Automatic date update in version.in 2015-07-27 00:00:08 +00:00
GDB Administrator 805cee45cd Automatic date update in version.in 2015-07-26 00:00:11 +00:00
H.J. Lu 18d9555c6e Add missing ChangeLog files 2015-07-25 08:10:51 -07:00
H.J. Lu 1659f720b0 Skip missing symbol version section check for executable
Missing symbol version section is a run-time problem only if it will
be referenced dynamically at run-time.  We should skip the check for
locally defined symbol, which isn't referenced by shared library, when
linking executable.

bfd/

	PR ld/18718
	* elflink.c (elf_link_output_extsym): Check symbol version
	section check only if not linking executable, the symbol is
	referenced by shared library or not locally defined.

ld/testsuite/

	PR ld/18718
	* ld-elf/pr18718.c: New file.
	* ld-elf/shared.exp: Run tests for PR ld/18718.
2015-07-25 08:07:33 -07:00
Alan Modra a496fbc880 Fix broken -Bsymbolic-functions
For selected targets.  The testcase reveals a number of targets that
still need fixing.

bfd/
	* elf32-arm.c (elf32_arm_final_link_relocate): Use SYMBOLIC_BIND to
	check if a symbol should be bound symbolically.
	* elf32-hppa.c (elf32_hppa_check_relocs,
	elf32_hppa_adjust_dynamic_symbol, elf32_hppa_relocate_section,
	elf32_hppa_finish_dynamic_symbol): Likewise.
	* elf32-m68k.c (elf_m68k_check_relocs,
	elf_m68k_relocate_section): Likewise.
	* elf32-nios2.c (nios2_elf32_relocate_section,
	nios2_elf32_check_relocs, allocate_dynrelocs): Likewise.
	* elf32-tic6x.c (elf32_tic6x_finish_dynamic_symbol,
	elf32_tic6x_relocate_section): Likewise.
ld/testsuite/
	* ld-elf/symbolic-func.s,
	* ld-elf/symbolic-func.r: New test.
	* ld-elf/elf.exp: Run it.
2015-07-25 20:41:04 +09:30
GDB Administrator f7d3050b19 Automatic date update in version.in 2015-07-25 00:00:08 +00:00
Alan Modra 91cb26dac4 Correct reloc section name
* elf.c (_bfd_elf_assign_file_positions_for_non_load): Use .rela
	prefix for reloc section corresponding to rela section associated
	with renamed debug section.
2015-07-24 14:48:55 +09:30
Alan Modra 2fb9328d8d bfd_get_section_by_name_if hash chain traversal
This function stops too soon, as I found when the hash chain happened
to contain two .debug_macro sections and a .bss section:
.debug_macro -> .bss -> .debug_macro

	* section.c (bfd_get_section_by_name_if): Iterate over entire hash
	chain.
2015-07-24 14:48:35 +09:30
GDB Administrator f0b0791b05 Automatic date update in version.in 2015-07-24 00:00:14 +00:00
Joseph Myers d5cff5df74 Fix DT_MIPS_RLD_MAP_REL tag for n64 target and 32-bit host.
For the case of MIPS n64 target and 32-bit host, the computation of
the DT_MIPS_RLD_MAP_REL tag involves sdyn->output_section->vma +
sdyn->output_offset (64-bit) being added to b (32-bit host pointer),
so losing the high part and resulting in an incorrect
DT_MIPS_RLD_MAP_REL tag, and all dynamically linked glibc tests
failing for n64.  This patch fixes this (spot-tested with glibc tests;
however, I don't have a self-contained testcase for this bug).

	* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections)
	<DT_MIPS_RLD_MAP_REL>: Add target address to host address
	difference, not to host pointer.
2015-07-23 21:52:04 +00:00
GDB Administrator 510fac86d7 Automatic date update in version.in 2015-07-23 00:00:07 +00:00
Alan Modra bb854a36d1 Fix ppc64 ELFv1 assertion failure
Bogus assembly can hit an assertion in opd_entry_value when the symbol
referenced by a function descriptor is undefined.  Worse, the code
after the assert copies unitialised memory to return the code section.
This uninitialised pointer can later be dereferencd, possibly causing
a linker segmentation fault.

	* elf64-ppc.c (opd_entry_value): Remove assertion.  Instead,
	return -1 if symbol referenced is not defined.  Tidy.
2015-07-22 19:20:38 +09:30
GDB Administrator 6dca8d51d5 Automatic date update in version.in 2015-07-22 00:00:08 +00:00
GDB Administrator 391538482e Automatic date update in version.in 2015-07-21 00:00:07 +00:00
H.J. Lu 7ac018954b Make binutils abort message GDB friendly
We used to generate abort messages like:

internal error, aborting at .../bfd/elf64-x86-64.c line 1554 in elf_x86_64_check_relocs

We can't cut and paste "file line ???" to GDB.  This patch changes those
abort messages to

internal error, aborting at .../bfd/elf64-x86-64.c:1554 in elf_x86_64_check_relocs

so that we can cut and paste "file:???" to GDB.

bfd/

	* bfd.c (_bfd_abort): Replace " line " with ":" in output
	message.

gas/

	* messages.c (as_assert): Replace " line " with ":" in output
	message.
	(as_abort): Likewise.

ld/

	* ldmisc.c (ld_abort): Replace " line " with ":" in output
	message.
2015-07-20 05:53:31 -07:00
Alan Modra f2d7e0f450 Regen two files
bfd/
	* po/SRC-POTFILES.in: Regenerate.
binutils/
	* doc/Makefile.in: Regenerate.
2015-07-20 14:31:23 +09:30
GDB Administrator 5e63e45255 Automatic date update in version.in 2015-07-20 00:00:07 +00:00
GDB Administrator 0bda1f8819 Automatic date update in version.in 2015-07-19 00:00:08 +00:00
GDB Administrator ce62125ee9 Automatic date update in version.in 2015-07-18 00:00:08 +00:00
Jiong Wang 4c0a9a6fa1 [AArch64] Sort TLS reloc types alphabetically 2015-07-17 13:03:26 +01:00
GDB Administrator 4f9b735fea Automatic date update in version.in 2015-07-17 00:00:08 +00:00
Jiong Wang 77a69ff840 [AArch64][3/3] LD support BFD_RELOC_AARCH64_TLSLD_ADR_PREL21 2015-07-16 15:46:21 +01:00
Jiong Wang 6c37fedc41 [AArch64][2/3] GAS support BFD_RELOC_AARCH64_TLSLD_ADR_PREL21 2015-07-16 15:43:21 +01:00
GDB Administrator bb20bd8373 Automatic date update in version.in 2015-07-16 00:00:07 +00:00
GDB Administrator 2101878487 Automatic date update in version.in 2015-07-15 00:00:08 +00:00
GDB Administrator 05e83eb1b6 Automatic date update in version.in 2015-07-14 00:00:08 +00:00
GDB Administrator c576455ba7 Automatic date update in version.in 2015-07-13 00:00:08 +00:00
GDB Administrator 9394ff46fb Automatic date update in version.in 2015-07-12 00:00:08 +00:00
GDB Administrator e571fc2b05 Automatic date update in version.in 2015-07-11 00:00:08 +00:00
H.J. Lu 889884731e Properly convert objects between different ELF classes
The output SHF_COMPRESSED section size is different from input if
ELF classes of input and output aren't the same.  We must adjust
the section sizes as well as the compression headers in
SHF_COMPRESSED sections when converting objects between different
ELF classes.

bfd/

	 PR binutils/18656
	 * bfd.c (bfd_convert_section_size): New function.
	 (bfd_convert_section_contents): Likewise.
	 * bfd-in2.h: Regenerated.

binutils/

2015-07-10  H.J. Lu  <hongjiu.lu@intel.com>

	 PR binutils/18656
	 * objcopy.c (setup_section): Call bfd_convert_section_size
	 to get the output section size.
	 (copy_section): Get the section size from the output section
	 and call bfd_get_full_section_contents to convert section
	 contents for output.

binutils/testsuite/

	 PR binutils/18656
	 * binutils-all/compress.exp (convert_test): New proc.
	 Run conversion tests between x86-64 and x32.
2015-07-10 14:27:39 -07:00
GDB Administrator f250f5c6dd Automatic date update in version.in 2015-07-10 00:00:08 +00:00
Catherine Moore de231f2015 2015-07-09 Catherine Moore <clm@codesourcery.com>
* elflink.c (bfd_elf_size_dynamic_sections): Call to
        _bfd_elf_maybe_strip_eh_frame_hdr should be before
        bed->elf_backend_size_dynamic_sections.
2015-07-09 08:07:47 -07:00
GDB Administrator de0ef28545 Automatic date update in version.in 2015-07-09 00:00:07 +00:00
Denis Chertykov 328e7bfdde Define DIFF_EXPR_OK for avr target to allow PC relative difference relocation.
When generating relocation (tc_gen_reloc) 32 bit relocation fixup
is changed to new 32 bit PC relative relocation if the fixup has pc-relative
flag set.

bfd/ChangeLog

2015-07-06  Pitchumani Sivanupandi <pitchumani.s@atmel.com>

    * elf32-avr.c: Add 32 bit PC relative relocation for AVR target.

gas/ChangeLog

2015-07-06  Pitchumani Sivanupandi <pitchumani.s@atmel.com>

    * config/tc-avr.c (tc_gen_reloc): Change 32 bit relocation to
    32 bit PC relative and update offset if the fixup is pc-relative.
    * config/tc-avr.h (DIFF_EXPR_OK): Define to enable PC relative diff
    relocs.

gas/testsuite/ChangeLog

2015-07-06  Pitchumani Sivanupandi <pitchumani.s@atmel.com>

    * gas/avr/pc-relative-reloc.d: New test for 32 bit pc relative reloc.
    * gas/avr/per-function-debugline.s: New test source.

include/ChangeLog

2015-07-06  Pitchumani Sivanupandi <pitchumani.s@atmel.com>

    * elf/avr.h: Add new 32 bit PC relative relocation.

ld/testsuite/ChangeLog

2015-07-06  Pitchumani Sivanupandi <pitchumani.s@atmel.com>

    * ld-avr/gc-section-debugline.d: New test.
    * ld-avr/per-function-debugline.s: Source for new test.
2015-07-08 21:41:52 +03:00
GDB Administrator 501f83eb18 Automatic date update in version.in 2015-07-08 00:00:07 +00:00
GDB Administrator fa446e20d9 Automatic date update in version.in 2015-07-07 00:00:08 +00:00
H.J. Lu 1a617dc351 Remove the merge conflict introduced by
commit 2f0c68f23b
Author: Catherine Moore <clm@codesourcery.com>
Date:   Thu May 28 14:50:36 2015 -0700

    Compact EH Support
2015-07-06 12:03:01 -07:00
GDB Administrator 0d3a523baa Automatic date update in version.in 2015-07-06 00:00:07 +00:00
Richard Sandiford 92a9c616e4 Fix an opd->append index in elf64-ppc.c
bfd/
	* elf64-ppc.c (toc_adjusting_stub_needed): Use the symbol value
	plus addend rather than the original st_value when looking up
	entries in opd->adjust.

ld/testsuite/
	* ld-powerpc/tocopt6-inc.s, ld-powerpc/tocopt6a.s,
	ld-powerpc/tocopt6b.s, ld-powerpc/tocopt6c.s,
	ld-powerpc/tocopt6.d: New test.
	* ld-powerpc/powerpc.exp (ppc64elftests): Add it.
2015-07-05 19:57:07 +01:00
GDB Administrator 533edc14b8 Automatic date update in version.in 2015-07-05 00:00:07 +00:00
GDB Administrator e7ba597a2e Automatic date update in version.in 2015-07-04 00:00:08 +00:00
Kai Tietz 0f088b2a94 Add experimental support for --gc-sections with COFF and PE based targets.
PR ld/11539
bfd	* coffcode.h (coff_bfd_gc_sections): Define default
	to bfd_coff_gc_sections function.
	* cofflink.c (init_reloc_cookie): Copy and adjust coff
	related code about gc-sections from elflink.c to here.
	(fini_reloc_cookie): Likewise.
	(init_reloc_cookie_rels): Likewise.
	(fini_reloc_cookie_rels): Likewise.
	(init_reloc_cookie_for_section): Likewise.
	(fini_reloc_cookie_for_section): Likewise.
	(_bfd_coff_gc_mark_hook): Likewise.
	(_bfd_coff_gc_mark_rsec): Likewise.
	(_bfd_coff_gc_mark_reloc): Likewise.
	(_bfd_coff_gc_mark): Likewise.
	(_bfd_coff_gc_mark_extra_sections): Likewise.
	(coff_gc_sweep_symbol_info): Likewise.
	(coff_gc_sweep_symbol): Likewise.
	(gc_sweep_hook_fn): Likewise.
	(coff_gc_sweep): Likewise.
	(bfd_coff_gc_sections): Likewise.
	(_bfd_coff_gc_keep): Likewise.
	* libcoff.h (coff_reloc_cookie): New struct.
	(bfd_coff_gc_sections): New prototype.
	(coff_gc_mark_hook_fn): New type.

ld	* scripttempl/pep.sc: Mark .idata*, .CRT*, .tls*,
	.rsrc*, .init, .ctor*, .dtor*, .fini, .jcr,
	.eh_frame, .pdata. .xdata, and .gcc_except_table sections
	as KEEP.
	* scripttempl/pe.sc: Likewise.
2015-07-03 15:50:29 +01:00
GDB Administrator 69ae7f4d16 Automatic date update in version.in 2015-07-03 00:00:08 +00:00
GDB Administrator 7d8d1bd943 Automatic date update in version.in 2015-07-02 00:00:08 +00:00
Sandra Loosemore 8c163c5a87 Relocations for Nios II R2
2015-07-01  Sandra Loosemore  <sandra@codesourcery.com>
	    Cesar Philippidis  <cesar@codesourcery.com>

	bfd/
	* bfd-in2.h: Regenerated.
	* elf32-nios2.c (elf_nios2_howto_table_rel): Rename to...
	(elf_nios2_r1_howto_table_rel): This.
	(elf_nios2_r2_howto_table_rel): New.
	(BFD_IS_R2): New.
	(lookup_howto): Add ABFD parameter.  Adjust to look up in either
	the R1 or R2 relocation table, as determined by ABFD.
	(nios2_reloc_map): Add R2 relocations.
	(nios2_elf32_bfd_reloc_type_lookup): Do lookup using lookup_howto.
	Pass it the ABFD parameter.
	(nios2_elf32_bfd_reloc_name_lookup): Use ABFD to decide whether to
	return an R1 or R2 relocation.
	(nios2_elf32_info_to_howto): Do lookup using lookup_howto.
	Pass it the ABFD parameter.
	(nios2_elf32_do_call26_relocate): Check for alignment on a 4-byte
	boundary.
	(nios2_elf32_relocate_section): Adjust call to lookup_howto.
	* libbfd.h: Regenerated.
	* reloc.c (BFD_RELOC_NIOS2_R2_S12): New.
	(BFD_RELOC_NIOS2_R2_I10_1_PCREL): New.
	(BFD_RELOC_NIOS2_R2_T1I7_1_PCREL): New.
	(BFD_RELOC_NIOS2_R2_T1I7_2): New.
	(BFD_RELOC_NIOS2_R2_T2I4): New.
	(BFD_RELOC_NIOS2_R2_T2I4_1): New.
	(BFD_RELOC_NIOS2_R2_T2I4_2): New.
	(BFD_RELOC_NIOS2_R2_X1I7_2): New.
	(BFD_RELOC_NIOS2_R2_X2L5): New.
	(BFD_RELOC_NIOS2_R2_F1I5_2): New.
	(BFD_RELOC_NIOS2_R2_L5I4X1): New.
	(BFD_RELOC_NIOS2_R2_T1X1I6): New.
	(BFD_RELOC_NIOS2_R2_T1X1I6_2): New.

	include/elf/
	* nios2.h (R_NIOS2_R2_S12): New.
	(R_NIOS2_R2_I10_1_PCREL): New.
	(R_NIOS2_R2_T1I7_1_PCREL): New.
	(R_NIOS2_R2_T1I7_2): New.
	(R_NIOS2_R2_T2I4): New.
	(R_NIOS2_R2_T2I4_1): New.
	(R_NIOS2_R2_T2I4_2): New.
	(R_NIOS2_R2_X1I7_2): New.
	(R_NIOS2_R2_X2L5): New.
	(R_NIOS2_R2_F1I5_2): New.
	(R_NIOS2_R2_L5I4X1): New.
	(R_NIOS2_R2_T1X1I6): New.
	(R_NIOS2_R2_T1X1I6_2): New.
	(R_NIOS2_ILLEGAL): Renumber.
2015-07-01 16:02:09 -07:00
Sandra Loosemore 965b1d8083 Add Nios II arch flags and compatibility tests
2015-07-01  Sandra Loosemore  <sandra@codesourcery.com>
	    Cesar Philippidis  <cesar@codesourcery.com>

	bfd/
	* archures.c (bfd_mach_nios2r1, bfd_mach_nios2r2): New.
	* bfd-in2.h: Regenerated.
	* cpu-nios2.c (nios2_compatible): New.
	(N): Use nios2_compatible instead of bfd_default_compatible.
	(NIOS2R1_NEXT, NIOS2R2_NEXT): Define.
	(arch_info_struct): New.
	(bfd_nios2_arch): Chain to NIOS2R1_NEXT.
	* elf32-nios2.c (is_nios2_elf): New.
	(nios2_elf32_merge_private_bfd_data): New.
	(nios2_elf32_object_p): New.
	(bfd_elf32_bfd_merge_private_bfd_data): Define.
	(elf_backend_object_p): Define.

	gas/
	* config/tc-nios2.c: Adjust includes.
	(OPTION_MARCH): Define.
	(md_longopts): Add -march option.
	(nios2_architecture): New.
	(nios2_use_arch): New.
	(md_parse_option): Handle OPTION_MARCH.
	(md_show_usage): Document -march.
	(md_begin): Set arch in BFD.
	(nios2_elf_final_processing): New.
	* config/tc-nios2.h (elf_tc_final_processing): Define.
	(nios2_elf_final_processing): New.
	* doc/c-nios2.texi (-march): Add documentation.

	include/elf/
	* nios2.h (EF_NIOS2_ARCH_R1, EF_NIOS2_ARCH_R2): Define.

	ld/testsuite/
	* ld-nios2/mixed1a.d: New.
	* ld-nios2/mixed1a.s: New.
	* ld-nios2/mixed1b.d: New.
	* ld-nios2/mixed1b.s: New.
	* ld-nios2/nios2.exp: Build the new compatibility tests.
2015-07-01 15:55:28 -07:00
H.J. Lu dfc87947b5 Refactor elf_x86_64_convert_mov_to_lea
* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Refactor.
2015-07-01 09:33:27 -07:00
GDB Administrator 7a53c6c9c7 Automatic date update in version.in 2015-07-01 00:00:08 +00:00
Nick Clifton 5ee4a1ca16 This fixes parsing a file containing ELF attributes with very large tag values.
PR binutils/18570
	* elf-attrs.c (obj_attr_size): Use an unsigned int type for the tag.
	(write_obj_attribute): Likewise.
	(elf_new_obj_attr): Likewise.
	(bfd_elf_get_obj_attr_int): Likewise.
	(bfd_elf_add_obj_attr_int): Likewise.
	(bfd_elf_add_obj_attr_string): Likewise.
	(bfd_elf_add_obj_attr_int_string): Likewise.
	(gnu_obj_attrs_arg_type): Likewise.
	(_bfd_elf_obj_attrs_arg_type): Likewise.
	(_bfd_elf_parse_attributes): Likewise.
	(_bfd_elf_merge_unknown_attribute_list): Likewise.
	* elf-bfd.h (struct obj_attribute_list): Likewise.
	Update prototypes.
2015-06-30 17:12:47 +01:00
Nick Clifton 54f66250d7 Add support for SADDR addressing to the RL78 port.
gas	* config/rl78-parse.y: Tag all saddr expressions throughout.
	(SET_SA): New.
	(expr_is_saddr): Allow symbolic expressions.
	* config/tc-rl78.c (md_apply_fix): Handle SADDR.

bfd	* elf32-rl78.c (rl78_elf_howto_table): Add RH_SADDR.
        (rl78_reloc_map): Add R_RL78_RH_SADDR.
	* reloc.c: Add BFD_RELOC_RL78_SADDR.
	* libbfd.h: Regenerate.
	* bfd-in2.h: Regenerate.
2015-06-30 11:25:18 +01:00
GDB Administrator 06b3fd23bf Automatic date update in version.in 2015-06-30 00:00:08 +00:00
GDB Administrator bb0eef66f8 Automatic date update in version.in 2015-06-29 00:00:07 +00:00
H.J. Lu ee0c0c503d Remove COMPRESS_DEBUG_ZLIB
COMPRESS_DEBUG_ZLIB isn't needed.  This patch removes COMPRESS_DEBUG_ZLIB
and replace COMPRESS_DEBUG_ZLIB with COMPRESS_DEBUG_GNU_ZLIB.

bfd/

	* bfd-in.h (compressed_debug_section_type): Remove
	COMPRESS_DEBUG_ZLIB.
	* bfd-in2.h : Regenerated.
gas/

	* as.c (parse_args): Replace COMPRESS_DEBUG_ZLIB with
	COMPRESS_DEBUG_GNU_ZLIB.
	* config/tc-i386.c (flag_compress_debug): Likewise.

ld/

	* emultempl/elf32.em  (gld${EMULATION_NAME}_handle_option):
	Replace COMPRESS_DEBUG_ZLIB with COMPRESS_DEBUG_GNU_ZLIB.
2015-06-28 06:30:10 -07:00
GDB Administrator e44fbadbed Automatic date update in version.in 2015-06-28 00:00:08 +00:00
GDB Administrator 98090c0be3 Automatic date update in version.in 2015-06-27 00:00:07 +00:00
Matthew Fortune a5499fa464 Add support for DT_MIPS_RLD_MAP_REL.
This tag makes it possible to access the debug map when debugging position
independent executables.

bfd/

	* elfxx-mips.c (_bfd_mips_elf_create_dynamic_sections): Use executable
	instead of !shared to indicate an application vs shared library.
	(_bfd_mips_elf_size_dynamic_sections): Likewise.
	(_bfd_mips_elf_finish_dynamic_sections): Handle DT_MIPS_RLD_MAP_REL.
	(_bfd_mips_elf_get_target_dtag): Likewise.

binutils/

	* readelf.c (get_mips_dynamic_type): Handle DT_MIPS_RLD_MAP_REL.

include/

	* elf/mips.h (DT_MIPS_RLD_MAP_REL): New macro.

ld/testsuite/

	* ld-mips-elf/pic-and-nonpic-3b.ad: Adjust for extra dynamic tag.
	* ld-mips-elf/pic-and-nonpic-4b.ad: Likewise.
	* ld-mips-elf/pic-and-nonpic-5b.ad: Likewise.
	* ld-mips-elf/pic-and-nonpic-6-n32.ad: Likewise.
	* ld-mips-elf/pic-and-nonpic-6-n64.ad: Likewise.
	* ld-mips-elf/pic-and-nonpic-6-o32.ad: Likewise.
	* ld-mips-elf/tlsdyn-o32-1.d: Likewise.
	* ld-mips-elf/tlsdyn-o32-1.got: Likewise.
	* ld-mips-elf/tlsdyn-o32-2.d: Likewise.
	* ld-mips-elf/tlsdyn-o32-2.got: Likewise.
	* ld-mips-elf/tlsdyn-o32-3.d: Likewise.
	* ld-mips-elf/tlsdyn-o32-3.got: Likewise.
	* ld-mips-elf/tlsdyn-o32.d: Likewise.
	* ld-mips-elf/tlsdyn-o32.got: Likewise.
	* ld-mips-elf/pie-n32.d: New file.
	* ld-mips-elf/pie-n64.d: Likewise.
	* ld-mips-elf/pie-o32.d: Likewise.
	* ld-mips-elf/pie.s: Likewise.
	* ld-mips-elf/mips-elf.exp: Add new tests.
2015-06-26 11:53:33 +01:00
GDB Administrator 920d644c63 Automatic date update in version.in 2015-06-26 00:00:07 +00:00
DJ Delorie 3f3070745b Fix REL handling for MSP430
* elf32-msp430.c (msp430_final_link_relocate): Fix comments.  Fix
REL loads to match RELA stores.
2015-06-25 17:20:15 -04:00
H.J. Lu 946748d5ed Don't set sh_size for .shstrtab twice
_bfd_elf_assign_file_positions_for_non_load will set the sh_size
field for .shstrtab section.  There is need to initialize it in
_bfd_elf_compute_section_file_positions.

	* elf.c (_bfd_elf_compute_section_file_positions): Don't
	initialize sh_size for .shstrtab here.
2015-06-25 13:04:07 -07:00
H.J. Lu ef10c3ace0 Use strtab with GC and suffix merging for .strtab
This patch uses ELF strtab with GC and suffix merging support to create
ELF .strtab section.  There is some small memory overhead to use ELF
strtab:

==14928== HEAP SUMMARY:
==14928==     in use at exit: 3,276,318 bytes in 679 blocks
==14928==   total heap usage: 1,544 allocs, 865 frees, 15,259,146 bytes allocated

vs.

==14936== HEAP SUMMARY:
==14936==     in use at exit: 3,276,318 bytes in 679 blocks
==14936==   total heap usage: 1,532 allocs, 853 frees, 15,026,402 bytes allocated

when running:

./ld-new -m elf_x86_64 -o tmpdir/ld-partial.o -r ldgram.o ldlex-wrapper.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o plugin.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o eelf_x86_64.o eelf32_x86_64.o eelf_i386.o eelf_iamcu.o ei386linux.o eelf_l1om.o eelf_k1om.o ldbuildid.o

The results are

  [32] .strtab STRTAB 0+ 3beff8 00407a 00 0 0 1

vs

  [32] .strtab STRTAB 0+ 3beff8 0041d8 00 0 0 1

It reduces the .strtab size by 350 bytes, about 2%

Saving on libc.so from glibc is much more since libc.so has many alias
symbols with the same suffix.  For x32 glibc,

 [82] .strtab STRTAB 0+ 81b348 0159e7 00 0 0 1

vs

 [82] .strtab STRTAB 0+ 81b8bc 019e72 00 0 0 1

It reduces the .strtab size by 17547 bytes, about 16%.

bfd/

	PR gas/18451
	* elf-bfd.h (elf_sym_strtab): New.
	(elf_link_hash_table): Add strtabcount, strtabsize and
	strtab.
	(_bfd_elf_stringtab_init): Removed.
	* elf.c (_bfd_elf_stringtab_init): Removed.
	(_bfd_elf_compute_section_file_positions): Replace
	bfd_strtab_hash/_bfd_elf_stringtab_init/_bfd_stringtab_free/
	_bfd_stringtab_size with
	elf_strtab_hash/_bfd_elf_strtab_init/_bfd_elf_strtab_free/
	_bfd_elf_strtab_size.  Use _bfd_elf_strtab_add,
	_bfd_elf_strtab_finalize and _bfd_elf_strtab_offset to get
	st_name.
	(swap_out_syms): Likewise.
	* elflink.c (elf_final_link_info): Replace bfd_strtab_hash
	with elf_strtab_hash.  Remove symbuf, symbuf_count,
	symbuf_size and shndxbuf_size.
	(elf_link_flush_output_syms): Removed.
	(elf_link_output_sym): Renamed to ...
	(elf_link_output_symstrtab): This.  Replace _bfd_stringtab_add
	with _bfd_elf_strtab_add.  Don't flush symbols to the file nor
	swap out symbols.
	(elf_link_swap_symbols_out): New.
	(elf_link_output_extsym): Replace elf_link_output_sym with
	elf_link_output_symstrtab.
	(elf_link_input_bfd): Likewise.
	(elf_final_link_free): Replace _bfd_stringtab_free with
	_bfd_elf_strtab_free.  Remove symbuf.
	(bfd_elf_final_link): Replace _bfd_elf_stringtab_init with
	_bfd_elf_strtab_init.  Don't set symbuf, symbuf_count,
	symbuf_size nor shndxbuf_size.  Initialize strtabsize and
	strtab.  Initialize symshndxbuf to -1 when number of sections
	>= 64K.  Replace elf_link_output_sym/elf_link_output_sym with
	elf_link_output_symstrtab/elf_link_output_symstrtab. Don't
	call elf_link_flush_output_syms.  Call _bfd_elf_strtab_finalize
	and elf_link_swap_symbols_out.  Replace _bfd_stringtab_size
	and _bfd_stringtab_emit with _bfd_elf_strtab_size and
	_bfd_elf_strtab_emit.

gas/testsuite/

	PR gas/18451
	* gas/elf/elf.exp: Run strtab.
	* gas/elf/strtab.d: New file.
	* gas/elf/strtab.s: Likewise.

ld/testsuite/

	PR gas/18451
	* ld-elf/strtab.d: New file.
	* ld-elf/strtab.s: Likewise.
2015-06-25 08:16:14 -07:00
GDB Administrator 53f7371c77 Automatic date update in version.in 2015-06-25 00:00:16 +00:00
H.J. Lu 7cc152be3e Silence older GCC warning
* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Silence older
	GCC warning.
2015-06-24 15:02:02 -07:00
H.J. Lu 7c1e8d3ed5 Keep .plt section and DT_PLTGOT for prelink
Since the .plt section and DT_PLTGOT are used by prelink to undo
prelinking for dynamic relocations, we must keep them even if there is
no PLT relocation.  This patch reverted commit a3747075a.

bfd/

	* elf32-i386.c (elf_i386_allocate_dynrelocs): Always allocate
	space for the first .plt entry.
	(elf_i386_size_dynamic_sections): Always add DT_PLTGOT for .plt
	section.  Add DT_PLTRELSZ, DT_PLTREL and DT_JMPREL only if
	there are PLT relocations.
	* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Always
	allocate space for the first .plt entry.
	(elf_x86_64_size_dynamic_sections): Always add DT_PLTGOT for
	.plt section.  Add DT_PLTRELSZ, DT_PLTREL and DT_JMPREL only if
	there are PLT relocations.

ld/testsuite/

	* ld-i386/i386.exp: Run pltgot-2 for Linux targets.
	* ld-x86-64/x86-64.exp: Likewise.
	* ld-i386/pltgot-1.d: Updated.
	* ld-x86-64/pltgot-1.d: Likewise.
	* ld-i386/pltgot-2.d: New file.
	* ld-x86-64/pltgot-2.d: Likewise.
2015-06-24 13:47:37 -07:00
H.J. Lu 59cab53283 Don't convert R_X86_64_GOTPCREL if it will overflow
When converting "mov foo@GOTPCREL(%rip), %reg" to "lea foo(%rip), %reg"
with R_X86_64_PC32 relocation, it may overflow if the target section
is more than 2GB away.  This patch estimates distance between mov
instruction and the target section.  We convert R_X86_64_GOTPCREL to
R_X86_64_PC32 only if their distance is less than 2GB.

	PR ld/18591
	* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Don't convert
	R_X86_64_GOTPCREL to R_X86_64_PC32 if it will cause relocation
	overflow.
2015-06-24 10:20:41 -07:00
GDB Administrator 44d51e2c27 Automatic date update in version.in 2015-06-24 00:00:08 +00:00
Jiong Wang c217058957 [AArch64] Generate DT_TEXTREL for relocation against read-only section
2015-06-23  Jiong Wang  <jiong.wang@arm.com>

  bfd/
    * elfnn-aarch64.c (aarch64_readonly_dynrelocs): New function.
    (elfNN_aarch64_size_dynamic_sections): Traverse hash table to check
    relocations against read-only sections.

  ld/testsuite/
    * ld-aarch64/dt_textrel.s: New testcase.
    * ld-aarch64/dt_textrel.d: New expectation file.
    * ld-aarch64/aarch64-elf.exp: Run new testcase.
2015-06-23 12:12:06 +01:00
GDB Administrator e5ee3fe285 Automatic date update in version.in 2015-06-23 00:00:08 +00:00
GDB Administrator cb5d172ca4 Automatic date update in version.in 2015-06-22 00:00:07 +00:00
Alan Modra 02db4b0a9f Don't use $< in Makefiles
$< is a GNU make feature.

	* Makefile.am: Expand $<.
	* Makefile.in: Regenerate.
2015-06-21 13:07:57 +09:30
GDB Administrator bcdeacb69a Automatic date update in version.in 2015-06-21 00:00:08 +00:00