aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-06-24Delete delete_thread_silentPedro Alves2-27/+5
delete_thread_silent is no longer used anywhere. Delete it. Change-Id: Iafcec12339861d5ab2e29c14d7b1f884c9e11c0f
2022-06-24Automatic date update in version.inGDB Administrator1-1/+1
2022-06-23Don't declare cli_set_loggingTom Tromey1-5/+0
cli_set_logging is declared but not defined. It's probably a leftover from whenever interpreters were changed to use inheritance. This patch removes the declaration. Tested by grep and rebuilding.
2022-06-23Use PyBool_FromLongTom Tromey3-8/+4
I noticed a few spots that were explicitly creating new references to Py_True or Py_False. It's simpler here to use PyBool_FromLong, so this patch changes all the places I found.
2022-06-23PowerPC64: fix assertion in ppc_build_one_stub with -Os codeAlan Modra1-1/+2
save_res stubs aren't written in ppc_build_one_stub, their offsets (which are zero) should not be checked. * elf64-ppc.c (ppc_build_one_stub): Don't check save_res offsets.
2022-06-23Re: PowerPC64: stub debug dumpAlan Modra1-41/+61
Let's show the current stub as well as the previous one. Of interest is the current offset and a new field, id. Check that the build hash table traversal is in the same order as sizing traversal too. * elf64-ppc.c (struct ppc_stub_hash_entry): Add id. (struct ppc_link_hash_table): Add stub_id. (stub_hash_newfunc): Init id and symtype. (dump_stub): New function, extracted from.. (dump_previous_stub): ..here. Deleted. (ppc_build_one_stub): Sanity check stub id as well as offset. Show current stub as well as previous. (ppc_size_one_stub): Set stub id. (ppc64_elf_size_stubs): Init stub_id before traversal. (ppc64_elf_build_stubs): Likewise.
2022-06-23aarch64: Allow PC-relative relocations against protected STT_FUNC for -sharedFangrui Song4-1/+20
__attribute__((visibility("protected"))) void *foo() { return (void *)foo; } gcc -fpic -shared -fuse-ld=bfd fails with the confusing diagnostic: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `foo' which may bind externally can not be used when making a shared object; recompile with -fPIC Call _bfd_elf_symbol_refs_local_p with local_protected==true to suppress the error. The new behavior matches gold and ld.lld. Note: if some code tries to use direct access relocations to take the address of foo (likely due to -fno-pic), the pointer equality will break, but the error should be reported on the executable link, not on the innocent shared object link. glibc 2.36 will give a warning at relocation resolving time.
2022-06-23aarch64: Define elf_backend_extern_protected_data to 0 [PR 18705]Fangrui Song2-2/+2
Follow-up to commit 90b7a5df152a64d2bea20beb438e8b81049a5c30 ("aarch64: Disallow copy relocations on protected data"). Commit 32f573bcb3aaa1c9defcad79dbb5851fcc02ae2d changed ld to produce R_AARCH64_GLOB_DAT but that defeated the purpose of protected visibility as an optimization. Restore the previous behavior (which matches ld.lld) by defining elf_backend_extern_protected_data to 0.
2022-06-23Automatic date update in version.inGDB Administrator1-1/+1
2022-06-22Use std::string for interpreter_pTom Tromey4-31/+15
The global interpreter_p is a manually-managed 'char *'. This patch changes it to be a std::string instead, and removes some erroneous comments.
2022-06-22Move mi_interpreter to mi-interp.hTom Tromey3-51/+51
I noticed that touching interps.h caused a lot of recompilation. I tracked this down to mi-common.h including this file. This patch moves the MI interpreter to mi-interp.h, which cuts down on recompilation when modifying interps.h.
2022-06-22Use unique_xmalloc_ptr in interpTom Tromey2-8/+6
This changes interp::m_name to be a unique_xmalloc_ptr, removing some manual memory management. It also cleans up the initialization of the 'inited' member, and moves the 'private:' and 'public:' keywords to their proper spots.
2022-06-22aarch64: Disallow copy relocations on protected dataFangrui Song4-1/+46
If an executable has copy relocations for extern protected data, that can only work if the shared object containing the definition is built with assumptions (a) the compiler emits GOT-generating relocations (b) the linker produces R_*_GLOB_DAT instead of R_*_RELATIVE. Otherwise the shared object uses its own definition directly and the executable accesses a stale copy. Note: the GOT relocations defeat the purpose of protected visibility as an optimization, and it turns out this never worked perfectly. glibc 2.36 will warn on copy relocations on protected data. Let's produce a warning at link time, matching ld.lld which has been used on many aarch64 OSes. Note: x86 requires GNU_PROPERTY_NO_COPY_ON_PROTECTED to have the error. This is to largely due to GCC 5's "x86-64: Optimize access to globals in PIE with copy reloc" which started to use direct access relocations for external data symbols in -fpie mode. GCC's aarch64 port does not have the change. Nowadays with most builds switching to -fpie/-fpic, aarch64 mostly doesn't need to worry about copy relocations. So for aarch64 we simply don't check GNU_PROPERTY_NO_COPY_ON_PROTECTED.
2022-06-22Binutils support for split-dwarf and dwarf-5Kumar N, Bhuvanendra3-15/+56
* dwarf.c (fetch_indexed_string): Added new parameter str_offsets_base to calculate the string offset. (read_and_display_attr_value): Read DW_AT_str_offsets_base attribute. (process_debug_info): While allocating memory and initializing debug_information, do it for do_debug_info also, if its true. (load_separate_debug_files): Load .debug_str_offsets if exists. * dwarf.h (struct debug_info): Add str_offsets_base field.
2022-06-22RISC-V: Reorder the prefixed extensions which are out of order.Nelson Chu7-38/+0
This patch has been pending for almost a year... However, I noticed that llvm can already re-order the extensions, even if they are out of orders. Not really sure if they can also re-order the single letter extensions, but at least we can do this for the multi-letter extensions in binutils. bfd/ * elfxx-riscv.c (riscv_parse_prefixed_ext): Removed the code which are used to check the prefixed extension orders. gas/ * testsuite/gas/riscv/march-fail-order-x-z.d: Removed since we will help tp reorder the prefixed extensions for now. * testsuite/gas/riscv/march-fail-order-x-z.l: Likewise. * testsuite/gas/riscv/march-fail-order-x.d: Likewise. * testsuite/gas/riscv/march-fail-order-x.l: Likewise. * testsuite/gas/riscv/march-fail-order-z.d: Likewise. * testsuite/gas/riscv/march-fail-order-z.l: Likewise.
2022-06-22RISC-V: Use single h extension to control hypervisor CSRs and instructions.Nelson Chu16-364/+411
According to the picture 28.1 in the current ISA spec, h is no larger the multi-letter extension, it is a single extension after v. Therefore, this patch fix the implementation, and use the single h to control hypervisor CSRs and instructions, which we promised to do before. bfd/ * elfxx-riscv.c (riscv_supported_std_ext): Added h with version 1.0 after v. (riscv_supported_std_h_ext): Removed. (riscv_all_supported_ext): Updated since riscv_supported_std_h_ext is removed. (riscv_prefix_ext_class): Removed RV_ISA_CLASS_H. (parse_config): Updated since riscv_prefix_ext_class is removed. (riscv_recognized_prefixed_ext): Likewise. (riscv_get_default_ext_version): Likewise. (riscv_multi_subset_supports): Handle INSN_CLASS_H for hypervisor instructions. (riscv_multi_subset_supports_ext): Likewise. gas/ * config/tc-riscv.c (riscv_csr_class): Added CSR_CLASS_H and CSR_CLASS_H_32 for hypervisor CSRs. (riscv_csr_address): Likewise. * testsuite/gas/riscv/csr-version-1p10.d: Updated since hypervisor CSRs are controlled by single h extension for now. * testsuite/gas/riscv/csr-version-1p10.l: Likewise. * testsuite/gas/riscv/csr-version-1p11.d: Likewise. * testsuite/gas/riscv/csr-version-1p11.l: Likewise. * testsuite/gas/riscv/csr-version-1p12.d: Likewise. * testsuite/gas/riscv/csr-version-1p12.l: Likewise. * testsuite/gas/riscv/csr-version-1p9p1.d: Likewise. * testsuite/gas/riscv/csr-version-1p9p1.l: Likewise. * testsuite/gas/riscv/h-ext-32.d: Added h to architecture string. * testsuite/gas/riscv/h-ext-64.d: Likewise. * testsuite/gas/riscv/march-fail-single-prefix-h: Removed since h is no longer multi-letter extension. * testsuite/gas/riscv/march-fail-unknown-h.d: Likewise. include/ * opcode/riscv-opc.h: Control hypervisor CSRs by h extension, rather than the privileged spec verisons. * opcode/riscv.h (riscv_insn_class): Added INSN_CLASS_H. opcodes/ * riscv-opc.c (riscv_opcodes): Control hypervisor instructions by h extension.
2022-06-22RISC-V: Add 'H' to canonical extension orderingTsukasa OI1-1/+1
This commit adds 'H' to canonical extension ordering based on current consensus (not officially ratified as a new ISA specification manual but discussion for software compatibility is made). bfd/ChangeLog * elfxx-riscv.c (riscv_ext_canonical_order): Add 'H' for canonical extension ordering based on current consensus.
2022-06-22RISC-V: Prepare i18n for required ISA extensionsTsukasa OI1-13/+14
Some strings returned by the riscv_multi_subset_supports_ext function contain not just extension names but words like "and" and "or". This commit wraps such strings with the gettext macro (_) for internationalization in the future. bfd/ChangeLog: * elfxx-riscv.c (riscv_multi_subset_supports_ext): Wrap some strings with the gettext macro to prepare future i18n.
2022-06-22RISC-V: Fix inconsistent error message (range)Tsukasa OI1-1/+1
This commit fixes inconsistent error message format involving compressed funct<n> fields. In specific, funct6 had an error message with range 0..2^<n> ("0..64") unlike other funct<n> fields with 0..2^<n>-1 (e.g. funct4 with "0..15"). gas/ChangeLog: * config/tc-riscv.c (riscv_ip): Fix inconsistent error message.
2022-06-22readelf: replace xmalloc with malloc in slurp_relr_relocsMarcus Nilsson2-1/+6
Using xmalloc makes the null check redundant since failing allocation will exit the program. Instead use malloc and let the error be conveyed up the call chain.
2022-06-22PowerPC64: stub debug dumpAlan Modra1-2/+57
powerpc64le-linux-ld is failing the assertion in ppc_build_one_stub, again apparently, which means a stub will overwrite the tail of a previous stub. The difficulty with debugging these issues is that it's not a problem with the stub that triggers the assertion, but the previous stub in that section. This patch keeps track of the last stub and adds a debug dump. Hopefully that will help. * elf64-ppc.c (enum _ppc64_sec_type): Add sec_stub. (struct _ppc64_elf_section_data): Add u.last_ent. (dump_previous_stub): New function. (ppc_build_one_stub): Keep track of previous stub, and dump it when finding an overlapping stub.
2022-06-22PR29270, DW_FORM_udata signed outputAlan Modra1-1/+5
PR 29270 * dwarf.c (read_and_display_attr_value): Output DW_FORM_udata as unsigned.
2022-06-22Automatic date update in version.inGDB Administrator1-1/+1
2022-06-21ld: regenerate configure after recent misgenerationNick Alcock1-118/+103
Things work again after this. ld/ChangeLog: * configure: Regenerate.
2022-06-21libctf: tests: prune warnings from compiler outputNick Alcock2-6/+6
We were failing to call prune_warnings appropriately, leading to false-positive test failures on some platforms (observed on sparclinux). libctf/ChangeLog: * testsuite/lib/ctf-lib.exp: Prune warnings from compiler and linker output. * testsuite/libctf-regression/libctf-repeat-cu.exp: Likewise, and ar output too.
2022-06-21libctf: avoid mingw warningNick Alcock1-1/+1
A missing paren led to an intended cast to avoid dependence on the size of size_t in one argument of ctf_err_warn applying to the wrong type by mistake. libctf/ChangeLog: * ctf-serialize.c (ctf_write_mem): Fix cast.
2022-06-21libctf: fix linking together multiple objects derived from the same sourceNick Alcock8-33/+280
Right now, if you compile the same .c input repeatedly with CTF enabled and different compilation flags, then arrange to link all of these together, then things misbehave in various ways. libctf may conflate either inputs (if the .o files have the same name, say if they are stored in different .a archives), or per-CU outputs when conflicting types are found: the latter can lead to entirely spurious errors when it tries to produce multiple per-CU outputs with the same name (discarding all but the last, but then looking for types in the earlier ones which have just been thrown away). Fixing this is multi-pronged. Both inputs and outputs need to be differentiated in the hashtables libctf keeps them in: inputs with the same cuname and filename need to be considered distinct as long as they have different associated CTF dicts, and per-CU outputs need to be considered distinct as long as they have different associated input dicts. Right now there is nothing tying the two together other than the CU name: fix this by introducing a new field in the ctf_dict_t named ctf_link_in_out, which (for input dicts) points to the associated per-CU output dict (if any), and for output dicts points to the associated input dict. At creation time the name used is completely arbitrary: it's only important that it be distinct if CTF dicts are distinct. So, when a clash is found, adjust the CU name by sticking the number of elements in the input on the end. At output time, the CU name will appear in the linked object, so it matters a little more that it look slightly less ugly: in conflicting cases, append an incrementing integer, starting at 0. This naming scheme is not very helpful, but it's hard to see what else we can do. The input .o name may be the same. The input .a name is not even visible to ctf_link, and even *that* might be the same, because .a's can contain many members with the same name, all of which participate in the link. All we really know is that the two have distinct dictionaries with distinct types in them, and at least this way they are all represented, any any symbols, variables etc referring to those types are accurately stored. (As a side-effect this also fixes a use-after-free and double-free when errors are found during variable or symbol emission.) Use the opportunity to prevent a couple of sources of problems, to wit changing the active CU mappings when a link has already been done (no effect on ld, which doesn't use CU mappings at all), and causing multiple consecutive ctf_link's to have the same net effect as just doing the last one (no effect on ld, which only ever does one ctf_link) rather than having the links be a sort of half-incremental not-really-intended mess. libctf/ChangeLog: PR libctf/29242 * ctf-impl.h (struct ctf_dict) [ctf_link_in_out]: New. * ctf-dedup.c (ctf_dedup_emit_type): Set it. * ctf-link.c (ctf_link_add_ctf_internal): Set the input CU name uniquely when clashes are found. (ctf_link_add): Document what repeated additions do. (ctf_new_per_cu_name): New, come up with a consistent name for a new per-CU dict. (ctf_link_deduplicating): Use it. (ctf_create_per_cu): Use it, and ctf_link_in_out, and set ctf_link_in_out properly. Don't overwrite per-CU dicts with per-CU dicts relating to different inputs. (ctf_link_add_cu_mapping): Prevent per-CU mappings being set up if we already have per-CU outputs. (ctf_link_one_variable): Adjust ctf_link_per_cu call. (ctf_link_deduplicating_one_symtypetab): Likewise. (ctf_link_empty_outputs): New, delete all the ctf_link_outputs and blank out ctf_link_in_out on the corresponding inputs. (ctf_link): Clarify the effect of multiple ctf_link calls. Empty ctf_link_outputs if it already exists rather than having the old output leak into the new link. Fix a variable name. * testsuite/config/default.exp (AR): Add. (OBJDUMP): Likewise. * testsuite/libctf-regression/libctf-repeat-cu.exp: New test. * testsuite/libctf-regression/libctf-repeat-cu*: Main program, library, and expected results for the test.
2022-06-21Document how GDB searches for files when using -s, -e, and -se optionsKevin Buettner1-0/+5
GDB's documentation of the 'file' command says: If you do not specify a directory and the file is not found in the GDB working directory, GDB uses the environment variable PATH as a list of directories to search, just as the shell does when looking for a program to run. The same is true for files specified via commandline options -s, -e, and -se. This commit adds a cross reference to the file command for these options.
2022-06-21Binutils support for dwarf-5 (location and range lists related)Nick Clifton3-13/+51
* dwarf.h (struct debug_info): Add rnglists_base field. * dwarf.c (read_and_display_attr_value): Read attribute DW_AT_rnglists_base. (display_debug_rnglists_list): While handling DW_RLE_base_addressx, DW_RLE_startx_endx, DW_RLE_startx_length items, pass the proper parameter value to fetch_indexed_addr(), i.e. fetch the proper entry in .debug_addr section. (display_debug_ranges): Add rnglists_base to the .debug_rnglists base address. (load_separate_debug_files): Load .debug_addr section, if exists.
2022-06-21Default to disabling the linker warnings about execstack and RWX segments if ↵Nick Clifton4-109/+164
the target is the HPPA architecture. PR 29263 * configure.ac (ac_default_ld_warn_execstack): Default to 'no' for HPPA targets. (ac_default_ld_warn_rwx_segments): Likewise. * configure: Regenerate. * testsuite/ld-elf/elf.exp: Add the --warn-execstack command line option to the command line when running execstack tests for the HPPA target.
2022-06-21Automatic date update in version.inGDB Administrator1-1/+1
2022-06-20Move finish_print out of value_print_optionsTom Tromey3-9/+10
'finish_print' does not really belong in value_print_options -- this is consulted only when deciding whether or not to print a value, and never during the course of printing. This patch removes it from the structure and makes it a static global in infcmd.c instead. Tested on x86-64 Fedora 34.
2022-06-20PR29262, memory leak in pr_function_typeAlan Modra1-5/+2
PR 29262 * prdbg.c (pr_function_type): Free "s" on failure path.
2022-06-20PR29261, memory leak in parse_stab_struct_fieldsAlan Modra1-1/+4
PR 29261 * stabs.c (parse_stab_struct_fields): Free "fields" on failure path.
2022-06-20Automatic date update in version.inGDB Administrator1-1/+1
2022-06-19Automatic date update in version.inGDB Administrator1-1/+1
2022-06-18Fix assertion failure in copy_typeTom Tromey2-12/+12
PR exp/20630 points out a simple way to cause an assertion failure in copy_type -- but this was found in the wild a few times as well. copy_type only works for objfile-owned types, but there isn't a deep reason for this. This patch fixes the bug by updating copy_type to work for any sort of type. Better would perhaps be to finally implement type GC, but I still haven't attempted this. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20630
2022-06-18Fix the sorting algorithm for reloc entriesTomoaki Kawada4-2/+41
The optimized insertion sort algorithm in `elf_link_adjust_relocs` incorrectly assembled "runs" from unsorted entries and inserted them to an already-sorted prefix, breaking the loop invariants of insertion sort. This commit updates the run assembly loop to break upon encountering a non-monotonic change in the sort key. PR 29259 bfd/ * elflink.c (elf_link_adjust_relocs): Ensure run being inserted is sorted. ld/ * testsuite/ld-elf/pr29259.d, * testsuite/ld-elf/pr29259.s, * testsuite/ld-elf/pr29259.t: New test.
2022-06-18gdb/python: Export nibbles to python layerEnze Li3-1/+84
This patch makes it possible to allow Value.format_string() to return nibbles output. When we set the parameter of nibbles to True, we can achieve the displaying binary values in groups of every four bits. Here's an example: (gdb) py print (gdb.Value (1230).format_string (format='t', nibbles=True)) 0100 1100 1110 (gdb) Note that the parameter nibbles is only useful if format='t' is also used. This patch also includes update to the relevant testcase and documentation. Tested on x86_64 openSUSE Tumbleweed.
2022-06-18gdb/doc: Documentation for the new print commandEnze Li2-4/+36
Document the new command "print nibbles" and add a NEWS entry.
2022-06-18gdb: Add new 'print nibbles' featureEnze Li8-3/+113
Make an introduction of a new print setting that can be set by 'set print nibbles [on|off]'. The default value if OFF, which can be changed by user manually. Of course, 'show print nibbles' is also included in the patch. The new feature displays binary values by group, with four bits per group. The motivation for this work is to enhance the readability of binary values. Here's a GDB session before this patch is applied. (gdb) print var_a $1 = 1230 (gdb) print/t var_a $2 = 10011001110 With this patch applied, we can use the new print setting to display the new form of the binary values. (gdb) print var_a $1 = 1230 (gdb) print/t var_a $2 = 10011001110 (gdb) set print nibbles on (gdb) print/t var_a $3 = 0100 1100 1110 Tested on x86_64 openSUSE Tumbleweed.
2022-06-18Automatic date update in version.inGDB Administrator1-1/+1
2022-06-17gdb: NEWS: Move LoongArch gdbserver to the correct sectionTiezhu Yang1-3/+8
commit e5ab6af52d38 ("gdbserver: Add LoongArch/Linux support") was merged into the master since GDB 12, so we should put the news in the "Changes since GDB 12" section. Thanks Tom Tromey for your correction [1], sorry for that. [1] https://sourceware.org/pipermail/gdb-patches/2022-June/190122.html Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-06-17PR29256, memory leak in obj_elf_section_nameAlan Modra1-14/+18
When handling section names in quotes obj_elf_section_name calls demand_copy_C_string, which puts the name on the gas notes obstack. Such strings aren't usually freed, since obstack_free frees all more recently allocated objects as well as its arg. When handling non-quoted names, obj_elf_section_name mallocs the name. Due to the mix of allocation strategies it isn't possible for callers to free names, if that was desirable. Partially fix this by always creating names on the obstack, which is more efficient anyway. (You still can't obstack_free on error paths due to the xtensa tc_canonicalize_section_name.) Also remove a couple of cases where the name is dup'd for no good reason as far as I know. PR 29256 * config/obj-elf.c (obj_elf_section_name): Create name on notes obstack. (obj_elf_attach_to_group): Don't strdup group name. (obj_elf_section): Likewise. (obj_elf_vendor_attribute): Use xmemdup0 rather than xstrndup.
2022-06-17PR29255, memory leak in make_tempdirAlan Modra1-9/+11
PR 29255 * bucomm.c (make_tempdir, make_tempname): Free template on all failure paths.
2022-06-17PR29254, memory leak in stab_demangle_v3_argAlan Modra1-1/+4
PR 29254 * stabs.c (stab_demangle_v3_arg): Free dt on failure path.
2022-06-17Fix GDB build with GCC 4.8 & 4.9Pedro Alves2-10/+15
With gcc 4.8/4.9, we run into this build failure (and other similar ones): /home/palves/gdb/binutils-gdb/src/gdb/location.h:224:59: error: could not convert ‘{0, LINE_OFFSET_UNKNOWN}’ from ‘<brace-enclosed initializer list>’ to ‘line_offset’ struct line_offset line_offset = {0, LINE_OFFSET_UNKNOWN}; ^ The issue is that at around the GCC 4.8/4.9 era, a default member initializer prevented the struct from being an aggregate, so you cannot use aggregate initialization on them. That rule changed after GCC 4.9 and GCC 5 & later uses new rules. Fix this by not using aggregate initialization for struct line_offset. The default member initization already leaves line_offset as {0, LINE_OFFSET_UNKNOWN}, so initialization to those values can just go away. The remaining cases are of the form {0, LINE_OFFSET_NONE}, and those cases can be better rewritten to delay setting the sign field until we know we have a valid offset. Change-Id: I0506ea4a83c5fa2f15e159569db68b3b0a7509b4
2022-06-17Convert set_location_spec_string to a methodPedro Alves3-27/+19
This converts set_location_spec_string to a method of location_spec, and makes the location_spec::as_string field protected, renaming it to m_as_string along the way. Change-Id: Iccfb1654e9fa7808d0512df89e775f9eacaeb9e0
2022-06-17Convert location_spec_to_string to a methodPedro Alves8-49/+27
This converts location_spec_to_string to a method of location_spec, simplifying the code using it, as it no longer has to use std::unique_ptr::get(). Change-Id: I621bdad8ea084470a2724163f614578caf8f2dd5
2022-06-17Convert location_spec_type to a methodPedro Alves5-31/+25
This converts location_spec_type to location_spec::type(). Change-Id: Iff4cbfafb1cf3d22adfa142ff939b4a148e52273