Commit Graph

2789 Commits

Author SHA1 Message Date
Ronald Hoogenbllon 2b35fb28f3 Add ability for objcopy to insert new symbols into a binary.
PR binutils/19104
binutils * objcopy.c (command_line_switch): Add OPTION_ADD_SYMBOL.
	(copy_options): Add add-symbol.
	(copy_usage): Likewise.
	(parse_symflags): New function.
	(need_sym_before): New function.
	(create_new_symbol): New function.
	(filter_symbols): Add code to insert new symbols.
	(copy_main): Process OPTION_ADD_SYMBOL.
	* doc/binutils.texi: Document new feature.
	* NEWS: Add note about the new feature.

tests	* binutils-all/add-symbol.d: New test.
	* binutils-all/objcopy.exp: Run the new test.
2015-10-21 15:16:35 +01:00
Paul Pluzhnikov 595712bb07 Fix PR binutils/19147 -- off by one when printing NT_FILE note. 2015-10-18 09:39:25 -07:00
Alan Modra 21c40443ce binutils objcopy test tidy
The main aim of this patch is to perform more objcopy tests when we
can build executables but not run them.  ie. non-native with cross
compiler available.

	* binutils-all/objcopy.exp: Delete trailing whitespace.  Use
	"string equal" rather than "string match" when making simple
	string comparisons.  Revert 2008-07-08 host_triplet checks.
	Perform non-run tests when we can build executable.
	(strip_executable, strip_executable_with_saving_a_symbol): Move
	run test later.  Take extra param on whether to perform run test.
	Update callers.
	(keep_debug_symbols_and_test_copy): Delete unused vars.
2015-10-15 23:38:29 +10:30
Alan Modra e43fb83166 objcopy --extract-symbol
Calling bfd_copy_private_bfd_data is necessary to copy ELF file header
info.

binutils/
	* objcopy.c (copy_object): Don't omit bfd_copy_private_bfd_data
	call when extract_symbol.
bfd/
	* elf32-v850.c (v850_elf_copy_private_bfd_data): Remove assertion
	that input and output .note.renesas sections are same size.
	Instead, only copy input to output if they are.
2015-10-15 23:38:29 +10:30
Andrew Burgess 431ff0756a avr: Fix bugs in org/align tracking.
This commit fixes a few issues in the mechanism for passing information
about ".org" and ".align" directives from the assembler to the linker,
used by the avr target.

In the original commit fdd410ac7a, there
were some mistakes when writing out information about ".align"
directives:
  - An align with fill does not write out its information correctly, the
    fill data overwrites the alignment data.
  - Each alignment directive is recorded at the location where the
    previous alignment directive should be recorded, the first alignment
    directive is discarded.

In commit 137c83d69f, the data produced by
objdump is not correct:
   - It's miss-aligned due to a missing whitespace.
   - The fill data for align with fill records is not displayed
     correctly.

All of the above issues are addressed in this commit, and the test is
improved to cover these cases.

binutils/ChangeLog:

	* od-elf32_avr.c (elf32_avr_dump_avr_prop): Fix printing of align
	specific data, fix formatting for align and org data.

gas/ChangeLog:

	* config/tc-avr.c (avr_output_property_record): Fix overwrite bug
	for align and fill records.
	(avr_handle_align): Record fill information for align frags.
	(create_record_for_frag): Add next frag assertion, use correct
	address for align records.

gas/testsuite/ChangeLog:

	* gas/avr/avr-prop-1.s: Use fill in some cases.
	* gas/avr/avr-prop-1.d: Update expected results.
2015-10-12 09:43:11 +01:00
Nick Clifton 886a250647 New ARC implementation.
bfd	* archures.c: Remove support for older ARC. Added support for new
	ARC cpus (ARC600, ARC601, ARC700, ARCV2).
	* bfd-in2.h: Likewise.
	* config.bfd: Likewise.
	* cpu-arc.c: Likewise.
	* elf32-arc.c: Totally changed file with a refactored
	inplementation of the ARC port.
	* libbfd.h: Added ARC specific relocation types.
	* reloc.c: Likewise.

gas     * config/tc-arc.c: Revamped file for ARC support.
        * config/tc-arc.h: Likewise.
        * doc/as.texinfo: Add new ARC options.
        * doc/c-arc.texi: Likewise.

ld	* configure.tgt: Added target arc-*-elf* and arc*-*-linux-uclibc*.
	* emulparams/arcebelf_prof.sh: New file
	* emulparams/arcebelf.sh: Likewise.
	* emulparams/arceblinux_prof.sh: Likewise.
	* emulparams/arceblinux.sh: Likewise.
	* emulparams/arcelf_prof.sh: Likewise.
	* emulparams/arcelf.sh: Likewise.
	* emulparams/arclinux_prof.sh: Likewise.
	* emulparams/arclinux.sh: Likewise.
	* emulparams/arcv2elfx.sh: Likewise.
	* emulparams/arcv2elf.sh: Likewise.
	* emultempl/arclinux.em: Likewise.
	* scripttempl/arclinux.sc: Likewise.
	* scripttempl/elfarc.sc: Likewise.
	* scripttempl/elfarcv2.sc: Likewise
	* Makefile.am: Add new ARC emulations.
	* Makefile.in: Regenerate.
	* NEWS: Mention the new feature.

opcodes * arc-dis.c: Revamped file for ARC support
	* arc-dis.h: Likewise.
	* arc-ext.c: Likewise.
	* arc-ext.h: Likewise.
	* arc-opc.c: Likewise.
	* arc-fxi.h: New file.
	* arc-regs.h: Likewise.
	* arc-tbl.h: Likewise.

binutils * readelf.c (get_machine_name): Remove A5 reference. Add ARCompact
	and ARCv2.
	(get_machine_flags): Handle EM_ARCV2 and EM_ARCOMPACT.
	(guess_is_rela): Likewise.
	(dump_relocations): Likewise.
	(is_32bit_abs_reloc): Likewise.
	(is_16bit_abs_reloc): Likewise.
	(is_none_reloc): Likewise.
	* NEWS: Mention the new feature.

include	* dis-asm.h (arc_get_disassembler): Correct declaration.
	* arc-reloc.def: Macro file with definition of all relocation
	types.
	* arc.h: Changed macros for the newly supported ARC cpus.  Altered
	enum defining the supported relocations.
	* common.h: Changed EM_ARC_A5 definition to EM_ARC_COMPACT. Added
	macro for EM_ARC_COMPACT2.
        * arc-func.h: New file.
        * arc.h: Likewise.
2015-10-07 14:20:19 +01:00
H.J. Lu 4ee959fb24 Handle symbolic link when copying source file
* lib/utils-lib.exp (run_dump_test): Handle symbolic link when
	copying source file.
2015-09-30 10:50:36 -07:00
H.J. Lu cbd44e247e Don't use the output section size to copy input section
We can't use the output section size to copy input section since
--interleave will shrink the output section.  Instead, we change
bfd_convert_section_contents to return the updated input section
size.  When we do that, we don't need to adjust the output section
size to skip gap fills.

bfd/

	PR binutils/19020
	* bfd.c (bfd_convert_section_contents): Add ptr_size parameter.
	* bfd-in2.h: Regenerated.

binutils/

	PR binutils/19020
	* objcopy.c (copy_object): Don't adjust the output section size
	when copying from input sections.
	(copy_section): Use input section size for the copy.  Get the
	updated section size from bfd_convert_section_contents.

binutils/testsuite/

	PR binutils/19020
	* binutils-all/objcopy.exp: Run pr19020a and pr19020b.
	* lib/utils-lib.exp (run_dump_test): Support binary input.
	* binutils-all/pr19020.in: New file.
	* binutils-all/pr19020a.d: Likewise.
	* binutils-all/pr19020b.d: Likewise.
2015-09-29 13:31:57 -07:00
H.J. Lu c68c163716 Adjust the output section size to skip gap fills
In objcopy, copy_object calls copy_section to copy contents of input
section to output section.  When --gap-fill= is used, objcopy extends
the size of output sectios to fill gaps between output sections with
gap fills.  In this case, we adjust the output section size to skip
gap files to avoid reading beypond the input section buffer before
calling copy_section and restore the output section size after input
sections have been copied.

binutils/

	PR binutils/19005
	* objcopy.c (copy_object): Adjust the output section size to
	skip gap fills between sections when copying from input sections
	to output sections.

ld/testsuite/

	PR binutils/19005
	* ld-elf/pr19005.d: New file.
	* ld-elf/pr19005.s: Likewise.
	* ld-elf/pr19005.t: Likewise.
2015-09-29 06:33:24 -07:00
Nick Clifton b08b78e7d4 Updare French translation for binutils and German translation for opcodes. 2015-09-28 16:34:00 +01:00
jamesbowman 9a09557a93 The FT32's disassembly of 10-bit literals has the incorrect mask.
[opcodes]
	* ft32-dis.c (print_insn_ft32): Fix incorrect data field mask.
2015-09-25 12:33:30 -07:00
Nick Clifton 6a40cf0c5c Add support for files that contain multiple symbol index tables. Fixes PR 15835
binutils	PR binutils/15835
	* readelf.c (struct elf_section_list): New structure.
	(symtab_shndx_hdr): Replace with symtab_shndx_list.
	(get_32bit_elf_symbols): Scan for a symbol index table matching
	the symbol table in use.
	(get_64bit_elf_symbols): Likewise.
	(process_section_headers): Handle multiple symbol index sections.

bfd	* elf-bfd.h (struct elf_section_list): New structure.
	(struct elf_obj_tdata): Replace symtab_shndx_hdr with
	symtab_shndx_list.  Delete symtab_shndx_section.
	(elf_symtab_shndx): Replace macro with elf_symtab_shndx_list.
	* elf.c (bfd_elf_get_syms): If symtab index sections are present,
	scan them for the section that matches the provided symbol table.
	(bfd_section_from_shdr): Record all SHT_SYMTAB_SHNDX sections.
	(assign_section_numbers): Use the first symtab index table in the
	list.
	(_bfd_elf_compute_section_file_positions): Replace use of
	symtab_shndx_hdr with use of symtab_shndx_list.
	(find_section_in_list): New function.
	(assign_file_postions_except_relocs): Use new function.
	(_bfd_elf_copy_private_symbol_data): Likewise.
	(swap_out_syms): Handle multiple symbol table index sections.
	* elf32-m32c.c (m32c_elf_relax_section): Replace use of
	symtab_shndx_hdr with use of symtab_shndx_list.
	* elf32-rl78.c (rl78_elf_relax_section): Likewise.
	* elf32-rx.c (rx_relax_section): Likewise.
	* elf32-v850.c (v850_elf_relax_delete_bytes): Likewise.
	* elflink.c (bfd_elf_final_link): Likewise.
2015-09-23 17:23:58 +01:00
Rainer Orth 5c383f0262 Solaris PIE support
include/elf:
	* common.h (DF_1_STUB, DF_1_PIE): Define.

	ld:
	* emulparams/solaris2.sh (GENERATE_PIE_SCRIPT): Set to yes.

	* emultempl/elf32.em: Include ldlex.h.
	(gld${EMULATION_NAME}_handle_option) [GENERATE_PIE_SCRIPT]
	<OPTION_PIE>: Set DF_1_PIE.

	binutils:
	* readelf.c (process_dynamic_section): Handle DF_1_STUB, DF_1_PIE.
2015-09-22 11:12:51 +02:00
Erik Ackermann 55edd97b4b Adds an option to the strings program to specify a separator between the emitted pieces of text.
* strings.c: Add -s/--output-separator option to specify custom
	separator string.
	* NEWS: Mention the new feature.
	* doc/binutils.text (strings): Document the new command line
	option.
2015-09-10 09:29:13 +01:00
Nick Clifton d8f187c1ab Remove sentance in binutils documentation saying that thin archives cannot contain absolute paths or paths outside of the current directory - they can.
* doc/binutils.texi (ar): Remove bogus sentance concerning thin
	archives and invalid paths.
2015-09-09 14:33:31 +01:00
Nick Clifton 1a9155522d Fix seg-fault in readelf when scanniing a corrupt binary.
PR binutils/18879
	* readelf.c (get_unwind_section_word): Check for negative offsets
	and very small sections.
	(dump_arm_unwind): Warn if the table offset is too large.
2015-09-03 16:15:49 +01:00
H.J. Lu 32a40e8ea9 Also install readelf into tooldir/bin directory
* Makefile.am (TOOL_PROGS): Add readelf.
	* Makefile.in: Regenerated.
2015-08-28 08:34:44 -07:00
Yaakov Selkowitz cfe101c6a8 Missing parts of fixes for in-tree libiconv
(Commit d23d1dff missed pushing the config/iconv.m4 change, and to
regenerate binutils' configure.)

Original description:

This is the second in a series of patches to make a build with an
in-tree GNU libiconv work as designed.

Currently GDB is the only toolchain component which actually uses an
in-tree libiconv.  This patch modifies the common AM_ICONV to use an
in-tree libiconv when present and not already provided by libc.
(GDB's workaround uses an in-tree libiconv even when libc provides
iconv(3); I'm not sure when or why that would be desirable.)

config/ChangeLog:
2015-08-24  Yaakov Selkowitz  <yselkowi@redhat.com>

	* iconv.m4 (AM_ICONV_LINK): Use in-tree libiconv when present.

binutils/ChangeLog:
2015-08-24  Yaakov Selkowitz  <yselkowi@redhat.com>

	* configure: Regenerate.
2015-08-24 10:57:03 +01:00
Alan Modra 2309f87570 Regen binutils/configure
Looks like previous regen wasn't using current sources.

	* configure: Regenerate.
2015-08-17 12:07:12 +09:30
H.J. Lu 3aade68889 Remove trailing spaces in binutils 2015-08-12 04:42:37 -07:00
Alan Modra c8373ebb4e Tweak binutils testsuite
Some targets provide aligned .bss sections, so explicitly align.
msp430 and rl78 emit "magic" symbols when assembling symbol.s, and
mips targets emit STT_OBJECT rather than STT_NOTYPE syms.

	* binutils-all/strip-12.s: Align .bss section.
	* binutils-all/strip-12.d: Adjust.
	* binutils-all/symbols-1.d: Allow extraneous symbols.
	* binutils-all/symbols-2.d: Likewise, and V for weakened syms.
	* binutils-all/symbols-3.d: Likewise.
	* binutils-all/symbols-4.d: Likewise.
2015-08-11 23:29:36 +09:30
Hans-Peter Nilsson 0a77d46120 binutils-all/strip-12.s: Use ".section .bss" instead of ".bss"
which isn't supported by all ELF targets.
2015-08-08 01:07:30 +02: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
Andrew Burgess 0b45135ec1 objcopy: Improve wildcard matching for symbols with '!' prefix.
When using options such as --localize-symbol, --globalize-symbol, etc,
along with the --wildcard option, prefixing a symbol name with '!'
should provide non-matching behaviour, as example the following example
is given in the manual:

    --wildcard --weaken-symbol !foo --weaken-symbol fo*

which should weaken all symbols matching the pattern 'fo*', but not the
symbol 'foo'.

However, this currently does not work, the current logic will waken all
symbols matching the pattern 'fo*' AND all symbols that are not 'foo'.
The symbol 'foo' is covered by the first condition, and so is weakened,
while, other symbols, for example 'bar' will match the second condition,
and so be weakened.

This patch adjusts the logic so that a pattern prefixed with '!'
specifically DOES NOT apply the relevant change to any matching symbols,
instead of applying the change to all non-matching symbols.  So this:

    --weaken-symbol !foo

will ensure that the symbol 'foo' is not weakened, but says nothing
about symbols that are not 'foo'.  As a result, a pattern prefixed with
'!' now only makes sense when used alongside a more wide ranging
wildcard pattern.

This change should make the wildcard matching feature more useful, with
no overall loss of functionality.  The example given in the manual,
weaken all symbols matching 'fo*' except 'foo' can now be achieved, but
so too can more complex examples, such as weaken all symbols matching
'fo*' except 'foo', 'foa', and 'fob', like this:

    --wildcard --weaken-symbol !foo \
               --weaken-symbol !foa \
               --weaken-symbol !fob \
               --weaken-symbol fo*

Under the previous scheme, something as symbols as, weaken all symbols
except 'foo' could have been achieved with this:

    --weaken-symbol !foo

however, this will no longer work.  To achieve the same result under the
new scheme this is now required:

    --weaken-symbol !foo --weaken-symbol *

binutils/ChangeLog:

	* objcopy.c (is_specified_symbol_predicate): Don't stop at first
	match.  Non-match rules set found to FALSE.

binutils/testsuite/ChangeLog:

	* binutils-all/objcopy.exp: Run new symbol tests.
	(objcopy_test_symbol_manipulation): New function.
	* binutils-all/symbols-1.d: New file.
	* binutils-all/symbols-2.d: New file.
	* binutils-all/symbols-3.d: New file.
	* binutils-all/symbols-4.d: New file.
	* binutils-all/symbols.s: New file.
2015-08-07 11:41:40 +02:00
DJ Delorie 016a325163 Yaakov Selkowitz: fixes for in-tree libiconv
* Makefile.def (libiconv): Define bootstrap=true.
        Mark pdf/html/info as missing.
        (configure-gcc): Depend on all-libiconv.
        (all-gcc): Ditto.
        (configure-libcpp): Ditto.
        (all-libcpp): Ditto.
        (configure-intl): Ditto.
        (all-intl): Ditto.
        * Makefile.in: Regenerate.

binutils/
        * configure: Regenerate.

gdb/
        * Makefile.in (LIBICONV): Define.
        (CLIBS): Add LIBICONV.
        * acinclude.m4: Use config/iconv.m4 instead of custom AM_ICONV.
        * configure: Regenerate.
2015-08-06 23:55:06 -04: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
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
Nick Clifton 4e13f8fb05 Fix memory leak in ar if it encounters an invalid path whilst extracting files.
* ar.c (extract_file): Free cbuf if the path is invalid.
2015-08-04 14:50:40 +01:00
Nick Clifton beab5d94ab Update description of proc run_dump_test
* lib/utils-lib.exp (run_dump_test): Document DUMPPROG, readelf
	and size parameters.  Alpha-sort switch tables.  Include
	addr2line, and size in list of possible auto-detected dump
	programs.
2015-08-04 08:19:12 +01: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
H.J. Lu 7cb9e39bd8 Use 0xffffffffffffffffLL to silence GCC 6 warning
GCC 6 warns:

error: result of ‘4294967295ll << 32’ requires 65 bits to represent, but ‘long long int’ only has 64 bits [-Werror=shift-overflow=]

on ((((bfd_signed_vma) 0xffffffff) << 32) | 0xffffffff).  This patch
replaces it with bfd_signed_vma) 0xffffffffffffffffLL.

	* stabs.c (parse_stab_range_type): Use 0xffffffffffffffffLL.
2015-07-24 09:05:33 -07:00
Nick Clifton aff1a65ecb Fix the evaluation of RL78 complex relocs, by making immediate values be computed relative to a new absolute symbol.
gas	* config/tc-rl78.c (rl78_abs_sym): New local variable.
	(md_begin): Initialise the new symbol.
	(OPIMM): Define the value to be relative to the new symbol and not
	the absolute section symbol.

ld	* emulparams/elf32rl78.sh (OTHER_SECTIONS): Provide a value for
	the _-rl78_abs__ symbol.

tests	* gas/all/struct.d: Allow for extra symbols in the output.
	* gas/macros/test1.d: Likewise.
	* gas/elf/elf.exp: Add an rl78 machine.
	* gas/elf/sections2e-rl78: New file.

tests	* binutils-all/localize-hidden-1.d: Allow for extra symbols in the
	output.
        * binutils-all/strip-11.d: Skip for the RL78.
2015-07-24 16:44:27 +01:00
H.J. Lu 72f4393d8c Remove leading/trailing white spaces in ChangeLog 2015-07-24 04:16:47 -07:00
Alan Modra 7360e63f80 readelf display of 0x800...000 addend
* readelf.c (dump_relocations): Show MIN_INT addends as negative.
2015-07-23 00:45:54 +09:30
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
Alan Modra 53c3012ccc Correct readelf dynamic section buffer overlow test
PR binutils/18672
	* readelf.c (get_32bit_dynamic_section): Correct buffer limit test.
	(get_64bit_dynamic_section): Likewise.
2015-07-17 00:27:10 +09:30
H.J. Lu 19a7fe52ae Make default compression gABI compliant
All programs in binutils+gdb git repo now support gABI compression
with the SHF_COMPRESSED bit.  This patch makes the zlib-gabi option
as compression default for gas, gold, ld and objcopy, instead of the
zlib-gnu option whose outputs are incompatible with gABI.

binutils/

	* objcopy.c (copy_file): Set BFD_COMPRESS_GABI if not
	zlib-gnu.
	* doc/binutils.texi: Change --compress-debug-sections and
	--compress-debug-sections=zlib to zlib-gabi.

binutils/testsuite/

	* binutils-all/compress.exp: Update.

gas/

	* as.c (parse_args): Make --compress-debug-sections and
	--compress-debug-sections=zlib the same as
	--compress-debug-sections=zlib-gabi.
	* doc/as.texinfo: Change --compress-debug-sections and
	--compress-debug-sections=zlib to zlib-gabi.

gold/

	* compressed_output.cc (Output_compressed_section::set_final_data_size):
	Make --compress-debug-sections=zlib the same as
	--compress-debug-sections=zlib-gabi.
	* testsuite/Makefile.am (flagstest_compress_debug_sections.check):
	Expect ".debug_.*" with the SHF_COMPRESSED bit, instead of
	".zdebug_".
	* testsuite/Makefile.in: Regenerated.

ld/

	* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Make
	--compress-debug-sections=zlib the same as
	--compress-debug-sections=zlib-gabi.
	* ld.texinfo: Change --compress-debug-sections=zlib to zlib-gabi.

ld/testsuite/

	* ld-elf/zlibbegin.rS: Updated to .debug_.* with the
	SHF_COMPRESSED bit.
	* ld-elf/zlibnormal.rS: Likewise.
2015-07-14 10:26:23 -07: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
H.J. Lu 813dabb9f0 Warn unsupported compress type and corrupted compressed section
* readelf.c (dump_section_as_strings): Warn unsupported compress
	type and corrupted compressed section.
	(dump_section_as_bytes): Likewise.
	(load_specific_debug_section): Likewise.
2015-07-10 10:23:12 -07:00
H.J. Lu be0496857f Updated to accept .debug_* sections
* binutils-all/dw2-3.W: Updated to accept .debug_* sections.
2015-07-10 08:14:59 -07:00
Catherine Moore 3350cc01de 2015-07-09 Catherine Moore <clm@codesourcery.com>
include/
        * elf/mips/mips.h (Val_GNU_MIPS_ABI_FP_NAN2008): New.

        gas/
        * config/tc-mips.c (check_fpabi):  Handle
        VAL_GNU_MIPS_ABI_FP_NAN2008.

        binutils/
        * readelf.c (print_mips_fp_abi_value): Handle
        Val_GNU_MIPS_ABI_FP_NAN2008.

        ld/testsuite/
        * ld-mips-elf/attr-gnu-4-08.d: Update expected output.
        * ld-mips-elf/attr-gnu-4-09.d: New.
        * ld-mips-elf/attr-gnu-4-19.d: New.
        * ld-mips-elf/attr-gnu-4-29.d: New.
        * ld-mips-elf/attr-gnu-4-39.d: New.
        * ld-mips-elf/attr-gnu-4-49.d: New.
        * ld-mips-elf/attr-gnu-4-59.d: New.
        * ld-mips-elf/attr-gnu-4-69.d: New.
        * ld-mips-elf/attr-gnu-4-79.d: New.
        * ld-mips-elf/attr-gnu-4-89.d: New.
        * ld-mips-elf/attr-gnu-4-9.s: New.
        * ld-mips-elf/mips-elf.exp: Run new tests.
2015-07-09 08:26:10 -07: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
Nick Clifton bdc4de1b24 Stop "objdump -d" from disassembling past a symbolic address.
include	* dis-asm.h (struct disassemble_info): Add stop_vma field.

binuti  * objdump.c (disassemble_bytes): Set the stop_vma field in the
	disassemble_info structure when disassembling code sections with
	-d.
	* doc/binutils.texi (objdump): Document the discrepancy between -d
	and -D.

opcodes	* dis-buf.c (buffer_read_memory): Fail is stop_vma is set and the
	requested region lies beyond it.
	* bfin-dis.c (print_insn_bfin): Ignore sysop instructions when
	looking for 32-bit insns.
	* mcore-dis.c (print_insn_mcore): Disable stop_vma when reading
	data.
	* sh-dis.c (print_insn_sh): Likewise.
	* tic6x-dis.c (print_insn_tic6x): Disable stop_vma when reading
	blocks of instructions.
	* vax-dis.c (print_insn_vax): Check that the requested address
	does not clash with the stop_vma.

tests	* gas/arm/backslash-at.s: Add extra .byte directives so that the
	foo symbol does not appear to point half way through an
	instruction.
	* gas/arm/backslash-at.d: Update expected disassembly.
	* gas/i386/ilp32/x86-64-opcode-inval-intel.d: Likewise.
	* gas/i386/ilp32/x86-64-opcode-inval.d: Likewise.
	* gas/i386/x86-64-opcode-inval-intel.d: Likewise.
	* gas/i386/x86-64-opcode-inval.d: Likewise.
2015-06-22 16:53:27 +01:00
Nick Clifton 8fcc61b42b Improves the detection of partial .debug_line sections.
* dwarf.c (read_debug_line_header): Use reloc_at to detect
	incomplete .debug_line headers
2015-06-05 16:58:35 +01:00
Roland McGrath 14ae95f220 Recognize GNU_ABI_TAG_SYLLABLE and GNU_ABI_TAG_NACL.
binutils/
	* readelf.c (print_gnu_note: NT_GNU_ABI_TAG): Recognize
	GNU_ABI_TAG_SYLLABLE and GNU_ABI_TAG_NACL.

include/elf/
	* common.h (GNU_ABI_TAG_SYLLABLE): New macro.
	(GNU_ABI_TAG_NACL): New macro.
2015-05-29 09:13:53 -07:00
Stephen Kitt 030f4c7f08 Fixes a couple of bugs reported in dlltool.
* dlltool.c (make_one_lib_file): Clear .idata$6 before use.
	(main): Fail if the output file specified by the -z option cannot
	be opened.
2015-05-29 11:03:03 +01:00
Ed Maste 7e16ef3474 All FreeBSD targets are ELF except i?86-*-freebsd\[12\].*.
FreeBSD has used ELF for all targets for more than 15 years. Add
*-*-freebsd* except i?86-*-freebsd\[12\].* to is_elf_format. Update
is_aout_format to include a trailing dot, so that it does not match
freebsd-10.0 and later.
2015-05-26 22:52:39 +09:30
Nick Clifton b4477bc818 Fix seg-fault in readelf when decoding corrupt IA64 unwind information.
PR binutils/18420
	* ia64-unwind.c (unw_decode): Add end parameter.  Pass parameter
	on to decode functions.
	(unw_devode_p2_p5): Pass end paraemter to UNW_DEC_SPILL_MASK.
	(UNW_DEC_SPILL_MASK): Add end parameter.  Check that unw_rlen does
	not take us beyond the end of the buffer.
	* ia64-unwind.h (unw_decode): Update prototype.
	* readelf.c (dump_ia64_unwind): Pass end pointer to unw_decode.
2015-05-18 15:58:46 +01:00
Nick Clifton 35d7c4317b Fix dw-2 test for 16-bit targets.
* binutils-all/dw2-3.S: Replace .int with .4byte.
2015-05-18 14:36:15 +01:00
H.J. Lu fd8008d83c Change pointers from char * to unsigned char *
GCC 4.2 complaints:

cc1: warnings being treated as errors
binutils/readelf.c:12057: warning: dereferencing type-punned pointer will break strict-aliasing rules

This patch silences this GCC warning.

	* readelf.c (dump_section_as_strings): Change pointers from
	char * to unsigned char *.
2015-05-15 10:29:03 -07:00
H.J. Lu 5db04b0965 Support AMD64/Intel ISAs in assembler/disassembler
AMD64 spec and Intel64 spec differ in direct unconditional branches in
64-bit mode.  AMD64 supports direct unconditional branches with 16-bit
offset via the data size prefix, which truncates RIP to 16 bits, while
the data size prefix is ignored by Intel64.

This patch adds -mamd64/-mintel64 option to x86-64 assembler and
-Mamd64/-Mintel64 option to x86-64 disassembler.  The most permissive
ISA, which is AMD64, is the default.

GDB can add an option, similar to

(gdb) help set disassembly-flavor
Set the disassembly flavor.
The valid values are "att" and "intel", and the default value is "att".

to select which ISA to disassemble.

binutils/

	PR binutis/18386
	* doc/binutils.texi: Document -Mamd64 and -Mintel64.

gas/

	PR binutis/18386
	* config/tc-i386.c (OPTION_MAMD64): New.
	(OPTION_MINTEL64): Likewise.
	(md_longopts): Add -mamd64 and -mintel64.
	(md_parse_option): Handle OPTION_MAMD64 and OPTION_MINTEL64.
	(md_show_usage): Add -mamd64 and -mintel64.
	* doc/c-i386.texi: Document -mamd64 and -mintel64.

gas/testsuite/

	PR binutis/18386
	* gas/i386/i386.exp: Run x86-64-branch-2 and x86-64-branch-3.
	* gas/i386/x86-64-branch.d: Also pass -Mintel64 to objdump.
	* gas/i386/ilp32/x86-64-branch.d: Likewise.
	* gas/i386/x86-64-branch-2.d: New file.
	* gas/i386/x86-64-branch-2.s: Likewise.
	* gas/i386/x86-64-branch-3.l: Likewise.
	* gas/i386/x86-64-branch-3.s: Likewise.

ld/testsuite/

	PR binutis/18386
	* ld-x86-64/tlsgdesc.dd: Also pass -Mintel64 to objdump.
	* ld-x86-64/tlspic.dd: Likewise.
	* ld-x86-64/x86-64.exp (x86_64tests): Also pass -Mintel64 to
	objdump for tlspic.dd and tlsgdesc.dd.

opcodes/

	PR binutis/18386
	* i386-dis.c: Add comments for '@'.
	(x86_64_table): Use '@' on call/jmp for X86_64_E8/X86_64_E9.
	(enum x86_64_isa): New.
	(isa64): Likewise.
	(print_i386_disassembler_options): Add amd64 and intel64.
	(print_insn): Handle amd64 and intel64.
	(putop): Handle '@'.
	(OP_J): Don't ignore the operand size prefix for AMD64 in 64-bit.
	* i386-gen.c (cpu_flags): Add CpuAMD64 and CpuIntel64.
	* i386-opc.h (AMD64): New.
	(CpuIntel64): Likewise.
	(i386_cpu_flags): Add cpuamd64 and cpuintel64.
	* i386-opc.tbl: Add direct call/jmp with Disp16|Disp32 for AMD64.
	Mark direct call/jmp without Disp16|Disp32 as Intel64.
	* i386-init.h: Regenerated.
	* i386-tbl.h: Likewise.
2015-05-15 09:48:10 -07:00
Nick Clifton 0e602686df Add --decompress option to readelf to decompress sections before they are dumped.
bin	* readelf.c (options): Add "decompress".
	(usage): Mention -z/--decompress.
	(parse_args): Handle -z.
	(uncompress_section_contents): Move to earlier in the file.
	(dump_section_as_strings): If requested, decompress the section
	before dumping.
	(dump_section_as_bytes): Likewise.
	* doc/binutils.texi: Document the new option.

tests	* binutils-all/z.s: New test.  Checks the --decompress option to
	readelf.
	* binutils-all/readelf.exp: Run the test.
	* binutils-all/readelf.z: Expected output from readelf.
2015-05-15 17:16:31 +01:00
Nick Clifton d1c4b12b9d Fix PR18374 by making readelf and objdump ignore end-of-list markers in the .debug_loc section if there are relocations against them.
PR binutils/18374
bin	* dwarf.h (struct dwarf_section): Add reloc_info and num_relocs
	fields.
	(struct dwarf_section_display): Change bitfield to boolean.
	(reloc_at): Add prototype.
	* dwarf.c (display_loc_list): Ignore list terminators if there are
	relocs against them.
	(display_debug_loc): Issue a warning if there are relocs against
	the .debug_loc section.
	(display_displays): Initialise reloc_info and num_relocs fields.
	* objdump.c (load_specific_debug_section): Initialise reloc_info
	and num_relocs fields.
	(reloc_at): New function.
	* readelf.c (is_32bit_abs_reloc): Add IA64's R_IA64_DIS32LSB
	reloc.
	(reloc_at): New function.
	(apply_relocations): Add relocs_return and num_relocs_return
	parameters.  Fill them in with the loaded relocs if non-NULL.
	(dump_section_as_bytes): Update call to apply_relocations.
	(load_specific_debug_section): Initialise reloc_info and
	num_relocs fields.

tests	* binutils-all/pr18374.s: New test file.
	* binutils-all/readelf.exp: Assemble and run the new test.
	* binutils-all/readelf.pr18374: Expected output from readelf.
2015-05-15 11:24:33 +01:00
Peter Bergner 4bc0608a8b Fix some PPC assembler errors.
Remove the wait instructions for server processors, since they were never
implemented.  Also add the extra operands added to the tlbie and slbia
instructions with ISA 2.06 and ISA 2.05 respectively.

binutils/
	* MAINTAINERS: Add myself as PPC maintainer.

opcodes/
        * ppc-opc.c (IH) New define.
        (powerpc_opcodes) <wait>: Do not enable for POWER7.
        <tlbie>: Add RS operand for POWER7.
        <slbia>: Add IH operand for POWER6.

gas/testsuite/
        * gas/ppc/power4.d: Add a slbia test.
        * gas/ppc/power4.s: Likewise.
        * gas/ppc/power6.d: Add slbia and tlbie tests.
        * gas/ppc/power6.s: Likewise.
        * gas/ppc/power7.d: Remove wait tests. Add a tlbie test.
        * gas/ppc/power7.s: Likewise.
2015-05-14 21:02:50 -05:00
H.J. Lu dab394de9e Don't add the zlib header to SHF_COMPRESSED section
In a SHF_COMPRESSED compressed section, the raw compressed data should
begin immediately after the compression header.  This patch removes the
extra zlib header from the SHF_COMPRESSED section.

bfd/

	* bfd.c (bfd_update_compression_header): Also write the zlib
	header if the SHF_COMPRESSED bit cleared..
	(bfd_check_compression_header): Return the uncompressed size.
	* compress.c (decompress_contents): Don't skip the zlib header.
	(bfd_compress_section_contents): Properly handle ELFCOMPRESS_ZLIB,
	which doesn't have the zlib header.
	(bfd_init_section_decompress_status): Likewise.
	(bfd_get_full_section_contents): Updated.
	(bfd_is_section_compressed): Likewise.
	(bfd_is_section_compressed_with_header): Return the uncompressed
	size.
	* elf.c (_bfd_elf_make_section_from_shdr): Updated.
	* bfd-in2.h: Regenerated.

binutils/

	* readelf.c (uncompress_section_contents): Add a parameter for
	uncompressed size.  Don't check the zlib header.
	(load_specific_debug_section): Updated.

binutils/testsuite/

	* binutils-all/compress.exp: Replace "$OBJDUMP -s -j .debug_info"
	with "$OBJDUMP -W".
	* binutils-all/libdw2-compressedgabi.out: Updated.

gas/

2015-05-14  H.J. Lu  <hongjiu.lu@intel.com>

	* write.c (compress_debug): Don't write the zlib header, which
	is handled by bfd_update_compression_header.
2015-05-14 16:02:08 -07:00
H.J. Lu aa9f728672 Return ELF_CLASS_BOTH by default
* elfedit.c (elf_class): Return ELF_CLASS_BOTH by default.
2015-05-13 03:57:46 -07:00
Andreas Krebbel 6604eb5f40 MAINTAINERS: Add myself as s390 and s390x maintainer.
binutils/
	* MAINTAINERS: Add myself as s390 and s390x maintainer.
2015-05-13 08:19:45 +02:00
H.J. Lu 98624574ea Also skip x86_64-*-nacl*
* binutils-all/elfedit-1.d: Also skip x86_64-*-nacl*.
2015-05-12 12:47:27 -07:00
Stephen Kitt 5b155b955a Enables the -t abbreviated form of the --temp-prefix command line option for dlltool.
* dlltool.c (main): Accept -t as an abbreviation for
	--temp-prefix.
2015-05-12 11:16:03 +01:00
H.J. Lu e83c417475 Allow mixing target and not-target directives
Mixing target and not-target directives can be used to run for x86_64-*-*
target while skipping x86_64-*-gnux32 target.  This patch allows mixing
target and not-target directives. It is used to skip elfedit-1 for
x86_64-*-gnux32.

	* binutils-all/elfedit-1.d: Skip x86_64-*-gnux32.
	* lib/utils-lib.exp (run_dump_test): Allow mixing target and
	not-target directives.
2015-05-11 12:29:27 -07:00
H.J. Lu 3d875af575 Add init_dwarf_regnames_iamcu
* dwarf.c (dwarf_regnames_iamcu): New.
	(init_dwarf_regnames_iamcu): Likewise.
	(init_dwarf_regnames): Call init_dwarf_regnames_iamcu for EM_IAMCU.
	* dwarf.h (init_dwarf_regnames_iamcu): New.
	* objdump.c (dump_dwarf): Call init_dwarf_regnames_iamcu for
	bfd_arch_iamcu.
2015-05-11 10:41:44 -07:00
H.J. Lu bf64a9511f Add Intel MCU support to bfd
bfd/

	* Makefile.am (ALL_MACHINES): Add cpu-iamcu.lo.
	(ALL_MACHINES_CFILES): Likewise.
	* archures.c (bfd_mach_iamcu): New.
	(bfd_mach_i386_iamcu): Likewise.
	(bfd_mach_i386_iamcu_intel_syntax): Likewise.
	(bfd_iamcu_arch): Likewise.
	(bfd_archures_list): Add &bfd_iamcu_arch.
	* config.bfd (targ_selvecs): Add iamcu_elf32_vec to
	i386_elf32_vec.
	(targ_archs): Add bfd_iamcu_arch if needed.
	* configure.ac: Support iamcu_elf32_vec.
	* cpu-iamcu.c: New file.
	* elf32-i386.c (elf32_iamcu_elf_object_p): New function.
	Add support for iamcu_elf32_vec and elf32_iamcu_bed.
	* targets.c (iamcu_elf32_vec): New.
	(_bfd_target_vector): Add iamcu_elf32_vec.
	* Makefile.in: Regenerated.
	* bfd-in2.h: Likewise.
	* configure: Likewise.

binutils/testsuite/

	* binutils-all/objdump.exp (cpus_expected): Append iamcu.
2015-05-11 10:31:00 -07:00
H.J. Lu 6c14750f48 Add EM_386/EM_IAMCU support to elfedit.c
binutils/

	* elfedit.c (enum elfclass): New.
	(input_elf_class): Change type to enum elfclass.
	(output_elf_class): New.
	(elf_class): Change return type to enum elfclass.  Support EM_386
	and EM_IAMCU.
	(update_elf_header): Check if input and output ELF classes match.
	(elf_machine): Support EM_386 and EM_IAMCU.
	(main): Update input_elf_class.  Set output_elf_class.
	* doc/binutils.texi: Update elfedit.

binutils/testsuite/

	* binutils-all/elfedit-5.d: New file.
	* binutils-all/elfedit.exp: Run elfedit-5.
2015-05-11 09:57:21 -07:00
H.J. Lu 22abe5566a Rename EM_486 to EM_IAMCU
bfd/

	* elfcode.h (elf_object_p): Replace EM_486 with EM_IAMCU.

binutils/

	* dwarf.c (init_dwarf_regnames): Replace EM_486 with EM_IAMCU.
	* readelf.c (guess_is_rela): Likewise.
	(dump_relocations): Likewise.
	(get_machine_name): Likewise.
	(get_elf_section_flags): Likewise.
	(process_section_headers): Likewise.
	(is_32bit_abs_reloc): Likewise.
	(is_32bit_pcrel_reloc): Likewise.

include/elf/

	* common.h (EM_486): Renamed to ...
	(EM_IAMCU): This.
2015-05-11 08:53:05 -07:00
Nick Clifton 153a27763c Fix handling of relocs for the MeP target.
bfd	PR 18317
	* elf32-mep.c (MEPREL): Use bfd_elf_generic_reloc instead of
	mep_reloc.
	(mep_reloc): Delete unused function.

bin	* readelf.c (get_machine_flags): Add description of MeP flags.

tests	* binutils-all/objdump.exp (cpus_expected): Add MeP CPU names.
2015-04-30 15:57:41 +01:00
Andreas Krebbel 643f7afb0d S/390: z13 use GNU attribute to indicate vector ABI
bfd/
	* elf-s390-common.c (elf_s390_merge_obj_attributes): New function.
	* elf32-s390.c (elf32_s390_merge_private_bfd_data): Call
	elf_s390_merge_obj_attributes.
	* elf64-s390.c (elf64_s390_merge_private_bfd_data): New function.

binutils/
	* readelf.c (display_s390_gnu_attribute): New function.
	(process_s390_specific): New function.
	(process_arch_specific): Call process_s390_specific.

gas/
	* doc/as.texinfo: Document Tag_GNU_S390_ABI_Vector.

include/elf/
	* s390.h: Define Tag_GNU_S390_ABI_Vector.
2015-04-27 10:32:23 +02:00
Nick Clifton de13ef81f0 Fix compile time warning messages about variables being used before they are initialised.
PR 18313
bin	* ieee.c (ieee_read_cxx_class): Initialise the varargs variable.
	* readelf.c (uncompress_section_contents): Zero initialise the
	zstream structure.

bfd	* compress.c (decompress_contents): Zero initialse the z_stream
	structure.
2015-04-24 17:13:22 +01:00
H.J. Lu f6fe1ccd62 Don't change compressed input debug section names
Change compressed input debug section name for objdump is very confusing.
But we need to change it for linker so that linker will consider the
input section as a debug section.  This patch delays section rename to
elf_fake_sections for objcopy and avoids it for objdump.

bfd/

	PR binutils/18209
	* bfd.c (bfd): Add is_linker_input.
	* elf.c (convert_debug_to_zdebug): New.
	(convert_zdebug_to_debug): Likewise.
	(_bfd_elf_make_section_from_shdr): Don't convert .debug_* to
	.zdebug_* here.  Use convert_zdebug_to_debug.  Set SEC_ELF_RENAME.
	(_bfd_elf_init_reloc_shdr): Pass a pointer to section name
	instead of a pointer to section.
	(elf_fake_sections): Rename the section name if SEC_ELF_RENAME
	is set.
	* section.c (SEC_ELF_RENAME): New.
	* bfd-in2.h: Regenerated.

binutils/

	PR binutils/18209
	* objcopy.c (setup_section): Copy compress status.

binutils/testsuite/

	PR binutils/18209
	* binutils-all/compress.exp: Replace dw2-3.W with dw2-3gabi.W
	on zlib-gabi output.
	* binutils-all/dw2-1.W: Convert section names to .zdebug_*.
	* binutils-all/dw2-3.W: Likewise.
	* binutils-all/objdump.W: Likewise.
	* binutils-all/dw2-3gabi.W: New file.

ld/

	PR binutils/18209
	* ldfile.c (ldfile_try_open_bfd): Set is_linker_input to 1.
2015-04-23 07:59:59 -07:00
H.J. Lu be59ad3d96 Don't hardcode offset of .shstrtab section
There is no requirement on placement of section name section, .shstrtab.
This patch removes hardcoded offsets of .shstrtab sections.

binutils/testsuite/

	* binutils-all/i386/compressed-1b.d: Don't hardcode offset of
	.shstrtab section.
	* binutils-all/i386/compressed-1c.d: Likewise.
	* binutils-all/readelf.s-64: Likewise.
	* binutils-all/x86-64/compressed-1b.d: Likewise.
	* binutils-all/x86-64/compressed-1c.d: Likewise.

gas/testsuite/

	* gas/i386/ilp32/x86-64-unwind.d: Don't hardcode offset of
	.shstrtab section.
	* gas/i386/x86-64-unwind.d: Likewise.
	* gas/ia64/alias-ilp32.d: Likewise.
	* gas/ia64/alias.d: Likewise.
	* gas/ia64/group-1.d: Likewise.
	* gas/ia64/group-2.d: Likewise.
	* gas/ia64/secname-ilp32.d: Likewise.
	* gas/ia64/secname.d: Likewise.
	* gas/ia64/unwind-ilp32.d: Likewise.
	* gas/ia64/unwind.d: Likewise.
	* gas/mmix/bspec-1.d: Likewise.
	* gas/mmix/byte-1.d: Likewise.
	* gas/mmix/loc-1.d: Likewise.
	* gas/mmix/loc-2.d: Likewise.
	* gas/mmix/loc-3.d: Likewise.
	* gas/mmix/loc-4.d: Likewise.
	* gas/mmix/loc-5.d: Likewise.
	* gas/tic6x/scomm-directive-4.d: Likewise.

ld/testsuite/

	* ld-mmix/bspec1.d: Don't hardcode offset of .shstrtab section.
	* ld-mmix/bspec2.d: Likewise.
	* ld-mmix/local1.d: Likewise.
	* ld-mmix/local3.d: Likewise.
	* ld-mmix/local5.d: Likewise.
	* ld-mmix/local7.d: Likewise.
	* ld-mmix/undef-3.d: Likewise.
	* ld-sh/sh64/crangerel1.rd: Likewise.
	* ld-sh/sh64/crangerel2.rd: Likewise.
	* ld-tic6x/common.d: Likewise.
	* ld-tic6x/shlib-1.rd: Likewise.
	* ld-tic6x/shlib-1b.rd: Likewise.
	* ld-tic6x/shlib-1r.rd: Likewise.
	* ld-tic6x/shlib-1rb.rd: Likewise.
	* ld-tic6x/shlib-app-1.rd: Likewise.
	* ld-tic6x/shlib-app-1b.rd: Likewise.
	* ld-tic6x/shlib-app-1r.rd: Likewise.
	* ld-tic6x/shlib-app-1rb.rd: Likewise.
	* ld-tic6x/shlib-noindex.rd: Likewise.
	* ld-tic6x/static-app-1.rd: Likewise.
	* ld-tic6x/static-app-1b.rd: Likewise.
	* ld-tic6x/static-app-1r.rd: Likewise.
	* ld-tic6x/static-app-1rb.rd: Likewise.
	* ld-x86-64/ilp32-4.d: Likewise.
	* ld-x86-64/split-by-file-nacl.rd: Likewise.
	* ld-x86-64/split-by-file.rd: Likewise.
2015-04-20 09:55:47 -07:00
H.J. Lu ea556d2590 Mention --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]
binutils/

	* NEWS: Mention
	--compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi].

gas/

	* NEWS: Mention
	--compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi].

ld/

	* NEWS: Mention
	--compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi].
2015-04-15 05:26:41 -07:00
Nick Clifton 6ff71e7681 Adds support to the RL78 port for linker relaxation affecting .debug sections.
gas	* config/tc-rl78.h (TC_LINKRELAX_FIXUP): Define.
	(TC_FORCE_RELOCATION_SUB_SAME): Define.
	(DWARF2_USE_FIXED_ADVANCE_PC): Define.

	* gas/lns/lns.exp: Add RL78 to list of targets using
	DW_LNS_fixed_advance_pc.

bfd	* elf32-rl78.c (RL78_OP_REL): New macro.
	(rl78_elf_howto_table): Use it for complex relocs.
	(get_symbol_value): Handle the cases when the info or status
	arguments are NULL.
	(get_romstart): Cache the status returned by get_symbol_value.
	(get_ramstart): Likewise.
	(RL78_STACK_PUSH): Generate an error message if the stack
	overflows.
	(RL78_STACK_POP): Likewise for underflows.
	(rl78_compute_complex_reloc): New function.  Contains the basic
	processing code for all RL78 complex relocs.
	(rl78_special_reloc): New function.  Provides special reloc
	handling for complex relocs.
	(rl78_elf_relocate_section): Use rl78_compute_complex_reloc.
	(rl78_offset_for_reloc): Likewise.

binutils* readelf.c (target_specific_reloc_handling): Add code to handle
	RL78 complex relocs.
2015-04-14 16:23:33 +01:00
Doug Evans 0d2a7a9322 Fix reading of .debug_str_offsets{,.dwo} twice.
PR binutils/18218
	* readelf.c (printable_section_name): Constify sec argument.
	(apply_relocations): Ditto.  New arg "size".  All callers updated.
	(load_specific_debug_section): Constify sec argument.
	Remove side-effect of modifying sec->sh_size.
2015-04-13 12:50:17 -07:00
H.J. Lu cd6faa73f8 Properly check --compress-debug-sections=XXX
We can't check if input is ELF in copy_file since some targets may only
set xvec after bfd_check_format_matches is called.  This patch moves
this check to copy_object.

bfd/

	* elfxx-target.h (TARGET_BIG_SYM): Add BFD_COMPRESS_GABI to
	object_flags.
	(TARGET_LITTLE_SYM): Likewise.

binutils/

	* objcopy.c (do_debug_sections): Use bit patterns.
	(copy_object): Return FALSE for compress_zlib, compress_gnu_zlib
	and compress_gabi_zlib on non-ELF input.
	(copy_file): Don't check non-ELF input here.
2015-04-09 10:56:28 -07:00
Nick Clifton 3525236c57 Add support to the RX toolchain to restrict the use of string instructions.
bfd	* elf32-rx.c (describe_flags): Report the settings of the string
	insn using bits.
	(rx_elf_merge_private_bfd_data): Handle merging of the string insn
	using bits.

bin	* readelf.c (get_machine_flags): Report the setting of the string
	insn using bits.

gas	* config/tc-rx.c (enum options): Add OPTION_DISALLOW_STRING_INSNS.
	(md_longopts): Add -mno-allow-string-insns.
	(md_parse_option): Handle -mno-allow-string-insns.
	(md_show_usage): Mention -mno-allow-string-insns.
	(rx_note_string_insn_use): New function.  Produces an error
	message if a string insn is used when it is not allowed.
	* config/rx-parse.y (SCMPU): Call rx_note_string_insn_use.
	(SMOVU, SMOVB, SMOVF, SUNTIL, SWHILE, RMPA): Likewise.
	* config/rx-defs.h (rx_note_string_insn_use): Prototype.
	* doc/c-rx.texi: Document -mno-allow-string-insns.

elf	* rx.h (E_FLAG_RX_SINSNS_SET): New bit in e_flags field.
	(E_FLAG_RX_SINSNS_YES): Likewise.
	(E_FLAG_RX_SINSNS_MASK): New define.
2015-04-09 12:48:37 +01:00
H.J. Lu 151411f8af Add SHF_COMPRESSED support to gas and objcopy
This patch adds --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}
options to gas and objcopy for ELF files. They control how DWARF debug
sections are compressed.  --compress-debug-sections=none is equivalent to
--nocompress-debug-sections.  --compress-debug-sections=zlib and
--compress-debug-sections=zlib-gnu are equivalent to
--compress-debug-sections.  --compress-debug-sections=zlib-gabi compresses
DWARF debug sections with SHF_COMPRESSED from the ELF ABI.  No linker
changes are required to support SHF_COMPRESSED.

bfd/

	* archive.c (_bfd_get_elt_at_filepos): Also copy BFD_COMPRESS_GABI
	bit.
	* bfd.c (bfd::flags): Increase size to 18 bits.
	(BFD_COMPRESS_GABI): New.
	(BFD_FLAGS_SAVED): Add BFD_COMPRESS_GABI.
	(BFD_FLAGS_FOR_BFD_USE_MASK): Likewise.
	(bfd_update_compression_header): New fuction.
	(bfd_check_compression_header): Likewise.
	(bfd_get_compression_header_size): Likewise.
	(bfd_is_section_compressed_with_header): Likewise.
	* compress.c (MAX_COMPRESSION_HEADER_SIZE): New.
	(bfd_compress_section_contents): Return the uncompressed size if
	the full section contents is compressed successfully.  Support
	converting from/to .zdebug* sections.
	(bfd_get_full_section_contents): Call
	bfd_get_compression_header_size to get compression header size.
	(bfd_is_section_compressed): Renamed to ...
	(bfd_is_section_compressed_with_header): This.  Add a pointer
	argument to return compression header size.
	(bfd_is_section_compressed): Use it.
	(bfd_init_section_decompress_status): Call
	bfd_get_compression_header_size to get compression header size.
	Return FALSE if uncompressed section size is 0.
	* elf.c (_bfd_elf_make_section_from_shdr): Support converting
	from/to .zdebug* sections.
	* bfd-in2.h: Regenerated.

binutils/

	* objcopy.c (do_debug_sections): Add compress_zlib,
	compress_gnu_zlib and compress_gabi_zlib.
	(copy_options): Use optional_argument on compress-debug-sections.
	(copy_usage): Update --compress-debug-sections.
	(copy_file): Handle compress_zlib, compress_gnu_zlib and
	compress_gabi_zlib.
	(copy_main): Handle
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
	* doc/binutils.texi: Document
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.

binutils/testsuite/

	* compress.exp: Add tests for
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
	* binutils-all/dw2-3.rS: New file.
	* binutils-all/dw2-3.rt: Likewise.
	* binutils-all/libdw2-compressedgabi.out: Likewise.

gas/

	* as.c (show_usage): Update --compress-debug-sections.
	(std_longopts): Use optional_argument on compress-debug-sections.
	(parse_args): Handle
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
	* as.h (compressed_debug_section_type): New.
	(flag_compress_debug): Change type to compressed_debug_section_type.
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
	* write.c (compress_debug): Set BFD_COMPRESS_GABI for
	--compress-debug-sections=zlib-gabi.  Call
	bfd_get_compression_header_size to get compression header size.
	Don't rename section name for --compress-debug-sections=zlib-gabi.
	* config/tc-i386.c (compressed_debug_section_type): Set to
	COMPRESS_DEBUG_ZLIB.
	* doc/as.texinfo: Document
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.

gas/testsuite/

	* gas/i386/dw2-compressed-1.d: New file.
	* gas/i386/dw2-compressed-2.d: Likewise.
	* gas/i386/dw2-compressed-3.d: Likewise.
	* gas/i386/x86-64-dw2-compressed-2.d: Likewise.
	* gas/i386/i386.exp: Run dw2-compressed-2, dw2-compressed-1,
	dw2-compressed-3 and x86-64-dw2-compressed-2.

ld/testsuite/

	* ld-elf/compress.exp: Add a test for
	--compress-debug-sections=zlib-gabi.
	(build_tests): Add 2 tests for --compress-debug-sections=zlib-gabi.
	(run_tests): Likewise.
	Verify linker output with zlib-gabi compressed debug input.
	* ld-elf/compressed1a.d: New file.
	* ld-elf/compressed1b.d: Likewise.
	* ld-elf/compressed1c.d: Likewise.
2015-04-08 07:54:09 -07:00
H.J. Lu bfcf0ccd01 Display --interleave[=<number>]
Optional argument of a command line option must start with "=".

	* objcopy.c (copy_usage): Replace "--interleave [<number>]" with
	--interleave[=<number>].
2015-04-08 05:04:13 -07:00
H.J. Lu dae148f3b9 Remove is_zlib_supported
Since zlib is always supported, there is no need for is_zlib_supported.

binutils/testsuite/

	* binutils-all/compress.exp: Remove is_zlib_supported check.
	* binutils-all/objdump.exp: Likewise.
	* binutils-all/readelf.exp (readelf_compressed_wa_test): Likewise.
	* lib/utils-lib.exp (run_dump_test): Likewise.
	* lib/binutils-common.exp (is_zlib_supported): Removed.

gas/testsuite/

	* lib/gas-defs.exp (run_dump_test): Remove is_zlib_supported check.

ld/testsuite/

	* ld-elf/compress.exp: Remove is_zlib_supported check.
	Fail if --compress-debug-sections doesn't work.
	* lib/ld-lib.exp (run_dump_test): Remove is_zlib_supported check.
2015-04-06 12:19:13 -07:00
H.J. Lu fd5136e57c Remove "/dev/null" from remote_exec
We should catch all errors/warnings from cmp.

	* binutils-all/compress.exp (compression_used): Remove "/dev/null"
	from remote_exec.
2015-04-06 09:02:52 -07:00
H.J. Lu 77115a4a15 Add SHF_COMPRESSED support to readelf
This patch updates readelf to dump compression header with

readelf -S -W:

  [ 4] .debug_info PROGBITS  00000000 000038 00007d 00   C 0   0  1

readelf -t -W:

  [ 4] .debug_info
       PROGBITS        00000000 000038 00007d 00   0   0  1
       [00000800]: COMPRESSED
       ZLIB, 0000009d, 1

It also checks the compression header when decompressing the compressed
section.

	* readelf.c (get_elf_section_flags): Support SHF_COMPRESSED.
	(get_compression_header): New.
	(process_section_headers): Dump compression header if needed.
	(uncompress_section_contents): Don't free compressed_buffer here.
	(load_specific_debug_section): Free the compressed buffer, update
	the section buffer and the section size if uncompress is
	successful.
2015-04-05 09:29:57 -07:00
H.J. Lu 317974f683 Xfail the compressed debug sections
There is no need to generate compressed debug section if compressed
section size is the same as before compression.  We should xfail the
compressed debug section test if there are no compressed sections

binutils/testsuite/

	* binutils-all/compress.exp (compression_used): New.
	Xfail test if compression didn't make the section smaller.

gas/

2015-04-05  H.J. Lu  <hongjiu.lu@intel.com>

	* write.c (compress_debug): Don't write the zlib header if
	compressed section size is the same as before compression.
2015-04-05 08:15:35 -07:00
H.J. Lu e268c0a63c Add a dw2-3.S test
This patch adds a dw2-3.S test for upcoming SHF_COMPRESSED test. The
existing dw2-1.S/dw2-2.S tests generate non-compressed debug sections
for SHF_COMPRESSED since SHF_COMPRESSED compressed debug sections are
bigger.

	* binutils-all/compress.exp (testfile): Remove suffix.
	(compressedfile): Likewise.
	(compressedfile2): Likewise.
	(libfile): Likewise.
	(testfile3): New.
	(compressedfile3): Likewise.
	Updated.
	Add a dw2-3.S test.
	* binutils-all/dw2-3.S: New file.
	* binutils-all/dw2-3.W: Likewise.
2015-04-04 07:34:25 -07:00
H.J. Lu cbf0179287 Make is_zlib_supported always return 1
* lib/binutils-common.exp (is_zlib_supported): Always return 1.
2015-04-03 04:03:07 -07:00
Nick Clifton 4295609462 Fix the binutils readelf.ss test for the AArch64 target.
* binutils-all/readelf.ss-64: Move possible location of the $d
	mapping symbol.
2015-04-02 15:28:02 +01:00
H.J. Lu 39f3de7c43 Regenerate configure in bfd/binutils/gas/gdb/gold
bfd/

	* configure: Regenerated.

binutils/

	* configure: Regenerated.

gas/

	* configure: Regenerated.

gdb/

	* Makefile.in (top_srcdir): New.
	* configure: Regenerated.

gold/

	* configure: Regenerated.
2015-04-02 05:45:03 -07:00
Mike Frysinger 3d5ff6205b binutils: update my e-mail address 2015-04-02 00:51:56 -04:00
H.J. Lu afa59b7900 Regenerate configure in bfd/binutils/gas/gdb
bfd/

2015-04-01  H.J. Lu  <hongjiu.lu@intel.com>

	* configure: Regenerated.

binutils/

2015-04-01  H.J. Lu  <hongjiu.lu@intel.com>

	* configure: Regenerated.

gas/

2015-04-01  H.J. Lu  <hongjiu.lu@intel.com>

	* configure: Regenerated.

gdb/

2015-04-01  H.J. Lu  <hongjiu.lu@intel.com>

	* configure: Regenerated.
2015-04-01 04:55:48 -07:00
H.J. Lu ed2b5077eb Revert the AM_ZLIB change in binutils
* configure.ac: Revert the AM_ZLIB change.
	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.
2015-03-31 06:39:57 -07:00
H.J. Lu 0ee42ecde7 Add --with-system-zlib in binutils
This patch adds --with-system-zlib and remove --with-zlib in binutils.

	* Makefile.am (ZLIB): New.
	(ZLIBINC): Likewise.
	(AM_CFLAGS): Add $(ZLIBINC).
	(readelf_LDADD): Add $(ZLIB).
	* configure.ac (AM_ZLIB): Removed.
	(zlibdir): New.  AC_SUBST.
	(zlibinc): Likewise.
	Add --with-system-zlib.
	* readelf.c: Don't check HAVE_ZLIB_H to include <zlib.h>.
	(uncompress_section_contents): Don't check HAVE_ZLIB_H.
	* Makefile.in: Regenerated.
	* config.in: Likewise.
	* configure: Likewise.
2015-03-31 03:53:55 -07:00
Renlin Li 72a9c03c27 [Patch ]Fix bintest.s failure after previous AArch64 map symbol commit
2015-03-26  Renlin Li  <renlin.li@arm.com>

binutils/testsuite/
  * binutils-all/readelf.s-64: Support aarch64 case.
  * binutils-all/readelf.ss-64: Likewise.
2015-03-27 10:22:46 +00:00
Nick Clifton 1740ba0cec Add support for G13 and G14 flag bits in RL78 ELF binaries.
inc	* rl78.h (E_FLAG_RL78_G10): Redefine.
	(E_FLAG_RL78_CPU_MASK, E_FLAG_RL78_ANY_CPU, E_FLAG_RL78_G13
	E_FLAG_RL78_G14): New flags.

bin	* readelf.c (get_machine_flags): Decode RL78's G13 and G14 flags.

gas	* config/tc-rl78.c (enum options): Add G13 and G14.
	(md_longopts): Add -mg13 and -mg14.
	(md_parse_option): Handle -mg13 and -mg14.
	(md_show_usage): List -mg13 and -mg14.
	* doc/c-rl78.texi: Add description of -mg13 and -mg14 options.

bfd	* elf32-rl78.c (rl78_cpu_name): New function.  Prints the name of
	the RL78 core based upon the flags.
	(rl78_elf_merge_private_bfd_data): Handle merging of G13 and G14
	flags.
	(rl78_elf_print_private_bfd_data): Use rl78_cpu_name.
	(elf32_rl78_machine): Always return bfd_mach_rl78.
2015-03-19 15:37:43 +00:00
H.J. Lu d94077e27d Add a testcase for PR gas/18087
PR gas/18087
	* gas/i386/dw2-compress-1.d: Revert the last change.
	* gas/i386/dw2-compress-3.d: New.
	* gas/i386/dw2-compress-3.s: Likewise.
	* gas/i386/i386.exp: Run dw2-compress-3 for ELF targets.
2015-03-18 09:39:02 -07:00
Jon Turney 273a49858f Fix debug section compression so that it is only performed if it would make the section smaller.
PR binutils/18087
gas	* doc/as.texinfo: Note that when gas compresses debug sections the
	compression is only performed if it makes the section smaller.
	* write.c (compress_debug): Do not compress a debug section if
	doing so would make it larger.

tests	* gas/i386/dw2-compress-1.d: Do not expect the .debug_abbrev or
	.debug_info sections to be compressed.

binu	* doc/binutils.texi: Note that when objcopy compresses debug
	sections the compression is only performed if it makes the section
	smaller.

bfd	* coffgen.c (make_a_section_from_file): Only prepend a z to a
	debug section's name if the section was actually compressed.
	* elf.c (_bfd_elf_make_section_from_shdr): Likewise.
	* compress.c (bfd_init_section_compress_status): Do not compress
	the section if doing so would make it bigger.  In such cases leave
	the section alone and return COMPRESS_SECTION_NONE.
2015-03-18 15:47:13 +00:00
Alan Modra 50a0d11989 Run objcopy --update-section test only on ELF targets
* binutils-all/update-section.exp: Only run on ELF targets.
2015-03-11 17:59:29 +10:30
H.J. Lu 5656ba2c21 Move nothing to do warning to main
PR binutils/18101
	* readelf.c (parse_args): Move nothing to do warning to ...
	(main): Here.
2015-03-10 06:57:14 -07:00
Nick Clifton b6370efb1e Fixes "readelf -s --wide" not returning an error status or help message.
PR binutils/18101
	* readelf.c (parse_args): Enhance check for nothing to do by
	accounting for the --wide option.
2015-03-10 13:44:51 +00:00
Nick Clifton cfad873011 Fixes a problem with objcopy leaving temporary files and directories around if it encounters a problem during a copy.
PR binutils/17636
	* objcopy.c (copy_object): Avoid calling fatal as that does not
	allow the parent to clean up temporary files.
2015-03-10 13:38:24 +00:00
Jiong Wang a5721eddd1 [ARM] PR ld/16572: Remove EF_ARM_HASENTRY flag
bfd/
2015-03-10  Yuri Gribov  <y.gribov@samsung.arm>

	PR ld/16572
	* elf32-arm.c (elf32_arm_final_link_relocate): Remove
	support for ELF_ARM_HASENTRY.
	(elf32_arm_print_private_bfd_data): Likewise.

binutils/
2015-03-10  Yuri Gribov  <y.gribov@samsung.arm>

	PR ld/16572
	* readelf.c: Remove support for ELF_ARM_HASENTRY.

include/
2015-03-10  Matthew Wahab  <matthew.wahab@arm.com>

	PR ld/16572
	* elf/arm.h (EF_ARM_HASENTRY): Remove.
2015-03-10 11:15:13 +00:00
Nick Clifton 4fd77a3d12 Extend description of --add-gnu-debuglink option to explain why the file must exist.
PR binutils/18064
	* doc/binutils.texi (objcopy): Extend description of
	--add-gnu-debuglink option to explain that the separate debug info
	file must exist.  Add a description of what to do if the debug
	info file is built in one place but then installed into a separate
	location.
2015-03-05 16:45:15 +00:00
Nick Clifton 81fb971a3d Fixes PR 17994 - which reported that dlltool was not deleting temporary files if it encounters a fatal error.
PR binutils/17994
	* dlltool.c (temp_file_to_remove): New local array.
	(unlink_temp_files): New functions - unlinks any file in the
	temp_file_to_remove array, unless dotdeltemps is set.
	(gen_exp_file): Add temp files to array.
	(make_head): Likewise.
	(make_delay_head): Likewise.
	(make_tail): Likewise.
	(gen_lib_file): Call unlink_temp_files.
2015-03-05 15:13:08 +00:00
Jiong Wang d8282f0eb1 [ARM] Skip private symbol when doing objdump
2015-03-03  Jiong Wang  <jiong.wang@arm.com>

  opcode/
    * arm-dis.c (arm_symbol_is_valid): Skip ARM private symbols.

  binutils/testsuite/
    * binutils-all/arm/rvct_symbol.s: New testcase.
    * binutils-all/arm/objdump.exp: Run it.
2015-03-03 15:00:59 +00:00
Andrew Burgess acf1419f9c objcopy: Add --update-section option.
New option for objcopy --update-section allows the contents of a section
to be updated while maintaining the section flags, and, for ELF files,
the section to segment mapping.

New test uses --dump-section and --update-section to check that a
section can be made larger and smaller with an update.

binutils/ChangeLog:

	* objcopy.c (update_sections): New list.
	(command_line_switch): Add OPTION_UPDATE_SECTION.
	(copy_options): Add update-section.
	(copy_usage): Document new option.
	(is_update_section): New function.
	(is_strip_section_1): Add check for attempt to update and remove
	the same section.
	(copy_object): Update size and content of requested sections.
	(skip_section): Don't copy for updated sections.
	(copy_main): Handle --update-section.
	* doc/binutils.texi (objcopy): Add description of --update-section
	option.
	* NEWS: Mention --update-section option.

binutils/testsuite/ChangeLog:

	* binutils-all/update-1.s: New file.
	* binutils-all/update-2.s: New file.
	* binutils-all/update-3.s: New file.
	* binutils-all/update-4.s: New file.
	* binutils-all/update-section.exp: New file.
2015-02-28 21:25:51 +00:00
Nick Clifton d93c7787a0 Fix arithmetic overflows running srconv on fuzzed binaries.
PR binutils/17512
	* coffgrok.c (do_type): Check for an out of range tag index.
	Check for integer overflow computing array dimension.
	(do_define): Likewise.
2015-02-26 22:16:16 +00:00
Andrew Burgess 06b73f4199 objcopy: Avoid shadowing optarg.
In commit 7173b38a44 I used optarg as the
name for a function parameter, shadowing the global of that name.  This
commit changes the function parameter to be called arg.

binutils/ChangeLog:

	* objcopy.c (init_section_add): Rename optarg to arg in order to
	avoid shadowing a global variable.
2015-02-26 18:05:10 +00:00
Nick Clifton c8071705c6 Fix undefined arithmetic operations detected by -fsanitize=undefined when running readelf on fuzzed binaries.
PR binutils/17512
	* dwarf.c (display_debug_loc): Pacify the undefined behaviour
	sanitizer by simplifying address difference calculation.
	(struct Frame_Chunk): Change type of cfa_offset to dwarf_vma in
	order to avoid arithmetic overflows.
	(frame_display_row): Cast cfa_offset before printing it.
	(display_debug_frames): Likewise.
	Check for an unexpected segment size.
	Chnage type of 'l' local to dwarf_vma and cast it back to an int
	when printing.
	(process_cu_tu_index): Tighten check for an invalid ncols value.
	* readelf.c (process_corefile_note_segment): Check for
	inote.descdata extending beyond the end of the section.
	(process_v850_notes): Likewise.
2015-02-26 14:23:27 +00:00
Nick Clifton e3ee40059d Fixes a resource exhaustion problem when running windres on a corrupt binary.
PR binutils/17512
	* resrc.c (write_rc_messagetable): Tighten check for invalid
	message lengths.
2015-02-26 12:23:18 +00:00
Terry Guo 99654aaf36 [ARM]Update for Tag_ABI_HardFP_use per EABI doc
Updated how we merge and display this attribute per the latest
EABI documents.

bfd/ChangeLog
	* elf32-arm.c (elf32_arm_merge_eabi_attributes): Update how we
	merge Tag_ABI_HardFP_use.

binutils/ChangeLog
	* readelf.c (arm_attr_tag_ABI_HardFP_use): Update how we
	display it.

ld/testsuite/ChangeLog
	* ld-arm/attr-merge-3.attr: Remove Tag_ABI_HardFP_use.
	* ld-arm/attr-merge-vfp-10.d: Likewise.
	* ld-arm/attr-merge-vfp-10r.d: Likewise.
	* ld-arm/attr-merge-vfp-12.d: Likewise.
	* ld-arm/attr-merge-vfp-12r.d: Likewise.
	* ld-arm/attr-merge-vfp-13.d: Likewise.
	* ld-arm/attr-merge-vfp-13r.d: Likewise.
	* ld-arm/attr-merge-vfp-14.d: Likewise.
	* ld-arm/attr-merge-vfp-14r.d: Likewise.
	* ld-arm/attr-merge-vfp-6.d: Likewise.
	* ld-arm/attr-merge-vfp-6r.d: Likewise.
	* ld-arm/attr-merge-vfp-7.d: Likewise.
	* ld-arm/attr-merge-vfp-7r.d: Likewise.
	* ld-arm/attr-merge-vfp-8.d: Likewise.
	* ld-arm/attr-merge-vfp-8r.d: Likewise.
2015-02-26 14:11:41 +08:00
Andrew Burgess 7173b38a44 objcopy: Factor out some of the option parsing code.
This patch splits out some of the option parsing code, increasing code
reuse.

binutils/ChangeLog:

	* objcopy.c (init_section_add): New function.
	(section_add_load_file): New function.
	(copy_main): Make use of new functions.
2015-02-25 23:57:30 +00:00
Andrew Burgess 137c83d69f avr/objdump: Support dumping .avr.prop section.
Add support to objdump for dumping the .avr.prop section in a structured
way.

binutils/ChangeLog:

	* od-elf32_avr.c: Add elf32-avr.h include.
	(OPT_AVRPROP): Define.
	(options[]): Add 'avr-prop' entry.
	(elf32_avr_help): Add avr-prop help text.
	(elf32_avr_dump_avr_prop): New function.
	(elf32_avr_dump): Add check for avr-prop.

bfd/ChangeLog:

	* elf32-avr.h (struct avr_property_header): New strucure.
	(avr_elf32_load_property_records): Declare.
	(avr_elf32_property_record_name): Declare.
	* elf32-avr.c: Add bfd_stdint.h include.
	(retrieve_local_syms): New function.
	(get_elf_r_symndx_section): New function.
	(get_elf_r_symndx_offset): New function.
	(internal_reloc_compare): New function.
	(struct avr_find_section_data): New structure.
	(avr_is_section_for_address): New function.
	(avr_find_section_for_address): New function.
	(avr_elf32_load_records_from_section): New function.
	(avr_elf32_load_property_records): New function.
	(avr_elf32_property_record_name): New function.

gas/testsuite/ChangeLog:

	* gas/avr/avr-prop-1.d: New file.
	* gas/avr/avr-prop-1.s: New file.
2015-02-25 23:17:27 +00:00
Nick Clifton 685080f210 Adds support for generating notes in V850 binaries.
bfd	* elf32-v850.c (v850_set_note): New function.  Creates a Renesas
	style note entry.
	(v850_elf_make_note_section): New function.  Creates a note
	section.
	(v850_elf_create_sections): New function.  Create a note section
	if one is not already present.
	(v850_elf_set_note): New function.  Adds a note to a bfd.
	(v850_elf_copy_private_bfd_data): New function.  Copies V850
	notes.
	(v850_elf_merge_notes): New function.  Merges V850 notes.
	(print_v850_note): New function.  Displays a V850 note.
	(v850_elf_print_notes): New function. Displays all notes attached
	to a bfd.
	(v850_elf_merge_private_bfd_data): Call v850_elf_merge_notes.
	(v850_elf_print_private_bfd_data): Call v850_elf_print_notes.
	(v850_elf_fake_sections): Set the type of the V850 note section.
	* bfd-in.h (v850_elf_create_sections): Add prototype.
	(v850_elf_set_note): Add prototype.
	* bfd-in2.h: Regenerate.

binutils* readelf.c (get_machine_flags): Remove deprecated V850 machine
	flags.
	(get_v850_section_type_name): New function.  Handles V850 special
	sections.
	(get_section_type_name): Add support for V850.
	(get_v850_elf_note_type): New function.  Returns the name of a
	V850 note.
	(print_v850_note): New function.  Prints a V850 note.
	(process_v850_notes): New function.  Prints V850 notes.
	(process_note_sections): Add support for V850.

binutils/testsute
	* binutils-all/objcopy.exp: Skip the strip-10 test for the V850.

gas	* config/tc-v850.c (soft_float): New variable.
	(v850_data_8): New variable.
	(md_show_usage): Add -msoft-float/-mhard-float.
	(md_parse_option): Likewise.
	(md_begin): Set the default value of soft_float.
	(v850_md_end): New function.  Creates a note section.
	* config/tc-v850.h (md_end): Define.
	* doc/c-v850.texi: Document -msoft-float/-mhard-float.

gas/testsuite
	* gas/elf/elf.exp: Add special version of the section2 test for
	the V850.
	* gas/elf/section2.e-v850: New file.

include/elf
	* v850.h (EF_RH850_SIMD): Delete deprecated flag.
	(EF_RH850_CACHE): Likewise.
	(EF_RH850_MMU): Likewise.
	(EF_RH850_DATA_ALIGN8): Likewise.
	(SHT_RENESAS_IOP): Fix typo in name.
	(SHT_RENESAS_INFO): Define.
	(V850_NOTE_SECNAME): Define.
	(SIZEOF_V850_NOTE): Define.
	(V850_NOTE_NAME): Define.
	(enum v850_notes): New enum.
	(NUM_V850_NOTES): Define.

ld/ChangeLog
2015-02-24  Nick Clifton  <nickc@redhat.com>

	* Makefile.am (ev850.c): Add dependency upon
	$(srcdir)/emultempl/v850elf.em.
	(ev850_rh850.c): Likewise.
	* Makefile.in: Regenerate.
	* emultempl/v850elf.em: New file.
	* emulparams/v850.sh (EXTRA_EM_FILE): Define.
	* emulparams/v850_rh850.sh (EXTRA_EM_FILE): Define.
	* scripttempl/v850.sc: Add .note.renesas section.
	* scripttempl/v850_rh850.sc: Likewise.

ld/testsuite
	* ld-elf/extract-symbol-1sec.d: Expect to fail on the V850.
2015-02-24 17:54:09 +00:00
Mike Frysinger 94d15024fe readelf: handle corrupted chains better
The current chain walker tries to protect itself against loops, by only
works with loops of length 1: a chain that points to itself.  If you have
a chain longer than that (3->4->3->4->...), readelf will still hang.

Since we know the max length of the chain, simply abort when we've walked
more times than that.  The only way that could have happened is if there
was a loop.
2015-02-24 10:36:51 -05:00
Dmitry Antipov 948f632f56 Speed up the display of unwind tables by using a binary chop search to locate function symbols.
* readelf.c (find_symbol_for_address): Use a binary search to
	speed up symbol location.  Skip check for function symbol type.
	(*_unw_aux_info): Add funtab and nfuns fields contains a sorted
	list of function symbols.
	(dump_ia64_unwind): Initialise the funtab and nfuns fields and
	pass them to find_symbol_for_address.
	(dump_hppa_unwind): Likewise.
	(arm_print_vma_and_name): Pass funtab to find_symbol_for_address.
	(dump_arm_unwind): Initialise the funtab and nfuns fields.
2015-02-24 13:21:10 +00:00
Nick Clifton 0821d5b14e Improves the warning message produyced by objdump when it cannot load a section.
* objdump.c (dump_section): Extend the warning message displayed
	when a section cannot be loaded.
2015-02-24 11:10:07 +00:00
Mike Frysinger 9035ed5110 binutils: readelf: add missing newline to warning message 2015-02-21 16:10:04 -05:00
Andreas Arnez 4ef9f41a95 S390: Support new vector register sections
The IBM z13 has new 128-bit wide vector registers v0-v31, where v0-v15
include the existing 64-bit wide floating point registers.  The Linux
kernel presents the vector registers as two additional register sets,
one for the right halves of v0-v15 and another one for the full
registers v16-v31.  Thus a new core file may contain two new register
note sections, and this patch adds support to binutils for them.

bfd/
	* elf-bfd.h (elfcore_write_s390_vxrs_low): Add prototype.
	(elfcore_write_s390_vxrs_high): Likewise.
	* elf.c (elfcore_grok_s390_vxrs_low): New function.
	(elfcore_grok_s390_vxrs_high): New function.
	(elfcore_grok_note): Call them.
	(elfcore_write_s390_vxrs_low): New function.
	(elfcore_write_s390_vxrs_high): New function.
	(elfcore_write_register_note): Call them.

binutils/
	* readelf.c (get_note_type): Add NT_S390_VXRS_LOW and
	NT_S390_VXRS_HIGH.

include/elf/
	* common.h (NT_S390_VXRS_LOW): New macro.
	(NT_S390_VXRS_HIGH): Likewise.
2015-02-20 10:39:53 +01:00
Nick Clifton ffc0f143c7 Fixes for memory access violations triggered by running readelf on fuzzed binaries.
PR binutils/17531
	* dwarf.c (display_debug_aranges): Add check for an excessive
	ar_length value.
	(process_cu_tu_index): Check for a row * columns sum being too
	large.
2015-02-13 14:17:18 +00:00
Nick Clifton 951eaaec17 Fix illegal memory access errors triggered by running srconv on fuzzed binaries.
PR binutils/17512
	* dwarf.c (read_leb128): Fix test for shift becoming too large.

	* coffgrok.c (do_define): Add check for type size overflow.
	* srconv.c (walk_tree_sfile): Check that enough sections are
	available before parsing.
	(prescan): Likewise.
2015-02-13 12:14:05 +00:00
Nick Clifton f641dd969f Fix mistake in recent code to check for an unterminated leb128 number.
* dwarf.c (read_leb128): Fix test for shift becoming too large.
2015-02-13 11:13:20 +00:00
Alan Modra b4eb7656c2 binutils/dwarf.c white space
The style fix here is for num_units * sizeof * debug_information.

	* dwarf.c: Formatting, whitespace.
	(process_debug_info): Style fix.
2015-02-13 13:54:03 +10:30
Nick Clifton 0e7f931f3a oops - changelog entry accidentally omitted from previous delta. 2015-02-12 16:33:28 +00:00
Nick Clifton 362beea4b4 Fixes for invalid memory accesses triggered by running readelf on fuzzed binaries.
PR binutils/17531
	* dwarf.c (display_debug_pubnames_worker): Work around compiler
	bug checking address ranges.
	(display_debug_frames): Likewise.
	(display_gdb_index): Likewise.
	(process_cu_tu_index): Add range check on the ncols value.
2015-02-11 13:05:04 +00:00
Nick Clifton 834f871cdc Fix memory access violations discovered by running readelf compiled with undefined memory access sanitization on fuzzed binaries.
PR binutils/17531
	* dwarf.c (display_debug_pubnames_worker): Use dwarf_vma type for
	offset.
	* readelf.c (dump_relocations): Handle printing offsets which are
	MIN_INT.
	(process_corefile_note_segment): Add range check of the namesz
	field.
2015-02-10 17:53:53 +00:00
Nick Clifton 03a91817f1 Fixes for memory access violations triggered by running readelf on fuzzed binaries.
PR binutils/17531
	* dwarf.c (process_debug_info): Zero the debug information array
	since correct initialisation cannot be relied upon.
	(process_cu_tu_index): Improve range checks.
2015-02-10 17:13:31 +00:00
Nick Clifton 77ef865475 Fix memory access violations triggered by running objdump compiled with out-of-bounds sanitization checking.
PR binutils/17512
	* dwarf.c (eh_addr_size): Use an unsigned type.
	(size_of_encoded_value): Return an unsigned type.
	(read_leb128): Break if the shift becomes too big.
	(process_extended_line_op): Do not read the address if the length
	is too long.
	(read_cie): Warn and fail if the pointer size or segment size are
	too big.
	* dwarf.h (DWARF2_External_LineInfo): Delete unused and incorrect
	structure definition.
	(DWARF2_External_PubNames): Likewise.
	(DWARF2_External_CompUnit): Likewise.
	(DWARF2_External_ARange): Likewise.
	(DWARF2_Internal_LineInfo): Use dwarf_vma type for
	li_prologue_length.
	(eh_addr_size): Update prototype.

	* coffcode.h (styp_to_sec_flags): Use an unsigned long type to
	hold the flag bits.
	* peXXigen.c (pe_print_reloc): Use unsigned types to hold the
	size and number of relocs.
	(pe_print_debugdata): Use a 32-bit aligned buffer to store the
	codeview record.
	* versados.c (process_otr): Check the esdid value before using it
	to access the EDATA.
2015-02-10 14:11:00 +00:00
Mark Wielaard 5a19504458 Recognize new DWARF5/GCC5 DW_LANG constants for Fortran 03 and Fortran 08.
DWARFv5 defines and GCC5 may output two new DW_LANG constants for the
Fortran 2003 and Fortran 2008 standards. Handle and display both in
binutils.

binutils/ChangeLog:

	* dwarf.c (read_and_display_attr_value): Handle DW_LANG_Fortran03
	and DW_LANG_Fortran08.

include/ChangeLog:

	* dwarf2.h: Add DW_LANG_Fortran03 and DW_LANG_Fortran08.

http://dwarfstd.org/ShowIssue.php?issue=141121.1
2015-02-10 09:07:25 +01:00
Nick Clifton 5532504724 Fix an invalid memory access triggered by running readelf on a fuzzed binary.
PR binutils/17531
	* readelf.c (process_mips_specific): Fail if an option has an
	invalid size.
2015-02-06 13:03:08 +00:00
Nick Clifton 8490fb409a Fix memory access violations triggered by processing fuzzed binaries with a 32-bit version of readelf, compiled on a 64-bit host.
PR binutils/17531
	* dwarf.c (xcmalloc): Fail if the arguments are too big.
	(xcrealloc): Likewise.
	(xcalloc2): Likewise.
2015-02-06 12:19:20 +00:00
Nick Clifton 5929c344f9 Fixes illegal memory accesses triggereb by running a 32-bit binary version of objdump compiled on a 64-bit host.
PR binutils/17512
	* dwarf.c (display_debug_frames): Fix range checks to work on
	32-bit binaries complied on a 64-bit host.

	* peXXigen.c (rsrc_print_resource_entries): Add range check for
	addresses that wrap around the address space.
	(rsrc_parse_entry): Likewise.
2015-02-06 11:12:54 +00:00
Alan Modra 7cc78d0780 Don't refer to optarg in dwarf.c function
This one is passed in optarg as its argument.

	PR binutils/17926
	* dwarf.c (dwarf_select_sections_by_letters): Don't refer to optarg.
2015-02-05 17:50:37 +10:30
Nick Clifton f3853b3444 More fixes for memory access violations triggered by running readelf on fuzzed binaries.
PR binutils/17531
	* dwarf.c (read_and_display_attr_value): Test for a block length
	being so long that it wraps around to before the start of the block.
	(process_debug_info): Test for section_begin wrapping around to
	before the start of the section.
	(display_gdb_index): Test for num_cus being so large that the end
	address wraps around to before the start of the section.
	(process_cu_tu_index): Test for j being so large that the section
	index pool wraps around to before the start of the section.
2015-02-04 10:48:46 +00:00
Nick Clifton 570286220e Fix memory access violations triggered by running readelf on fuzzed binaries.
PR binutils/17531
	* dwarf.c (process_debug_info): Add range check.
	(display_debug_pubnames_worker): Likewise.
	(display_gdb_index): Fix range check.
	(process_cu_tu_index): Add range check.
	* readelf.c (get_data): Change parameter types from size_t to
	bfd_size_type.  Add checks for loss of accuracy when casting from
	bfd_size_type to size_t.
	(get_dynamic_data): Likewise.
	(process_section_groups): Limit number of error messages.
2015-02-03 20:42:36 +00:00
Nick Clifton 64d2901806 More fixes for illegal memory accesses triggered by running objdump on fuzzed binaries.
PR binutils/17512
	* objdump.c (display_any_bfd): Fail if archives nest too deeply.

	* ecoff.c: Use bfd_alloc2 to allocate space for structure arrays.
	(_bfd_ecoff_slurp_symbol_table): Check for a negative symbol
	index or an out of range fdr index.
	* elf-m10300.c (mn10300_info_to_howto): Fix typo in error message.
	* elf32-arc.c (arc_info_to_howto_rel): Likewise.
	* elf32-avr.c (avr_info_to_howto_rela): Likewise.
	* elf32-cr16.c (elf_cr16_info_to_howto): Likewise.
	* elf32-cr16c.c (elf_cr16c_info_to_howto_rel): Likewise.
	* elf32-cris.c (cris_info_to_howto_rela): Likewise.
	* elf32-crx.c (elf_crx_info_to_howto): Likewise.
	* elf32-d10v.c (d10v_info_to_howto_rel): Likewise.
	* elf32-d30v.c (d30v_info_to_howto_rel): Likewise.
	* elf32-epiphany.c (epiphany_info_to_howto_rela): Likewise.
	* elf32-fr30.c (fr30_info_to_howto_rela): Likewise.
	* elf32-frv.c (frv_info_to_howto_rela): Likewise.
	* elf32-i370.c (i370_elf_info_to_howto): Likewise.
	* elf32-i960.c (elf32_i960_info_to_howto_rel): Likewise.
	* elf32-ip2k.c (ip2k_info_to_howto_rela): Likewise.
	* elf32-iq2000.c (iq2000_info_to_howto_rela): Likewise.
	* elf32-lm32.c (lm32_info_to_howto_rela): Likewise.
	* elf32-m32c.c (m32c_info_to_howto_rela): Likewise.
	* elf32-m32r.c (m32r_info_to_howto_rel): Likewise.
	* elf32-m68hc11.c (m68hc11_info_to_howto_rel): Likewise.
	* elf32-m68hc12.c (m68hc11_info_to_howto_rel): Likewise.
	* elf32-mcore.c (mcore_elf_info_to_howto): Likewise.
	* elf32-mep.c (mep_info_to_howto_rela): Likewise.
	* elf32-metag.c (metag_info_to_howto_rela): Likewise.
	* elf32-microblaze.c (microblaze_elf_info_to_howto): Likewise.
	* elf32-moxie.c (moxie_info_to_howto_rela): Likewise.
	* elf32-msp430.c (msp430_info_to_howto_rela): Likewise.
	* elf32-mt.c (mt_info_to_howto_rela): Likewise.
	* elf32-nds32.c (nds32_info_to_howto_rel): Likewise.
	* elf32-or1k.c (or1k_info_to_howto_rela): Likewise.
	* elf32-pj.c (pj_elf_info_to_howto): Likewise.
	* elf32-ppc.c (ppc_elf_info_to_howto): Likewise.
	* elf32-rl78.c (rl78_info_to_howto_rela): Likewise.
	* elf32-rx.c (rx_info_to_howto_rela): Likewise.
	* elf32-sh.c (sh_elf_info_to_howto): Likewise.
	* elf32-spu.c (spu_elf_info_to_howto): Likewise.
	* elf32-v850.c (v850_elf_perform_relocation): Likewise.
	* elf32-vax.c (rtype_to_howto): Likewise.
	* elf32-visium.c (visium_info_to_howto_rela): Likewise.
	* elf32-xgate.c (xgate_info_to_howto_rel): Likewise.
	* elf32-xtensa.c (elf_xtensa_info_to_howto_rela): Likewise.
	* elf64-alpha.c (elf64_alpha_info_to_howto): Likewise.
	* elf64-mmix.c (mmix_info_to_howto_rela): Likewise.
	* mach-o.c: Use bfd_alloc2 to allocate space for structure arrays.
	(bfd_mach_o_canonicalize_one_reloc): Fix check on out
	of range symbol indicies.
	(bfd_mach_o_canonicalize_relocs): Check for out of range alloc.
	(bfd_mach_o_canonicalize_dynamic_reloc): Likewise.
	(bfd_mach_o_build_dysymtab): Likewise.
	(bfd_mach_o_write_symtab_content): Set the string table size to
	zero upon error.
	(bfd_mach_o_read_symtab_symbols): Reset the nsyms value if the
	read fails.
	* peXXigen.c (pe_print_edata):  Check for numeric overflow in edt
	fields.
	* tekhex.c (first_phase): Check for src pointer reaching end of
	buffer.
2015-02-03 14:34:54 +00:00
Alan Modra 3f8107ab38 FT32 initial support
FT32 is a new 32-bit RISC core developed by FTDI for embedded applications.

	* configure.ac: Add FT32 support.
	* configure: Regenerate.
bfd/
	* Makefile.am: Add FT32 files.
	* archures.c (enum bfd_architecture): Add bfd_arch_ft32.
	(bfd_mach_ft32): Define.
	(bfd_ft32_arch): Declare.
	(bfd_archures_list): Add bfd_ft32_arch.
	* config.bfd: Handle FT32.
	* configure.ac: Likewise.
	* cpu-ft32.c: New file.
	* elf32-ft32.c: New file.
	* reloc.c (BFD_RELOC_FT32_10, BFD_RELOC_FT32_20, BFD_RELOC_FT32_17,
	BFD_RELOC_FT32_18): Define.
	* targets.c (_bfd_target_vector): Add ft32_elf32_vec.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* po/SRC-POTFILES.in: Regenerate.
binutils/
	* readelf.c: Add FT32 support.
gas/
	* Makefile.am: Add FT32 files.
	* config/tc-ft32.c: New file.
	* config/tc-ft32.h: New file.
	* configure.tgt: Add FT32 support.
	* Makefile.in: Regenerate.
	* po/POTFILES.in: Regenerate.
gas/testsuite/
	* gas/ft32/ft32.exp: New file.
	* gas/ft32/insn.d: New file.
	* gas/ft32/insn.s: New file.
include/
	* dis-asm.h (print_insn_ft32): Declare.
include/elf/
	* common.h (EM_FT32): Define.
	* ft32.h: New file.
include/opcode/
	* ft32.h: New file.
ld/
	* Makefile.am: Add FT32 files.
	* configure.tgt: Handle FT32 target.
	* emulparams/elf32ft32.sh: New file.
	* scripttempl/ft32.sc: New file.
	* Makefile.in: Regenerate.
opcodes/
	* Makefile.am: Add FT32 files.
	* configure.ac: Handle FT32.
	* disassemble.c (disassembler): Call print_insn_ft32.
	* ft32-dis.c: New file.
	* ft32-opc.c: New file.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* po/POTFILES.in: Regenerate.
2015-01-28 16:25:18 +10:30
Nick Clifton 0897ec1581 Fixes for invalid memory accesses triggered by running windres on corrupt binaries.
PR binutils/17512
	* rcparse.y: Add checks to avoid integer divide by zero.
	* rescoff.c (read_coff_rsrc): Add check on the size of the
	resource section.
	(read_coff_res_dir): Add check on the nesting level.
	Check for resource names overrunning the buffer.
	* resrc.c (write_rc_messagetable): Update formatting.
	Add check of 'elen' being zero.
2015-01-27 17:32:23 +00:00
Nick Clifton 877a8638ba Fixes for memory access violations triggered by running addr2line on fuzzed binaries.
PR binutils/17512
	* addr2line.c (slurp_symtab): If the symcount is zero, free the
	symbol table pointer.

	* dwarf2.c (concat_filename): Check for an empty directory table.
	(scan_unit_for_symbols): Check for reading off the end of the
	unit.
	(parse_comp_unit): Check for a DW_AT_comp_dir attribute with a
	non-string form.
	* elf64-ppc.c (opd_entry_value): Fail if there are no relocs
	available.
2015-01-27 15:49:12 +00:00
Nick Clifton 37e3922eed Fix memory access violations triggered by running dlltool on corrupt binaries.
PR binutils/17512
	* dlltool.c (identify_search_archive): If the last archive was the
	same as the current archive, terminate the loop.

	* pdp11.c (aout_get_external_symbols): Return false if there are
	no symbols.
2015-01-27 11:30:15 +00:00
Nick Clifton bb97bdd70c Fix build errors when compiling nlmconv.c on a 32-bit host.
* nlmconv.c (powerpc_mangle_relocs): Fix build errors introduced
	by recent delta, when compiling on for a 32-bit host.
2015-01-23 16:39:53 +00:00
Nick Clifton 86eafac0aa Fix memory access violations triggered by running strip on fuzzed binaries.
PR binutils/17512
	* coffcode.h (coff_set_arch_mach_hook): Check return value from
	bfd_malloc.
	(coff_slurp_line_table): Return FALSE if the line number
	information was corrupt.
	(coff_slurp_symbol_table): Return FALSE if the symbol information
	was corrupt.
	* mach-o.c (bfd_mach_o_bfd_copy_private_header_data): Always
	initialise the fields of the dyld_info structure.
	(bfd_mach_o_build_exec_seg_command): Replace assertion with an
	error message and a return value.
	(bfd_mach_o_layout_commands): Change the function to boolean.
	Return FALSE if the function fails.
	(bfd_mach_o_build_commands): Fail if bfd_mach_o_layout_commands
	fails.
	(bfd_mach_o_read_command): Fail if an unrecognised command is
	encountered.
	* peXXigen.c (_bfd_XXi_swap_aouthdr_in): Set bfd_error if the
	read fails.
	(slurp_symtab): Check the return from bfd_malloc.
	(_bfd_XX_bfd_copy_private_bfd_data_common): Fail if the copy
	encountered an error.
	(_bfd_XXi_final_link_postscript): Fail if a section could not be
	copied.
	* peicode.h (pe_bfd_object_p): Fail if the header could not be
	swapped in.
	* tekhex.c (first_phase): Fail if the section is too big.
	* versados.c (struct esdid): Add content_size field.
	(process_otr): Use and check the new field.
	(versados_get_section_contents): Check that the section exists and
	that the requested data is available.

	PR binutils/17512
	* addr2line.c (main): Call bfd_set_error_program_name.
	* ar.c (main): Likewise.
	* coffdump.c (main): Likewise.
	* cxxfilt.c (main): Likewise.
	* dlltool.c (main): Likewise.
	* nlmconv.c (main): Likewise.
	* nm.c (main): Likewise.
	* objdump.c (main): Likewise.
	* size.c (main): Likewise.
	* srconv.c (main): Likewise.
	* strings.c (main): Likewise.
	* sysdump.c (main): Likewise.
	* windmc.c (main): Likewise.
	* windres.c (main): Likewise.
	* objcopy.c (main): Likewise.
	(copy_relocations_in_section): Check for relocs without associated
	symbol pointers.
2015-01-21 17:37:23 +00:00
Ramana Radhakrishnan 6c1965f995 Add self to ARM Maintainers 2015-01-21 11:15:58 +00:00
Nick Clifton 5b7d62376f This patch fixes some illegal memory accesses triggered by running coffdump on fuzzed binaries.
PR binutils/17512
	* coffgrok.c (do_type): Check that computed ref exists.
	(doit): Add range checks when computing section for scope.
2015-01-21 10:33:19 +00:00
H.J. Lu a0a3b04c61 Properly check abbrev size
abbrev_base is independent of abbrev_size.  We should use abbrev_base +
abbrev_size to check abbrev section size.

	* dwarf.c (process_debug_info): Properly check abbrev size.
2015-01-12 13:34:24 -08:00
Nick Clifton 1306a7421c Another fix for memory access errors trigegred by running readelf on a corrupt binary.
PR binutils/17531
	* dwarf.c (display_debug_addr): Use xcalloc to allocate the debug_addr_info
	array.  Check for an address_base that is too large.
2015-01-12 17:28:55 +00:00
Nick Clifton 72c61a0d1e More fixes for memory access errors when running readelf on fuzzed binaries.
PR binutils/17531
	* dwarf.c (process_debug_info): Check for abbrev_base being larger
	than the section size.
	(process_cu_tu_index): Use xcalloc2 to allocate the CU and TU
	arrays.
	(xcalloc2): New function.  Like xcalloc, but checks for overflow.
	* dwarf.h (xcalloc2): Prototype.
2015-01-12 16:08:41 +00:00
Alan Modra b38ead219b Assorted compiler warning fixes
The C standard doesn't guarantee a function pointer can be cast to
void* and vice versa.

binutils/
	* prdbg.c (print_debugging_info): Don't use void* for function
	pointer param.
	* budbg.h (print_debugging_info): Update prototype.
gas/
	* read.c (s_altmacro, s_reloc): Make definition static.
2015-01-12 18:07:52 +10:30
Nick Clifton 063bb0250d Fix memory access violations exposed by running strip on fuzzed binaries.
PR binutils/17512
	* coffcode.h (coff_slurp_symbol_table): Return false if we failed
	to load the line table.
	* elf.c (_bfd_elf_map_sections_to_segments): Enforce a minimum
	maxpagesize of 1.
	* peXXigen.c (_bfd_XX_bfd_copy_private_bfd_data_common): Fail if
	the Data Directory Size is too large.

	* objcopy.c (copy_object): Free the symbol table if no symbols
	could be loaded.
	(copy_file): Use bfd_close_all_done to close files that could not
	be copied.
2015-01-08 15:39:49 +00:00
Nick Clifton 848cde35d6 Fix memory access violations triggered by running sysdump on fuzzed binaries.
PR binutils/17512
	* sysdump.c (getINT): Fail if reading off the end of the buffer.
	Replace call to abort with a call to fatal.
	(getCHARS): Prevetn reading off the end of the buffer.
2015-01-08 13:52:42 +00:00
Nick Clifton 3565cf8fed Fixes for memory access violations triggered by running nlmconv on
fuzzed binaries.

	PR binutils/17512
	* nlmconv.c (i386_mangle_relocs): Skip relocs without an
	associated symbol.
	(powerpc_mangle_relocs): Skip unrecognised relocs.  Check address
	range before applying a reloc.
2015-01-08 12:37:46 +00:00
Nick Clifton d7b24d2941 Fix memory access violations uncovered by running the dlltool on fuzzed binaries.
PR binutils/17512
	* dlltool.c (scan_obj_file): Break loop if the last archive
	displayed matches the current archive.
2015-01-07 17:33:17 +00:00
Nick Clifton c88f5b8e49 Fix memory access violations exposed by running the srconv tool on fuzzed binaries.
PR binutils/17512
	* objdump.c (display_any_bfd): Add a depth limit to nested archive
	display in order to avoid infinite loops.
	* srconv.c: Replace calls to abort with calls to fatal with an
	error message.
2015-01-07 16:41:25 +00:00
Nick Clifton 85880250e5 Fixes for memory access violations in the coffdump program.
PR binutils/17512
	* coffdump.c (dump_coff_section): Check for a symbol being
	available before printing its name.
	(main): Check the return value from coff_grok.
	* coffgrok.c: Reformat and tidy.
	Add range checks to most functions.
	(coff_grok): Return NULL if the input bfd is not in a COFF
	format.
	* coffgrok.h: Reformat and tidy.
	(struct coff_section): Change the nrelocs field to unsigned.
	* srconv.c (main): Check the return value from coff_grok.

	* coff-i860.c (CALC_ADDEND): Always set an addend value.
	* tekhex.c (getvalue): Add an end pointer parameter.  Use it to
	avoid reading off the end of the buffer.
	(getsym): Likewise.
	(first_phase): Likewise.
	(pass_over): Pass an end pointer to the invoked function.
2015-01-06 16:06:45 +00:00
Nick Clifton 896ca09813 More fixes for invalid memory accesses triggered by fuzzed binaries.
PR binutils/17512
	* nm.c (print_symbol): Add 'is_synthetic' parameter.  Use it to
	help initialize the info.elfinfo field.
	(print_size_symbols): Add 'synth_count' parameter.  Use it to set
	the is_synthetic parameter when calling print_symbol.
	(print_symbols): Likewise.
	(display_rel_file): Pass synth_count to printing function.
	(display_archive): Break loop if the last archive displayed
	matches the current archive.
	* size.c (display_archive): Likewise.

	* archive.c (do_slurp_bsd_armap): Make sure that the parsed sized
	is at least big enough for the header to be read.
	* elf32-i386.c (elf_i386_get_plt_sym_val): Skip unknown relocs.
	* mach-o.c (bfd_mach_o_get_synthetic_symtab): Add range checks.
	(bfd_mach_o_read_command): Prevetn duplicate error messages about
	unrecognized commands.
	* syms.c (_bfd_stab_section_find_nearest_line): Add range checks
	when indexing into the string table.
2015-01-05 23:13:50 +00:00