aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-08-04IBM Z: Remove lpswey parameterAndreas Krebbel4-3/+5
opcodes/ * s390-opc.c (INSTR_SIY_RD): New instruction format. (MASK_SIY_RD): New instruction mask. * s390-opc.txt: Change instruction format of lpswey to SIY_RD. gas/ * testsuite/gas/s390/zarch-arch14.d: Remove last operand of lpswey. * testsuite/gas/s390/zarch-arch14.s: Likewise.
2021-08-04PR28162, segment fault in mips_elf_assign_gpAlan Modra2-7/+7
For the testcase in the PR, _bfd_mips_elf32_gprel16_reloc is passed a NULL output_bfd. As expected for reloc special functions if called by objdump or when final linking. The function attempts to find the output by output_bfd = symbol->section->output_section->owner; That makes some sense, since when handling a gp-relative reloc we need the relevant gp to which the symbol is relative. Possibly the gp value can be one for a shared library? But that doesn't seem useful or supported by the various abi docs and won't work as written. Symbols defined in shared libraries have section->output_section NULL, and what's more the code in mips_elf_assign_gp isn't set up to look at shared library symbols. Also, if the symbol is a SHN_ABS one the owner of *ABS* section is NULL, which will result in the testcase segfault. The only gp to which an absolute symbol can be relative is the linker output bfd when linking, or the input bfd when not. This patch arranges to do that for all gp-relative reloc symbols. * elf32-mips.c (_bfd_mips_elf32_gprel16_reloc): Don't use the section symbol to find the output bfd, use input_section. (mips_elf_gprel32_reloc, mips16_gprel_reloc): Likewise. * elf64-mips.c (mips_elf64_gprel16_reloc): Likewise. (mips_elf64_literal_reloc, mips_elf64_gprel32_reloc): Likewise. (mips16_gprel_reloc): Likewise.
2021-08-04[gdb/symtab] Use lambda function instead of addrmap_foreach_checkTom de Vries1-30/+21
Use a lambda function instead of addrmap_foreach_check, which removes the need for static variables. Also remove unnecessary static on local var temp_obstack in test_addrmap. gdb/ChangeLog: 2021-08-04 Tom de Vries <tdevries@suse.de> * addrmap.c (addrmap_foreach_check): Remove. (array, val1, val2): Move ... (test_addrmap): ... here. Remove static on temp_obstack. Use lambda function instead of addrmap_foreach_check.
2021-08-04elf: Treat undefined version as hiddenH.J. Lu16-12/+63
Since undefined version can't be used to resolve any references without the original definition, treat it as hidden. bfd/ PR binutils/28158 * elf.c (_bfd_elf_get_symbol_version_string): Treat undefined version as hidden. ld/ PR binutils/28158 * testsuite/ld-elf/linux-x86.exp: Run PR binutils/28158 tests. * testsuite/ld-elf/pr28158-1.c: New file. * testsuite/ld-elf/pr28158-2.S: Likewise. * testsuite/ld-elf/pr28158.nd: Likewise. * testsuite/ld-elf/pr28158.rd: Likewise. * testsuite/ld-elf/pr28158.t: Likewise. * testsuite/ld-elfvers/vers2.dsym: Updated. * testsuite/ld-elfvers/vers3.dsym: Likewise. * testsuite/ld-elfvers/vers6.dsym: Likewise. * testsuite/ld-elfvers/vers19.dsym: Likewise. * testsuite/ld-elfvers/vers22.dsym: Likewise. * testsuite/ld-elfvers/vers23.dsym: Likewise. * testsuite/ld-elfvers/vers23d.dsym: Likewise. * testsuite/ld-elfvers/vers27d4.dsym: Likewise. * testsuite/ld-elfvers/vers28c.dsym: Likewise.
2021-08-04[gdb/symtab] Implement addrmap_mutable_findTom de Vries1-4/+126
Currently addrmap_mutable_find is not implemented: ... static void * addrmap_mutable_find (struct addrmap *self, CORE_ADDR addr) { /* Not needed yet. */ internal_error (__FILE__, __LINE__, _("addrmap_find is not implemented yet " "for mutable addrmaps")); } ... I implemented this because I needed it during debugging, to be able to do: ... (gdb) p ((dwarf2_psymtab *)addrmap_find (map, addr))->filename ... before and after a call to addrmap_set_empty. Since this is not used otherwise, added addrmap unit test. Build on x86_64-linux, tested by doing: ... $ gdb -q -batch -ex "maint selftest addrmap" Running selftest addrmap. Ran 1 unit tests, 0 failed ... gdb/ChangeLog: 2021-08-03 Tom de Vries <tdevries@suse.de> * gdb/addrmap.c (addrmap_mutable_find): Implement [GDB_SELF_TESTS] (CHECK_ADDRMAP_FIND): New macro. [GDB_SELF_TESTS] (core_addr, addrmap_foreach_check, test_addrmap) (_initialize_addrmap): New function.
2021-08-04gas: correctly output XCOFF tbss symbols with XTY_CM type.Clément Chigot1-1/+2
Global tbss symbols weren't correctly handled and were generating a symbol with XTY_SD instead of XTY_CM as expected. gas/ * config/tc-ppc.c (ppc_frog_symbol): Generate a XTY_CM when a symbol has a storage class of XMC_UL.
2021-08-04gas: always add dummy symbols when creating XCOFF sections.Clément Chigot1-17/+11
Most of the algorithms for XCOFF in tc-ppc.c assume that the csects field of a ppc_xcoff_section isn't NULL. This was already made for most of the sections with the creation of a dummy symbol. This patch simply mades it default when creating a xcoff_section. gas/ * config/tc-ppc.c (ppc_init_xcoff_section): Always create the dummy symbol. (md_begin): Adjust ppc_init_xcoff_section call. (ppc_comm): Likewise. (ppc_change_csect): Likewise.
2021-08-04PR28156, rename.c doesn't compile with MinGWAlan Modra1-0/+2
Guard against lack of struct timespec definition. PR 28156 * rename.c (get_stat_atime, get_stat_mtime): Don't compile unless HAVE_UTIMENSAT is defined.
2021-08-04PR28155, Superfluous "the" in the man pageAlan Modra1-1/+1
PR 28155 * ld.texi (Options <runtime library name>): Correct grammar.
2021-08-04revise PE IMAGE_SCN_LNK_NRELOC_OVFL testAlan Modra1-1/+1
* coffcode.h (coff_set_alignment_hook): Test that the resulting reloc count is not less than 0xffff.
2021-08-03gdb: follow-fork: push target and add thread in target_follow_forkSimon Marchi15-142/+172
In the context of ROCm-gdb [1], the ROCm target sits on top of the linux-nat target. when a process forks, it needs to carry over some data from the forking inferior to the fork child inferior. Ideally, the ROCm target would implement the follow_fork target_ops method, but there are some small problems. This patch fixes these, which helps the ROCm target, but also makes things more consistent and a bit nicer in general, I believe. The main problem is: when follow-fork-mode is "parent", target_follow_fork is called with the parent as the current inferior. When it's "child", target_follow_fork is called with the child as the current inferior. This means that target_follow_fork is sometimes called on the parent's target stack and sometimes on the child's target stack. The parent's target stack may contain targets above the process target, such as the ROCm target. So if follow-fork-child is "parent", the ROCm target would get notified of the fork and do whatever is needed. But the child's target stack, at that moment, only contains the exec and process target copied over from the parent. The child's target stack is set up by follow_fork_inferior, before calling target_follow_fork. In that case, the ROCm target wouldn't get notified of the fork. For consistency, I think it would be good to always call target_follow_fork on the parent inferior's target stack. I think it makes sense as a way to indicate "this inferior has called fork, do whatever is needed". The desired outcome of the fork (whether an inferior is created for the child, do we need to detach from the child) can be indicated by passed parameter. I therefore propose these changes: - make follow_fork_inferior always call target_follow_fork with the parent as the current inferior. That lets all targets present on the parent's target stack do some fork-related handling and push themselves on the fork child's target stack if needed. For this purpose, pass the child inferior down to target_follow_fork and follow_fork implementations. This is nullptr if no inferior is created for the child, because we want to detach from it. - as a result, in follow_fork_inferior, detach from the parent inferior (if needed) only after the target_follow_fork call. This is needed because we want to call target_follow_fork before the parent's target stack is torn down. - hand over to the targets in the parent's target stack (including the process target) the responsibility to push themselves, if needed, to the child's target stack. Also hand over the responsibility to the process target, at the same time, to create the child's initial thread (just like we do for follow_exec). - pass the child inferior to exec_on_vfork, so we don't need to swap the current inferior between parent and child. Nothing in exec_on_vfork depends on the current inferior, after this change. Although this could perhaps be replaced with just having the exec target implement follow_fork and push itself in the child's target stack, like the process target does... We would just need to make sure the process target calls beneath()->follow_fork(...). I'm not sure about this one. gdb/ChangeLog: * target.h (struct target_ops) <follow_fork>: Add inferior* parameter. (target_follow_fork): Likewise. * target.c (default_follow_fork): Likewise. (target_follow_fork): Likewise. * fbsd-nat.h (class fbsd_nat_target) <follow_fork>: Likewise. (fbsd_nat_target::follow_fork): Likewise, and call inf_ptrace_target::follow_fork. * linux-nat.h (class linux_nat_target) <follow_fork>: Likewise. * linux-nat.c (linux_nat_target::follow_fork): Likewise, and call inf_ptrace_target::follow_fork. * obsd-nat.h (obsd_nat_target) <follow_fork>: Likewise. * obsd-nat.c (obsd_nat_target::follow_fork): Likewise, and call inf_ptrace_target::follow_fork. * remote.c (class remote_target) <follow_fork>: Likewise. (remote_target::follow_fork): Likewise, and call process_stratum_target::follow_fork. * process-stratum-target.h (class process_stratum_target) <follow_fork>: New. * process-stratum-target.c (process_stratum_target::follow_fork): New. * target-delegates.c: Re-generate. [1] https://github.com/ROCm-Developer-Tools/ROCgdb Change-Id: I460bd0af850f0485e8aed4b24c6d8262a4c69929
2021-08-04Automatic date update in version.inGDB Administrator1-1/+1
2021-08-03Fixes for mi-fortran-modules.exp fixesCarl Love1-2/+2
Output has additional information for a given filename. gdb/testsuite/ChangeLog * gdb.mi/mi-fortran-modules.exp (system_modules_pattern, system_module_symbols_pattern): Add check for additional symbols on the line
2021-08-03gdbsupport: add debug assertions in gdb::optional::getSimon Marchi1-2/+14
The libstdc++ version of optional contains some runtime checks enabled when _GLIBCXX_DEBUG is defined. I think it would be useful if our version contained similar checks. Add checks in the two `get` methods, also conditional on _GLIBCXX_DEBUG. I think it's simpler to use that macro rather than introducing a new GDB-specific one, as I think that if somebody is interested in enabling these runtime checks, they'll also be interested in enabling the libstdc++ runtime checks (and vice-versa). I implemented these checks using gdb_assert. Note that gdb_assert throws (after querying the user), and we are in noexcept methods. That means that std::terminate / abort will immediately be called. I think this is ok, since if those were "real" _GLIBCXX_DEBUG checks, abort would be called straight away. If I add a dummy failure, it looks like so: $ ./gdb -q -nx --data-directory=data-directory /home/simark/src/binutils-gdb/gdb/../gdbsupport/gdb_optional.h:206: internal-error: T& gdb::optional<T>::get() [with T = int]: Assertion `this->has_value ()' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) n [1] 658767 abort (core dumped) ./gdb -q -nx --data-directory=data-directory Change-Id: Iadfdcd131425bd2ca6a2de30d7b22e9b3cc67793
2021-08-03[gdb/testsuite] templates.exp to accept clang++ outputAlok Kumar Sharma1-0/+3
Please consider below testcase with intended error. `````````` constexpr const char cstring[] = "Eta"; template <const char*, typename T> class Column {}; using quick = Column<cstring,double>; // cstring without '&' void lookup() { quick c1; c1.ls(); } `````````` It produces below error. `````````` no member named 'ls' in 'Column<&cstring, double>'. `````````` Please note that error message contains '&' for cstring, which is absent in actual program. Clang++ does not generate & in such cases and this should also be accepted as correct output. gdb/testsuite/ChangeLog: * gdb.cp/templates.exp: Accept different but correct output from the Clang++ compiled binary also.
2021-08-03Automatic date update in version.inGDB Administrator1-1/+1
2021-08-02Handle compiler-generated suffixes in Ada namesTom Tromey3-1/+120
The compiler may add a suffix to a mangled name. A typical example would be splitting a function and creating a ".cold" variant. This patch changes Ada decoding (aka demangling) to handle these suffixes. It also changes the encoding process to handle them as well. A symbol like "function.cold" will now be displayed to the user as "function[cold]". The "." is not simply preserved because that is already used in Ada.
2021-08-02Remove uses of fprintf_symbol_filteredTom Tromey3-17/+7
I believe that many calls to fprintf_symbol_filtered are incorrect. In particular, there are some that pass a symbol's print name, like: fprintf_symbol_filtered (gdb_stdout, sym->print_name (), current_language->la_language, DMGL_ANSI); fprintf_symbol_filtered uses the "demangle" global to decide whether or not to demangle -- but print_name does this as well. This can lead to double-demangling. Normally this could be innocuous, except I also plan to change Ada demangling in a way that causes this to fail.
2021-08-02Handle type qualifier for enumeration nameTom Tromey4-2/+112
Pierre-Marie noticed that the Ada expression "TYPE'(NAME)" resolved incorrectly when "TYPE" was an enumeration type. Here, "NAME" should be unambiguous. This patch fixes this problem. Note that the patch is not perfect -- it does not give an error if TYPE is an enumeration type but NAME is not an enumerator but does have some other meaning in scope. Fixing this proved difficult, and so I've left it out.
2021-08-02Remove the type_qualifier globalTom Tromey1-13/+1
The type_qualifier global is no longer needed in the Ada expression parser, so this removes it.
2021-08-02Defer Ada character literal resolutionTom Tromey7-44/+204
In Ada, an enumeration type can use a character literal as one of the enumerators. The Ada expression parser handles the appropriate conversion. It turns out, though, that this conversion was handled incorrectly. For an expression like TYPE'(EXP), the conversion would be done for any such literal appearing in EXP -- but only the outermost such expression should really be affected. This patch defers the conversion until the resolution phase, fixing the bug.
2021-08-02Refactor Ada resolutionTom Tromey3-10/+42
In a subsequent patch, it will be convenient if an Ada expression operation can supply its own replacement object. This patch refactors Ada expression resolution to make this possible.
2021-08-02Remove add_symbols_from_enclosing_procsTom Tromey1-28/+2
I noticed that add_symbols_from_enclosing_procs is empty, and can be removed. The one caller, ada_add_local_symbols, can also be simplified, removing some code that, I think, was an incorrect attempt to handle nested functions.
2021-08-02Avoid crash in varobj deletionTom Tromey2-2/+16
PR varobj/28131 points out a crash in the varobj deletion code. It took a while to reproduce this, but essentially what happens is that a top-level varobj deletes its root object, then deletes the "dynamic" object. However, deletion of the dynamic object may cause ~py_varobj_iter to run, which in turn uses gdbpy_enter_varobj: gdbpy_enter_varobj::gdbpy_enter_varobj (const struct varobj *var) : gdbpy_enter (var->root->exp->gdbarch, var->root->exp->language_defn) { } However, because var->root has already been destroyed, this is invalid. I've added a new test case. This doesn't reliably crash, but the problem can easily be seen under valgrind (and, I presume, with ASAN, though I did not try this). Tested on x86-64 Fedora 32. I also propose putting this on the GDB 11 branch, with a suitable ChangeLog entry of course. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28131
2021-08-02[gdb/testsuite] Fix gdb.dwarf2/dw2-using-debug-str.exp with cc-with-dwz-mTom de Vries1-0/+13
When running with target board cc-with-dwz-m, we run into: ... (gdb) file dw2-using-debug-str-no-debug-str^M Reading symbols from dw2-using-debug-str-no-debug-str...^M (gdb) FAIL: gdb.dwarf2/dw2-using-debug-str.exp: file dw2-using-debug-str ... With native, the .debug_str section is present in the dw2-using-debug-str executable, and removed from the dw2-using-debug-str-no-debug-str executable. When loading the latter, a dwarf error is triggered. With cc-with-dwz-m, the .debug_str section is not present in the dw2-using-debug-str executable, because it's already moved to .tmp/dw2-using-debug-str.dwz. Consequently, the removal has no effect, and no dwarf error is triggered, which causes the FAIL. The same problem arises with target board cc-with-gnu-debuglink. Fix this by detecting whether the .debug_str section is missing, and skipping the remainder of the test-case. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-08-02 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/dw2-using-debug-str.exp: Handle missing .debug_str section in dw2-using-debug-str.
2021-08-02[gdb/testsuite] Fix gdb.dwarf2/dw2-using-debug-str.exp with cc-with-gdb-indexTom de Vries1-12/+16
When running with target board cc-with-gdb-index, we run into: ... (gdb) file dw2-using-debug-str-no-debug-str^M Reading symbols from dw2-using-debug-str-no-debug-str...^M Dwarf Error: DW_FORM_strp used without required section^M (gdb) FAIL: gdb.dwarf2/dw2-using-debug-str.exp: file dw2-using-debug-str ... The test expects the dwarf error, but has no matching pattern for the entire output. Fix this by updating the regexp. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-08-02 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/dw2-using-debug-str.exp: Update regexp to match cc-with-gdb-index output.
2021-08-02[gdb/testsuite] Fix gdb.dwarf2/per-bfd-sharing.exp with cc-with-gdb-indexTom de Vries1-1/+5
When running with target board cc-with-gdb-index, we run into: ... rm: cannot remove '/tmp/tmp.JmYTeiuFjj/*.gdb-index': \ No such file or directory^M FAIL: gdb.dwarf2/per-bfd-sharing.exp: \ couldn't remove files in temporary cache dir ... Fix this, as in gdb.base/index-cache.exp, by only FAILing when $expecting_index_cache_use. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-08-02 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/per-bfd-sharing.exp: Only expect index-cache files when $expecting_index_cache_use.
2021-08-02[gdb/testsuite] Fix gdb.dwarf2/gdb-index-nodebug.exp with cc-with-gdb-indexTom de Vries1-2/+21
When running with target board cc-with-gdb-index, we run into: ... (gdb) save gdb-index .^M Error while writing index for `gdb-index-nodebug': \ Cannot use an index to create the index^M (gdb) FAIL: gdb.dwarf2/gdb-index-nodebug.exp: try to save gdb index ... Fix this by detecting an already present index, and marking the test unsupported. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-08-02 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/gdb-index-nodebug.exp: Mark unsupported when index already present.
2021-08-02[gdb/testsuite] Fix gdb.dwarf2/fission-relative-dwo.exp with cc-with-gdb-indexTom de Vries1-0/+14
When running with target board cc-with-gdb-index, we run into: ... gdb compile failed, warning: Could not find DWO CU \ fission-relative-dwo.dwo(0x1234) referenced by CU at offset 0xc7 \ [in module outputs/gdb.dwarf2/fission-relative-dwo/.tmp/fission-relative-dwo] UNTESTED: gdb.dwarf2/fission-relative-dwo.exp: fission-relative-dwo.exp ERROR: failed to compile fission-relative-dwo ... The problem is that: - the .dwo file is found relative to the executable, and - cc-with-tweaks.sh moves the executable to a temp dir, but not the .dwo file. Fix this by copying the .dwo file alongside the executable in the temp dir. Verified changes using shellcheck. Tested on x86_64-linux. gdb/ChangeLog: 2021-08-02 Tom de Vries <tdevries@suse.de> * contrib/cc-with-tweaks.sh: Copy .dwo files alongside executable.
2021-08-02gdb: Make the builtin "boolean" type an unsigned typeShahab Vahedi2-1/+69
When printing the fields of a register that is of a custom struct type, the "unpack_bits_as_long ()" function is used: do_val_print (...) cp_print_value_fields (...) value_field_bitfield (...) unpack_value_bitfield (...) unpack_bits_as_long (...) This function may sign-extend the extracted field while returning it: val >>= lsbcount; if (...) { valmask = (((ULONGEST) 1) << bitsize) - 1; val &= valmask; if (!field_type->is_unsigned ()) if (val & (valmask ^ (valmask >> 1))) val |= ~valmask; } return val; lsbcount: Number of lower bits to get rid of. bitsize: The bit length of the field to be extracted. val: The register value. field_type: The type of field that is being handled. While the logic here is correct, there is a problem when it is handling "field_type"s of "boolean". Those types are NOT marked as "unsigned" and therefore they end up being sign extended. Although this is not a problem for "false" (0), it definitely causes trouble for "true". This patch constructs the builtin boolean type as such that it is marked as an "unsigned" entity. The issue tackled here was first encountered for arc-elf32 target running on an x86_64 machine. The unit-test introduced in this change has passed for all the targets (--enable-targets=all) running on the same x86_64 host. Fixes: https://sourceware.org/PR28104
2021-08-02Automatic date update in version.inGDB Administrator1-1/+1
2021-08-01[gdb/testsuite] Fix gdb.base/maint.exp with cc-with-gdb-indexTom de Vries1-13/+21
With target board cc-with-gdb-index we run into: ... FAIL: gdb.base/maint.exp: maint print statistics ... The output that is checked is: ... Statistics for 'maint':^M Number of "minimal" symbols read: 53^M Number of "full" symbols read: 40^M Number of "types" defined: 60^M Number of symbol tables: 7^M Number of symbol tables with line tables: 2^M Number of symbol tables with blockvectors: 2^M Number of read CUs: 2^M Number of unread CUs: 5^M Total memory used for objfile obstack: 20320^M Total memory used for BFD obstack: 4064^M Total memory used for string cache: 4064^M ... and the regexp doesn't match because it expects the "Number of read/unread CUs" lines in a different place. Fix this by updating the regexp. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-08-01 Tom de Vries <tdevries@suse.de> * gdb.base/maint.exp: Update "maint print statistics" to match output with target board cc-with-gdb-index.
2021-08-01[gdb/testsuite] Fix gdb.base/index-cache.exp with cc-with-gdb-indexTom de Vries1-1/+1
With target board cc-with-gdb-index we run into: ... FAIL: gdb.base/index-cache.exp: couldn't remove files in temporary cache dir ... The problem is that there are no files to remove, because the index cache isn't used, as indicated by $expecting_index_cache_use. Fix this by only FAILing when $expecting_index_cache_use. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-08-01 Tom de Vries <tdevries@suse.de> * gdb.base/index-cache.exp:
2021-08-01Automatic date update in version.inGDB Administrator1-1/+1
2021-07-31Automatic date update in version.inGDB Administrator1-1/+1
2021-07-30Use iterator_range in more placesTom Tromey1-50/+9
This changes a couple of spots to replace custom iterator range classes with a specialization of iterator_range. Regression tested on x86-64 Fedora 34.
2021-07-30Replace exception_print_same with operator!=Tom Tromey4-18/+18
I noticed that exception_print_same is only used in a single spot, and it seemed to be better as an operator!= method attached to gdb_exception. Regression tested on x86-64 Fedora 34.
2021-07-30[gdb/build] Disable attribute nonnullTom de Vries1-0/+75
With trunk gcc (12.0) we're running into a -Werror=nonnull-compare build breaker in gdb, which caused a broader review of the usage of the nonnull attribute. The current conclusion is that it's best to disable this. This is explained at length in the gdbsupport/common-defs.h comment. Tested by building with trunk gcc. gdb/ChangeLog: 2021-07-29 Tom de Vries <tdevries@suse.de> * gdbsupport/common-defs.h (ATTRIBUTE_NONNULL): Disable.
2021-07-30gas: ensure XCOFF DWARF subsection are initialized to 0Clément Chigot1-1/+1
debug_abbrev doesn't use end_exp to compute its size. However, it must be NULL. Otherwise, ppc_xcoff_end might try to access uninitialized memory. gas/ * config/tc-ppc.c (ppc_dwsect): Use XCNEW instead of XNEW when creating a new subsection.
2021-07-30bfd: ensure that symbols targeted by DWARF relocations are kept in XCOFFClément Chigot1-79/+106
This patch improves XCOFF garbage collector pass, in order to keep symbols being referenced only by special sections like DWARF sections. bfd/ * xcofflink.c (xcoff_mark): Replace SEC_MARK by gc_mark. Look through relocations even if xcoff_section_data is NULL. (xcoff_sweep): Check if any sections of a file is kept before adding its special sections. Call xcoff_mark for special sessions being kept instead of just marking them. (SEC_MARK): Remove (xcoff_mark_symbol): Replace SEC_MARK by gc_mark. (xcoff_keep_symbol_p): Likewise. (bfd_xcoff_size_dynamic_sections): Likewise. (xcoff_find_tc0): Likewise.
2021-07-30bfd: avoid a crash when debug_section isn't created in XCOFFClément Chigot1-1/+2
bfd/ * xcofflink.c (bfd_xcoff_size_dynamic_sections): Add check to know if debug_section is initialized.
2021-07-30readelf: catch archive_file_size of -1Alan Modra1-3/+1
Fuzzers might put -1 in arhdr.ar_size. If the size is rounded up to and even number of bytes we get zero. * readelf.c (process_archive): Don't round up archive_file_size. Do round up next_arhdr_offset calculation.
2021-07-30reloc_upper_bound size calculationsAlan Modra5-5/+5
Section reloc_count is an unsigned int. Adding one for a NULL terminator to an array of arelent pointers can wrap the count to zero. Avoid that by doing the addition as longs. * coffgen.c (coff_get_reloc_upper_bound): Don't overflow unsigned int expression. * elf.c (_bfd_elf_get_reloc_upper_bound): Likewise. * elf64-sparc.c (elf64_sparc_get_reloc_upper_bound): Likewise. * mach-o.c (bfd_mach_o_get_reloc_upper_bound): Likewise. * vms-alpha.c (alpha_vms_get_reloc_upper_bound): Likewise.
2021-07-30Sanity check _bfd_coff_read_string_tableAlan Modra1-3/+12
* coffgen.c (_bfd_coff_read_string_table): Catch overflows when calculating string table file location.
2021-07-30IMAGE_SCN_LNK_NRELOC_OVFLAlan Modra1-0/+6
From microsoft docs: It is an error if IMAGE_SCN_LNK_NRELOC_OVFL is set and there are fewer than 0xffff relocations in the section. * coffcode.h (coff_set_alignment_hook): Sanity check overflow reloc count.
2021-07-29gdb: fix nr_bits gdb_assert in append_flags_type_fieldSimon Marchi1-1/+1
The assertion gdb_assert (nr_bits >= 1 && nr_bits <= type_bitsize); is not correct. Well, it's correct in that we do want the number of bits to be in the range [1, type_bitsize]. But we don't check anywhere that the end of the specified flag is within the containing type. The following code should generate a failed assertion, as the flag goes past the 32 bits of the underlying type, but it's currently not caught: static void test_print_flag (gdbarch *arch) { type *flags_type = arch_flags_type (arch, "test_type", 32); type *field_type = builtin_type (arch)->builtin_uint32; append_flags_type_field (flags_type, 31, 2, field_type, "invalid"); } (You can test this by registering it as a selftest using selftests::register_test_foreach_arc and running.) Change the assertion to verify that the end bit is within the range of the underlying type. This implicitly verifies that nr_bits is not too big as well, so we don't need a separate assertion for that. Change-Id: I9be79e5fd7a5917bf25b03b598727e6274c892e8 Co-Authored-By: Tony Tye <Tony.Tye@amd.com>
2021-07-30Automatic date update in version.inGDB Administrator1-1/+1
2021-07-29obsd-nat: Report both thread and PID in ::pid_to_str.John Baldwin1-1/+1
This improves the output of info threads when debugging multiple inferiors (e.g. after a fork with detach_on_fork disabled).
2021-07-29obsd-nat: Various fixes for fork following.John Baldwin2-30/+25
- Don't use #ifdef's on ptrace ops. obsd-nat.h didn't include <sys/ptrace.h>, so the virtual methods weren't always overridden causing the fork following to not work. In addition, the thread and fork code is intertwined in ::wait and and the lack of #ifdef's there already assumed both were present. Finally, both of these ptrace ops have been present in OpenBSD for at least 10 years. - Move duplicated code to enable PTRACE_FORK event reporting to a single function and invoke it on new child processes reported via PTRACE_FORK. - Don't return early from PTRACE_FORK handling, but instead reset wptid to the correct ptid if the child reports its event before the parent. This allows the ptid fixup code to add thread IDs if the first event for a process is a PTRACE_FORK event. This also properly returns ptid's with thread IDs when reporting PTRACE_FORK events. - Handle detach_fork by skipping the PT_DETACH.
2021-07-29obsd-nat: Various fixes to obsd_nat_target::wait.John Baldwin1-49/+12
- Call inf_ptrace_target::wait instead of duplicating the code. Replace a check for WIFSTOPPED on the returned status from waitpid by checking for TARGET_WAITKIND_STOPPED in the parsed status as is done in fbsd_nat_target::wait. - Don't use inferior_ptid when deciding if a new process is a child vs parent of the fork. Instead, use find_inferior_pid and assume that if an inferior already exists, the pid in question is the parent; otherwise, the pid is the child. - Don't use inferior_ptid when deciding if the ptid of the process needs to be updated with an LWP ID, or if this is a new thread. Instead, use the approach from fbsd-nat which is to check if a ptid without an LWP exists and if so update the ptid of that thread instead of adding a new thread.