Skip to content
Snippets Groups Projects
  1. Mar 14, 2023
    • Alan Modra's avatar
      objdump segfault after symbol table error · c8b3d02c
      Alan Modra authored
      This memcpy segfaults if symcount is -1 (=> syms is NULL).
            memcpy (sorted_syms, symcount ? syms : dynsyms,
      	      sorted_symcount * sizeof (asymbol *));
      
      	* objdump.c (slurp_symtab): Don't leave symcount as -1 after
      	an error.
      	(slurp_dynamic_symtab): Likewise for dynsymcount.
      c8b3d02c
    • Alan Modra's avatar
      Sanity check read_section_stabs_debugging_info · 746598e0
      Alan Modra authored
      	* rddbg.c (read_section_stabs_debugging_info): Exclude sections
      	without contents.  Use bfd_malloc_and_get_section.  Don't alloc
      	one extra for strings.
      746598e0
  2. Mar 09, 2023
    • Alan Modra's avatar
      objdump: report no section contents · 093b5677
      Alan Modra authored
      objdump's read_section is never used for bss-style sections, so to
      plug a hole that fuzzers have found, exclude sections without
      SEC_HAS_CONTENTS.
      
      	* objdump.c (read_section): Report and return an error on
      	a no contents section.
      093b5677
  3. Mar 08, 2023
    • Alan Modra's avatar
      Re: Move nm.c cached line number info to bfd usrdata · 160f2007
      Alan Modra authored
      Commit e3f450f3 resulted in a nm -l segfault on object files
      without undefined symbols.  Fix that, and be paranoid about bfd
      section count changing.
      
      	* nm.c (struct lineno_cache): Add seccount.
      	(free_lineno_cache): Don't segfault on NULL lc->relocs.
      	(print_symbol): Stash section count when creating arrays.
      160f2007
  4. Mar 06, 2023
    • Alan Modra's avatar
      Downgrade objdump fatal errors to non-fatal · ffdfc835
      Alan Modra authored
      	* objdump.c (slurp_symtab): Replace bfd_fatal calls with calls
      	to my_bfd_nonfatal.
      	(slurp_dynamic_symtab, disassemble_section): Likewise.
      	(disassemble_data): Replace fatal call with non_fatal call, and
      	set exit_status.  Don't error on non-existent dynamic relocs.
      	Don't call bfd_fatal on bfd_canonicalize_dynamic_reloc error.
      	(dump_ctf, dump_section_sframe): Replace bfd_fatal calls with
      	calls to my_bfd_nonfatal and clean up memory.
      	(dump_relocs_in_section): Don't call bfd_fatal on errors.
      	(dump_dynamic_relocs): Likewise.
      	(display_any_bfd): Make archive nesting too depp non_fatal.
      ffdfc835
    • Alan Modra's avatar
      Downgrade addr2line fatal errors to non-fatal · 5db0367e
      Alan Modra authored
      	* addr2line.c (slurp_symtab): Don't exit on errors.
      	(process_file): Likewise.
      5db0367e
    • Alan Modra's avatar
      Downgrade nm fatal errors to non-fatal · 86a2562b
      Alan Modra authored
      Many of the fatal errors in nm ought to be recoverable.  This patch
      downgrades most of them.  The ones that are left are most likely due
      to memory allocation failures.
      
      	* nm.c (print_symdef_entry): Don't bomb with a fatal error
      	on a corrupted archive symbol table.
      	(filter_symbols): Silently omit symbols that return NULL
      	from bfd_minisymbol_to_symbol rather than giving a fatal
      	error.
      	(display_rel_file): Don't give a fatal error on
      	bfd_read_minisymbols returning an error, or on not being able
      	to read dynamic symbols for synth syms.
      	(display_archive): Downgrade bfd_openr_next_archived_file
      	error.
      	(display_file): Don't bomb on a bfd_close failure.
      86a2562b
    • Alan Modra's avatar
      Move nm.c cached line number info to bfd usrdata · e3f450f3
      Alan Modra authored
      Replace the static variables used by nm to cache line number info
      with a struct attached to the bfd.  Cleaner, and it avoids any concern
      that lineno_cache_bfd is somehow left pointing at memory for a closed
      bfd and that memory is later reused for another bfd, not that I think
      this is possible.  Also don't bomb via bfd_fatal on errors getting
      the line number info, just omit the line numbers.
      
      	* nm.c (struct lineno_cache): Rename from get_relocs_info.
      	Add symcount.
      	(lineno_cache_bfd, lineno_cache_rel_bfd): Delete.
      	(get_relocs): Adjust for struct rename.  Don't call bfd_fatal
      	on errors.
      	(free_lineno_cache): New function.
      	(print_symbol): Use lineno_cache in place of statics.  Don't
      	call bfd_fatal on errors reading symbols, just omit the line
      	info.
      	(display_archive, display_file): Call free_lineno_cache.
      e3f450f3
    • Alan Modra's avatar
      Correct objdump command line error handling · a734d906
      Alan Modra authored
      bfd_nonfatal is used when a bfd error is to be printed.  That's not
      the case for command line errors.
      
      	* objdump.c (nonfatal): Rename to my_bfd_nonfatal.
      	(main): Use non_fatal and call usage on unrecognized arg errors.
      	Don't set exit_status when calling usage.
      a734d906
  5. Mar 03, 2023
    • Alan Modra's avatar
      Tidy type handling in binutils/rdcoff.c · 945efa5c
      Alan Modra authored
      There isn't really any good reason for code in rdcoff.c to distinguish
      between "basic" types and any other type.  This patch dispenses with
      the array reserved for basic types and instead handles all types using
      coff_get_slot, simplifying the code.
      
      	* rdcoff.c (struct coff_types, coff_slots): Merge.  Delete
      	coff_slots.
      	(T_MAX): Delete.
      	(parse_coff_base_type): Use coff_get_slot to store baseic types.
      	(coff_get_slot, parse_coff_type, parse_coff_base_type),
      	(parse_coff_struct_type, parse_coff_enum_type),
      	(parse_coff_symbol, parse_coff): Pass types as coff_types**.
      945efa5c
    • Alan Modra's avatar
      binutils coff type list · de357ff4
      Alan Modra authored
      As for commit 72d225ef, handle type numbers starting anywhere.
      
      	PR 17512
      	* rdcoff.c (struct coff_slots): Add base_index.
      	(coff_get_slot): Delete pr17512 excessively large slot check.
      	Don't allocate entire array from 0 to type number, allocate a
      	sparse array.
      de357ff4
  6. Feb 24, 2023
    • Clément Chigot's avatar
      testsuite: prune DOS drive letter in test outputs · 2b693257
      Clément Chigot authored
      On DOS systems, absolute paths start with the drive letter. This can
      trigger failures in the regexp from dump tests, especially for those
      checking for warnings or errors. They are usually skipping everything
      before the first ":" as it has to be the file path.
        | [^:]*: warning: ...
      
      In order to avoid modifying many regexps to allow such drive letters,
      prune them from all the outputs if they are found at the beginning of
      a line.
      
      binutils/ChangeLog:
      
      	* testsuite/lib/binutils-common.exp (prune_dump_output): New
      	(run_dump_test): Use it.
      
      ld/ChangeLog:
      
      	* testsuite/ld-elf/noinit-sections-2.l: Remove DOS drive letter
      	handler.
      2b693257
  7. Feb 22, 2023
  8. Feb 21, 2023
    • Alan Modra's avatar
      Re: objdump read_section_stabs · 45b36294
      Alan Modra authored
      Commit f9c36cc9 changed (and renamed) read_section_stabs with one
      difference in overall behaviour.  Previously read_section_stabs would
      return a NULL for an empty section, which was then treated the same as
      a missing section.  Now an empty section is recognized and dumped.
      This leads to NULL stabp and stabs_end in print_section_stabs.  Since
      stabs_end - STABSIZE is then a pointer to a very large address, the
      test "stabp < stabs_end - STABSIZE" succeeds.
      
      	* objdump.c (print_section_stabs): Correct STABSIZE comparison.
      45b36294
  9. Feb 17, 2023
    • Alan Modra's avatar
      ld test asciz and ascii fails · 5f497256
      Alan Modra authored
      Fix these fails:
      alpha-dec-vms  +FAIL: ld-scripts/asciz
      alpha-dec-vms  +FAIL: ld-scripts/ascii
      i386-go32  +FAIL: ld-scripts/asciz
      sh-coff  +FAIL: ld-scripts/asciz
      
      It's better to positively select targets for .section support than to
      try to exclude all targets that don't.  Make a new is_coff_format so
      we can easily select such.
      
      binutils/
      	* testsuite/lib/binutils-common.exp (is_coff_format): New.
      ld/
      	* testsuite/ld-scripts/ascii.d: Use is_elf_format and
      	is_coff_format to select targets, exclude ti coff.
      	* testsuite/ld-scripts/asciz.d: Likewise.  Accept trailing zeros.
      5f497256
  10. Feb 16, 2023
    • Alan Modra's avatar
      Delete PROGRESS macros · 7ed4ad59
      Alan Modra authored
      I don't see much point in cluttering the source with the PROGRESS
      macros, which of course do nothing at all with the definitions in
      progress.h.  progress.h is unchanged apart from the copyright comment
      since commit d4d4c53c in 1994.
      
      binutils/
      	* ar.c: Don't include progress.h, or invoke PROGRESS macros.
      	* nm.c: Likewise.
      	* objcopy.c: Likewise.
      	* objdump.c: Likewise.
      gas/
      	* as.h: Don't include progress.h.
      	* as.c: Don't invoke PROGRESS macros.
      	* write.c: Likewise.
      include/
      	* progress.h: Delete.
      ld/
      	* ldmain.c: Don't include progress.h, or invoke PROGRESS macros.
      7ed4ad59
  11. Feb 15, 2023
    • Alan Modra's avatar
      objdump read_section_stabs · f9c36cc9
      Alan Modra authored
      This function is used to read sections other than stabs, and there is
      now another version of it that extracts different info from the bfd
      section.  Rename it and return the bfd section instead of assorted
      fields of the bfd section.
      
      	* objcopy.c (read_section): Renamed from read_section_stabs.
      	Delete size_ptr and entsize_ptr params, add contents param.
      	Return asection pointer.  Don't unnecessarily free contents on
      	failure from bfd_malloc_and_get_section.
      	(find_stabs_section): Use read_section.
      	(dump_ctf, dump_section_sframe): Likewise.
      	(read_section_sframe): Delete.
      f9c36cc9
    • Alan Modra's avatar
      objdump -G memory leak · 11066c2a
      Alan Modra authored
      	* objdump.c (find_stabs_section): Free stabs.
      11066c2a
    • Alan Modra's avatar
      binutils stabs type list · 72d225ef
      Alan Modra authored
      Fuzzers have found that specifying a large stab type number results in
      lots of memory being requested, as the list is extended with a 16
      element array at a time until we reach the given stab type.  It also
      takes a long time.  Of course normal sane stab types use small
      positive integers, but it's not hard to modify the code to handle type
      numbers starting anyhere.
      
      	* stabs.c (struct stab_types): Add base_index.
      	(stab_find_slot): Simplify filenum check.  Delete type number
      	check.  Don't allocate entire array from 0 to type number,
      	allocate a sparse array.
      72d225ef
  12. Feb 13, 2023
    • Andrew Burgess's avatar
      opcodes/mips: disassemble unknown micromips instructions as two shorts · 77be7257
      Andrew Burgess authored
      Before commit:
      
        commit 2438b771
        Date:   Wed Nov 2 15:53:43 2022 +0000
      
            opcodes/mips: use .word/.short for undefined instructions
      
      unknown 32-bit microMIPS instructions were disassembled as a raw
      32-bit number with no '.word' directive.  The above commit changed
      this and added a '.word' directive before the 32-bit number.
      
      It was pointed out on the mailing list, that for microMIPS it would be
      better to display such 32-bit instructions using a '.short' directive
      followed by two 16-bit values.
      
      This commit updates the mips disassembler to do this, and adds a new
      test that validates this output.
      77be7257
    • Alan Modra's avatar
      objcopy memory leaks · 3eef3b2c
      Alan Modra authored
      This fixes some objcopy memory leaks.  commit 450da4bd used
      xatexit to tidy most of the hash table memory, but of course that's
      ineffective without a call to xexit.  The other major memory leak
      happens if there is an error of some sort writing the output file, due
      to not closing the input file and thus not freeing memory attached to
      the bfd.
      
      	* objcopy.c (copy_file): Don't return when bfd_close of output
      	gives an error, always bfd_close input too.
      	(main): Call xexit.
      3eef3b2c
  13. Feb 11, 2023
    • Alan Modra's avatar
      objdump -D of bss sections and -s with -j · 0a3137ce
      Alan Modra authored
      There is some inconsistency between the behaviour of objdump -D and
      objdump -s, both supposedly operating on all sections by default.
      objdump -s ignores bss sections, while objdump -D dissassembles the
      zeros.  Fix this by making objdump -D ignore bss sections too.
      
      Furthermore, "objdump -s -j .bss" doesn't dump .bss as it should,
      since the user is specifically asking to look at all those zeros.
      
      This change does find some tests that used objdump -D with expected
      output in bss-style sections.  I've updated all the msp430 tests that
      just wanted to find a non-empty section to look at section headers
      instead, making the tests slightly more stringent.  The ppc xcoff and
      spu tests are fixed by adding -j options to objdump, which makes the
      tests somewhat more lenient.
      
      binutils/
      	* objdump.c (disassemble_section): Ignore sections without
      	contents, unless overridden by -j.
      	(dump_section): Allow -j to override the default of not
      	displaying sections without contents.
      	* doc/binutils.texi (objdump options): Update -D, -s and -j
      	description.
      gas/
      	* testsuite/gas/ppc/xcoff-tls-32.d: Select wanted objdump
      	sections with -j.
      	* testsuite/gas/ppc/xcoff-tls-64.d: Likewise.
      ld/
      	* testsuite/ld-msp430-elf/main-bss-lower.d,
      	* testsuite/ld-msp430-elf/main-bss-upper.d,
      	* testsuite/ld-msp430-elf/main-const-lower.d,
      	* testsuite/ld-msp430-elf/main-const-upper.d,
      	* testsuite/ld-msp430-elf/main-text-lower.d,
      	* testsuite/ld-msp430-elf/main-text-upper.d,
      	* testsuite/ld-msp430-elf/main-var-lower.d,
      	* testsuite/ld-msp430-elf/main-var-upper.d: Expect -wh output.
      	* testsuite/ld-msp430-elf/msp430-elf.exp: Use objdump -wh
      	rather than objdump -D or objdump -d with tests checking for
      	non-empty given sections.
      	* testsuite/ld-spu/ear.d,
      	* testsuite/ld-spu/icache1.d,
      	* testsuite/ld-spu/ovl.d,
      	* testsuite/ld-spu/ovl2.d: Select wanted objdump sections.
      0a3137ce
  14. Feb 09, 2023
    • Tom Tromey's avatar
      Add full display feature to dwarf-mode.el · 93c80543
      Tom Tromey authored
      I've found that I often use dwarf-mode with relatively small test
      files.  In this situation, it's handy to be able to expand all the
      DWARF, rather than moving to each "..." separately and using C-u C-m.
      
      This patch implements this feature.  It also makes a couple of other
      minor changes:
      
      * I removed a stale FIXME from dwarf-mode.  In practice I find I often
        use "g" to restore the buffer to a pristine state; checking the file
        mtime would work against this.
      
      * I tightened the regexp in dwarf-insert-substructure.  This prevents
        the C-m binding from trying to re-read a DIE which has already been
        expanded.
      
      * Finally, I've bumped the dwarf-mode version number so that this
        version can easily be installed using package.el.
      
      2023-02-09  Tom Tromey  <tromey@adacore.com>
      
      	* dwarf-mode.el: Bump version to 1.8.
      	(dwarf-insert-substructure): Tighten regexp.
      	(dwarf-refresh-all): New defun.
      	(dwarf-mode-map): Bind "A" to dwarf-refresh-all.
      	(dwarf-mode): Remove old FIXME.
      93c80543
    • Alan Modra's avatar
      Clear cached file size when bfd changed to BFD_IN_MEMORY · 87d20657
      Alan Modra authored
      If file size is calculated by bfd_get_file_size, as it is by
      _bfd_alloc_and_read calls in coff_object_p, then it is cached and when
      pe_ILF_build_a_bfd converts an archive entry over to BFD_IN_MEMORY,
      the file size is no longer valid.  Found when attempting objdump -t on
      a very small (27 bytes) ILF file and hitting the pr24707 fix (commit
      781152ec).  So, clear file size when setting BFD_IN_MEMORY on bfds
      that may have been read.  (It's not necessary in writable bfds,
      because caching is ignored by bfd_get_size when bfd_write_p.)
      
      I also think the PR 24707 fix is no longer neeeded.  All of the
      testcases in that PR and in PR24712 are caught earlier by file size
      checks when reading the symbols from file.  So I'm reverting that fix,
      which just compared the size of an array of symbol pointers against
      file size.  That's only valid if on-disk symbols are larger than a
      host pointer, so the test is better done in format-specific code.
      
      bfd/
      	* coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Clear cached
      	file size when making a BFD_IN_MEMORY bfd.
      	* opncls.c (bfd_make_readable): Likewise.
      	* peicode.h (pe_ILF_build_a_bfd): Likewise.
      binutils/
      	PR 24707
      	* objdump.c (slurp_symtab): Revert PR24707 fix.  Tidy.
      	(slurp_dynamic_symtab): Tidy.
      87d20657
  15. Feb 07, 2023
  16. Feb 03, 2023
    • Jan Beulich's avatar
      RISC-V: don't disassemble unrecognized insns as .byte · 0655669b
      Jan Beulich authored
      Insn width granularity being 16 bits, producing byte granular output
      isn't very useful. With there being a way to specific otherwise
      unknown insns to the assembler, use that same representation (to be
      precise: its <length>,<encoding> flavor) for disassembly.
      0655669b
  17. Jan 31, 2023
    • Nick Clifton's avatar
    • Alan Modra's avatar
      PR 30060, ASAN error in bfd_cache_close · 6296342e
      Alan Modra authored
      After bfd_close nothing should access bfd memory.  Now that bfd_close
      always tidies up even after an error, attempting to tidy the cached
      bfd list by calling bfd_cache_close is wrong and not needed.
      
      	PR 30060
      	* ar.c (remove_output): Don't call bfd_cache_close.
      	(output_bfd): Delete.
      	* arsup.c (ar_end): Call bfd_close_all_done, not bfd_cache_close.
      6296342e
    • Alan Modra's avatar
      testsuite XPASSes · 9884676d
      Alan Modra authored
      This adjusts the testsuite to get rid of a number of XPASSes that have
      appeared.  Someone might like to look into a better patch for the s390
      change.
      
      aarch64-pe  XPASS: weak symbols
      arm-nacl  XPASS: rgn-over8
      mcore-pe  XPASS: ld-scripts/provide-8
      mips64-linux-gnuabi64  XPASS: vers4
      mips64-linux-gnuabi64  XPASS: vers4b
      mips-linux-gnu  XPASS: vers4
      mips-linux-gnu  XPASS: vers4b
      s390-linux-gnu  XPASS: undefined line
      sh4-linux-gnu  XPASS: --gc-sections with __start_SECTIONNAME
      sh-coff  XPASS: objcopy object (simple copy)
      sh-coff  XPASS: objcopy executable (pr25662)
      
      binutils/
      	* testsuite/binutils-all/objcopy.exp: Don't xfail "simple
      	copy" and "pr25662" on sh-*-coff.  Remove all non-ELF xfails
      	on "ELF unknown section type" test.
      ld/
      	* testsuite/ld-elfvers/vers.exp (vers4, vers4b): Don't xfail
      	all mips, just xfail mips irix.
      	* testsuite/ld-gc/pr19161.d: Don't xfail sh.
      	* testsuite/ld-scripts/rgn-over8-ok.d: Don't xfail nacl.
      	* testsuite/ld-scripts/weak.exp: Don't xfail aarch64-pe.
      	* testsuite/ld-undefined/undefined.exp: Conditionally xfail
      	"undefined line" depending on gcc version for s390.
      9884676d
  18. Jan 23, 2023
  19. Jan 20, 2023
  20. Jan 18, 2023
  21. Jan 16, 2023
  22. Jan 14, 2023
  23. Jan 12, 2023
  24. Jan 11, 2023
    • Mark Harmstone's avatar
      Add aarch64-w64-mingw32 target · 16fea92c
      Mark Harmstone authored
      This adds a mingw target for aarch64, including windres and dlltool.
      
      Note that the old value of jmp_aarch64_bytes was wrong, and this does
      the same thing as MSVC does.
      16fea92c
  25. Jan 09, 2023
Loading