daily update
daily update
daily update
daily update
daily update
[AArch64] Cortex-A53 erratum 835769 linker workaround

2014-10-24  Tejas Belagod  <tejas.belagod@arm.com>

    bfd/
    	* bfd-in.h (bfd_elf64_aarch64_set_options): Add a parameter.
    	* bfd-in2.h (bfd_elf64_aarch64_set_options): Likewise.
    	* elfnn-aarch64.c (aarch64_erratum_835769_stub): New.
    	(elf_aarch64_stub_type): Add new type
    	aarch64_stub_erratum_835769_veneer.
    	(elf_aarch64_stub_hash_entry): New fields for erratum 835769.
    	(aarch64_erratum_835769_fix): New data struct to record erratum
    	835769.
    	(elf_aarch64_link_hash_table: Global flags for 835769.
    	(aarch64_build_one_stub): Add case for 835769.
    	(aarch64_size_one_stub): Likewise.
    	(aarch64_mem_op_p, aarch64_mlxl_p,
    	aarch64_erratum_sequence,erratum_835769_scan):
    	New. Decode and scan functions for erratum 835769.
    	(elf_aarch64_create_or_find_stub_sec): New.
    	(elfNN_aarch64_size_stubs): Look for erratum 835769 and record
    	them.
    	(bfd_elfNN_aarch64_set_options: Set global flag for 835769.
    	(erratum_835769_branch_to_stub_data,
    	make_branch_to_erratum_835769_stub):New. Connect up all the
    	erratum stubs to occurances by branches.
    	(elfNN_aarch64_write_section): New hook.
    	(aarch64_map_one_stub): Output erratum stub symbol.
    	(elfNN_aarch64_size_dynamic_sections): Init mapping symbol
    	information for erratum 835769.
    	(elf_backend_write_section): Define.

    ld/
    	* emultempl/aarch64elf.em: Add command-line option for erratum
    	835769.

    ld/testsuite/
    	* ld-aarch64/aarch64-elf.exp (aarch64elftests): Drive erratum
    	835769 tests.
    	* ld-aarch64/erratum835769.d: New.
    	* ld-aarch64/erratum835769.s: New.
daily update
daily update
daily update
daily update
Fix memory overflow issue about strncat

If src contains n or more bytes, strncat() writes n+1 bytes to dest
(n from src plus the terminating null byte).   Therefore, the size of
dest must be at least strlen(dest)+n+1.

	* config/tc-tic4x.c (md_assemble): Correct strncat size.
ChangeLog typo fix
Define bfd_find_line entry of BFD_JUMP_TABLE_SYMBOLS using NAME

In https://www.sourceware.org/ml/binutils/2005-06/msg00082.html
HJ implemented bfd_find_line for DWARF2, but cheated a little in not
using the usual NAME##_find_line, saving quite a lot of boring
editing.  However that shortcut probably contributed to
bfd_find_nearest_line_discriminator being implemented the same way,
and missing support for some targets.

	* targets.c (BFD_JUMP_TABLE_SYMBOLS): Use NAME##_find_line.
	* aout-adobe.c (aout_32_find_line): Define.
	(aout_32_bfd_make_debug_symbol, aout_32_bfd_reloc_type_lookup,
	aout_32_bfd_reloc_name_lookup): Define using _bfd_nosymbols define.
	* aout-target.h (MY_find_line): Define.
	* aout-tic30.c (MY_find_line): Define.
	* binary.c (binary_find_line): Define.
	* bout.c (aout_32_find_line): Define.
	* coff-rs6000.c (_bfd_xcoff_find_line): Define.
	* coff64-rs6000.c (rs6000_xcoff64_vec): Use coff_find_line.
	(rs6000_xcoff64_aix_vec): Likewise.
	* elf-bfd.h (_bfd_generic_find_line): Don't define.
	* elfxx-target.h (bfd_elfNN_find_line): Define.
	* i386msdos.c (msdos_find_line): Define.
	* i386os9k.c (aout_32_find_line): Define.
	* ieee.c (ieee_find_nearest_line, ieee_find_inliner_info): Delete func.
	(ieee_find_nearest_line, ieee_find_line,
	ieee_find_inliner_info): Define.
	* ihex.c (ihex_find_line): Define.
	* libbfd-in.h (_bfd_nosymbols_find_line): Define.
	(_bfd_generic_find_line): Don't define.
	* libbfd.c (_bfd_generic_find_line): Delete.
	* libcoff-in.h (coff_find_line): Define.
	* libecoff.h (_bfd_ecoff_find_line): Define.
	* mach-o.h (bfd_mach_o_find_line): Define.
	* mmo.c (mmo_find_line): Define.
	* nlm-target.h (nlm_find_line): Define.
	* oasys.c (oasys_find_nearest_line, oasys_find_inliner_info): Delete.
	(oasys_find_nearest_line, oasys_find_line,
	oasys_find_inliner_info): Define.
	* pef.c (bfd_pef_find_line): Define.
	* plugin.c (bfd_plugin_find_line): Define.
	* ppcboot.c (ppcboot_find_line): Define.
	* som.c (som_find_line): Define.
	* srec.c (srec_find_line): Define.
	* tekhex.c (tekhex_find_line): Define.
	* versados.c (versados_find_line): Define.
	* vms-alpha.c (alpha_vms_find_line): Define.
	* xsym.c (bfd_sym_find_line): Define.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
Merge bfd_find_nearest_line variants

When bfd_find_nearest_line_discriminator was added, not enough care
was taken to ensure all targets had a proper definition of the function.
This patch cures that by merging bfd_find_nearest_line_discriminator
and bfd_find_nearest_line target implementations.

	PR 17481
	* aoutx.h (NAME (aout, find_nearest_line)): Add "discriminator_ptr"
	param, group "section" and "offset" params.  Zero discriminator.
	* bfd.c (bfd_find_nearest_line): Implement with new
	_bfd_find_nearest_line.
	(bfd_find_nearest_line_discriminator): Likewise.
	* coff-i386.c (_bfd_generic_find_nearest_line_discriminator): Don't
	define.
	* coff-rs6000.c (xcoff_find_nearest_line,
	xcoff_find_nearest_line_discriminator): Delete.
	(_bfd_xcoff_find_nearest_line): Don't define.
	(_bfd_xcoff_find_nearest_line): Define as coff_find_nearest_line.
	* coff-x86_64.c (_bfd_generic_find_nearest_line_discriminator): Don't
	define.
	* coff64-rs6000.c (rs6000_xcoff64_vec, rs6000_xcoff64_aix_vec): Adjust.
	* coffgen.c (coff_find_nearest_line_with_names): Reorder params,
	adjust _bfd_dwarf2_find_nearest_line call.
	(coff_find_nearest_line): Add "discriminator_ptr" param, reorder
	others.  Set discriminator.  Adjust call.
	(coff_find_nearest_line_discriminator): Delete.
	* dwarf1.c (_bfd_dwarf1_find_nearest_line): Reorder params.
	* dwarf2.c (find_line): Rename to..
	(_bfd_dwarf2_find_nearest_line): ..this, reordering params.
	Simplify setting of do_line.  Delete old function.
	(_bfd_dwarf2_find_line): Delete.
	* ecoff.c (_bfd_ecoff_find_nearest_line): Reorder params, add
	discriminator_ptr and set it.
	* elf-bfd.h (_bfd_elf_find_nearest_line): Update prototype.
	(_bfd_elf_find_nearest_line_discriminator): Delete.
	(_bfd_elf_find_line_discriminator): Delete.
	(_bfd_generic_find_nearest_line_discriminator): Don't define.
	* elf.c (elf_find_function): Reorder params.
	(_bfd_elf_find_nearest_line): Reorder params, add discriminator_ptr.
	Adjust calls.
	(_bfd_elf_find_nearest_line_discriminator): Delete.
	(_bfd_elf_find_line): Adjust call.
	* elf32-arm.c (arm_elf_find_function): Reorder params.
	(elf32_arm_find_nearest_line): Reorder params, add discriminator_ptr.
	Adjust calls.
	* elf64-alpha.c (elf64_alpha_find_nearest_line): Similarly.
	* elfnn-aarch64.c (aarch64_elf_find_function): Reorder params.
	(elfNN_aarch64_find_nearest_line): Reorder params, add
	discriminator_ptr.  Adjust calls.
	* elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Similarly.
	* elfxx-mips.h (_bfd_mips_elf_find_nearest_line): Update prototype.
	* libaout.h (NAME (aout, find_nearest_line)): Update prototype.
	* libbfd-in.h (_bfd_nosymbols_find_nearest_line): Update.
	(_bfd_dwarf1_find_nearest_line): Likewise.
	(_bfd_dwarf2_find_nearest_line): Likewise.
	(_bfd_dwarf2_find_line): Delete.
	(_bfd_generic_find_nearest_line_discriminator): Delete.
	* libbfd.c (_bfd_generic_find_nearest_line_discriminator): Delete.
	* libcoff-in.h (coff_find_nearest_line): Update prototype.
	(coff_find_nearest_line_discriminator): Delete.
	(coff_find_nearest_line_with_names): Update prototype.
	* libecoff.h (_bfd_ecoff_find_nearest_line): Update prototype.
	* mach-o.c (bfd_mach_o_find_nearest_line): Reorder params, add
	discriminator_ptr.  Adjust calls.
	* mach-o.h (bfd_mach_o_find_nearest_line): Update prototype.
	* pdp11.c (NAME (aout, find_nearest_line)): Reorder params, add
	discriminator_ptr and set.
	* som.c (som_find_nearest_line): Similarly.
	* targets.c (BFD_JUMP_TABLE_SYMBOLS): Delete entry for
	_bfd_find_nearest_line_discriminator.
	(struct bfd_target <_bfd_find_nearest_line>): Adjust prototype.
	(struct bfd_target <_bfd_find_nearest_line_discriminator>): Delete.
	* vms-alpha.c (_bfd_vms_find_nearest_dst_line): Rename to..
	(_bfd_vms_find_nearest_line): ..this.  Reorder params, add
	"discriminator" and set.
	(_bfd_vms_find_nearest_line_discriminator): Delete.
	(_bfd_generic_find_nearest_line_discriminator): Don't define.
	(alpha_vms_find_nearest_line): Update define.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
PR17488, powerpc64-linux-ld segfault

For binary ouput, we don't have an ELF bfd output so can't access
elf_elfheader.  The elf64-ppc.c changes are really just a tidy,
triggered by looking at all places where the abiversion bits are
accessed.

bfd/
	* elf64-ppc.c (ppc64_elf_before_check_relocs): Do .opd processing
	even when output is not ppc64 ELF.  Remove redundant tests on
	type of input bfd.
ld/
	PR 17488
	* emultempl/ppc64elf.em (gld${EMULATION_NAME}_finish): Don't attempt
	to access ELF header e_flags when not ppc64 ELF output.
Fix 17492, ld segfault with --oformat=binary

	PR 17492
	* elf32-arm.c (elf32_arm_add_symbol_hook): Only set has_gnu_symbols
	on ELF output bfd.
	* elf32-i386.c (elf_i386_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.
	* elf64-x86-64.c (elf_x86_64_add_symbol_hook): Likewise.
	* elfxx-aarch64.c (_bfd_aarch64_elf_add_symbol_hook): Likewise.
	* elf-s390-common.c (elf_s390_add_symbol_hook): Likewise.  Handle
	STB_GNU_UNIQUE too.
Fix PR17493, attempted output of *GAS `reg' section* symbol

The write.c change is to make gas report an error if reg_section
symbols should leak in future.  The tc-i386.c change is the real fix.

Note that the error isn't the most helpful, "redefined symbol cannot
be used on reloc", but I'm not inclined to improve what is really an
internal gas error.  reg_section symbols shouldn't leak..

gas/
	PR 17493
	* write.c (adjust_reloc_syms): Don't allow symbols in reg_section
	to be reduced to reg_section section symbol.
	* gas/config/tc-i386.c (i386_finalize_immediate): Reject all
	reg_section immediates.
gas/testsuite/
	* gas/i386/inval-equ-2.l: Adjust.
PowerPC64 ELFv1 function symbol definition vs LTO and discarded sections

When functions are emitted in comdat groups, global symbols defined in
duplicates of the group are treated as if they were undefined.  That
prevents the symbols in the discarded sections from affecting the
linker's global symbol hash table or causing duplicate symbol errors.
Annoyingly, when gcc emits a function to a comdat group, it does not
put *all* of a function's code and data in the comdat group.
Typically, constant tables, exception handling info, and debug info
are emitted to normal sections outside of the group, which is a
perennial source of linker problems due to the special handling needed
to deal with the extra-group pieces that ought to be discarded.  In
the case of powerpc64-gcc, the OPD entry for a function is not put in
the group.  Since the function symbol is defined on the OPD entry this
means we need to handle symbols in .opd specially.

To see how this affects LTO in particular, consider the linker
testcase PR ld/12942 (1).  This testcase links an LTO object file
pr12942a.o with a normal (non-LTO) object pr12942b.o.  Both objects
contain a definition for _Z4testv in a comdat group.  On loading
pr12942a.o, the linker sees a comdat group (actually linkonce section)
for _Z4testv and a weak _Z4testv defined in the IR.  On loading
pr12942b.o, the linker sees the same comdat group, and thus discards
it.  However, _Z4testv is a weak symbol defined in .opd, not part of
the group, so this weak symbol overrides the weak IR symbol.  On
(re)loading the LTO version of pr12942a.o, the linker sees another
weak _Z4testv, but this one does not override the value we have from
pr12942b.o.  The result is a linker complaint about "`_Z4testv'
... defined in discarded section `.group' of tmpdir/pr12942b.o".

	* elf64-ppc.c (ppc64_elf_add_symbol_hook): If function code
	section for function symbols defined in .opd is discarded, let
	the symbol appear to be undefined.
	(opd_entry_value): Ensure the result section is that for the
	function code section in the same object as the OPD entry.
Add gcc-4.9 libgomp symbols requiring --plt-thread-safe for power7

powerpc64 ld builds plt call stubs with a read barrier to provide
thread safety on lazy plt updates, necessary on multi-threaded apps
with power7 or later weakly ordered memory.  gcc-4.9 libgomp
introduced more functions that could call pthread_create, which means
we have more functions that if referenced in an executable should
cause a default of --plt-thread-safe.

bfd/
	* elf64-ppc.c (ppc64_elf_size_stubs): Add gcc-4.9 libgomp functions
	to thread_starter.
gold/
	* powerpc.cc (do_relax): Add gcc-4.9 libgomp functions to
	thread_starter.
ppc: enable msgclr and msgsnd on Power8

According to my reading of the spec it was an oversight for them to
not having got enabled when Power8 support got added.