Commit Graph

262 Commits

Author SHA1 Message Date
Alan Modra fdef394344 Remove IEEE 695 object support
include/
	* ieee.h: Delete.
bfd/
	* Makefile.am: Remove IEEE 695 support.
	* archures.c: Likewise.
	* bfd.c: Likewise.
	* config.bfd: Likewise.
	* configure.ac: Likewise.
	* doc/bfd.texinfo: Likewise.
	* doc/bfdint.texi: Likewise.
	* doc/bfdsumm.texi: Likewise.
	* section.c: Likewise.
	* targets.c: Likewise.
	* ieee.c: Delete.
	* libieee.h: Delete.
	* Makefile.in: Regenerate.
	* bfd-in2.h: Regenerate.
	* configure: Regenerate.
	* po/SRC-POTFILES.in: Regenerate.
binutils/
	* Makefile.am: Remove IEEE 695 support.
	* budbg.h: Likewise.
	* doc/binutils.texi: Likewise.
	* makefile.vms: Likewise.
	* objcopy.c: Likewise.
	* objdump.c: Likewise.
	* rddbg.c: Likewise.
	* ieee.c: Delete.
	* Makefile.in: Regenerate.
	* po/POTFILES.in: Regenerate.
gas/
	* app.c: Remove IEEE 695 support.
	* symbols.c: Likewise.
ld/
	* ld.texinfo: Remove IEEE 695 support.
	* mri.c: Likewise.
2018-04-16 15:16:00 +09:30
H.J. Lu 0e70b27ba9 Use binary search on dynamic relocations
Replace linear search with binary search on dynamic relocations.  After
finding a match, scan backward to the first matching relocation, then
scan forward for a matching relocation with non-absolute symbol.

On Fedora 27 x86-64, time for "objdump -d" on libxul.so from RHEL 7.4
x86-64 went from

134.46user 0.12system 2:15.03elapsed

to

8.49user 0.14system 0:08.64elapsed

	PR binutils/22911
	* objdump.c (is_significant_symbol_name): Return TRUE for all
	.plt* sections.
	(find_symbol_for_address): Replace linear search with binary
	search on dynamic relocations.
2018-03-05 03:45:03 -08:00
Andrew Burgess 5bb0830d10 binutils/riscv: Register names in DWARF output
Adds a register name table for RiscV so that objdump and readelf can
both use better register names.

binutils/ChangeLog:

	* dwarf.c (dwarf_regnames_riscv): New register name table.
	(init_dwarf_regnames_riscv): New function.
	(init_dwarf_regnames): Add call to initialise RiscV register
	names.
	* dwarf.h (init_dwarf_regnames_riscv): Declare.
	* objdump.c (dump_dwarf): Add call to initialise RiscV register
	names.
2018-02-02 18:50:40 +00:00
Alan Modra f2023ce7e8 PR22769, crash when running 32-bit objdump on corrupted file
PR 22769
	* objdump.c (load_specific_debug_section): Check for overflow
	when adding one to section size for a string section terminator.
2018-02-01 21:38:02 +10:30
Alan Modra 219d1afa89 Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
Nick Clifton d785b7d4b8 Stop objdump from attempting to allocate a huge chunk of memory when parsing relocs in a corrupt file.
PR 22508
	* objdump.c (dump_relocs_in_section): Also check the section's
	relocation count to make sure that it is reasonable before
	attempting to allocate space for the relocs.
2017-11-29 12:40:43 +00:00
Alan Modra 160b1a618a PR22443, Global buffer overflow in _bfd_elf_get_symbol_version_string
Symbols like *ABS* defined in bfd/section.c:global_syms are not
elf_symbol_type.  They can appear on relocs and perhaps other places
in an ELF bfd, so a number of places in nm.c and objdump.c are wrong
to cast an asymbol based on the bfd being ELF.  I think we lose
nothing by excluding all section symbols, not just the global_syms.

	PR 22443
	* nm.c (sort_symbols_by_size): Don't attempt to access
	section symbol internal_elf_sym.
	(print_symbol): Likewise.  Don't call bfd_get_symbol_version_string
	for section symbols.
	* objdump.c (compare_symbols): Don't attempt to access
	section symbol internal_elf_sym.
	(objdump_print_symname): Don't call bfd_get_symbol_version_string
	for section symbols.
2017-11-19 07:41:17 +10:30
Nick Clifton dda8d76d0d Add support to readelf and objdump for following links to separate debug information files.
Hi Guys,

  I am applying the rather large patch attached to this email to enhance
  the readelf and objdump programs so that they now have the ability to
  follow links to separate debug info files.  (As requested by PR
  15152).  So for example whereas before we had this output:

    $ readelf -wi main.exe

    Contents of the .debug_info section:
    [...]
    <15>   DW_AT_comp_dir    : (alt indirect string, offset: 0x30c)
    [...]

  With the new option enabled we get:

    $ readelf -wiK main.exe

    main.exe: Found separate debug info file: dwz.debug
    Contents of the .debug_info section (loaded from main.exe):
    [...]
    <15>   DW_AT_comp_dir    : (alt indirect string, offset: 0x30c) /home/nickc/Downloads/dwzm
    [...]

  The link following feature also means that we can get two lots of
  output if the same section exists in both the main file and the
  separate debug info file:

    $ readelf -wiK main.exe
    main.exe: Found separate debug info file: dwz.debug
    Contents of the .debug_info section (loaded from main.exe):
    [...]
    Contents of the .debug_info section (loaded from dwz.debug):
    [...]

  The patch also adds the ability to display the contents of debuglink
  sections:

    $ readelf -wk main.exe
    Contents of the .gnu_debugaltlink section:

      Separate debug info file: dwz.debug
      Build-ID (0x14 bytes):
     c4 a8 89 8d 64 cf 70 8a 35 68 21 f2 ed 24 45 3e 18 7a 7a 93

  Naturally there are long versions of these options (=follow-links and
  =links).  The documentation has been updated as well, and since both
  readelf and objdump use the same set of debug display options, I have
  moved the text into a separate file.  There are also a couple of new
  binutils tests to exercise the new behaviour.

  There are a couple of missing features in the current patch however,
  although I do intend to address them in follow up submissions:

  Firstly the code does not check the build-id inside separate debug
  info files when it is searching for a file specified by a
  .gnu_debugaltlink section.  It just assumes that if the file is there,
  then it contains the information being sought.

  Secondly I have not checked the DWARF-5 version of these link
  features, so there will probably be code to add there.

  Thirdly I have only implemented link following for the
  DW_FORM_GNU_strp_alt format.  Other alternate formats (eg
  DW_FORM_GNU_ref_alt) have yet to be implemented.

  Lastly, whilst implementing this feature I found it necessary to move
  some of the global variables used by readelf (eg section_headers) into
  a structure that can be passed around.  I have moved all of the global
  variables that were necessary to get the patch working, but I need to
  complete the operation and move the remaining, file-specific variables
  (eg dynamic_strings).

Cheers
  Nick

binutils	PR 15152
	* dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink,
	gnu_debugaltlink and separate_debug_str.
	(struct dwarf_section): Add filename field.
	Add prototypes for load_separate_debug_file, close_debug_file and
	open_debug_file.
	* dwarf.c (do_debug_links): New.
	(do_follow_links): New.
	(separate_debug_file, separate_debug_filename): New.
	(fetch_alt_indirect_string): New function.  Retrieves a string
	from the debug string table in the separate debug info file.
	(read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt.
	(load_debug_section_with_follow): New function.  Like
	load_debug_section, but if the first attempt fails, then tries
	again in the separate debug info file.
	(introduce): New function.
	(process_debug_info): Use load_debug_section_with_follow and
	introduce.
	(load_debug_info): Likewise.
	(display_debug_lines_raw): Likewise.
	(display_debug_lines_decoded): Likewise.
	(display_debug_macinfo): Likewise.
	(display_debug_macro): Likewise.
	(display_debug_abbrev): Likewise.
	(display_debug_loc): Likewise.
	(display_debug_str): Likewise.
	(display_debug_aranges): Likewise.
	(display_debug_addr); Likewise.
	(display_debug_frames): Likewise.
	(display_gdb_index): Likewise.
	(process_cu_tu_index): Likewise.
	(load_cu_tu_indexes): Likewise.
	(display_debug_links): New function.  Displays the contents of a
	.gnu_debuglink or .gnu_debugaltlink section.
	(calc_gnu_debuglink_ctc32):New function.  Calculates a CRC32
	value.
	(check_gnu_debuglink): New function.  Checks the CRC of a
	potential separate debug info file.
	(parse_gnu_debuglink): New function.  Reads a CRC value out of a
	.gnu_debuglink section.
	(check_gnu_debugaltlink): New function.
	(parse_gnu_debugaltlink): New function.  Reads the build-id value
	out of a .gnu_debugaltlink section.
	(load_separate_debug_info): New function.  Finds and loads a
	separate debug info file.
	(load_separate_debug_file): New function. Attempts to find and
	follow a link to a separate debug info file.
	(free_debug_memory): Free the separate debug info file
	information.
	(opts_table): Add "follow-links" and "links".
	(dwarf_select_sections_by_letters): Add "k" and "K".
	(debug_displays): Reformat.  Add .gnu-debuglink and
	.gnu_debugaltlink.
	Add an extra entry for .debug_str in a separate debug info file.
	* doc/binutils.texi: Move description of debug dump features
	common to both readelf and objdump into...
	* objdump.c (usage): Add -Wk and -WK.
	(load_specific_debug_section): Initialise the filename field in
	the dwarf_section structure.
	(close_debug_file): New function.
	(open_debug_file): New function.
	(dump_dwarf): Load and dump the separate debug info sections.
	* readelf.c (struct filedata): New structure.  Contains various
	variables that used to be global:
	(current_file_size, string_table, string_table_length, elf_header)
	(section_headers, program_headers, dump_sects, num_dump_sects):
	Move into filedata structure.
	(cmdline): New global variable.  Contains list of sections to dump
	by number, as specified on the command line.
	Add filedata parameter to most functions.
	(load_debug_section): Load the string table if it has not already
	been retrieved.
	(close_file): New function.
	(close_debug_file): New function.
	(open_file): New function.
	(open_debug_file): New function.
	(process_object): Process sections in any separate debug info files.
	* doc/debug.options.texi: New file.  Add description of =links and
	=follow-links options.
	* NEWS: Mention the new feature.
	* elfcomm.c: Have the byte gte functions take a const pointer.
	* elfcomm.h: Update prototypes.
	* testsuite/binutils-all/dw5.W: Update expected output.
	* testsuite/binutils-all/objdump.WL: Update expected output.
	* testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk.
	* testsuite/binutils-all/readelf.exp: Add test of -wK and -wk.
	* testsuite/binutils-all/readelf.k: New file.
	* testsuite/binutils-all/objdump.Wk: New file.
	* testsuite/binutils-all/objdump.WK2: New file.
	* testsuite/binutils-all/linkdebug.s: New file.
	* testsuite/binutils-all/debuglink.s: New file.

gas	* testsuite/gas/avr/large-debug-line-table.d: Update expected
	output.
	* testsuite/gas/elf/dwarf2-11.d: Likewise.
	* testsuite/gas/elf/dwarf2-12.d: Likewise.
	* testsuite/gas/elf/dwarf2-13.d: Likewise.
	* testsuite/gas/elf/dwarf2-14.d: Likewise.
	* testsuite/gas/elf/dwarf2-15.d: Likewise.
	* testsuite/gas/elf/dwarf2-16.d: Likewise.
	* testsuite/gas/elf/dwarf2-17.d: Likewise.
	* testsuite/gas/elf/dwarf2-18.d: Likewise.
	* testsuite/gas/elf/dwarf2-5.d: Likewise.
	* testsuite/gas/elf/dwarf2-6.d: Likewise.
	* testsuite/gas/elf/dwarf2-7.d: Likewise.

ld	* testsuite/ld-avr/gc-section-debugline.d: Update expected
	output.
2017-11-15 11:34:03 +00:00
Alan Modra bfec0f11ea PR22232, NULL pointer dereference in load_specific_debug_section
PR 22232
	PR 22230
	* objdump.c (load_specific_debug_section): Introduce a temp to
	stop bfd_get_full_section_contents NULLing out section->start.
2017-10-01 21:41:16 +10:30
Alan Modra 4f1881b944 PR22230, buffer overflow in display_debug_macro
PR 22230
	* objdump.c (load_specific_debug_section): Allocate an extra byte
	for a terminating NUL.
2017-10-01 12:07:07 +10:30
Alan Modra 8b5b252959 PR21978, objdump does not display line numbers in certain cases
Same line but different file ought to display file and line.

	PR 21978
	* objdump.c: Formatting.
	(show_line): Reset prev_line when function name changes.
2017-09-30 12:01:43 +09:30
Alan Modra bae7501e87 Use bfd_malloc_and_get_section
It's nicer than xmalloc followed by bfd_get_section_contents, since
xmalloc exits on failure and needs a check that its size_t arg doesn't
lose high bits when converted from bfd_size_type.

	PR binutils/21665
	* objdump.c (strtab): Make var a bfd_byte*.
	(disassemble_section): Don't limit malloc size.  Instead, use
	bfd_malloc_and_get_section.
	(read_section_stabs): Use bfd_malloc_and_get_section.  Return
	bfd_byte*.
	(find_stabs_section): Remove now unnecessary cast.
	* objcopy.c (copy_object): Use bfd_malloc_and_get_section.  Free
	contents on error return.
	* nlmconv.c (copy_sections): Use bfd_malloc_and_get_section.
2017-07-02 08:33:12 +09:30
Nick Clifton 60a02042ba Fix failures in MMIX linker tests introduced by fix for PR 21665.
PR binutils/21665
	* objdump.c (disassemble_section): Move check for an overlarge
	section to just before the allocation of memory.  Do not check
	section size against file size, but instead use an arbitrary 2Gb
	limit.  Issue a warning message if the section is too big.
2017-06-30 11:03:37 +01:00
H.J. Lu 47fdcf63c0 Change bfd_get_size/bfd_get_file_size to ufile_ptr
bfd_get_size and bfd_get_file_size should return the unsigned file
size.  Otherwise they return negative values for file >= 2GB with
32-bit ufile_ptr.

bfd/

	* bfd-in2.h: Regenerated.
	* bfdio.c (bfd_get_size): Change return type to ufile_ptr.
	(bfd_get_file_size): Likewise.

binutils/

	* objdump.c (dump_relocs_in_section): Cast to ufile_ptr when
	comparing against bfd_get_file_size return.
2017-06-28 11:01:21 -07:00
Nick Clifton cfd14a500e Fix address violations when atempting to parse fuzzed binaries.
PR binutils/21665
bfd	* opncls.c (get_build_id): Check that the section is beig enough
	to contain the whole note.
	* compress.c (bfd_get_full_section_contents): Check for and reject
	a section whoes size is greater than the size of the entire file.
	* elf32-v850.c (v850_elf_copy_notes): Allow for the ouput to not
	contain a notes section.

binutils* objdump.c (disassemble_section): Skip any section that is bigger
	than the entire file.
2017-06-26 15:25:08 +01:00
Nick Clifton d16fdddb4e Fix address violation when attempting to display disassembled data.
PR binutils/21619
	* objdump.c (disassemble_bytes): Check that there is sufficient
	data available before attempting to display it.
2017-06-19 15:57:19 +01:00
Nick Clifton ae87f7e73e Fix address violation when disassembling a corrupt binary.
PR binutils/21580
binutils * objdump.c (disassemble_bytes): Check for buffer overrun when
	printing out rae insns.

ld	* testsuite/ld-nds32/diff.d: Adjust expected output.
2017-06-14 16:50:03 +01:00
H.J. Lu 8e2f54bcee Add bfd_get_file_size to get archive element size
We can't use stat() to get archive element size.  Add bfd_get_file_size
to get size for both normal files and archive elements.

bfd/

	PR binutils/21519
	* bfdio.c (bfd_get_file_size): New function.
	* bfd-in2.h: Regenerated.

binutils/

	PR binutils/21519
	* objdump.c (dump_relocs_in_section): Replace get_file_size
	with bfd_get_file_size to get archive element size.
	* testsuite/binutils-all/objdump.exp (test_objdump_f): New
	proc.
	(test_objdump_h): Likewise.
	(test_objdump_t): Likewise.
	(test_objdump_r): Likewise.
	(test_objdump_s): Likewise.
	Add objdump tests on archive.
2017-05-30 06:34:40 -07:00
Yao Qi 003ca0fd22 Refactor disassembler selection
Nowadays, opcodes/disassemble.c:disassembler selects the proper
disassembler according to ABFD only.  However, it actually
selects disassemblers according to arch, mach, endianess, and
abfd.  This patch adds them to the parameters of disassembler,
so that its caller can still select disassemblers in case that
abfd is NULL (a typical case in GDB).

There isn't any functionality change.

binutils:

2017-05-24  Yao Qi  <yao.qi@linaro.org>

	* objdump.c (disassemble_data): Caller update.

include:

2017-05-24  Yao Qi  <yao.qi@linaro.org>

	* dis-asm.h (disassembler): Update declaration.

opcodes:

2017-05-24  Yao Qi  <yao.qi@linaro.org>

	* disassemble.c (disassembler): Add arguments a, big and mach.
	Use them.

sim/common:

2017-05-24  Yao Qi  <yao.qi@linaro.org>

	* sim-trace.c (trace_disasm): Caller update.
2017-05-24 17:23:52 +01:00
Nick Clifton 39ff1b79f6 Prevent memory exhaustion from a corrupt PE binary with an overlarge number of relocs.
PR 21440
	* objdump.c (dump_relocs_in_section): Check for an excessive
	number of relocs before attempting to dump them.
2017-05-02 11:54:53 +01:00
Alan Modra b02cd3e978 PR 21415, objdump fails to check bfd_get_section_contents status
PR 21415
	* objdump.c (disassemble_section): Check bfd_get_section_contents
	status.
2017-04-23 20:33:35 +09:30
Andi Kleen 4a14e30646 Add --inlines option to objdump to include scope backtrace of inlined functions when generating source line number information.
* objdump.c (unwind_inlines): Add.
	(option_values): Add OPTION_INLINES.
	(show_line): Unwind inlines if requested.
	(main): Parse OPTION_INLINES.
	(usage): Document --inlines.
	* doc/binutils.texi: Document --inlines.
	* NEWS: Likewise.
2017-03-21 13:05:19 +00:00
Alan Modra 5ef2d51bd6 objdump -dS: warn if source is more recent than object
If the source file is more recent than the object file, line number
information in the object may no longer match the source.  So print a
warning message.

	* objdump.c (update_source_path): Add abfd param.  Add struct
	stat vars.  Pass to try_print_file_open.  Warn if source is more
	recent than object.
	(try_print_file_open, slurp_file): Add struct stat param to
	return fstat.
	(show_line): Call update_source_path with bfd.
2017-03-13 21:20:02 +10:30
Chia-Hao Lo 7b5d48229b Make objdump's --wide command line option affect its output of DWARF debug information.
PR binutils/21235
	* objdump.c (main): Set do_wide with --wide.
2017-03-10 16:29:58 +00:00
Peter Bergner 65b48a8140 GDB: Add support for the new set/show disassembler-options commands.
This commit adds support to GDB so that it can modify the disassembler-options
value that is passed to the disassembler, similar to objdump's -M option.
Currently, the only supported targets are ARM, PowerPC and S/390, but
adding support for a new target(s) is not difficult.

include/
	* dis-asm.h (disasm_options_t): New typedef.
	(parse_arm_disassembler_option): Remove prototype.
	(set_arm_regname_option): Likewise.
	(get_arm_regnames): Likewise.
	(get_arm_regname_num_options): Likewise.
	(disassemble_init_s390): New prototype.
	(disassembler_options_powerpc): Likewise.
	(disassembler_options_arm): Likewise.
	(disassembler_options_s390): Likewise.
	(remove_whitespace_and_extra_commas): Likewise.
	(disassembler_options_cmp): Likewise.
	(next_disassembler_option): New inline function.
	(FOR_EACH_DISASSEMBLER_OPTION): New macro.

opcodes/
	* disassemble.c Include "safe-ctype.h".
	(disassemble_init_for_target): Handle s390 init.
	(remove_whitespace_and_extra_commas): New function.
	(disassembler_options_cmp): Likewise.
	* arm-dis.c: Include "libiberty.h".
	(NUM_ELEM): Delete.
	(regnames): Use long disassembler style names.
	Add force-thumb and no-force-thumb options.
	(NUM_ARM_REGNAMES): Rename from this...
	(NUM_ARM_OPTIONS): ...to this.  Use ARRAY_SIZE.
	(get_arm_regname_num_options): Delete.
	(set_arm_regname_option): Likewise.
	(get_arm_regnames): Likewise.
	(parse_disassembler_options): Likewise.
	(parse_arm_disassembler_option): Rename from this...
	(parse_arm_disassembler_options): ...to this.  Make static.
	Use new FOR_EACH_DISASSEMBLER_OPTION macro to scan over options.
	(print_insn): Use parse_arm_disassembler_options.
	(disassembler_options_arm): New function.
	(print_arm_disassembler_options): Handle updated regnames.
	* ppc-dis.c: Include "libiberty.h".
	(ppc_opts): Add "32" and "64" entries.
	(ppc_parse_cpu): Use ARRAY_SIZE and disassembler_options_cmp.
	(powerpc_init_dialect): Add break to switch statement.
	Use new FOR_EACH_DISASSEMBLER_OPTION macro.
	(disassembler_options_powerpc): New function.
	(print_ppc_disassembler_options): Use ARRAY_SIZE.
	Remove printing of "32" and "64".
	* s390-dis.c: Include "libiberty.h".
	(init_flag): Remove unneeded variable.
	(struct s390_options_t): New structure type.
	(options): New structure.
	(init_disasm): Rename from this...
	(disassemble_init_s390): ...to this.  Add initializations for
	current_arch_mask and option_use_insn_len_bits_p.  Remove init_flag.
	(print_insn_s390): Delete call to init_disasm.
	(disassembler_options_s390): New function.
	(print_s390_disassembler_options): Print using information from
	struct 'options'.
	* po/opcodes.pot: Regenerate.

binutils/
	* objdump.c (main): Use remove_whitespace_and_extra_commas.

gdb/
	* NEWS: Mention new set/show disassembler-options commands.
	* doc/gdb.texinfo: Document new set/show disassembler-options commands.
	* disasm.c: Include "arch-utils.h", "gdbcmd.h" and "safe-ctype.h".
	(prospective_options): New static variable.
	(gdb_disassembler::gdb_disassembler): Initialize
	m_di.disassembler_options.
	(gdb_buffered_insn_length_init_dis): Initilize di->disassembler_options.
	(get_disassembler_options): New function.
	(set_disassembler_options): Likewise.
	(set_disassembler_options_sfunc): Likewise.
	(show_disassembler_options_sfunc): Likewise.
	(disassembler_options_completer): Likewise.
	(_initialize_disasm): Likewise.
	* disasm.h (get_disassembler_options): New prototype.
	(set_disassembler_options): Likewise.
	* gdbarch.sh (gdbarch_disassembler_options): New variable.
	(gdbarch_verify_disassembler_options): Likewise.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Likewise.
	* arm-tdep.c (num_disassembly_options): Delete.
	(set_disassembly_style): Likewise.
	(arm_disassembler_options): New static variable.
	(set_disassembly_style_sfunc): Convert short style name into long
	option name.  Call set_disassembler_options.
	(show_disassembly_style_sfunc): New function.
	(arm_gdbarch_init): Call set_gdbarch_disassembler_options and
	set_gdbarch_verify_disassembler_options.
	(_initialize_arm_tdep): Delete regnames variable and update callers.
	(arm_disassembler_options): Initialize.
	(disasm_options): New variable.
	(num_disassembly_options): Rename from this...
	(num_disassembly_styles): ...to this.  Compute by scanning through
	disasm_options.
	(valid_disassembly_styles): Initialize using disasm_options.
	Remove calls to parse_arm_disassembler_option, get_arm_regnames and
	set_arm_regname_option.
	Pass show_disassembly_style_sfunc to the "disassembler" setshow command.
	* rs6000-tdep.c (powerpc_disassembler_options): New static variable.
	(rs6000_gdbarch_init): Call set_gdbarch_disassembler_options and
	set_gdbarch_verify_disassembler_options.
	* s390-tdep.c (s390_disassembler_options): New static variable.
	(s390_gdbarch_init):all set_gdbarch_disassembler_options and
	set_gdbarch_verify_disassembler_options.

gdb/testsuite/
	* gdb.arch/powerpc-power.exp: Delete test.
	* gdb.arch/powerpc-power.s: Likewise.
	* gdb.disasm/disassembler-options.exp: New test.
	* gdb.arch/powerpc-altivec.exp: Likewise.
	* gdb.arch/powerpc-altivec.s: Likewise.
	* gdb.arch/powerpc-altivec2.exp: Likewise.
	* gdb.arch/powerpc-altivec2.s: Likewise.
	* gdb.arch/powerpc-altivec3.exp: Likewise.
	* gdb.arch/powerpc-altivec3.s: Likewise.
	* gdb.arch/powerpc-power7.exp: Likewise.
	* gdb.arch/powerpc-power7.s: Likewise.
	* gdb.arch/powerpc-power8.exp: Likewise.
	* gdb.arch/powerpc-power8.s: Likewise.
	* gdb.arch/powerpc-power9.exp: Likewise.
	* gdb.arch/powerpc-power9.s: Likewise.
	* gdb.arch/powerpc-vsx.exp: Likewise.
	* gdb.arch/powerpc-vsx.s: Likewise.
	* gdb.arch/powerpc-vsx2.exp: Likewise.
	* gdb.arch/powerpc-vsx2.s: Likewise.
	* gdb.arch/powerpc-vsx3.exp: Likewise.
	* gdb.arch/powerpc-vsx3.s: Likewise.
	* gdb.arch/arm-disassembler-options.exp: Likewise.
	* gdb.arch/powerpc-disassembler-options.exp: Likewise.
	* gdb.arch/s390-disassembler-options.exp: Likewise.
2017-02-28 12:32:07 -06:00
Andrew Burgess 1737c64030 objdump: Better objdump section headers in wide mode
When displaying the section headers table using objdump (-h), the column
containing the section header name is currently fixed at 13 characters.
A section name that is longer than 13 characters will overflow the
column causing the table to become miss-aligned.

In this commit I change the behaviour so that _in wide mode_ (-w -h) the
section name column is dynamically resized to fit the longest section
name we plan to display.  In wide mode the column still retains a
minimum width of 13 characters.

In non-wide more the behaviour is completely unchanged.

While I was changing the dump_headers function I have unified the two
printf lines that handled the different address widths into a single
printf, the address width is now passed into printf using the '*' field
width format character.

binutils/ChangeLog:

	* objdump.c (dump_section_header): Extract max section name length
	from data parameter, use this when formatting output.
	(find_longest_section_name): New function.
	(dump_headers): Calculate longest section name when in wide mode,
	reformat to unify printing of header line.

ld/ChangeLog:

	* testsuite/ld-elf/eh-frame-hdr.d: Update expected results.
2017-01-20 09:05:41 +00:00
Nick Clifton cd6581da62 Speed up objdump when displaying disassembly mixed with line number and source code information.
bfd	* dwarf2.c (lookup_address_in_function_table): Return early if
	there are no functions in the given comp unit, or if the high
	address of the last function in the comp unit is less than the
	desired address.

binutils * objdump.c (display_file): Add new parameter 'last_file'.  If
	last_file is true, do not call bfd_close at the end of the
	function.
	(main): Set the value of the last_file parameter when calling
	display_file.
2017-01-09 16:49:48 +00:00
Alan Modra 2571583aed Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
Nick Clifton a24bb4f0cc Enhance objdump so that it will use .got, .plt and .plt.got section symbols when disassembling, and it will use dynamic relocs to interpret entries in the PLT and GOT.
binutils * objdump.c (is_significant_symbol_name): New function.
	(remove_useless_symbols): Do not remove significanr symbols.
	(find_symbol_for_address): If an exact match for the specified
	address has not been found, try scanning the dynamic relocs to see
	if one of these matches the address.  If so, use the symbol
	associated with the reloc.
	(objdump_print_addr_with_symbol): Do not print offsets to symbols
	with no value.
	(disassemble_section): Only use dynamic relocs if the user
	requested this.
	(disassemble_data): Always load dynamic relocs if they are
	available.

ld	* ld-aarch64/emit-relocs-515-be.d: Adjust output to match change
	in objdump.
	* ld-aarch64/emit-relocs-515.d: Likewise.
	* ld-aarch64/emit-relocs-516-be.d: Likewise.
	* ld-aarch64/emit-relocs-516.d: Likewise.
	* ld-aarch64/farcall-b-plt.d: Likewise.
	* ld-aarch64/farcall-bl-plt.d: Likewise.
	* ld-aarch64/gc-plt-relocs.d: Likewise.
	* ld-aarch64/tls-desc-ie.d: Likewise.
	* ld-aarch64/tls-tiny-desc.d: Likewise.
	* ld-aarch64/tls-tiny-gd.d: Likewise.
	* ld-aarch64/tls-tiny-ie.d: Likewise.
	* ld-arm/arm-app-abs32.d: Likewise.
	* ld-arm/arm-app.d: Likewise.
	* ld-arm/arm-lib-plt32.d: Likewise.
	* ld-arm/arm-lib.d: Likewise.
	* ld-arm/armthumb-lib.d: Likewise.
	* ld-arm/cortex-a8-fix-b-plt.d: Likewise.
	* ld-arm/cortex-a8-fix-bcc-plt.d: Likewise.
	* ld-arm/cortex-a8-fix-bl-plt.d: Likewise.
	* ld-arm/cortex-a8-fix-bl-rel-plt.d: Likewise.
	* ld-arm/cortex-a8-fix-blx-plt.d: Likewise.
	* ld-arm/farcall-mixed-app-v5.d: Likewise.
	* ld-arm/farcall-mixed-app.d: Likewise.
	* ld-arm/farcall-mixed-app2.d: Likewise.
	* ld-arm/farcall-mixed-lib-v4t.d: Likewise.
	* ld-arm/farcall-mixed-lib.d: Likewise.
	* ld-arm/ifunc-10.dd: Likewise.
	* ld-arm/ifunc-14.dd: Likewise.
	* ld-arm/ifunc-15.dd: Likewise.
	* ld-arm/ifunc-3.dd: Likewise.
	* ld-arm/ifunc-4.dd: Likewise.
	* ld-arm/ifunc-9.dd: Likewise.
	* ld-arm/long-plt-format.d: Likewise.
	* ld-arm/mixed-app-v5.d: Likewise.
	* ld-arm/mixed-app.d: Likewise.
	* ld-arm/mixed-lib.d: Likewise.
	* ld-arm/tls-lib-loc.d: Likewise.
	* ld-cris/dso-pltdis1.d: Likewise.
	* ld-cris/dso-pltdis2.d: Likewise.
	* ld-cris/dso12-pltdis.d: Likewise.
	* ld-elf/symbolic-func.r: Likewise.
	* ld-frv/fdpic-pie-1.d: Likewise.
	* ld-frv/fdpic-pie-2.d: Likewise.
	* ld-frv/fdpic-pie-6.d: Likewise.
	* ld-frv/fdpic-pie-7.d: Likewise.
	* ld-frv/fdpic-pie-8.d: Likewise.
	* ld-frv/fdpic-shared-1.d: Likewise.
	* ld-frv/fdpic-shared-2.d: Likewise.
	* ld-frv/fdpic-shared-3.d: Likewise.
	* ld-frv/fdpic-shared-4.d: Likewise.
	* ld-frv/fdpic-shared-5.d: Likewise.
	* ld-frv/fdpic-shared-6.d: Likewise.
	* ld-frv/fdpic-shared-7.d: Likewise.
	* ld-frv/fdpic-shared-8.d: Likewise.
	* ld-frv/fdpic-shared-local-2.d: Likewise.
	* ld-frv/fdpic-shared-local-8.d: Likewise.
	* ld-frv/fdpic-static-1.d: Likewise.
	* ld-frv/fdpic-static-2.d: Likewise.
	* ld-frv/fdpic-static-6.d: Likewise.
	* ld-frv/fdpic-static-7.d: Likewise.
	* ld-frv/fdpic-static-8.d: Likewise.
	* ld-frv/tls-dynamic-2.d: Likewise.
	* ld-frv/tls-initial-shared-2.d: Likewise.
	* ld-frv/tls-relax-shared-2.d: Likewise.
	* ld-frv/tls-shared-2.d: Likewise.
	* ld-i386/plt-nacl.pd: Likewise.
	* ld-i386/plt-pic-nacl.pd: Likewise.
	* ld-i386/plt-pic.pd: Likewise.
	* ld-i386/plt.pd: Likewise.
	* ld-i386/pr19636-1d-nacl.d: Likewise.
	* ld-i386/pr19636-1d.d: Likewise.
	* ld-i386/pr19636-2c-nacl.d: Likewise.
	* ld-i386/pr19636-2c.d: Likewise.
	* ld-ifunc/ifunc-21-x86-64.d: Likewise.
	* ld-ifunc/ifunc-22-x86-64.d: Likewise.
	* ld-ifunc/pr17154-i386.d: Likewise.
	* ld-ifunc/pr17154-x86-64.d: Likewise.
	* ld-m68k/plt1-68020.d: Likewise.
	* ld-m68k/plt1-cpu32.d: Likewise.
	* ld-m68k/plt1-isab.d: Likewise.
	* ld-m68k/plt1-isac.d: Likewise.
	* ld-metag/shared.d: Likewise.
	* ld-metag/stub_pic_app.d: Likewise.
	* ld-metag/stub_pic_shared.d: Likewise.
	* ld-metag/stub_shared.d: Likewise.
	* ld-s390/tlsbin_64.dd: Likewise.
	* ld-s390/tlspic_64.dd: Likewise.
	* ld-tic6x/shlib-1.dd: Likewise.
	* ld-tic6x/shlib-1b.dd: Likewise.
	* ld-tic6x/shlib-1rb.dd: Likewise.
	* ld-tic6x/shlib-app-1.dd: Likewise.
	* ld-tic6x/shlib-app-1b.dd: Likewise.
	* ld-tic6x/shlib-app-1r.dd: Likewise.
	* ld-tic6x/shlib-app-1rb.dd: Likewise.
	* ld-tic6x/shlib-noindex.dd: Likewise.
	* ld-vax-elf/export-class-data.dd: Likewise.
	* ld-vax-elf/plt-local-lib.dd: Likewise.
	* ld-vax-elf/plt-local.dd: Likewise.
	* ld-x86-64/bnd-ifunc-2.d: Likewise.
	* ld-x86-64/bnd-plt-1.d: Likewise.
	* ld-x86-64/gotpcrel1.dd: Likewise.
	* ld-x86-64/libno-plt-1b.dd: Likewise.
	* ld-x86-64/load1c-nacl.d: Likewise.
	* ld-x86-64/load1c.d: Likewise.
	* ld-x86-64/load1d-nacl.d: Likewise.
	* ld-x86-64/load1d.d: Likewise.
	* ld-x86-64/mov1a.d: Likewise.
	* ld-x86-64/mov1b.d: Likewise.
	* ld-x86-64/mov1c.d: Likewise.
	* ld-x86-64/mov1d.d: Likewise.
	* ld-x86-64/mov2a.d: Likewise.
	* ld-x86-64/mov2b.d: Likewise.
	* ld-x86-64/mov2c.d: Likewise.
	* ld-x86-64/mov2d.d: Likewise.
	* ld-x86-64/mpx3.dd: Likewise.
	* ld-x86-64/mpx4.dd: Likewise.
	* ld-x86-64/no-plt-1a.dd: Likewise.
	* ld-x86-64/no-plt-1b.dd: Likewise.
	* ld-x86-64/no-plt-1c.dd: Likewise.
	* ld-x86-64/no-plt-1e.dd: Likewise.
	* ld-x86-64/no-plt-1f.dd: Likewise.
	* ld-x86-64/no-plt-1g.dd: Likewise.
	* ld-x86-64/plt-main-bnd.dd: Likewise.
	* ld-x86-64/plt-nacl.pd: Likewise.
	* ld-x86-64/plt.pd: Likewise.
	* ld-x86-64/pr18591.d: Likewise.
	* ld-x86-64/pr19609-1c.d: Likewise.
	* ld-x86-64/pr19609-1e.d: Likewise.
	* ld-x86-64/pr19609-1j.d: Likewise.
	* ld-x86-64/pr19609-1l.d: Likewise.
	* ld-x86-64/pr19609-1m.d: Likewise.
	* ld-x86-64/pr19609-5b.d: Likewise.
	* ld-x86-64/pr19609-5c.d: Likewise.
	* ld-x86-64/pr19609-5e.d: Likewise.
	* ld-x86-64/pr19609-6b.d: Likewise.
	* ld-x86-64/pr19609-7b.d: Likewise.
	* ld-x86-64/pr19609-7d.d: Likewise.
	* ld-x86-64/pr19636-2d.d: Likewise.
	* ld-x86-64/pr20093-1.d: Likewise.
	* ld-x86-64/pr20093-2.d: Likewise.
	* ld-x86-64/pr20253-1b.d: Likewise.
	* ld-x86-64/pr20253-1d.d: Likewise.
	* ld-x86-64/pr20253-1f.d: Likewise.
	* ld-x86-64/pr20253-1h.d: Likewise.
	* ld-x86-64/pr20253-1j.d: Likewise.
	* ld-x86-64/pr20253-1l.d: Likewise.
	* ld-x86-64/protected3.d: Likewise.
	* ld-x86-64/tlsbin.dd: Likewise.
	* ld-x86-64/tlsbin2.dd: Likewise.
	* ld-x86-64/tlsbindesc.dd: Likewise.
	* ld-x86-64/tlsdesc-nacl.pd: Likewise.
	* ld-x86-64/tlsdesc.dd: Likewise.
	* ld-x86-64/tlsdesc.pd: Likewise.
	* ld-x86-64/tlsgd10.dd: Likewise.
	* ld-x86-64/tlsgd5.dd: Likewise.
	* ld-x86-64/tlsgd6.dd: Likewise.
	* ld-x86-64/tlsgd8.dd: Likewise.
	* ld-x86-64/tlsgdesc.dd: Likewise.
	* ld-x86-64/tlspic.dd: Likewise.
	* ld-x86-64/tlspic2.dd: Likewise.

2016-10-11  Nick Clifton  <nickc@redhat.com>

	PR ld/20535
	* emultempl/elf32.em (_search_needed): Add support for pseudo
	environment variables supported by ld.so.  Namely $ORIGIN, $LIB
	and $PLATFORM.
	* configure.ac: Add getauxval to list AC_CHECK_FUNCS list.
	* config.in: Regenerate.
	* configure: Regenerate.

2016-10-11  Alan Modra  <amodra@gmail.com>

	* ldlang.c (lang_do_assignments_1): Descend into output section
	statements that do not yet have bfd sections.  Set symbol section
	temporarily for symbols defined in such statements to the undefined
	section.  Don't error on data or reloc statements until final phase.
	* ldexp.c (exp_fold_tree_1 <etree_assign>): Handle bfd_und_section
	in expld.section.
	* testsuite/ld-mmix/bpo-10.d: Adjust.
	* testsuite/ld-mmix/bpo-11.d: Adjust.

2016-10-10  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

	* emulparams/elf64_s390.sh: Move binary start to 16M.
	* testsuite/ld-s390/tlsbin_64.dd: Adjust testcases accordingly.
	* testsuite/ld-s390/tlsbin_64.rd: Likewise.

2016-10-07  Alan Modra  <amodra@gmail.com>

	* ldexp.c (MAX): Define.
	(exp_unop, exp_binop, exp_trinop): Alloc at least enough for
	etree_type.value.

2016-10-07  Alan Modra  <amodra@gmail.com>

	* testsuite/lib/ld-lib.exp (is_generic_elf): New, extracted from..
	* testsuite/ld-elf/elf.exp: ..here.

2016-10-06  Ludovic Court?s  <ludo@gnu.org>

	* emulparams/elf32bmipn32-defs.sh: Shift quote of
	"x$EMULATION_NAME" to the left to work around
	<http://ftp.gnu.org/gnu/bash/bash-4.2-patches/bash42-007>.

2016-10-06  Alan Modra  <amodra@gmail.com>

	* lexsup.c: Spell fall through comments consistently and add
	missing fall through comments.

2016-10-06  Alan Modra  <amodra@gmail.com>

	* plugin.c (asymbol_from_plugin_symbol): Avoid compiler warning
	by adding return.

2016-10-04  Alan Modra  <amodra@gmail.com>

	* ld.texinfo (Expression Section): Update result of arithmetic
	expressions.
	* ldexp.c (arith_result_section): New function.
	(fold_binary): Use it.

2016-10-04  Alan Modra  <amodra@gmail.com>

	* ldexp.c (exp_value_fold): New function.
	(exp_unop, exp_binop, exp_trinop): Use it.

2016-09-30  Alan Modra  <amodra@gmail.com>

	* scripttempl/v850.sc: Don't reference __ctbp, __ep, __gp when
	not relocating.
	* scripttempl/v850_rh850.sc: Likewise.

2016-09-30  Alan Modra  <amodra@gmail.com>

	PR ld/20528
	* testsuite/ld-elf/pr20528a.d: xfail generic elf targets.  Allow
	multiple .text sections for hppa-linux.
	* testsuite/ld-elf/pr20528b.d: Likewise.

2016-09-30  Alan Modra  <amodra@gmail.com>

	* ldmain.c (default_bfd_error_handler): New function pointer.
	(ld_bfd_error_handler): New function.
	(main): Arrange to call it on bfd errors/warnings.
	(ld_bfd_assert_handler): Enable tail call.

2016-09-30  Alan Modra  <amodra@gmail.com>

	* ldlang.c (ignore_bfd_errors): Update params.

2016-09-29  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/20528
	* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Don't
	merge 2 sections with different SHF_EXCLUDE.
	* testsuite/ld-elf/pr20528a.d: New file.
	* testsuite/ld-elf/pr20528a.s: Likewise.
	* testsuite/ld-elf/pr20528b.d: Likewise.
	* testsuite/ld-elf/pr20528b.s: Likewise.

2016-09-28  Christophe Lyon  <christophe.lyon@linaro.org>

	PR ld/20608
	* testsuite/ld-arm/arm-elf.exp: Handle new testcase.
	* testsuite/ld-arm/farcall-mixed-app2.d: New file.
	* testsuite/ld-arm/farcall-mixed-app2.r: Likewise.
	* testsuite/ld-arm/farcall-mixed-app2.s: Likewise.
	* testsuite/ld-arm/farcall-mixed-app2.sym: Likewise.

2016-09-26  Vlad Zakharov  <vzakhar@synopsys.com>

	* Makefile.in: Regenerate.
	* configure: Likewise.

2016-09-26  Alan Modra  <amodra@gmail.com>

	* testsuite/ld-powerpc/attr-gnu-4-4.s: Delete.
	* testsuite/ld-powerpc/attr-gnu-4-14.d: Delete.
	* testsuite/ld-powerpc/attr-gnu-4-24.d: Delete.
	* testsuite/ld-powerpc/attr-gnu-4-34.d: Delete.
	* testsuite/ld-powerpc/attr-gnu-4-41.d: Delete.
	* testsuite/ld-powerpc/attr-gnu-4-32.d: Adjust expected warning.
	* testsuite/ld-powerpc/attr-gnu-8-23.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-01.d: Adjust expected output.
	* testsuite/ld-powerpc/attr-gnu-4-02.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-03.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-10.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-11.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-20.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-22.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-4-33.d: Likewise.
	* testsuite/ld-powerpc/attr-gnu-8-11.d: Likewise.
	* testsuite/ld-powerpc/powerpc.exp: Don't run deleted tests.

2016-09-23  Akihiko Odaki  <akihiko.odaki.4i@stu.hosei.ac.jp>

	PR ld/20595
	* testsuite/ld-arm/unwind-4.d: Add -q option to linker command
	line and -r option to objdump command line.  Match emitted relocs
	to make sure that superflous relocs are not generated.

2016-09-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

	* emulparams/elf64_s390.sh: Change TEXT_START_ADDR to 256MB.
	* testsuite/ld-s390/tlsbin_64.dd: Adjust testcase accordingly.
	* testsuite/ld-s390/tlsbin_64.rd: Likewise.

2016-09-22  Nick Clifton  <nickc@redhat.com>

	* emultempl/elf32.em (_try_needed): In verbose mode, report failed
	attempts to find a needed library.

2016-09-21  Richard Sandiford  <richard.sandiford@arm.com>

	* testsuite/ld-aarch64/emit-relocs-28.d: Expect spaces after ","
	in addresses.
	* testsuite/ld-aarch64/emit-relocs-301-be.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-301.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-302-be.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-302.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-310-be.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-310.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-313.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-515-be.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-515.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-516-be.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-516.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-531.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-532.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-533.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-534.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-535.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-536.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-537.d: Likewise.
	* testsuite/ld-aarch64/emit-relocs-538.d: Likewise.
	* testsuite/ld-aarch64/erratum835769.d: Likewise.
	* testsuite/ld-aarch64/erratum843419.d: Likewise.
	* testsuite/ld-aarch64/farcall-b-plt.d: Likewise.
	* testsuite/ld-aarch64/farcall-bl-plt.d: Likewise.
	* testsuite/ld-aarch64/gc-plt-relocs.d: Likewise.
	* testsuite/ld-aarch64/ifunc-21.d: Likewise.
	* testsuite/ld-aarch64/ifunc-7c.d: Likewise.
	* testsuite/ld-aarch64/tls-desc-ie.d: Likewise.
	* testsuite/ld-aarch64/tls-large-desc-be.d: Likewise.
	* testsuite/ld-aarch64/tls-large-desc.d: Likewise.
	* testsuite/ld-aarch64/tls-large-ie-be.d: Likewise.
	* testsuite/ld-aarch64/tls-large-ie.d: Likewise.
	* testsuite/ld-aarch64/tls-relax-all.d: Likewise.
	* testsuite/ld-aarch64/tls-relax-gd-ie.d: Likewise.
	* testsuite/ld-aarch64/tls-relax-gdesc-ie-2.d: Likewise.
	* testsuite/ld-aarch64/tls-relax-gdesc-ie.d: Likewise.
	* testsuite/ld-aarch64/tls-relax-large-desc-ie-be.d: Likewise.
	* testsuite/ld-aarch64/tls-relax-large-desc-ie.d: Likewise.
	* testsuite/ld-aarch64/tls-tiny-desc.d: Likewise.
	* testsuite/ld-aarch64/tls-tiny-gd.d: Likewise.

gas	* gas/arm/tls.d: Adjust output to match change in objdump.
2016-10-11 13:50:10 +01:00
Alan Modra 32a0481fb1 PR20337, Objdump makes poor choice of symbols
binutils/
	PR binutils/20337
	* objdump.c (compare_symbols): For ELF, sort same value/type
	symbols according to size.
ld/
	* testsuite/ld-powerpc/elfv2exe.d: Update.
2016-07-09 16:53:33 +09:30
Andre Vieria f0728ee368 [ARM] Change noread to purecode.
bfd/ChangeLog
2016-07-05  Andre Vieria  <andre.simoesdiasvieira@arm.com>

        * bfd-in2.h (SEC_ELF_NOREAD): Rename to ...
          (SEC_ELF_PURECODE): ... this.
        * elf32-arm.c (elf32_arm_post_process_headers): Rename SEC_ELF_NOREAD
          to SEC_ELF_NOREAD.
          (elf32_arm_fake_sections): Likewise.
          (elf_32_arm_section_flags): Likewise.
          (elf_32_arm_lookup_section_flags): Likewise.
        * section.c (SEC_ELF_NOREAD): Rename to ...
          (SEC_ELF_PURECODE): ... this.

binutils/ChangeLog
2016-07-05  Andre Vieria  <andre.simoesdiasvieira@arm.com>

        * objdump.c (dump_section_header): Rename SEC_ELF_NOREAD
          to SEC_ELF_NOREAD.
        * readelf.c (get_elf_section_flags): Rename ARM_NOREAD to
          ARM_PURECODE and SHF_ARM_NOREAD to SHF_ARM_PURECODE.
          (process_section_headers): Rename noread to purecode.

        * section.c (SEC_ELF_NOREAD): Rename to ...
          (SEC_ELF_PURECODE): ... this.

include/ChangeLog
2016-07-05  Andre Vieria  <andre.simoesdiasvieira@arm.com>

        * elf/arm.h (SHF_ARM_NOREAD): Rename to ...
          (SHF_ARM_PURECODE): ... this.

ld/ChangeLog
2016-07-05  Andre Vieria  <andre.simoesdiasvieira@arm.com>

        * testsuite/ld-arm/arm_noread.ld: Renamed to ...
          testsuite/ld-arm/arm_purecode.ld: ... this, and replaced
          all noread's by purecode.
2016-07-05 11:28:46 +01:00
Alan Modra f2b2af2c9f Invalid read in _bfd_elf_get_symbol_version_string
PR 20304
	* objdump.c (objdump_print_symname): Don't attempt to retrieve
	version info from synthetic symbols.
2016-06-28 19:09:10 +09:30
Alan Modra 43339b1d1c Limit objdump -S context lines
Showing context lines is confusing in many cases, an obvious example
being loops.

	* objdump.c (struct print_file_list): Add "max_printed".
	(try_print_file_open): Init new field.
	(show_line): Don't show 5 context lines when redisplaying source.
2016-06-24 23:05:48 +09:30
Andreas Arnez d6bb17b079 Add init_dwarf_regnames_s390
Define and use DWARF register names for s390.

binutils/ChangeLog:

	* dwarf.h (init_dwarf_regnames_s390): Declare.
	* dwarf.c (dwarf_regnames_s390): New.
	(init_dwarf_regnames_s390): New.
	(init_dwarf_regnames): Call it.
	* objdump.c (dump_dwarf): Likewise.
2016-04-13 10:56:30 +02:00
Nick Clifton e1fa016350 Remove use of alloca.
bfd	* warning.m4 (GCC_WARN_CFLAGS): Add -Wstack-usage=262144
	* configure: Regenerate.
	* elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Replace use of
	alloca with call to xmalloc.
	* elf32-nds32.c: Likewise.
	* elf64-hppa.c: Likewise.
	* elfxx-mips.c: Likewise.
	* pef.c: Likewise.
	* pei-x86_64.c: Likewise.
	* som.c: Likewise.
	* xsym.c: Likewise.

binutils * dlltool.c: Replace use of alloca with call to xmalloc.
	* dllwrap.c: Likewise.
	* nlmconv.c: Likewise.
	* objdump.c: Likewise.
	* resrc.c: Likewise.
	* winduni.c: Likewise.
	* configure: Regenerate.

gas	* atof-generic.c: Replace use of alloca with call to xmalloc.
	* cgen.c: Likewise.
	* dwarf2dbg.c: Likewise.
	* macro.c: Likewise.
	* remap.c: Likewise.
	* stabs.c: Likewise.
	* symbols.c: Likewise.
	* config/obj-elf.c: Likewise.
	* config/tc-aarch64.c: Likewise.
	* config/tc-arc.c: Likewise.
	* config/tc-arm.c: Likewise.
	* config/tc-avr.c: Likewise.
	* config/tc-ia64.c: Likewise.
	* config/tc-mips.c: Likewise.
	* config/tc-msp430.c: Likewise.
	* config/tc-nds32.c: Likewise.
	* config/tc-ppc.c: Likewise.
	* config/tc-sh.c: Likewise.
	* config/tc-tic30.c: Likewise.
	* config/tc-tic54x.c: Likewise.
	* config/tc-xstormy16.c: Likewise.
	* config/te-vms.c: Likewise.
	* configure: Regenerate.

ld	* emultempl/msp430.em: Replace use of alloca with call to xmalloc.
	* plugin.c: Likewise.
	* pe-dll.c: Likewise.
2016-03-21 16:31:46 +00:00
Mickael Guene 91f68a68f9 Add support for an ARM specific 'y' section attribute flag to mark the section as NOREAD.
bfd/ChangeLog:
      * elf32-arm.c ((elf32_arm_special_sections): Remove catch of noread
      section using '.text.noread' pattern.

gas/ChangeLog:
      * config/obj-elf.c (obj_elf_change_section) : Allow arm section with
      SHF_ARM_NOREAD section flag.
      * config/tc-arm.h (md_elf_section_letter) : Implement this hook to
      handle letter 'y'.
     (arm_elf_section_letter) : Declare it.
      * config/tc-arm.c (arm_elf_section_letter): Handle letter 'y' to set
      SHF_ARM_NOREAD section flag.
      * doc/c-arm.texi (ARM section attribute 'y'): Document it.

gas/testsuite/ChangeLog:
      * gas/arm/section-execute-only.s: New test case.
      * gas/arm/section-execute-only.d: Expected output.

ld/testsuite/ChangeLog:
      * ld-arm/thumb1-noread-not-present-mixing-two-section.s: Add 'y'
      attribute usage.
      * ld-arm/thumb1-noread-present-one-section.s: Likewise.
      * ld-arm/thumb1-noread-present-two-section.s: Likewise.
      * ld-arm/thumb1-input-section-flag-match.s: Likewise.

binutils/ChangeLog:
      * readelf.c (get_elf_section_flags): Display y letter for section
      with SHF_ARM_NOREAD section flag in readelf section output.
      (process_section_headers): Add y letter in readelf section output
      key mapping for ARM architecture.
2016-01-20 12:53:50 +00:00
Alan Modra 6f2750feaf Copyright update for binutils 2016-01-01 23:00:01 +10:30
H.J. Lu 3aade68889 Remove trailing spaces in binutils 2015-08-12 04:42:37 -07: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 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
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
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
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
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
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
Alan Modra b90efa5b79 ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
Alan Modra f4943d8253 Don't always build coffgen.o
Removes a bunch of unused functions from libbfd when building ELF or
AOUT.  Split off the bits we need externally when not building a COFF
target into coff-bfd.c and coff-bfd.h.

bfd/
	* Makefile.am (BFD32_LIBS, BFD32_LIBS_CFILES): Remove dwarf2
	and coffgen.  Add coff-bfd.  Sort.
	(BFD32_BACKENDS, BFD32_BACKENDS_CFILES): Add coffgen and dwarf2.
	* bfd-in.h (bfd_coff_get_syment, bfd_coff_get_auxent): Delete.
	(struct coff_comdat_info, bfd_coff_get_comdat_section): Delete.
	* coffgen.c (coff_symbol_from): Move to coff-bfd.h as macro,
	without unused param.  Update uses.
	(bfd_coff_get_comdat_section): Move to coff-bfd.h as macro.
	(bfd_coff_get_syment, bfd_coff_get_auxent): Move to coff-bfd.c.
	* libcoff-in.h: #include "coff-bfd.h".
	(struct coff_section_tdata, coff_section_data): Move to coff-bfd.h.
	(coff_symbol_from): Delete.
	* coff-bfd.c: New file.
	* coff-bfd.h: New file.
	* coff-i386.c: Update coff_symbol_from occurrences.
	* coff-i960.c: Likewise.
	* coff-m68k.c: Likewise.
	* coff-sh.c: Likewise.
	* coff-x86_64.c: Likewise.
	* coffcode.h: Likewise.
	* pe-mips.c: Likewise.
	* configure.ac (elf): Add dwarf2.lo.
	(coffgen, coff, ecoff, xcoff): Define.  Use when mapping bfd
	target vectors to .o files.  Add dwarf2 for mach-o targets.
	Fix the sh target FIXME.
	* po/SRC-POTFILES.in: Regenerate.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* bfd-in2.h: Regenerate.
	* libcoff.h: Regenerate.
binutils/
	* objdump.c: #include "coff-bfd.h".
ld/
	* ldmisc.c: #include "coff-bfd.h"
2014-12-10 23:13:49 +10:30
Nick Clifton f64e188b58 More fixes for memory access violations triggered by fuzzed binaries.
PR binutils/17512
	* objdump.c (display_any_bfd): Avoid infinite loop closing and
	opening the same archive again and again.

	* archive64.c (bfd_elf64_archive_slurp_armap): Add range checks.
	* libbfd.c (safe_read_leb128): New function.
	* libbfd-in.h (safe_read_leb128): Add prototype.
	* libbfd.h: Regenerate.
	* elf-attrs.c (_bfd_elf_parse_attributes): Use safe_read_leb128.
	Check for an over-long subsection length.
	* elf.c (elf_parse_notes): Check that the namedata is long enough
	for the string comparison that is about to be performed.
	(elf_read_notes): Zero-terminate the note buffer.
2014-12-09 12:42:18 +00:00
Nick Clifton db6b071a97 Fix memory access problems exposed by fuzzed binaries.
PR binutils/17512
	* objdump.c (free_debug_section): Reset the compress_status as
	well.

	* compress.c (bfd_get_full_section_contents): Fail if there are no
	section contents available when the compress_status is
	COMPRESS_SECTION_DONE.
	* libbfd.c (bfd_malloc): Refuse to allocate a negative size.
	(bfd_malloc2): Use bfd_malloc.
	(bfd_realloc): Refuse to reallocate a negative size.
	(bfd_realloc2): Use bfd_realloc.
	(bfd_realloc_or_free): Use bfd_realloc.
	(bfd_zmalloc): Use bfd_malloc.
	(bfd_zmalloc): Use bfd_malloc2.
	* opncls.c (bfd_alloc): Refuse to allocate a negative size.
2014-12-03 19:50:48 +00:00
Nick Clifton 06614111d1 More fixes for memory access violations exposed by fuzzed binaries.
PR binutils/17512
	* dwarf.h (struct dwarf_section): Add user_data field.
	* dwarf.c (frame_need_space): Check for an over large register
	number.
	(display_debug_frames): Check the return value from
	frame_need_space.  Check for a CFA expression that is so long the
	start address wraps around.
	(debug_displays): Initialise the user_data field.
	* objdump.c (load_specific_debug_section): Save the BFD section
	pointer in the user_data field of the dwarf_section structure.
	(free_debug_section): Update BFD section data when freeing section
	contents.
	* readelf.c (load_specific_debug_section): Initialise the
	user_data field.

	* archive.c (do_slurp_coff_armap): Add range checks to prevent
	running off the end of the string table.
	* compress.c (bfd_get_full_section_contents): Return a NULL
	pointer for zero sized sections.  Do not attempt to copy a buffer
	onto itself.
	* elf-attrs.c (_bfd_elf_parse_attributes): Check for an empty
	header.  Add range checks to avoid running off the end of the
	section.
	* elf.c (bfd_elf_get_str_section): Seek before allocating so that
	if the seek fails, no memory is allocated.
	(bfd_elf_string_from_elf_section): Do not allocate a string from a
	non string section.  It only leads to trouble later on.
	(_bfd_elf_print_private_bfd_data): Check for there being too
	little external dynamic data.
	(bfd_section_from_shdr): Replace assertion with a failure mode.
	(bfd_section_from_shdr): When walking a loaded group section use
	the internal structure size, not the external size.  Check for the
	group section being empty.
	* elf32-i386.c (elf_i386_rtype_to_howto): Replace assertion with a
	failure mode.
	* elfcode.h (elf_slurp_reloc_table): Likewise.
	* reloc.c (bfd_perform_relocation): Avoid seg-fault if the howto
	parameter is NULL.
2014-12-01 16:43:46 +00:00