Age | Commit message (Collapse) | Author | Files | Lines |
|
Don't warn if the offset of the first entry in .debug_rnglists starts
right after the header. Warn holes in .debug_ranges and debug_rnglists
sections only if the last end pointer isn't the same as the current
start pointer.
PR binutils/32927
* dwarf.c (display_debug_ranges_list): Return the pointer to the
end.
(display_debug_ranges): Don't warn if the offset of the first
entry in .debug_rnglists starts right after the header. Warn a
hole only if the last end pointer is the same as the next pointer.
* testsuite/binutils-all/x86-64/dwarf4.s: New file.
* testsuite/binutils-all/x86-64/dwarf5.s: Likewise.
* testsuite/binutils-all/x86-64/pr32927-1.d: Likewise.
* testsuite/binutils-all/x86-64/pr32927-2.d: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Co-Authored-By: Alan Modra <amodra@gmail.com>
|
|
.debug_loclists section is loaded into debug_information as DWARF-5 debug
info and .debug_loc section is loaded into debug_information as pre-DWARF-5
debug info. When dumping .debug_loc section, we should only process
pre-DWARF-5 debug info in debug_information. When dumping .debug_loclists
section, we should only process DWARF-5 info in debug_information.
binutils/
PR binutils/32809
* dwarf.c (display_debug_loc): Dump .debug_loclists only for
DWARF-5.
ld/
PR binutils/32809
* testsuite/ld-x86-64/dwarf4.s: New file.
* testsuite/ld-x86-64/dwarf5a.s: Likewise.
* testsuite/ld-x86-64/dwarf5b.s: Likewise.
* testsuite/ld-x86-64/pr32809.d: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr32809.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
binutils/
* MAINTAINERS: Add myself as PPC maintainer.
|
|
Also free malloc'd relocs.
|
|
* rescoff.c (read_coff_res_dir): Add more sanity checking.
Tidy and correct existing checks.
|
|
Also remove unnecessary casts on memory alloc function returns.
|
|
Commit 9e68cae4fdfb broke the check I added in commit 4846e543de95.
Add missing "return NULL".
|
|
The flag already exists but it's not been exposed to user.
Signed-off-by: Marek Pikuła <m.pikula@partner.samsung.com>
|
|
windres code has the habit of exiting on any error. That's not so
bad, but it does make oss-fuzz ineffective when testing windres. Fix
many places that print errors and exit to instead print the error and
pass status up the call chain. In the process of doing this, I
noticed write_res_file was calling bfd_close without checking return
status. Fixing that resulted in lots of testsuite failures. The
problem was a lack of bfd_set_format in windres_open_as_binary, which
leaves the output file as bfd_unknown format. As it happens this
doesn't make any difference in writing the output binary file, except
for the bfd_close return status.
|
|
oss-fuzz testcase manages to hit a buffer overflow. Sanity check
by passing the buffer length to bin_to_res_toolbar and ensuring reads
don't go off the end of the buffer.
|
|
Size being set for a symbol isn't a strict requirement in ELF. For ones
not having their size set, fall back to the same logic as used for non-
ELF, non-COFF symbols.
While there switch to using elf_symbol_from() instead of kind of open-
coding it.
|
|
Like ELF for all symbols, COFF can record size for at least function
ones. Use that - if available - in preference to the distance-to-next-
symbol heuristic.
To be able to use the new test there, make TI C54x follow TI C4x in
providing .sdef to cover for .def already having different meaning.
|
|
... to be a power of two, just like --section-alignment does.
|
|
There's no reason to limit this to just ELF. TI C30 and Z8k don't encode
section alignment in the section entries though (which can't be quite
right, or there would need to be another means by which to express
alignment needs), so --set-section-alignment simply has no effect there.
|
|
PR binutils/32732
The --set-section-alignment option is what ought to be used on object
files; --section-alignment should be affecting PE binaries only, and
only the value stored in the header. Sections don't individually have
alignment recorded there; see 6f8f6017a0c4 ("PR27567, Linking PE files
adds alignment section flags to executables").
Undo the core part of 121a3f4b4f4a ("Update objcopy's
--section-alignment option so that it sets the alignment flag on..."),
which includes removing the testcase again, while leaving all secondary
changes in place. (Note that the testcase did fail anyway for
i?86-interix, with objdump saying "option -P/--private not supported by
this file".)
|
|
With it only being the tail of the name which wants checking, using
lbasename() isn't helpful. Mirror what objcopy.c:main() does to ar.c,
merely chaning the plain int of the local variable to size_t.
|
|
By not linking the exact same object file twice, in particular ranlib can
benefit quite a bit from the compiler eliminating dead code.
|
|
By not linking the exact same object file twice, in particular strip can
benefit quite a bit from the compiler eliminating dead code.
|
|
u.kenum is always non-NULL, see debug_make_enum_type.
PR 32829
* debug.c (debug_type_samep): Correct incomplete enum test.
(debug_write_type): Remove dead code.
|
|
The output file could be created before the input is gathered by tail,
erasing the later before it's being proceeded.
This happened on rare cases when performing remote tests on
Ubuntu 24.04.
|
|
"objdump.out" is a testsuite trace and thus should be created within the
tmpdir.
|
|
Up to this point, no mention of RISC-V-specific disassembler options was
mentioned in binutils documentation. This patch includes description for
all of the currently supported options.
Signed-off-by: Marek Pikuła <m.pikula@partner.samsung.com>
|
|
Turns out the return value of parse_loongarch_dis_option acts as an
error code, and previously the function always signified failure with
a non-zero return value, making only the first disassembly option get
to take effect.
Fix by adding the missing `return 0`'s to the two success code paths.
Signed-off-by: WANG Xuerui <git@xen0n.name>
|
|
Section and file alignment are supposed to remain unaltered when PE
binaries are stripped. While this is the case when they're strip-ed
individually, passing multiple such files to strip would reset the
two values to their defaults in all but the first of those binaries.
|
|
|
|
|
|
Compilers may split functions, e.g. into a "hot" and "cold" part, or
they may emit special case instantiations (e.g. as a result of IPA). It
can be helpful to be able to disassemble all of the parts or clones in
one go. Permit using "--disassemble=" multiple times.
|
|
... when only their symbol was requested for disassembly. Addressing the
respective FIXME is as easy as coverting the "else" there to an if()
with the opposite condition, thus accounting for the disabling the
original if() may have effected.
|
|
- use find_section_by_type() instead of a for-loop.
- reindent the whole function accordingly.
- move declaration of variables nearer from their usage.
- prune else branch by using a goto in the error case.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 6d3ec65a8a1..878012da8f0 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -19268,42 +19268,32 @@ process_attributes (Filedata * filedata,
unsigned char * (* display_pub_attribute) (unsigned char *, const unsigned char * const),
unsigned char * (* display_proc_gnu_attribute) (unsigned char *, unsigned int, const unsigned char * const))
{
- Elf_Internal_Shdr * sect;
- unsigned i;
- bool res = true;
-
/* Find the section header so that we get the size. */
- for (i = 0, sect = filedata->section_headers;
- i < filedata->file_header.e_shnum;
- i++, sect++)
- {
- unsigned char * contents;
- unsigned char * p;
+ Elf_Internal_Shdr * sect = find_section_by_type (filedata, proc_type);
+ if (sect == NULL)
+ sect = find_section_by_type (filedata, SHT_GNU_ATTRIBUTES);
- if (sect->sh_type != proc_type && sect->sh_type != SHT_GNU_ATTRIBUTES)
- continue;
+ if (sect == NULL)
+ /* No section, exit without error. */
+ return true;
- contents = (unsigned char *) get_data (NULL, filedata, sect->sh_offset, 1,
- sect->sh_size, _("attributes"));
+ unsigned char * contents = (unsigned char *)
+ get_data (NULL, filedata, sect->sh_offset, 1, sect->sh_size, _("attributes"));
if (contents == NULL)
- {
- res = false;
- continue;
- }
+ return false;
- p = contents;
+ bool res = true;
+ unsigned char * p = contents;
/* The first character is the version of the attributes.
Currently only version 1, (aka 'A') is recognised here. */
if (*p != 'A')
{
printf (_("Unknown attributes version '%c'(%d) - expecting 'A'\n"), *p, *p);
res = false;
+ goto free_data;
}
- else
- {
- uint64_t section_len;
- section_len = sect->sh_size - 1;
+ uint64_t section_len = sect->sh_size - 1;
p++;
while (section_len > 0)
@@ -19456,10 +19446,9 @@ process_attributes (Filedata * filedata,
attr_len = 0;
}
}
- }
+free_data:
free (contents);
- }
return res;
}
|
|
|
|
|
|
Since commit ad6dde5aaae ("gdb/dwarf: write offset to parent entry for
DW_IDX_parent"), gdb now emits a .debug_names where the DW_IDX_parent
attribute refers to the parent entry's offset -- previously, due to
some confusion in the standard, gdb used the index of the parent's
name table entry.
This patch changes the .debug_names display code to display each
entry's offset. This makes it easy to refer from a DW_IDX_parent to
the correct entry.
The new output looks like this:
[...]
Symbol table:
[ 1] circular1: <0><1> DW_TAG_module DW_IDX_compile_unit=1 DW_IDX_die_offset=<0x19> DW_IDX_GNU_language=19
[...]
[ 6] found: <0x28><2> DW_TAG_subprogram DW_IDX_compile_unit=1 DW_IDX_die_offset=<0x38> DW_IDX_GNU_language=19 DW_IDX_parent=<0x0>
Here you can see that DW_IDX_parent=0 refers to "circular1: <0>".
|
|
This fixes a deficiency in commit 660df28acfa1, which should have used
the same logic as that in sym_ok. Ideally both places would not
compare section names, but it can be a little tricky to match a
section in the real object file with a section in a debug file.
Extend commit 39f0547e554d to use section name, vma and size.
* objcopy (is_same_section): New function.
(compare_symbols, sym_ok): Use it here.
|
|
read_coff_rsrc makes one check on object file contents, the existence
of a .rsrc section. It doesn't check that the file is PE but blindly
accesses bfd pe_data. Fix that by adding the necessary checks.
Also, the "resources nest too deep" error isn't an overrun, ie. the
"address out of bounds" message isn't correct. Fix that too.
|
|
Most of these were not needed, and moving a few functions around
removes the need for any.
|
|
ctf_archive_next returns an opened dict, which must be closed by the caller.
Thanks to Alan Modra for spotting this.
binutils/
* objdump.c (dump_ctf): Close dict.
* readelf.c (dump_section_as_ctf): Likewise.
|
|
<memory.h> is not needed and not standardized and is just an alias for
<string.h>.
<sys/param.h> is not needed and not standardized and contains a kitchen
sink of various unportable definitions not agreed upon and best done
manually or through other headers.
These fixes are needed to compile binutils on Sortix and other operating
systems with a strict POSIX.1-2024 libc without obsolete features.
Signed-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>
|
|
or -R options and no regular relocs are present.
PR 32459
|
|
After I found his email bouncing, Stan, via private communication which
Nick helped with, has indicated that - having retired - he won't any
longer fulfill the maintainer role here.
|
|
Today I learned that, at least on my system (Fedora 40), the printf
"%#x" format will produce "0" rather than "0x0" when given 0 as an
argument.
This causes dwarf-mode.el to not correctly fontify the very first
"Compilation Unit" line it sees.
This patch adapts dwarf-mode.el. As always, this patch bumps the
version number for easier installation.
I am checking this in.
|
|
plus a few other formatting fixes.
|
|
It is possible with fuzzed files to have num_debug_info_entries zero
after allocating space for debug_information, leading to multiple
allocations.
* dwarf.c (process_debug_info): Don't test num_debug_info_entries
to determine whether debug_information has been allocated,
test alloc_num_debug_info_entries.
|
|
PR binutils/32716
* bucomm.c (display_info): Free arg.info.
|
|
dlltool copies strings with strdup all over the place, seeming to take
the attitude that anything might be modified. That leads to lots of
memory leaks. Fixing the leaks by removing the strdup calls of course
means you need to take good care that strings *aren't* modified. This
isn't as easy as it sounds due to functions like xlate that have
const char* params but then manage to modify the strings. I've fixed
xlate, but if I've missed something somewhere then this patch likely
will break dlltool. Testsuite coverage of dlltool isn't good.
The leaks in defparse.y are small. It also is a little work to verify
that all the strings I'm freeing in defparse.y are in fact malloc'd,
which is no doubt why the leaks are there.
Using bfd_xalloc in make_one_lib_file and functions called from there
results in memory being freed automatically at the bfd_close in
make_one_lib_file, without any fuss.
The patch also makes use of xasprintf to replace xmalloc followed by
sprintf.
* defparse.y (opt_name2): Free incoming ID strings after
adding prefix/suffix.
* dlltool.c (struct ifunct): Constify char* fields.
(struct iheadt, struct dlist): Likewise.
(set_dll_name_from_def, def_heapsize, def_stacksize),
(def_section, assemble_file): Use xasprintf.
(def_name, def_library): Free dll_name and name.
(def_description, new_directove): Don't strdup incoming args.
(append_import): Likewise.
(def_import): Free module after appending dllext.
(run): Free temp_base.
(scan_filtered_symbols): Don't segfault on NULL strchr return.
Remove unnecessary strdup.
(scan_drectve_symbols): Likewise. Constify pointers.
Use bfd_malloc_and_get_section. Use xmemdup.
(add_excludes): Use xasprintf and xstrdup.
(gen_exp_file): Free xlate return. Constify pointer to suit
struct changes. Free copy.
(xlate): Always copy arg. Use xasprintf and xstrdup.
(make_imp_label): Add bfd arg. Use bfd_xalloc.
(gen_lib_file): Adjust to suit.
(make_one_lib_file): Likewise. Use bfd_xalloc for section data
and relocs. Simplify code calling xlate, and free xlate return.
(dll_name_list_free_contents): Flatten recursion.
(mangle_defs): Free d_export_vec.
(main): Formatting. Use xasprintf.
* resres.c (write_res_id): Free section data.
|
|
|
|
|
|
|
|
|
|
This allows you to specify a run_dump_test warning that may or may not
be present using
warning: (warning_text_goes_here)?
ie. the regexp matches an empty string.
|
|
|