Commit Graph

11438 Commits

Author SHA1 Message Date
Matthew Fortune 131e2f8ea1 Fix segfault when creating a dso with discarded .dynsym section.
bfd/

	* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Fix segfault
	when creating a dso with discarded dynsym section.
2014-11-05 10:56:59 +00:00
Matthew Fortune 09c14161c5 Update .MIPS.abiflags to support MIPS R6
bfd/

	* elfxx-mips.c (update_mips_abiflags_isa): Add E_MIPS_ARCH_32R6
	and E_MIPS_ARCH_64R6 support.

ld/testsuite/

	* ld-mips-elf/abiflags-strip10-ph.d: New file.
	* ld-mips-elf/mips-eld.exp: Run the new test.

gas/

	* config/tc-mips.c (mips_elf_final_processing): Add INSN_ISA32R6
	and INSN_ISA64R6 support.

gas/testsuite/

	* gas/mips/elf_arch_mips32r6.d: New file.
	* gas/mips/elf_arch_mips64r6.d: New file.
	* gas/mips/mips.exp: Run the new tests.
2014-11-05 10:48:38 +00:00
Nick Clifton 20ad5e2842 More fixes for processing corrupt files.
PR binutils/17512
	* coffcode.h (coff_set_alignment_hook): Warn if the file lies
	about the number of relocations it contains.
	(coff_sort_func_alent): Return 0 if the pointers are NULL.
	(coff_slurp_line_table): Add more range checks.  Do not free new
	tables created when sorting line numbers.
	* peXXigen.c (pe_print_idata): Add range checks.
	(pe_print_edata): Likewise.
	(rsrc_print_resource_entries): Likewise.  Avoid printing control
	characters.  Terminate priniting if corruption is detected.
	(rsrc_print_resource_directory): Terminate printing if an unknown
	directory type is encountered.
	(pe_print_debugdata): Fix off-by-one error.
	(rsrc_count_entries): Add range checking.
	(rsrc_parse_entry): Likewise.
2014-11-05 10:13:16 +00:00
Alan Modra 0b58352d43 daily update 2014-11-05 09:31:00 +10:30
Nick Clifton 79f2a78e76 Fix problem with linker created sections being mistakenly flagged
as corrupt by the new error checking code in bfd_get_full_section_contents.

	PR binutils/17512
	* compress.c (bfd_get_full_section_contents): Improve test for
	linker created objects.
2014-11-04 16:00:10 +00:00
Nick Clifton bb0d867169 Fix a seg-fault triggered by reading a mal-formed archive.
PR binutils/17533
	* archive.c (_bfd_slurp_extended_name_table): Handle archives with
	corrupt extended name tables.
2014-11-04 13:15:37 +00:00
Alan Modra ef42b83ec0 Provide stat function for spu overlay manager iovec
Commit f54498b4 broke spu-elf, specifically the change "Do not try to
load a string table bigger than the file", because bfd_get_size
returns zero for the spu built-in overlay manager bfd.

	* elf32-spu.c (ovl_mgr_stat): New function.
	(spu_elf_open_builtin_lib): Pass to bfd_openr_iovec.
2014-11-04 22:36:13 +10:30
Alan Modra f868b157aa daily update 2014-11-04 09:30:33 +10:30
Andrew Burgess 931b79ccd6 When relaxing, update size of symbols.
When performing linker relaxation, reduce the size of symbols that span
the deleted bytes.  This ensures that, for example, function symbols
will have the correct size.

bfd/ChangeLog:

	* elf32-avr.c (elf32_avr_relax_delete_bytes): During linker
	relaxation, reduce the size of symbols that span the deleted
	bytes.

ld/ChangeLog:

	* testsuite/ld-avr/relax-02.d: Update to check size of symbols has
	changed.
	* testsuite/ld-avr/relax-03.d: Likewise.
2014-11-03 20:34:13 +00:00
Andrew Burgess a12d0ffc72 When relaxing, update symbols at the very end of the section.
Symbols at the very end of a section were not being updated correctly
when linker relaxation takes place due to the use of '<' instead of
'<='.  Added a couple of tests to cover this behaviour.

bfd/ChangeLog:

	* elf32-avr.c (elf32_avr_relax_delete_bytes): Modify symbols
	located at the very end of the section.

ld/ChangeLog:

	* ld/testsuite/ld-avr/relax-02.d: New file.
	* ld/testsuite/ld-avr/relax-02.s: New file.
	* ld/testsuite/ld-avr/relax-03.d: New file.
	* ld/testsuite/ld-avr/relax-03.s: New file.
2014-11-03 20:33:25 +00:00
Nick Clifton 5a3f568b70 More fixes for buffer overruns instigated by corrupt binaries.
PR binutils/17512
	* objdump.c (slurp_symtab): Fail gracefully if the table could not
	be read.
	(dump_relocs_in_section): Likewise.

	* aoutx.h (slurp_symbol_table): Check that computed table size is
	not bigger than the file from which is it being read.
	(slurp_reloc_table): Likewise.
	* coffcode.h (coff_slurp_line_table): Remove unneeded local
	'warned'.  Do not try to print the details of a symbol with an
	invalid index.
	* coffgen.c (make_a_sectiobn_from_file): Check computed string
	index against length of string table.
	(bfd_coff_internal_syment_name): Check read in string offset
	against length of string table.
	(build_debug_section): Return a pointer to the section used.
	(_bfd_coff_read_string_table): Store the length of the string
	table in the coff_tdata structure.
	(bfd_coff_free_symbols): Set the length of the string table to
	zero when it is freed.
	(coff_get_normalized_symtab): Check offsets against string table
	or data table lengths as appropriate.
	* cofflink.c (_bfd_coff_link_input_bfd): Check offset against
	length of string table.
	* compress.c (bfd_get_full_section_contents): Check computed size
	against the size of the file.
	* libcoff-in.h (obj_coff_strings_len): Define.
	(struct coff_tdata): Add strings_len field.
	* libcoff.h: Regenerate.
	* peXXigen.c (pe_print_debugdata): Do not attempt to print the
	data if the debug section is too small.
	* xcofflink.c (xcoff_link_input_bfd):  Check offset against
	length of string table.
2014-11-03 17:44:00 +00:00
Nick Clifton ba241f2d5a Import updated translations supplied by the Translation Project.
bfd, binutils, gprof, opcodes:
	* po/fi.po: Updated Finnish translation.

	binutils:
	* po/sv.po: Updated Swedish translation.

	gprof:
	* po/hu.po: New Hungarian translation.
2014-11-03 12:26:48 +00:00
Alan Modra b71e4c7f63 daily update 2014-11-03 09:31:00 +10:30
Alan Modra a218b38d2e daily update 2014-11-02 09:30:42 +10:30
Alan Modra 657a7d7d23 daily update 2014-11-01 09:30:35 +10:30
Naveen H.S 2c62985659 MIPS: Add Octeon 3 support
binutils:
2014-10-31  Andrew Pinski  <apinski@cavium.com>
            Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>

	* readelf.c (print_mips_isa_ext): Print the value of Octeon3.

gas:
2014-10-31  Andrew Pinski  <apinski@cavium.com>
            Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>

	* config/tc-mips.c (CPU_IS_OCTEON): Handle CPU_OCTEON3.
	(mips_cpu_info_table): Octeon3 enables virt ase.
	* doc/c-mips.texi: Document octeon3 as an acceptable value for
	-march=.

gas/testsuite:
2014-10-31  Andrew Pinski  <apinski@cavium.com>
            Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>

	* gas/mips/mips.exp: Add support for Octeon3 architecture.
	Also add in support for running Octeon3 tests.
	* gas/mips/octeon3.d: New test.
	* gas/mips/octeon3.s: New test source.

opcodes:
2014-10-31  Andrew Pinski  <apinski@cavium.com>
            Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>

	* mips-dis.c (mips_arch_choices): Add octeon3.
	* mips-opc.c (IOCT): Include INSN_OCTEON3.
	(IOCT2): Likewise.
	(IOCT3): New define.
	(IVIRT): New define.
	(mips_builtin_opcodes): Add dmfgc0, dmtgc0, hypcall, mfgc0, mtgc0,
	tlbinv, tlbinvf, tlbgr, tlbgwi, tlbginv, tlbginvf, tlbgwr, tlbgp, tlti
	IVIRT instructions.
	Extend mtm0, mtm1, mtm2, mtp0, mtp1, mtp2 instructions to take another
	operand for IOCT3.

bfd:
2014-10-31  Andrew Pinski  <apinski@cavium.com>
            Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>

	* archures.c: Add octeon3 for mips target.
	* bfd-in2.h: Regenerate.
	* bfd/cpu-mips.c: Define I_mipsocteon3.
	nfo_struct): Add octeon3 support.
	* bfd/elfxx-mips.c: (_bfd_elf_mips_mach): Add support for
	octeon3.
	(mips_set_isa_flags): Add support for octeon3.
	(bfd_mips_isa_ext): Add bfd_mach_mips_octeon3.
	(mips_mach_extensions): Make bfd_mach_mips_octeon3 an
	extension of bfd_mach_mips_octeon2.
	(print_mips_isa_ext): Print the value of Octeon3.
2014-10-31 13:50:10 -07:00
Nick Clifton 690725fa0d Fix an (almost) infinite loop in the tekhex parser.
PR binutils/17512
	* tekhex.c (first_phase): Check that the section range is sane.
2014-10-31 18:00:55 +00:00
Nick Clifton f54498b457 Avoid allocating over-large buffers when parsing corrupt binaries.
PR binutils/17512
	* coffgen.c (_bfd_coff_get_external_symbols): Do not try to load a
	symbol table bigger than the file.
	* elf.c (bfd_elf_get_str_section): Do not try to load a string
	table bigger than the file.

	* readelf.c (process_program_headers): Avoid memory exhaustion due
	to corrupt values in a dynamis segment header.
	(get_32bit_elf_symbols): Do not attempt to read an over-large
	section.
	(get_64bit_elf_symbols): Likewise.
2014-10-31 16:36:31 +00:00
Alan Modra c21c8bde37 daily update 2014-10-31 09:30:33 +10:30
Nick Clifton 0102ea8cec Fixes a seg-fault in the ihex parser when it encounters a malformed ihex file.
PR binutils/17512
	* ihex.c (ihex_scan): Fix typo in invocation of ihex_bad_byte.
2014-10-30 17:16:17 +00:00
Nick Clifton 7e760b06b2 Closes another memory corruption, this time due to heap overrun.
PR binutils/17512
	* coffgen.c (coff_get_normalized_symtab): Prevent buffer overrun.
2014-10-30 15:52:10 +00:00
Alan Modra 0d93a331c2 daily update 2014-10-30 09:30:40 +10:30
Nick Clifton e5b470e24c Fixes another memory corruption bug introduced by patches for PR 17512.
* elf.c (bfd_section_from_shdr): Fix heap use after free memory
	leak.
2014-10-29 20:58:13 +00:00
Dennis Brueni d1e8523e40 Thix fixes an obvious coding error that led to a GDB crash on AIX or HPUX.
* elf.c (elfcore_write_lwpstatus): fix typo in call to memcpy
2014-10-29 17:17:32 +00:00
Alan Modra 5e1b37e7a3 daily update 2014-10-29 09:31:03 +10:30
Nick Clifton 5a4b0ccc20 More fixes for corrupt binaries crashing the binutils.
PR binutils/17512
	* elf.c (bfd_section_from_shdr): Allocate and free the recursion
	detection table on a per-bfd basis.
	* peXXigen.c (pe_print_edata): Handle binaries with a truncated
	export table.
2014-10-28 15:42:56 +00:00
Nick Clifton 708d7d0d11 This patch fixes a flaw in the SREC parser which could cause a stack overflow
and potential secuiryt breach.

	PR binutils/17510
	* srec.c (srec_bad_byte): Increase size of buf to allow for
	negative values.
	(srec_scan): Use an unsigned char buffer to hold header bytes.
2014-10-28 10:48:14 +00:00
Alan Modra 6fb9c0f832 daily update 2014-10-28 09:30:34 +10:30
Nick Clifton bf67003b45 This fixes more seg-faults in tools like "strings" and "objdump" when
presented with corrupt binaries.

	PR binutils/17512
	* elf.c (bfd_section_from_shdr): Detect and warn about ELF
	binaries with a group of sections linked by the string table
	indicies.
	* peXXigen.c (pe_print_edata): Detect out of range rvas and
	entry counts for the Export Address table, Name Pointer table
	 and Ordinal table.
2014-10-27 18:05:37 +00:00
Nick Clifton 7e1e19887a Fix a seg-fault in strings and other binutuils when parsing a corrupt PE
executable with an invalid value in the NumberOfRvaAndSizes field of the
AOUT header.

	PR binutils/17512
	* peXXigen.c (_bfd_XXi_swap_aouthdr_in): Handle corrupt binaries
	with an invalid value for NumberOfRvaAndSizes.
2014-10-27 14:45:06 +00:00
Nick Clifton 493a33860c This patch closes a potential security hole in applications that use
the bfd library to parse binaries containing maliciously corrupt section
group headers.

	PR binutils/17510
	* elf.c (setup_group): Improve handling of corrupt group
	sections.
2014-10-27 12:45:36 +00:00
Alan Modra 4744af9bf6 daily update 2014-10-27 09:30:40 +10:30
Alan Modra 9667818c4e daily update 2014-10-26 09:30:31 +10:30
Alan Modra f5627833b4 daily update 2014-10-25 09:31:03 +10:30
Jiong Wang 68fcca92b7 [AArch64] Cortex-A53 erratum 835769 linker workaround
2014-10-22  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.
2014-10-24 11:39:35 +01:00
Alan Modra 79ccd89e58 daily update 2014-10-24 09:30:51 +10:30
Victor Kamensky 685e70ae51 ARM: plt_size functions need to read instructions in right byte order
elf32_arm_plt0_size and elf32_arm_plt_size read instructions
to determine what is size of PLT entry.  However it does not
read instruction correctly in case of ARM big endian V7 case.
In this case instructions are still kept in little endian
order (BE8).

	* elf32-arm.c (read_code32): New function to read 32 bit
	arm instruction.
	(read_code16): New function to read 16 bit thumb instrution.
	(elf32_arm_plt0_size, elf32_arm_plt_size): Use read_code32
	and read_code16 to read instructions.
2014-10-23 11:53:53 +10:30
Alan Modra 65e84d12a0 daily update 2014-10-23 09:30:53 +10:30
Matthew Fortune 00ac7aa072 Show information about unknown ASEs and extensions in .MIPS.abiflags
bfd/
	* elfxx-mips.c (print_mips_ases): Print unknown ASEs.
	(print_mips_isa_ext): Print the value of an unknown extension.

binutils/

	* readelf.c (print_mips_ases): Print unknown ASEs.
	(print_mips_isa_ext): Print the value of an unknown extension.

include/

	* elf/mips.h (AFL_ASE_MASK): Define.
2014-10-22 10:37:26 +01:00
Alan Modra 6082299641 daily update 2014-10-22 09:30:32 +10:30
Alan Modra 7324227506 Relax ppc64_elf_tls_optimize assertion
The code in ppc64_elf_tls_optimize looking at the .toc is only
interested in .toc entries that are addresses.  .toc can contain more
than just an array of addresses, so if we have items that aren't
8-byte aligned, ignore them.

	* elf64-ppc.c (ppc64_elf_tls_optimize): Ignore relocs against toc
	entries that aren't a multiple of 8 rather than failing assertion.
2014-10-21 21:05:15 +10:30
Alan Modra 2300b5a141 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.

	* elf64-ppc.c (ppc64_elf_size_stubs): Add gcc-4.9 libgomp functions
	to thread_starter.
2014-10-21 17:17:36 +10:30
Alan Modra 5c0ac14e47 daily update 2014-10-21 09:30:53 +10:30
Alan Modra c6ecbe44d8 daily update 2014-10-20 09:30:41 +10:30
Alan Modra 5bb926bae5 daily update 2014-10-19 09:30:47 +10:30
Alan Modra b53dfeb26e 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.
2014-10-18 23:07:08 +10:30
Alan Modra bf97b6dd05 daily update 2014-10-18 09:30:32 +10:30
Alan Modra 48cfaa5c1d daily update 2014-10-17 09:31:12 +10:30
Alan Modra f1885d1e59 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.
2014-10-16 21:18:16 +10:30
Alan Modra 459609d6f8 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.
2014-10-16 11:22:14 +10:30