aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
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.
2025-03-04windres: delete function forward declaraionsAlan Modra1-91/+71
Most of these were not needed, and moving a few functions around removes the need for any.
2025-03-04Move BFD_FAKE_SECTION to libbfd.hAlan Modra7-87/+67
BFD_FAKE_SECTION and its sidekick GLOBAL_SYM_INIT don't need to be cluttering bfd.h, and probably shouldn't be used outside bfd/. To make them internal to bfd, make the bfd ecoff small common section declaration global so it can be used instead of a duplicate in gas/ecoff.c. Oddly this needs to go in bfd/ecofflink.c rather than bfd/ecoff.c as the former is compiled for all targets needing the ecoff small common section (some via a call in gas/config/obj-elf.c to a function in gas/ecoff.c) while the latter is not. While doing this rename ecoff_scom_section to _bfd_ecoff_scom_section and remove support for traditional C from GLOBAL_SYM_INIT.
2025-03-03Add language to type unit in debug-names-tu.exp.tclTom Tromey6-45/+67
I think debug-names-tu.exp.tcl only passes by accident -- the type unit does not have a language, which gdb essentially requires. This isn't noticeable right now because the type unit in question is expanded in one phase and then the symbol found in another. However, I'm working on a series that would regress this. This patch partially fixes the problem by correcting the test case, adding the language to the TU. Hoewver, it then goes a bit further and arranges for this information not to be written to .debug_names. Whether or not a type should be considered "static" seems like something that is purely internal to gdb, so this patch has the entry-creation function apply the appropriate transform. It also may make sense to change the "debug_names" proc in the test suite to process attributes more like the ordinary "cu" proc does.
2025-03-03gdb/dwarf: remove unnecessary abfd parameter in dwarf2_per_bfd::locate_sectionsSimon Marchi2-6/+5
The parameter `abfd` is always the same as `this->obfd`, there is no need to pass it as a parameter. Change-Id: If7ad58ad4efdf6b070cbf2b8a73436bd8b452fa6 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-03gdb/dwarf: rename dwarf2_per_cu_data -> dwarf2_per_cuSimon Marchi21-298/+260
This scratches an itch I had for a while. I don't know why this struct type has "data" in its name. Others like "dwarf2_per_objfile" and "dwarf2_per_bfd" don't. The primary job of a structure is to hold data, there's no need to specify it. It also makes the name a bit shorter, which is always nice. Rename related types too. Change-Id: Ifb63195ff105809fc15b502f639c0bb4d18a675e Approved-By: Tom Tromey <tom@tromey.com> Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
2025-03-03Bploc should try to return full pathSimon Farre1-3/+22
Compilers often emit relative paths in the line number program, relative to the build directory for that compilation unit (if it's DWARF>=4 I think). Therefore use symtab->fullname() when not null as this seemingly has attempted path normalization for the symtab and only fall back on symtab->filename which will never be null if that fails. This has a much better UX. Applications may choose to expose this name as a clickable link to some file, at which point a non-normalized and non-absolute path would lead nowhere. When I wrote this feature the first time, I don't think this relative-to-cu-scheme was as prevalent in the output of gcc/clang for DWARF. Approved-By: Tom Tromey <tom@tromey.com>
2025-03-03[gdb/doc] Indicate in which languages 'filename'::funcaddr worksTom de Vries1-4/+8
In the docs I read [1]: ... In this section, we discuss operators that you can use in GDB expressions regardless of your programming language. ... GDB supports these operators, in addition to those common to programming languages: ‘::’ allows you to specify a variable in terms of the file or function where it is defined. See Program Variables. ... In fact, this is not supported in Ada: ... (gdb) b *'foo.adb'::foo No file or function "foo.adb'". (gdb) ... and likewise in a few other working languages. Fix this by making this restriction explicit. Approved-By: Eli Zaretskii <eliz@gnu.org> PR gdb/32753 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32753 [1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Expressions.html
2025-03-03[gdb/doc] Fix address location with file prefixTom de Vries1-2/+4
In the docs I read [1]: ... Address locations indicate a specific program address. They have the generalized form *address. funcaddr An address of a function or procedure derived from its name. ... 'filename':funcaddr Like funcaddr above, but also specifies the name of the source file explicitly. This is useful if the name of the function does not specify the function unambiguously, e.g., if there are several functions with identical names in different source files. ... This is incorrect, the notation is in fact 'filename'::funcaddr. Fix this by correcting the typo, and add a reference to "variable name conflict", where the concept is explained in more detail. Approved-By: Eli Zaretskii <eliz@gnu.org> PR gdb/32748 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32748 [1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Address-Locations.html
2025-03-03[gdb/doc] Don't advertise *&function for pascal and modula-2Tom de Vries1-4/+3
In the docs I read [1]: ... Address locations indicate a specific program address. They have the generalized form *address. ... funcaddr An address of a function or procedure derived from its name. ... In Pascal and Modula-2, this is &function. ... I tried "break *&function" for Pascal and Modula-2, and this doesn't work, while "break *function" works fine. Fix this by updating the documentation to reflect actual behaviour. Approved-By: Eli Zaretskii <eliz@gnu.org> PR gdb/32754 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32754 [1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Address-Locations.html
2025-03-03gdb: remove some unused includes from printcmd.cSimon Marchi1-2/+0
clangd reports them as unused. Change-Id: I50a3c13db128ffe1630364f707d66a24ce11d352
2025-03-03gdb: remove unused include from frame.cSimon Marchi1-1/+0
clangd reports it as unused. Change-Id: I636e57747d3c42ce6615a14d4cf5dc115628a73d
2025-03-03RISC-V: Support ssqosid extension with version 1.0.Kito Cheng11-0/+31
It only add one new CSR: `srmcfg`. Ref: https://github.com/riscv/riscv-ssqosid/releases/tag/v1.0
2025-03-03RISC-V: Re-define mapping symbol $x to the file elf architecture attributeAndrew Oates3-6/+32
The mapping symbol "$x" without an ISA string "means using ISA configuration from ELF attribute."[1]. Currently the code does not reset the subset_list. This means that a previous mapping symbol that overrides the ISA string will continue to be used, rather than the default string set in the ELF file's .riscv.attributes section. This can cause incorrect or failed instruction decodings. In practice, this causes problems when disassembling code generated by LLVM, which (unlike gas) does not emit explicit mapping symbols at the start of each section. This change stores the default architecture string seen at the beginning of disassembly in the global parse data struct, and restores that to subset_list whenever a bare "$x" symbol is seen. [1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#mapping-symbol Before this patch, the mapping-x.s was dumped as, 00000000 <.text>: 0: 00000013 nop 4: 0001 .insn 2, 0x0001 6: 0001 .insn 2, 0x0001 Which is caused by the definiation of $x was conflict with the psABI.
2025-03-03RISC-V: Stop generating mapping symbol $x, replace with $x<isa>.Nelson Chu2-28/+30
The psABI defined $x to the architecture which is same as the file elf attribute. But GNU defined it to that is same as the previous $x<isa>, and always generated $x<isa> at the begining of each section. That is because considering two objects have different architecture in their elf attributes, then $x will always be wrong after linking since the merged arch string will be changed. For example, object A with rv32ic and object B with rv32ia, $x from A is rv32ic and $x from B is rv32ia, but the final output is rv32ica, so $x from A and B need to be updated to rv32ic and rv32ia by linker respectively. I think let linker to do this is not good, so in order to follow the psABI, we will stop generating the $x for now. Instead, all $x will be replaced with the corresponding $x<isa>. The dis-assembler will also treat $x like what psABI defined.
2025-03-03Automatic date update in version.inGDB Administrator1-1/+1
2025-03-03gprof: only process line numbers for intersection of vmas and histogramsRichard Allen2-56/+63
Some programs like RTOS firmware may have a large number of symbols. By loading the histograms before loading symbols, we can look up only the line numbers that were captured in the histogram file, which reduces processing time for such a firmware from ~2 minutes to ~2 seconds. Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-03-02Automatic date update in version.inGDB Administrator1-1/+1
2025-03-01gprof: fix symbol miscount by merging passesRichard Allen1-79/+27
Instead of fixing "somebody miscounted" errors, this patch combines the core_create_line_syms() passes, and dynamically expands the ltab buffer. Reducing the number of passes will make future optimizations simpler. Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-03-01gprof: remove unused variablesRichard Allen1-21/+1
Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-03-01gprof: speed up line-by-line for MIPS/PowerPC/RISCV/SuperHRichard Allen1-0/+7
Roughly halves the number of bfd_find_nearest_line() calls, about 40% less time for a few different large ELF files. Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-03-01gprof: rename min_insn_size to insn_boundaryRichard Allen1-5/+6
This distinction is important for architecures like Xtensa, where 2B and 3B instructions are common, but the correct value for instruction iteration is 1B, not 2B. Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-03-01gprof: remove ASCII formfeed/0x0C bytes from source codeRichard Allen26-26/+26
Signed-off-by: Richard Allen <rsaxvc@gmail.com>