aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-03-06Revert "gprof: only process line numbers for intersection of vmas and ↵H.J. Lu2-63/+56
histograms" This reverts commit b8189cf9e40bd90502c9a2ce0df39dd54419bea4 to fix PR gprof/32764: https://sourceware.org/bugzilla/show_bug.cgi?id=32764
2025-03-06Automatic date update in version.inGDB Administrator1-1/+1
2025-03-06ld: Update PR ld/25237 testH.J. Lu2-4/+7
1. Skip targets which don't support the .bss section alignment, 1 << 16. 2. Replace .bss with ".section .bss". 3. Use ".zero 0xb60000" for targets which pad the section to its alignment. PR ld/25237 * testsuite/ld-elf/pr25237.d: Skip avr-*-* and h8300-*-*. Update expected segment size to 0xb60000. * testsuite/ld-elf/pr25237.s: Use ".section .bss" and ".zero 0xb60000". Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-05gdb/testsuite: add test for memory requirements of gcoreGuinevere Larsen2-0/+149
For a long time, Fedora has been carrying an out-of-tree patch with a similar test to the one proposed in this patch, that ensures that the memory requirements don't grow with the inferior's memory. It's been so long that the context for why this test exists has been lost, but it looked like it could be interesting for upstream. The test runs twice, once with the inferior allocating 4Mb of memory, and the other allocating 64Mb. My plan was to find the rate at which things increase based on inferior size, and have that tested to ensure we're not growing that requirement accidentally, but my testing actually showed memory requirements going down as the inferior increases, so instead I just hardcoded that we need less than 2Mb for the command, and it can be tweaked later if necessary. Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb: do not handle a NULL linebuffer in pager_file::putsSimon Marchi1-2/+1
This patch [1] has shown that different implementations of ui_file::puts handle a NULL line differently. pager_file::puts handles a NULL argument gracefully, as a no-op, while other implementations don't and likely crash. This causes subtle bugs: things will be working until the current ui_file is suddenly not a pager_file anymore. I think it would be better to be consistent here, so change pager_file::puts to not accept a NULL line. A regular test run on Linux shows no regression. [1] https://inbox.sourceware.org/gdb-patches/edfe6e17-1c20-4a4c-944f-247ff71b6c10@simark.ca/T/#m864aea10de8ca6fa84757971fcbaf3180e2eaefa Change-Id: Ieb465c86cd2c42a248cf481cd174c8622ef6724b Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05Inconsistent treatment of template parameters in DWARF readerTom Tromey2-14/+7
I noticed that if you hack some clean_restart calls into paramless.exp, the test will fail. That is, the test currently relies on the desired CUs already being expanded when trying to set a breakpoint -- which is clearly a bug, the CU expansion state should not affect "break". I tracked this down to incorrect construction of a lookup_name_info in cooked_index_functions::expand_symtabs_matching. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32510 Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-03-05gdb/dwarf: store dwo_file_up in dwo_file_setSimon Marchi2-92/+97
Heap-allocated dwo_file objects, stored in dwarf2_per_bfd::dwo_files, are never freed. They are created in one of the create_dwo_unit_in_dwp_* or lookup_dwo_cutu functions. I confirmed this by running: $ make check TESTS="gdb.cp/anon-ns.exp" RUNTESTFLAGS="--target_board=fission-dwp" $ ./gdb -q -nx --data-directory=data-directory testsuite/outputs/gdb.cp/anon-ns/anon-ns -ex "p main" -ex "file" -batch ... and checking the ASan leak report. I also debugged this invocation of GDB, placed a breakpoint on ~dwo_file, and didn't see any hit. Change the dwo_file set to hold dwo_file_up objects. When the dwarf2_per_bfd object gets destroyed, dwo_file objects will automatically get destroyed. With this change, I see the related leaks disappear in the ASan leak report, and my ~dwo_file breakpoint gets hit when debugging GDB. Change-Id: Icb38539c3f9e553f3625c625a00fc63dd6e9f3c5 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: make dwarf2_per_bfd::dwo_files a gdb::unordered_setSimon Marchi2-166/+147
Change the dwarf2_per_bfd::dwo_files htab to a gdb::unordered_set. No behavior change expected, except maybe the failure case in lookup_dwo_cutu. If open_and_init_dwo_file returns nullptr, the previous code would leave the slot value empty (nullptr). Is this legit? With the new hash table, the only thing we can do really is not attempt to insert the nullptr value. Change-Id: I63992f388b1197e696ded4ea483634e8ae67fce4 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: change htabs holding dwo_unit objects to gdb::unordered_setSimon Marchi1-181/+99
Change a few occurences of htabs holding `dwo_unit *` values, using their signature as identity, to gdb::unordered_set. allocate_dwo_unit_table and allocate_dwp_loaded_cutus_table appeared to create hash tables with identical behavior, so they both use the same set type now. The only expected change in behavior is that when there are multiple units with the same signature, we will now keep the unit previously in the set, rather than overwriting it. But this seems ok, as it's a case of bad DWARF. Also, in the complaint in create_debug_type_hash_table, I think we previously erroneously printed the same sect_off twice. Change-Id: I57739977735ee1fd5c7b754107f5624f0621baa5 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: remove unused local variable in create_debug_type_hash_tableSimon Marchi1-1/+0
Change-Id: I40679fbe32a8a1a9cced085532c83f06affc294c Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: remove unnecessary parameters to create_{cus,debug_type}_hash_tableSimon Marchi1-30/+21
In create_cus_hash_table, we can get the section and hash table from the dwo_file directly. In create_debug_type_hash_table, we can get the hash table from the dwo_file directly - the section varies. Change-Id: I1d5ef49df98fe2620e12b83484b28cd7398f24ae Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: remove die_reader_specsSimon Marchi1-109/+78
die_reader_specs is a relic of some past design, today it only serves as (useless) a base class for cutu_reader. Remove it and move all its fields to cutu_reader. Change-Id: I5d55018eb8c6e0b828ef5d2f6d09b2047d1a5912 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: remove unnecessary parameter of create_cus_hash_tableSimon Marchi1-4/+3
We can use `cu->per_objfile` instead of passing down a dwarf2_per_objfile explicitly. Change-Id: Ie1fd93d9e7a74d09b857f1f0909d7441b79ed893 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: remove unnecessary local variable in dw2_get_file_names_readerSimon Marchi1-3/+2
It seems like the lh_cu variable is not necessary, we can just use this_cu. Change-Id: Ic2ed6ee82faf1fb5d340cd92dc8ef15434b20cb8 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb: fix null pointer dereference on missing PATH variableDaniel Starke1-3/+4
When running "show" with missing PATH variable a null pointer is being dereferenced in path_info(). path_command() correctly checks whether PATH has been set before using it. It then calls path_info() which retrieves the variable again but fails to perform the null pointer test on it. As a result, the application crashes with SIGSEGV on Windows for example. Fix this by handling the null pointer case in path_info() accordingly. Signed-off-by: Daniel Starke <daniel-email@gmx.net> Co-Authored-By: Simon Marchi <simon.marchi@efficios.com> Approved-By: Tom Tromey <tom@tromey.com> Change-Id: I41ef10f00802d3163793491454190008e78f5dc1
2025-03-05Create dwarf2/parent-map.cTom Tromey3-66/+89
This creates a new file, dwarf2/parent-map.c, to hold some code related to parent maps. This helps shrink read.c a bit. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-03-05Dump debug names indexTom Tromey1-1/+1
This changes the .debug_names reader to dump the contents of the index. This follows what the cooked index does, and also fixes a couple of test failures when run with the debug-names board: forward-spec-inter-cu.exp and backward-spec-inter-cu.exp. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-03-05elfxx-aarch64.c: Replace nested function with a static inline version instead.Nick Clifton1-10/+13
2025-03-05ld: Add a test for PR ld/25237H.J. Lu2-0/+25
PR ld/25237 * testsuite/ld-elf/pr25237.d: New file. * testsuite/ld-elf/pr25237.s: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-05ld: Pass -Wl,-z,lazy to compiler for i386 lazy binding testsH.J. Lu2-8/+8
Pass -Wl,-z,lazy to compiler for i386 tests which require lazy binding to support compilers which default to non-lazy binding. PR ld/32762 * testsuite/ld-i386/i386.exp: Pass -Wl,-z,lazy for "Build ifunc-1a with PIE -z ibtplt" test. * testsuite/ld-i386/no-plt.exp: Pass -Wl,-z,lazy for "Build libno-plt-1b.so", "No PLT (dynamic 1a)", "No PLT (dynamic 1b)", "No PLT (dynamic 1c)", "No PLT (PIE 1e)", "No PLT (PIE 1f)", "No PLT (PIE 1g)" tests. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-05Automatic date update in version.inGDB Administrator1-1/+1
2025-03-04gdb/dwarf: pass is_dwz to dwarf2_per_cu constructorSimon Marchi3-28/+33
It is always known at construction time whether a dwarf2_per_cu is built to represent a unit from a dwz file or not, so pass that information through the constructor. Change-Id: I278c1894ed606451aad02e830085190bb724c473 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-04gdb/dwarf: make dwarf2_get_dwz_file a method of dwarf2_per_bfdSimon Marchi9-44/+32
dwarf2_get_dwz_file looks more or less like a simple getter of dwarf2_per_bfd::dwz_file, so make it into a method. I typically avoid the `get_` prefix for getters, but that would conflict with the field name here. Change-Id: Idd0d5b1bd3813babf438b20aac514b19c77cfc18 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-04gdb/dwarf: remove create_cu_from_index_listSimon Marchi3-24/+3
I noticed that create_cu_from_index_list is only used in read-gdb-index.c, so I started by moving it there. But given that this function is use at only one spot and doesn't do much, I opted to inline its code in the caller instead. Change-Id: Iebe0dc20d345fa70a2f11aa9ff1a04fe26a31407 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-04Check whether gnatmake can link with -sharedTom Tromey2-0/+10
Currently, gnat-llvm does not ship a shared libgnat. This patch changes the relevant test to check whether linking with -shared actually works.
2025-03-04Check whether gnatmake supports -OgTom Tromey2-0/+9
gnat-llvm does not support the -Og flag. This arranges to check for this flag before using it.
2025-03-04Look for -fgnat-encodings optionTom Tromey2-4/+24
gnat-llvm does not support the -fgnat-encodings option, and does not emit GNAT encodings at all -- it only supports the equivalent of GCC's "minimal" encodings; which is to say, ordinary DWARF. This patch changes gdb to test whether gnatmake supports this flag and adapt accordingly. foreach_gnat_encoding is changed to pretend that the "minimal" mode is in effect, as some test examine the mode.
2025-03-04Check -fvar-tracking via ada_simple_compileTom Tromey3-2/+7
A couple of Ada tests check whether the C compiler supports -fvar-tracking. However, this doesn't really work when using gnat-llvm, because that will invoke clang under the hood. This patch arranges to check gnatmake instead, which is more robust even when toolchains are mix-and-matched.
2025-03-04Introduce ada_simple_compileTom Tromey2-11/+56
This introduces ada_simple_compile, an Ada-specific analog of gdb_simple_compile. gdb_compile_test is split into two procs to make this possible. ada_simple_compile isn't used in this patch but will be by later patches in this series.
2025-03-04Check for compiler support in scalar_storage.expTom Tromey1-2/+14
gnat-llvm does not currently handle Scalar_Storage_Order. This patch changes the scalar_storage.exp test to check the compiler error messages and report "unsupported" in this case. This way, the test ought to start working automatically if this feature is added to gnat-llvm.
2025-03-04refactoring elf_find_and_remove_propertyMatthieu Longo1-15/+29
This refactoring focuses primarily on code readability and reuse. - Use the already defined _bfd_elf_find_property instead of another raw for-loop. - Extract _bfd_elf_remove_property out of the function body.
2025-03-04refactoring _bfd_elf_get_propertyMatthieu Longo2-18/+58
- Extract _bfd_elf_find_property and _bfd_elf_insert_property from the function's body to improve the code readability. - Export _bfd_elf_find_property's symbol as it will be used in a later commit.
2025-03-04refactoring bfd_linear_search_one_with_gnu_propertyMatthieu Longo1-30/+40
- remove the definition of the search predicate outside of the for loop. - change the function's return type to struct to adopt a more functional coding style.
2025-03-04aarch64: setup_gnu_properties only creates the notes section when none existsMatthieu Longo1-17/+26
The creation of .note.gnu.property section should not be based on the presence of GNU properties, but rather on whether this section exits or not. However, there is one exception to this: PR23900 [1]. Old linkers were treating .note.gnu.property as a generic note section, so old objects might contain properties inside .note instead of .note.gnu.property. In this case, the section won't be detected but the properties are still parsed. So the absence of the .note.gnu.property section is necessary but not enough to create the section. The condition of the creation of the section has also to include the absence of GNU properties. [1] PR23900: https://sourceware.org/bugzilla/show_bug.cgi?id=23900
2025-03-04clean-up bfd/elf-attrs.c: move specific-code to parse object attributes v1 ↵Matthieu Longo1-135/+147
into a new function
2025-03-04clean-up bfd: rename functions for object attributes v1Matthieu Longo1-42/+50
2025-03-04clean-up aarch64: move the name of the build attributes section into ↵Matthieu Longo2-1/+3
include/elf/aarch64.h
2025-03-04clean-up create_obj_attrs_section: comment about .gnu.attributes VS ↵Matthieu Longo1-10/+10
.gnu.build.attributes
2025-03-04clean-up: move writing of build attributes section into a functionMatthieu Longo3-19/+38
- add obj_build_attributes to struct elf_backend_data similarly sframe. - new function _bfd_elf_write_section_build_attributes encapsulating the writing of the build attributes section into a function.
2025-03-04clean-up readelf: simplify and flatten body of process_attributesMatthieu Longo1-164/+153
- 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; }
2025-03-04clean-up bfd/elf-attrs.c: change return type of uleb128_size to unsignedMatthieu Longo1-5/+4
2025-03-04clean-up: fix conflicting symbol with unknown from bfd/elf-bfd.hMatthieu Longo1-8/+8
2025-03-04clean-up: fix annoying spaces in binutils/readelf.cMatthieu Longo1-27/+27
2025-03-04clean-up: fix annoying spaces in bfd/elf-bfd.hMatthieu Longo1-1/+1
2025-03-03Display entry offset for .debug_namesTom Tromey1-2/+3
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>".
2025-03-03Obvious comment fix in cooked-index.hTom Tromey1-1/+1
I noticed that cooked-index.h still refers to a vector of parent maps, but the code itself actually uses a parent_map here.
2025-03-04Automatic date update in version.inGDB Administrator1-1/+1
2025-03-04ecoff: check result of statAlan Modra1-3/+3
* ecoff.c (_bfd_ecoff_write_armap): Don't use statbuf.st_mtime if stat call returns non-zero. Use ARMAP_TIME_OFFSET rather than its expansion.
2025-03-04objdump: is_same_sectionAlan Modra1-24/+27
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.
2025-03-04rescoff: ensure file is PEAlan Modra1-1/+4
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.