aboutsummaryrefslogtreecommitdiff
path: root/binutils
AgeCommit message (Collapse)AuthorFilesLines
2023-04-06Re: objcopy write_debugging_info memory leaksAlan Modra1-6/+1
Oops, tried to free too much * wrstabs.c (write_stabs_in_sections_debugging_info): Don't free strings.
2023-04-06objdump print_debugging_info memory leaksAlan Modra1-148/+172
Fix memory leaks and do a general tidy of the code for printing coff and stabs debug. * prdbg.c: Delete unnneeded forward function declarations. Delete unnecessary casts throughout. Free all strings returned from pop_type throughout file. (struct pr_stack): Delete "num_parents". Replace tests for "num_parents" non-zero with tests of "parents" non-NULL throughout. Free "parents" before assigning, and set to NULL after freeing. Remove const from "method". Always strdup strings assigned to method, and free before assigning. (print_debugging_info): Free info.stack and info.filename.
2023-04-06objdump -g on gcc COFF/PE filesAlan Modra1-4/+6
objdump -g can't be used much. Trying to dump PE files invariably seems to run into "debug_name_type: no current file" or similar errors, because parse_coff expects a C_FILE symbol to be the first symbol. Dumping -gstabs output works since the N_SO stab is present. Pre-setting the file name won't hurt stabs dumping. * rddbg.c (read_debugging_info): Call debug_set_filename.
2023-04-06objcopy write_debugging_info memory leaksAlan Modra2-217/+167
The old stabs code didn't bother too much about freeing memory. This patch corrects that and avoids some dubious copying of strings. * objcopy.c (write_debugging_info): Free both strings and syms on failure to create sections. * wrstabs.c: Delete unnecessary forward declarations and casts throughout file. (stab_write_symbol_and_free): New function. Use it throughout, simplifying return paths. (stab_push_string): Don't strdup string. Use it thoughout for malloced strings. (stab_push_string_dup): New function. Use it throughout for strings in auto buffers. (write_stabs_in_sections_debugging_info): Free malloced memory. (stab_enum_type): Increase buffer sizing for worst case. (stab_range_type, stab_array_type): Reduce buffer size. (stab_set_type): Likewise. (stab_method_type): Free args on error return. Correct buffer size. (stab_struct_field): Fix memory leaks. (stab_class_static_member, stab_class_baseclass): Likewise. (stab_start_class_type): Likewise. Correct buffer size. (stab_class_start_method): Correct buffer size. (stab_class_method_var): Free memory on error return. (stab_start_function): Fix "rettype" memory leak.
2023-04-04Use bfd_alloc memory for read_debugging_info storageAlan Modra8-325/+313
Trying to free malloc'd memory used by the stabs and coff debug info parsers is complicated, and traversing the trees generated requires a lot of code. It's better to bfd_alloc the memory which allows it all to be freed without fuss when the bfd is closed. In the process of doing this I reverted most of commit a6336913332. Some of the stabs handling code grows arrays of pointers with realloc, to deal with arbitrary numbers of fields, function args, etc. The code still does that but copies over to bfd_alloc memory when finished. The alternative is to parse twice, once to size, then again to populate the arrays. I think that complication is unwarranted. Note that there is a greater than zero chance this patch breaks something, eg. that I missed an attempt to free obj_alloc memory. Also it seems there are no tests in the binutils testsuite aimed at exercising objdump --debugging. * budbg.h (finish_stab, parse_stab): Update prototypes * debug.c: Include bucomm.h. (struct debug_handle): Add "abfd" field. (debug_init): Add "abfd" param. bfd_alloc handle. (debug_xalloc, debug_xzalloc): New functions. Use throughout in place of xmalloc and memset. (debug_start_source): Remove "name_used" param. * debug.h (debug_init, debug_start_source): Update prototypes. (debug_xalloc, debug_xzalloc): Declare. * objcopy.c (copy_object): Don't free dhandle. * objdump.c (dump_bfd): Likewise. * rdcoff.c (coff_get_slot): Add dhandle arg. debug_xzalloc memory in place of xcalloc. Update callers. (parse_coff_struct_type): Don't leak on error return. Copy fields over to debug_xalloc memory. (parse_coff_enum_type): Copy names and vals over the debug_xalloc memory. * rddbg.c (read_debugging_info): Adjust debug_init call. Don't free dhandle. (read_section_stabs_debugging_info): Don't free shandle. Adjust parse_stab call. Call finish_stab on error return. (read_symbol_stabs_debugging_info): Similarly. * stabs.c (savestring): Delete unnecessary forward declaration. Add dhandle param. debug_xalloc memory. Update callers. (start_stab): Delete unnecessary casts. (finish_stab): Add "emit" param. Free file_types, so_string, and stabs handle. (parse_stab): Delete string_used param. Revert code dealing with string_used. Copy so_string passed to debug_set_filename and stored as main_filename to debug_xalloc memory. Similarly for string passed to debug_start_source and push_bincl. Copy args to debug_xalloc memory. Don't leak args. (parse_stab_enum_type): Copy names and values to debug_xalloc memory. Don't free name. (parse_stab_struct_type): Don't free fields. (parse_stab_baseclasses): Delete unnecessary cast. (parse_stab_struct_fields): Return debug_xalloc fields. (parse_stab_cpp_abbrev): Use debug_xalloc for _vb$ type name. (parse_stab_one_struct_field): Don't free name. (parse_stab_members): Copy variants and methods to debug_xalloc memory. Don't free name or argtypes. (parse_stab_argtypes): Use debug_xalloc memory for physname and args. (push_bincl): Add dhandle param. Use debug_xalloc memory. (stab_record_variable): Use debug_xalloc memory. (stab_emit_pending_vars): Don't free var list. (stab_find_slot): Add dhandle param. Use debug_xzalloc memory. Update all callers. (stab_find_tagged_type): Don't free name. Use debug_xzalloc. (stab_demangle_qualified): Don't free name. (stab_demangle_template): Don't free s1. (stab_demangle_args): Tidy pvarargs refs. Copy *pargs on success to debug_xalloc memory, free on failure. (stab_demangle_fund_type): Don't free name. (stab_demangle_v3_arglist): Copy args to debug_xalloc memory. Don't free dt.
2023-04-03rddbg.c stabs FIXMEsAlan Modra5-23/+36
This should sort out some very old FIXMEs in code handling stabs debug info. Necessary if we are to fuss over freeing up memory before objdump and objcopy exit. It is of course better from a user viewpoint to *not* free memory, which takes some time, and leave that to process exit. The only reason to do so is that having many memory leaks in binutils/ code tends to hide leaks in bfd/ or opcodes/, which we should care about. * budbg.h (parse_stab): Update prototype. * debug.h (debug_start_source): Update prototype. * debug.c (debug_start_source): Add name_used. Set if stashed. * rddbg.c (read_symbol_stabs_debugging_info): Always malloc stab string passed to parse_stab. Free stab string when unreferenced. (read_section_stabs_debugging_info): Likewise, and strings section contents. * stabs.c (parse_stab): Add string_used param. Set if string stashed. Pass to debug_start_source. Realloc file_types array rather that using malloc. Clarify comment about debug_make_indirect_type.
2023-04-03Memory leak in process_abbrev_setAlan Modra1-7/+3
We may have added some abbrevs to the list before hitting an error. Free the list elements too. free_abbrev_list returns list->next so we need to init it earlier to avoid an uninitialised memory access. * dwarf.c (process_abbrev_set): Call free_abbrev_list on errors. Set list->next earlier.
2023-03-30Fix an illegal memory access triggered by parsing corrupt DWARF info.Nick Clifton2-3/+35
PR 30284 * dwarf.c (read_and_display_attr_value): Detect and ignore negative base values.
2023-03-30Tidy leaked objcopy memoryAlan Modra2-22/+31
* objcopy.c (delete_symbol_htabs): Also free symbols. (write_debugging_info): Free strings and syms once written. * wrstabs.c (write_stabs_in_sections_debugging_info): memset entire info struct. Free hash tables before returning. Free syms on error return.
2023-03-30Tidy memory on addr2line failuresAlan Modra1-0/+3
* addr2line.c (process_file): Close bfd on error paths.
2023-03-27Use stdint types in coff internal_auxentAlan Modra1-4/+4
long is a poor choice of type to store 32-bit values read from objects files by H_GET_32. H_GET_32 doesn't sign extend so tests like that in gdb/coffread.c for "negative" values won't work if long is larger than 32 bits. If long is 32-bit then code needs to be careful to not accidentally index negative array elements. (I'd rather see a segfault on an unmapped 4G array index than silently reading bogus data.) long is also a poor choice for x_sect.s_scnlen, which might have 64-bit values. It's better to use unsigned exact width types to avoid surprises. I decided to change the field names too, which makes most of this patch simply renaming. Besides that there are a few places where casts are no longer needed, and where printf format strings or tests need adjusting. include/ * coff/internal.h (union internal_auxent): Use unsigned stdint types. Rename l fields to u32 and u64 as appropriate. bfd/ * coff-bfd.c, * coff-rs6000.c, * coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c, * coffswap.h, * peXXigen.c, * xcofflink.c: Adjust to suit internal_auxent changes. binutils/ * rdcoff.c: Adjust to suit internal_auxent changes. gas/ * config/obj-coff.h, * config/tc-ppc.c: Adjust to suit internal_auxent changes. gdb/ * coffread.c, * xcoffread.c: Adjust to suit internal_auxent changes. ld/ * pe-dll.c: Adjust to suit internal_auxent changes.
2023-03-27coffgrok access of u.auxent.x_sym.x_tagndx.pAlan Modra1-30/+10
u.auxent.x_sym.x_tagndx is a union. The p field is only valid when fix_tag is set. This patch fixes code in coffgrok.c that accessed the field without first checking fix_tag, and removes a whole lot of code validating bogus pointers to prevent segfaults (which no longer happen, I checked the referenced PR 17512 testcases). The patch also documents this in the fix_tag comment, makes is_sym a bitfield, and sorts the selecter fields a little. bfd/ * coffcode.h (combined_entry_type): Make is_sym a bitfield. Sort and comment on union selectors. * libcoff.h: Regenerate. binutils/ * coffgrok.c (do_type): Make aux a combined_entry_type. Test fix_tag before accessing u.auxent.x_sym.x_tagndx.p. Remove now unnecessary pointer bounds checking.
2023-03-23Add support to readelf for the PT_OPENBSD_MUTABLE segment type.Frederic Cambus2-0/+6
binutils * readelf.c (get_segment_type): Handle PT_OPENBSD_MUTABLE segment type. include * elf/common.h (PT_OPENBSD_MUTABLE): Define.
2023-03-19Another sanity check for read_section_stabs_debugging_infoAlan Modra1-0/+1
* rddbg.c (read_section_stabs_debugging_info): Ignore invalid stab sections with size less than 12 bytes.
2023-03-16readelf: add support for QNT_STACK note subsectionsClément Chigot1-0/+67
QNX provides some .note subsections. QNT_STACK is the one controling the stack allocation. bfd/ChangeLog: * elf.c (BFD_QNT_CORE_INFO): Delete. (BFD_QNT_CORE_STATUS): Likewise. (BFD_QNT_CORE_GREG): Likewise. (BFD_QNT_CORE_FPREG): Likewise. (elfcore_grok_nto_note): Replace BFD_QNT_* by QNT_*. binutils/ChangeLog: * readelf.c (get_qnx_elfcore_note_type): New function. (print_qnx_note): New function. (process_note): Add support for QNX support. include/ChangeLog: * elf/common.h (QNT_DEBUG_FULLPATH): New define. (QNT_DEBUG_RELOC): New define. (QNT_STACK): New define. (QNT_GENERATOR): New define. (QNT_DEFAULT_LIB): New define. (QNT_CORE_SYSINFO): New define. (QNT_CORE_INFO): New define. (QNT_CORE_STATUS): New define. (QNT_CORE_GREG): New define. (QNT_CORE_FPREG): New define. (QNT_LINK_MAP): New define.
2023-03-16Re: Sanity check read_section_stabs_debugging_infoAlan Modra1-1/+2
* rddbg.c (read_section_stabs_debugging_info): Don't segfault on zero size string section.
2023-03-14Prevent an over large memory allocation in readelf when parsing a corrupt ↵Nick Clifton2-0/+9
DWARF file. PR 30227 * dwarf.c (process_cu_tu_index): Prevent excessive memory allocation when nused is large and ncols is zero.
2023-03-14Adjust the decoded line output to fit into 80 columns.Nick Clifton3-16/+21
PR 30216 * dwarf.c (display_debug_lines_decoded): Reduce space for filenames. * testsuite/binutils-all/dw5.W: Adjust expected output. * testsuite/binutils-all/objdump.WL: Adjust expected output.
2023-03-14objdump segfault after symbol table errorAlan Modra1-0/+2
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.
2023-03-14Sanity check read_section_stabs_debugging_infoAlan Modra1-10/+9
* rddbg.c (read_section_stabs_debugging_info): Exclude sections without contents. Use bfd_malloc_and_get_section. Don't alloc one extra for strings.
2023-03-09objdump: report no section contentsAlan Modra1-10/+10
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.
2023-03-08Re: Move nm.c cached line number info to bfd usrdataAlan Modra1-6/+7
Commit e3f450f3933d 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.
2023-03-06Downgrade objdump fatal errors to non-fatalAlan Modra1-48/+95
* 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.
2023-03-06Downgrade addr2line fatal errors to non-fatalAlan Modra1-5/+14
* addr2line.c (slurp_symtab): Don't exit on errors. (process_file): Likewise.
2023-03-06Downgrade nm fatal errors to non-fatalAlan Modra1-24/+12
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.
2023-03-06Move nm.c cached line number info to bfd usrdataAlan Modra1-85/+65
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.
2023-03-06Correct objdump command line error handlingAlan Modra1-10/+15
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.
2023-03-03Tidy type handling in binutils/rdcoff.cAlan Modra1-80/+26
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**.
2023-03-03binutils coff type listAlan Modra1-18/+12
As for commit 72d225ef9cc7, 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.
2023-02-24testsuite: prune DOS drive letter in test outputsClément Chigot1-1/+17
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.
2023-02-22set bfd_error on make_tempname or make_tempdir failureAlan Modra1-1/+5
* bucomm.c (make_tempname, make_tempdir): Set bfd_error on error.
2023-02-22Re: objdump read_section_stabsAlan Modra1-1/+1
Also fix ubsan "applying zero offset to null pointer". * objdump.c (print_section_stabs): Avoid ubsan warning.
2023-02-22Re: objdump read_section_stabsAlan Modra1-1/+1
Commit f9c36cc99518 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.
2023-02-17ld test asciz and ascii failsAlan Modra1-0/+15
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.
2023-02-16Delete PROGRESS macrosAlan Modra4-33/+1
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 d4d4c53c68f0 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.
2023-02-15objdump read_section_stabsAlan Modra1-63/+33
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.
2023-02-15objdump -G memory leakAlan Modra1-1/+4
* objdump.c (find_stabs_section): Free stabs.
2023-02-15binutils stabs type listAlan Modra1-21/+15
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.
2023-02-13opcodes/mips: disassemble unknown micromips instructions as two shortsAndrew Burgess5-0/+33
Before commit: commit 2438b771ee07be19d5b01ea55e077dd8b7cef445 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.
2023-02-13objcopy memory leaksAlan Modra1-2/+1
This fixes some objcopy memory leaks. commit 450da4bd38ae 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.
2023-02-11objdump -D of bss sections and -s with -jAlan Modra2-17/+25
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.
2023-02-09Add full display feature to dwarf-mode.elTom Tromey2-3/+22
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.
2023-02-09Clear cached file size when bfd changed to BFD_IN_MEMORYAlan Modra1-38/+13
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 781152ec18f5). 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.
2023-02-07Fix documentation of the 'n' symbol type displayed by nm.Nick Clifton2-1/+7
PR 30080 * doc/binutils.texi (nm): Update description of the 'n' symbol type.
2023-02-03RISC-V: don't disassemble unrecognized insns as .byteJan Beulich1-3/+3
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.
2023-01-31Updated Swedish translation for the binutils sub-directoryNick Clifton2-762/+314
2023-01-31PR 30060, ASAN error in bfd_cache_closeAlan Modra2-8/+3
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.
2023-01-31testsuite XPASSesAlan Modra1-9/+0
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.
2023-01-23Updated Swedish translation for the binutils sub-directoryNick Clifton2-393/+257
2023-01-23Fix objdump --reloc for specific symbolVladislav Khmelevsky1-0/+7
If objdump is used with both --disassemble=symbol and --reloc options skip relocations that have addresses before the symbol, so that they are not displayed.