aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-04-17Fix the test for PR 18963 so that it will work on 16-bit targets.Stephen Casner3-9/+20
PR 18963 * testsuite/ld-scripts/pr18963.t: Reduce section sizes to fit in 16-bit address space. * testsuite/ld-scripts/pr18963.d: Likewise.
2020-04-17Revert "Fix the test for PR 18963 so that it will work on 16-bit targets."Nick Clifton5-33/+16
This reverts commit 7a1a12f4d1c6152017142d74c736dc1cc6b0e81c.
2020-04-17[PATCH 1/2] coff-go32: update ldscriptJuan Manuel Guerrero2-0/+18
* scripttempl/i386go32.sc: Provide symbol _environ. Link in .ctors and .dtors. Discard LTO sections.
2020-04-17 Commit: Running the linker testsuite with clangNick Clifton4-3/+71
* testsuite/config/default.exp: If not already set then create the CCC_OVERRIDE_OPTIONS environment variable to help when running the testsuite with clang. * testsuite/ld-elf/pr22269-1.c: Add a missing return statement. * testsuite/ld-elfvers/vers.exp: Add checks to detect if files were built before attempting to copy them.
2020-04-17Remove obsolete and unused inf_ptrace_target::auxv_parseKamil Rytarowski3-41/+5
The only two potential users (NetBSD, OpenBSD) use svr4_auxv_parse. gdb/ChangeLog: * nbsd-nat.c (inf_ptrace_target::auxv_parse): Remove. * nbsd-nat.h (inf_ptrace_target::auxv_parse): Likewise.
2020-04-17bfin: allow ".=.+delta"Alan Modra2-1/+5
BFIN has lots of instructions that contain "=", so "sym = expression" is disabled for that target. This makes an exception for assignment to dot, fixing the recent regression of ld-scripts/pr18963. * config/tc-bfin.h (TC_EQUAL_IN_INSN): Allow assignment to dot.
2020-04-17PR25842, Null pointer dereference in nm-newAlan Modra2-2/+12
PR 25842 * elf.c (_bfd_elf_get_symbol_version_string): Don't segfault on NULL nodename.
2020-04-17PR25840, Null pointer dereference in objdumpAlan Modra2-0/+7
PR 25840 * debug.c (debug_class_type_samep): Don't segfault on NULL type.
2020-04-17Automatic date update in version.inGDB Administrator1-1/+1
2020-04-16gdb: is_linked_with_cygwin_dll: mention filename in warning messagesSimon Marchi2-6/+13
When a warning is displayed, it isn't clear to the user which file is the cause of the warning. Add the filename in there. Remove the "Failed to parse .idata section" part, since the .idata section is always mentioned one way or another anyway, so it just contributes to make the message longer than it needs to be. gdb/ChangeLog: * windows-tdep.c (is_linked_with_cygwin_dll): Add filename to warning messages.
2020-04-16gdb: is_linked_with_cygwin_dll: handle import table not at beginning of ↵Simon Marchi2-13/+39
.idata section When loading the file C:\Windows\SysWOW64\msvcrt.dll, taken from a Windows 10 system, into GDB, we get the following warning: warning: Failed to parse .idata section: name's virtual address (0x0) is outside .idata section's range [0xb82b8, 0xb97f0[. This uncovers an issue with how we parse the import table, part of the .idata section. Right now, we assume that the import table is located at the beginning of the section. That was the case in everything I had tried so far, but this file is an example where that's not true. We need to compute the offset of the import table within the .idata section, and start there, instead of at the beginning of the .idata section. Using the file mentioned above, this is the values we have to work with: A) bfd_section_vma (idata_section) 101b8000 B) Import table's virtual address b82b8 C) Image base 10100000 The virtual address that BFD returns us for the section has the image base applied, so we need to subtract it first. The offset of the table in the section is therefore: B - (A - C) This patch implements that. gdb/ChangeLog: * windows-tdep.c (is_linked_with_cygwin_dll): Consider case where import table is not at beginning of .idata section.
2020-04-16Stop the MIPS assembler from accepting ifunc symbols.Nick Clifton6-9/+40
PR 25803 gas * config/obj-elf.c (obj_elf_type): Reject ifunc symbols on MIPS targets. * testsuite/gas/elf/elf.exp: Add MIPS targets to the list to skip for the type-2 test. * testsuite/gas/elf/type-noifunc.e: Update to allow for MIPS targets running this test. bfd * elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Replace an abort with a more helpful error message.
2020-04-16Fix the test for PR 18963 so that it will work on 16-bit targets.Stephen Casner5-16/+33
PR ld/18963 * testsuite/ld-scripts/pr18963.s: New, replaces empty data.s to allocate space in text, data, bss here rather than pr18963.t. * testsuite/ld-scripts/pr18963.t: Remove assignments to dot. * testsuite/ld-scripts/pr18963.d: Change addresses to fit 16 bits.
2020-04-16Refactor delete_program_space as a destructorPedro Alves4-47/+71
Currently, while the program_space's ctor adds the new pspace to the pspaces list, the destructor doesn't remove the pspace from the pspace list. Instead, you're supposed to use delete_program_space, to both remove the pspace from the list, and deleting the pspace. This patch eliminates delete_program_space, and makes the pspace dtor remove the deleted pspace from the pspace list itself, i.e., makes the dtor do the mirror opposite of the ctor. I found this helps with a following patch that will allocate a mock program_space on the stack. It's easier to just let the regular dtor remove the mock pspace from the pspace list than arrange to call delete_program_space instead of the pspace dtor in that situation. While at it, move the ctor/dtor intro comments to the header file, and make the ctor explicit. gdb/ChangeLog: 2020-04-16 Pedro Alves <palves@redhat.com> * inferior.c (delete_inferior): Use delete operator directly instead of delete_program_space. * progspace.c (add_program_space): New, factored out from program_space::program_space. (remove_program_space): New, factored out from delete_program_space. (program_space::program_space): Remove intro comment. Rewrite. (program_space::~program_space): Remove intro comment. Call remove_program_space. (delete_program_space): Delete. * progspace.h (program_space::program_space): Make explicit. Move intro comment here, adjusted. (program_space::~program_space): Move intro comment here, adjusted. (delete_program_space): Remove.
2020-04-16Fix Cygwin gdb buildTom Tromey6-20/+55
Simon pointed out that the windows-nat sharing series broke the Cygwin build. This patch fixes the problem, by moving the Cygwin-specific code to a new handler function. This approach is taken because this code calls find_pc_partial_function, which isn't available in gdbserver. gdb/ChangeLog 2020-04-16 Tom Tromey <tromey@adacore.com> * windows-nat.c (windows_nat::handle_access_violation): New function. * nat/windows-nat.h (handle_access_violation): Declare. * nat/windows-nat.c (handle_exception): Move Cygwin code to windows-nat.c. Call handle_access_violation. gdbserver/ChangeLog 2020-04-16 Tom Tromey <tromey@adacore.com> * win32-low.cc (windows_nat::handle_access_violation): New function.
2020-04-16[gdb/symtab] Handle PU without import in "save gdb-index"Tom de Vries6-48/+160
Consider the test-case added in this patch, with resulting dwarf: ... Compilation Unit @ offset 0xc7: Length: 0x2c (32-bit) Version: 4 Abbrev Offset: 0x64 Pointer Size: 8 <0><d2>: Abbrev Number: 2 (DW_TAG_partial_unit) <d3> DW_AT_language : 2 (non-ANSI C) <d4> DW_AT_name : imported_unit.c <1><e4>: Abbrev Number: 3 (DW_TAG_base_type) <e5> DW_AT_byte_size : 4 <e6> DW_AT_encoding : 5 (signed) <e7> DW_AT_name : int <1><eb>: Abbrev Number: 4 (DW_TAG_subprogram) <ec> DW_AT_name : main <f1> DW_AT_type : <0xe4> <f5> DW_AT_external : 1 <1><f6>: Abbrev Number: 0 Compilation Unit @ offset 0xf7: Length: 0x2c (32-bit) Version: 4 Abbrev Offset: 0x85 Pointer Size: 8 <0><102>: Abbrev Number: 2 (DW_TAG_compile_unit) <103> DW_AT_language : 2 (non-ANSI C) <104> DW_AT_name : <artificial> <1><111>: Abbrev Number: 3 (DW_TAG_subprogram) <112> DW_AT_abstract_origin: <0xeb> <116> DW_AT_low_pc : 0x4004a7 <11e> DW_AT_high_pc : 0x4004b2 <1><126>: Abbrev Number: 0 ... When run with target board cc-with-gdb-index, we run into: ... (gdb) break main warning: (Internal error: pc 0x4004a7 in read in CU, but not in symtab.) <repeat> warning: (Internal error: pc 0x4004ab in read in CU, but not in symtab.) <repeat> Breakpoint 1 at 0x4004ab (gdb) PASS: gdb.dwarf2/imported-unit-runto-main.exp: setting breakpoint at main run Starting program: /data/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.dwarf2/imported-unit-runto-main/imported-unit-runto-main warning: (Internal error: pc 0x4004a7 in read in CU, but not in symtab.) <repeat> warning: (Internal error: pc 0x4004ab in read in CU, but not in symtab.) <repeat> Breakpoint 1, warning: (Internal error: pc 0x4004ab in read in CU, but not in symtab.) warning: (Internal error: pc 0x4004ab in read in CU, but not in symtab.) <repeat> 0x00000000004004ab in main () warning: (Internal error: pc 0x4004ab in read in CU, but not in symtab.) <repeat> (gdb) FAIL: gdb.dwarf2/imported-unit-runto-main.exp: running to main in runto ... Looking at the .gdb_index section contents using objdump --dwarf=gdb_index, we have: ... CU table: [ 0] 0x0 - 0x2d [ 1] 0x2e - 0xa4 [ 2] 0xa5 - 0xc6 [ 3] 0xf7 - 0x126 [ 4] 0x127 - 0x2de [ 5] 0x2df - 0x300 Address table: 00000000004004a7 00000000004004b2 4 Symbol table: [489] main: 4 [global, function] ... We see that both the main symbol, and main address range map to CU 4, which has offset range 0x127 - 0x2de, while main actually is contained in CU 3 at offset range 0xf7 - 0x126. This is caused by this continue in write_gdbindex, which triggers for the PU: ... /* CU of a shared file from 'dwz -m' may be unused by this main file. It may be referenced from a local scope but in such case it does not need to be present in .gdb_index. */ if (psymtab == NULL) continue; ... The continue causes the PU to be skipped in the CU table (we can see that the PU offset range 0xc7-0xf6 is missing) but the references are not taking that into account. I've tried fixing this in the optimal way, by updating the references, but ran into trouble when follow_die_offset tries to find the CU for the inter-CU ref. Because the PU is missing from the CU table, dwarf2_find_containing_comp_unit bisects to the wrong CU. Fix this by not skipping the PU in the CU table. Build and reg-tested on x86_64-linux, with native and target boards cc-with-gdb-index, cc-with-dwz and cc-with-dwz-m. gdb/ChangeLog: 2020-04-16 Tom de Vries <tdevries@suse.de> PR symtab/25791 * dwarf2/index-write.c (write_gdbindex): Generate CU table entries for CUs without psymtab. gdb/testsuite/ChangeLog: 2020-04-16 Tom de Vries <tdevries@suse.de> PR symtab/25791 * gdb.dwarf2/gdb-add-index.exp (add_gdb_index): Move ... (ensure_gdb_index): and factor out and move ... * lib/gdb.exp (add_gdb_index, ensure_gdb_index): ... here. * gdb.dwarf2/imported-unit-runto-main.exp: New file.
2020-04-16Fix compilation of python/python.c for Python 3.9Kevin Buettner2-0/+10
This commit fixes a compilation warning/error when building GDB with Python 3.9: g++ -x c++ -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -DDNF_DEBUGINFO_INSTALL -I. -I../../gdb -I../../gdb/config -DLOCALEDIR="\"/usr/share/locale\"" -DHAVE_CONFIG_H -I../../gdb/../include/opcode -I../bfd -I../../gdb/../bfd -I../../gdb/../include -I../libdecnumber -I../../gdb/../libdecnumber -I../../gdb/../gnulib/import -I../gnulib/import -DTUI=1 -I/usr/include/guile/2.0 -pthread -I/usr/include/python3.9 -I/usr/include/python3.9 -I../../gdb/.. -pthread -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-variable -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-error=maybe-uninitialized -Wno-mismatched-tags -Wsuggest-override -Wimplicit-fallthrough=3 -Wduplicated-cond -Wshadow=local -Wdeprecated-copy -Wdeprecated-copy-dtor -Wredundant-move -Wformat -Wformat-nonliteral -Wno-unused -Werror -c -o ser-tcp.o -MT ser-tcp.o -MMD -MP -MF ./.deps/ser-tcp.Tpo ../../gdb/ser-tcp.c ../../gdb/python/python.c: In function 'bool do_start_initialization()': ../../gdb/python/python.c:1621:23: error: 'void PyEval_InitThreads()' is deprecated [-Werror=deprecated-declarations] 1621 | PyEval_InitThreads (); | ^ In file included from /usr/include/python3.9/Python.h:141, from ../../gdb/python/python-internal.h:86, from ../../gdb/python/python.c:92: /usr/include/python3.9/ceval.h:132:37: note: declared here 132 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void); | ^~~~~~~~~~~~~~~~~~ Information about the deprecated function can be found here: https://docs.python.org/3.9/whatsnew/3.9.html#deprecated Specifically, with regard to PyEval_InitThreads(), it says: The PyEval_InitThreads() and PyEval_ThreadsInitialized() functions are now deprecated and will be removed in Python 3.11. Calling PyEval_InitThreads() now does nothing. The GIL is initialized by Py_Initialize() since Python 3.7. (Contributed by Victor Stinner in bpo-39877.) I chose to disable the call with a #if test using PY_VERSION_HEX. There is precedent for use of PY_VERSION_HEX; it's used in two places in python-internal.h. I noticed that under certain circumstances python-internal.h defines PyEval_InitThreads to be nothing, which accomplishes the same thing. I considered doing something similar for this case, but decided against it because, at some point in the future, the presence of PyEval_InitThreads() without some explanation will be confusing to a reader who won't be able to find PyEval_InitThreads in the current (future for us) Python API. IMO, use of the #if along with an accompanying comment seemed more straightforward. gdb/ChangeLog: * python/python.c (do_start_initialization): Don't call PyEval_InitThreads for Python 3.9 and beyond. Change-Id: I0679fc10b6b76761a99538568f13188c6d8014e0
2020-04-16PR25827, Null pointer dereferencing in scan_unit_for_symbolsAlan Modra2-5/+13
PR 25827 * dwarf2.c (scan_unit_for_symbols): Wrap overlong lines. Don't strdup(0).
2020-04-16cpu,gas,opcodes: support for eBPF JMP32 instruction classDavid Faust11-25/+600
Add support for the JMP32 class of eBPF instructions. cpu/ChangeLog * bpf.cpu (define-cond-jump-insn): Renamed from djci. (dcji) New version with support for JMP32 gas/ChangeLog * testsuite/gas/bpf/bpf.exp: Run jump32 tests. * testsuite/gas/bpf/jump32.s: New file. * testsuite/gas/bpf/jump32.d: Likewise. opcodes/ChangeLog * bpf-desc.c: Regenerate. * bpf-desc.h: Likewise. * bpf-opc.c: Regenerate. * bpf-opc.h: Likewise.
2020-04-16[gdb/testsuite] Fix maint-expand-symbols-header-file.exp for cc-with-gdb-indexTom de Vries2-1/+12
With test-case gdb.base/maint-expand-symbols-header-file.exp and target board cc-with-gdb-index, we have: ... FAIL: gdb.base/maint-expand-symbols-header-file.exp: \ verify no symtabs are expanded ... By default, with partial symbols, we find the main function in the partial symbols, and derive the initial language setting from that, without expanding any psymtab. But that doesn't work with the indices, because the indices don't store the language with the symbols. So instead, the main psymtab is expanded to get the language of main, which causes the FAIL. Fix this by manually setting the language. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-04-16 Tom de Vries <tdevries@suse.de> * gdb.base/maint-expand-symbols-header-file.exp: Set language before loading exec.
2020-04-16PowerPC64 GOT reloc reserving PLT entry for ifuncAlan Modra1-8/+0
I can't see any reason why ELFv2 should create a PLT entry for ifuncs referenced by GOT relocs as long as the GOT entry remains. The GOT entry ought to be resolved by ld.so to the value returned by the ifunc resolver, or if there is global entry stub created for some other reason, by the linker to the stub address. * elf64-ppc.c (ppc64_elf_check_relocs): Don't create plt entries for GOT relocs against ifuncs.
2020-04-16PowerPC64 GOT reloc optimisationAlan Modra1-0/+9
When the symbol referenced by a GOT reloc is an ifunc, we can't optimise away the GOT indirection. Well, we can, but only if a global entry stub is created with the ifunc symbol redefined to the stub. But that results in slower code and an indirection via the PLT so there isn't much to like about that solution. * elf64-ppc.c (ppc64_elf_edit_toc): Exclude ifunc from GOT optimisation. (ppc64_elf_relocate_section): Likewise.
2020-04-16Extend objdump --no-addresses infoAlan Modra2-1/+7
* doc/binutils.texi: Mention --no-show-raw-insn in objdump --no-addresses description.
2020-04-15gdbserver: fix format string warning in win32-low.ccSimon Marchi2-1/+5
When compiling on Cygwin, we get: CXX win32-low.o /home/smarchi/src/binutils-gdb/gdbserver/win32-low.cc: In function ‘int get_child_debug_event(DWORD*, target_waitstatus*)’: /home/smarchi/src/binutils-gdb/gdbserver/win32-low.cc:1459:17: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long int’ [-Werror=format=] 1459 | OUTMSG2 (("get_windows_debug_event - " | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1460 | "unexpected stop in 0x%x (expecting 0x%x)\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1461 | ptid.lwp (), desired_stop_thread_id)); | ~~~~~~~~~~~ | | | long int /home/smarchi/src/binutils-gdb/gdbserver/win32-low.cc:52:11: note: in definition of macro ‘OUTMSG2’ 52 | printf X; \ | ^ /home/smarchi/src/binutils-gdb/gdbserver/win32-low.cc:1460:26: note: format string is defined here 1460 | "unexpected stop in 0x%x (expecting 0x%x)\n", | ~^ | | | unsigned int | %lx `ptid.lwp ()` is a `long` value, so it indeed needs the `l` size modifier. gdbserver/ChangeLog: * win32-low.cc (get_child_debug_event): Fix format string warning.
2020-04-16Automatic date update in version.inGDB Administrator1-1/+1
2020-04-15Fix OpenBSD build error.Kamil Rytarowski2-6/+12
This was likely introduced by 5b6d1e4fa4fc6827c7b3f0e99ff120dfa14d65d2 gdb/ChangeLog: 2020-04-15 Kamil Rytarowski <n54@gmx.com> * obsd-nat.c (obsd_nat_target::update_thread_list): Pass "this" to thread functions. (obsd_nat_target::wait): Likewise. Change-Id: Ib8d11238c55e0ebdbcf127d1f28c9693c785527a
2020-04-15Use debug_printf in windows-nat.cTom Tromey2-4/+9
While debugging a bug on Windows, I noticed that windows-nat.c is not sending its debugging output to gdb_stdlog. This is unfortunate because it means that "set logging debugredirect" doesn't work properly. This patch fixes the problem by changing windows-nat.c to use debug_printf. Note that get_windows_debug_event also writes one debugging message unconditionally. It isn't clear to me if this really ought to use DEBUG_EVENTS or not, since it seems like perhaps it is intended to note an unexpected event occurring. So, I didn't change this. I'm checking this in. gdb/ChangeLog 2020-04-15 Tom Tromey <tromey@adacore.com> * windows-nat.c (DEBUG_EXEC, DEBUG_EVENTS, DEBUG_MEM) (DEBUG_EXCEPT): Use debug_printf.
2020-04-15gdb: Don't corrupt completions hash when expanding the hash tableAndrew Burgess4-1/+120
Commit: commit 724fd9ba432a20ef2e3f2c0d6060bff131226816 Date: Mon Jan 27 17:37:20 2020 +0000 gdb: Restructure the completion_tracker class caused the completion hash table to become corrupted if the table ever needed to grow beyond its original size of 200 elements. The hash table stores completion_tracker::completion_hash_entry objects, but hashes them based on their name, which is only one field of the object. When possibly inserting a new element we compute the hash with htab_hash_string of the new elements name, and then lookup matching elements using htab_find_slot_with_hash. If there's not matching element we create a completion_hash_entry object within the hash table. However, when we allocate the hash we pass htab_hash_string to htab_create_alloc as the hash function, and this is not OK. This means that when the hash table needs to grow, existing elements within the hash are re-hashed by passing the completion_hash_entry pointer to htab_hash_string, which obviously does not do what we expect. The solution is to create a new hash function that takes a pointer to a completion_hash_entry, and then calls htab_hash_string on the name of the entry only. This regression was spotted when running the gdb.base/completion.exp test on the aarch64 target. gdb/ChangeLog: * completer.c (class completion_tracker::completion_hash_entry) <hash_name>: New member function. (completion_tracker::discard_completions): New callback to hash a completion_hash_entry, pass this to htab_create_alloc. gdb/testsuite/ChangeLog: * gdb.base/many-completions.exp: New file.
2020-04-15Better handling of realpath() failure in windows_make_so() on CygwinJon Turney2-1/+9
It seems Cygwin's realpath() can fail on certain DLLs (apparently some AV software prevent it working on it's DLLs; See [1], [2]). Warn rather than stopping with an error if that occurs. Based on an original patch from Tim Chick. [1] https://cygwin.com/ml/cygwin/2014-08/msg00401.html [2] https://cygwin.com/ml/cygwin/2015-11/msg00353.html gdb/ChangeLog: 2016-01-20 Jon Turney <jon.turney@dronecode.org.uk> * windows-nat.c (windows_make_so): Warn rather than stopping with an error if realpath() fails.
2020-04-15Unify the behaviour of ld.bfd and ld.gold with respect to warning about ↵Fangrui Song18-86/+115
unresolved symbol references. (PR 24613) PR binutils/24613 include * bfdlink.h (enum report_method): Delete RM_GENERATE_WARNING and RM_GENERATE_ERROR. Add RM_DIAGNOSE. (struct bfd_link_info): Add warn_unresolved_syms. ld * lexsup.c (parse_args): Change RM_GENERATE_WARNING and RM_GENERATE_ERROR to RM_DIAGNOSE. * emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Change RM_GENERATE_ERROR to RM_DIAGNOSE. * emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Likewise. bfd * coff-rs6000.c (xcoff_ppc_relocate_section): Change RM_GENERATE_ERROR to RM_DIAGNOSE plus a check of warn_unresolved_syms. * coff64-rs6000.c (xcoff_ppc_relocate_section): Likewise. * elf-bfd.h (_bfd_elf_large_com_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise. * elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-hppa.c (elf64_hppa_relocate_section): Likewise. * elflink.c (elf_link_output_extsym): Likewise. * elfxx-mips.c (mips_elf_calculate_relocation): Likewise.
2020-04-15objdump --no-addressesAlan Modra3-18/+54
I find this useful when needing to compare compiler output, where the address of the instruction and the value of symbols results in unwanted differences. * objdump.c (no_addresses): New static var. (usage): Print help for --no-addresses. (long_options): Add --no-addresses entry. (objdump_print_addr_with_sym, objdump_print_addr): Omit symbol address. (disassemble_bytes): Don't print current line address, or reloc address. * doc/binutils.texi: Document objdump --no-addresses.
2020-04-15PR25823, Use after free in bfd_hash_lookupAlan Modra2-10/+17
PR 25823 * peXXigen.c (_bfd_XXi_swap_sym_in <C_SECTION>): Don't use a pointer into strings that may be freed for section name, always allocate a new string.
2020-04-15Fix makeinfo warnings in gdb.texinfo and python.texi docsArtur Shepilko3-11/+18
Building gdb-9.1 on a system that has an older version of makeinfo (4.8) shows the following warnings: ----------------- make[4]: Entering directory '/home/tester/gdb-9.1/build/gdb/doc' makeinfo --split-size=5000000 --split-size=5000000 -I ../../../gdb/doc/../../readline/readline/doc -I ../../../gdb/doc/../mi -I ../../../gdb/doc \ -o gdb.info ../../../gdb/doc/gdb.texinfo ../../../gdb/doc/gdb.texinfo:21867: warning: unlikely character [ in @var. ../../../gdb/doc/gdb.texinfo:21867: warning: unlikely character ] in @var. ../../../gdb/doc/gdb.texinfo:21868: warning: unlikely character [ in @var. ../../../gdb/doc/gdb.texinfo:21868: warning: unlikely character ] in @var. ../../../gdb/doc/gdb.texinfo:21869: warning: unlikely character [ in @var. ../../../gdb/doc/gdb.texinfo:21869: warning: unlikely character ] in @var. ../../../gdb/doc/gdb.texinfo:21872: warning: unlikely character [ in @var. ../../../gdb/doc/gdb.texinfo:21872: warning: unlikely character ] in @var. ../../../gdb/doc/gdb.texinfo:21874: warning: unlikely character [ in @var. ../../../gdb/doc/gdb.texinfo:21874: warning: unlikely character ] in @var. ../../../gdb/doc/gdb.texinfo:21876: warning: unlikely character [ in @var. ../../../gdb/doc/gdb.texinfo:21876: warning: unlikely character ] in @var. ../../../gdb/doc/gdb.texinfo:21879: warning: unlikely character [ in @var. ../../../gdb/doc/gdb.texinfo:21879: warning: unlikely character ] in @var. ../../../gdb/doc/gdb.texinfo:21931: warning: unlikely character [ in @var. ../../../gdb/doc/gdb.texinfo:21931: warning: unlikely character ] in @var. ../../../gdb/doc/gdb.texinfo:21933: warning: unlikely character [ in @var. ../../../gdb/doc/gdb.texinfo:21933: warning: unlikely character ] in @var. ../../../gdb/doc/gdb.texinfo:21936: warning: unlikely character [ in @var. ../../../gdb/doc/gdb.texinfo:21936: warning: unlikely character ] in @var. ../../../gdb/doc/gdb.texinfo:21939: warning: unlikely character [ in @var. ../../../gdb/doc/gdb.texinfo:21939: warning: unlikely character ] in @var. ../../../gdb/doc//python.texi:3297: warning: `.' or `,' must follow @xref, not `A'. make[4]: Leaving directory '/home/tester/gdb-9.1/build/gdb/doc' ----------------- These are thrown by expressions like `@var{[host]}`, intended to produce `[HOST]`. In that context this should instead be changed to `[@var{host}]`, which has the same effect but without the warnings. As for the warning in `python.texi`, there's period missing at the end of one `@xref{}` clause. Added. gdb/doc/ChangeLog: 2020-04-15 Artur Shepilko <nomadbyte@gmail.com> * gdb.texinfo: Transform @var{[host]} to [@var{host}]; this clears makeinfo warnings. * python.texi: Add a missing period trailing an @xref{} clause; this clears a makeinfo warning.
2020-04-15PR25822, Invalid read in process_symbol_tableAlan Modra2-1/+9
PR 25822 * readelf.c (get_num_dynamic_syms): Don't set num_of_syms when reading buckets or chains fails.
2020-04-15readelf: zero static vars after freeingAlan Modra2-0/+13
When readelf is processing more than one file, static bss vars won't start out as zero for the second file unless they are cleared. * readelf.c (process_symbol_table): Zero gnubuckets, gnuchains etc. after freeing.
2020-04-15readelf: increase size of static buffersAlan Modra2-23/+17
Translated strings might be larger than the original. * readelf.c (get_group_flags): Translate text. (get_file_type, get_symbol_binding, get_symbol_type), (get_ppc64_symbol_other, get_symbol_other): Increase size of buffer.
2020-04-15Re: readelf: Consolidate --syms --use-dynamic with --dyn-symsAlan Modra2-1/+6
PR 25821 * readelf.c (get_num_dynamic_syms): Typo fix.
2020-04-15Automatic date update in version.inGDB Administrator1-1/+1
2020-04-14[PATCH v2 2/2] coff-go32: support extended relocationsJuan Manuel Guerrero8-28/+250
This patch extends the relocation and line number counters for coff-go32 and coff-go32-exe to 32 bits. As I understand it works the same as for PE-COFF: If the number of relocations in an object file exceeds 65534, the NRELOC field is set to 65535 and the actual number of relocations is stored in the VADDR field of the first relocation entry. Executable files have no relocations, and thus the NRELOC field is repurposed to extend NLNNO to 32-bits. bfd * coff-go32.c (COFF_GO32, IMAGE_SCN_LNK_NRELOC_OVFL) (coff_SWAP_scnhdr_in, coff_SWAP_scnhdr_out): Define. (_bfd_go32_swap_scnhdr_in, _bfd_go32_swap_scnhdr_out) (_bfd_go32_mkobject): New functions. * coff-stgo32.c (IMAGE_SCN_LNK_NRELOC_OVFL) (coff_SWAP_scnhdr_in, coff_SWAP_scnhdr_out): Define. (go32exe_mkobject): Call _bfd_go32_mkobject. * coffcode.h (COFF_WITH_EXTENDED_RELOC_COUNTER): Define. (coff_set_alignment_hook): Define function for COFF_GO32_EXE and COFF_GO32. (coff_write_relocs): Enable extended reloc counter code if COFF_WITH_EXTENDED_RELOC_COUNTER is defined. Test for obj_go32. (coff_write_object_contents): Likewise. Pad section headers for COFF_GO32 and COFF_GO32EXE. Use bfd_coff_swap_scnhdr_out instead of coff_swap_scnhdr_out. * cofflink.c (_bfd_coff_final_link): Test also for obj_go32 to enable extended reloc counter. * coffswap.h: (coff_swap_scnhdr_in, coff_swap_scnhdr_out): Declare with ATTRIBUTE_UNUSED. * libcoff-in.h: (struct coff_tdata): New field go32. (obj_go32): Define. * libcoff.h: Regenerate.
2020-04-14Implement IP_STAT+IP_STATUS (aliases of the same format) on NetBSDKamil Rytarowski2-0/+108
Output based on FreeBSD with the following changes: - "utime+stime, children" merged from "utime, children" and "stime, children". - "Minor faults, children", "Major faults, children", "Virtual memory size" removed as not available in a direct equivalent. No new values missing or skipped in FreeBSD are printed, although there is a long list of potential candiates. gdb/ChangeLog: * nbsd-nat.c (nbsd_pid_to_kinfo_proc2): New. (nbsd_nat_target::info_proc): Add do_status.
2020-04-14The assembler only supports 32-bit stabs. So set sh_entsize unconditionally ↵Fangrui Song2-3/+7
to 12. PR gas/25768 * elf.c (assign_section_numbers): Always set .stab sh_entsize to 12.
2020-04-14readelf memory leaks processing mipsAlan Modra2-3/+12
* readelf.c (process_mips_specific): Free eopt and iopt. Avoid possibility of overflow when checking number of conflicts.
2020-04-14Fixes for the magic number used in PDP11 AOUT binaries.Stephen Casner19-7/+457
PR ld/25677 include * aout/aout64.h (N_DATADDR): Add IMAGIC case. bfd * pdp11.c: Add implementation of --imagic option. (adjust_o_magic): Fix objcopy --extract-symbol test. * libaout.h (enum aout_magic): Add i_magic. ld * emulparams/pdp11.sh (SCRIPT_NAME): Change to pdp11. (EXTRA_EM_FILE): New, add emulation file pdp11. * scripttempl/pdp11.sc: New, derived from aout.sc without irrelevant input sections. * emultempl/pdp11.em (_add_options, _handle_option) (_list_options): New. Add options -z, --imagic for pdp11-aout. (_before_parse): Make --omagic be default instead of --nmagic. (_get_script): Modify special-case linker script for --imagic. * lexsup.c (parse_args): Explictly set config.text_read_only for -n. * ld.texi (Options): Add documentation of PDP11-specific options. (Options): Fix unrelated typo to --no-compact-branches. * gen-doc.texi: @set PDP11. * testsuite/ld-pdp11/pdp11.exp: New, start pdp11 testing. * testsuite/ld-pdp11/sections.s: New, source for options tests. * testsuite/ld-pdp11/imagic.d: New, test --imagic format. * testsuite/ld-pdp11/imagicz.d: New, test -z (imagic) format. * testsuite/ld-pdp11/nmagic.d: New, test --nmagic format. * testsuite/ld-pdp11/omagic.d: New, test --omagic format.
2020-04-14[gdb] Fix missing symtab includesTom de Vries5-18/+141
[ The test-case requires commit c1a66c0629 "[gdb] Expand symbolless symtabs using maint expand-symtabs". ] Consider the debug info for the test-case included in this patch. It consists of a PU: ... <0><d2>: Abbrev Number: 2 (DW_TAG_partial_unit) <1><d3>: Abbrev Number: 0 ... imported by a CU: ... <0><df>: Abbrev Number: 2 (DW_TAG_compile_unit) <e0> DW_AT_language : 2 (non-ANSI C) <e1> DW_AT_stmt_list : 0xe9 <1><e5>: Abbrev Number: 3 (DW_TAG_imported_unit) <e6> DW_AT_import : <0xd2> [Abbrev Number: 2] <1><ea>: Abbrev Number: 0 ... and the CU has a dw2-symtab-includes.h file in the .debug_line file name table: ... The Directory Table (offset 0x101): 1 /data/gdb_versions/devel/src/gdb/testsuite/gdb.dwarf2 The File Name Table (offset 0x138): Entry Dir Time Size Name 1 1 0 0 dw2-symtab-includes.h ... After expanding all symtabs, we can see the CU listed in the user field of the PU, and vice-versa the PU listed in the includes of the CU: ... $ gdb.sh -batch \ -iex "set language c" \ outputs/gdb.dwarf2/dw2-symtab-includes/dw2-symtab-includes \ -ex "maint expand-symtabs" \ -ex "maint info symtabs" ... { ((struct compunit_symtab *) 0x394dd60) debugformat DWARF 2 producer (null) dirname (null) blockvector ((struct blockvector *) 0x394dea0) user ((struct compunit_symtab *) 0x394dba0) } { ((struct compunit_symtab *) 0x394dba0) debugformat DWARF 2 producer (null) dirname (null) blockvector ((struct blockvector *) 0x394dd10) user ((struct compunit_symtab *) (null)) ( includes ((struct compunit_symtab *) 0x394dd60) ) } ... But if we instead only expand the symtab for the dw2-symtab-includes.h file, the includes and user links are gone: ... $ gdb -batch \ -iex "set language c" \ outputs/gdb.dwarf2/dw2-symtab-includes/dw2-symtab-includes \ -ex "maint expand-symtabs dw2-symtab-includes.h" \ -ex "maint info symtabs" ... { ((struct compunit_symtab *) 0x2728210) debugformat DWARF 2 producer (null) dirname (null) blockvector ((struct blockvector *) 0x2728350) user ((struct compunit_symtab *) (null)) } { ((struct compunit_symtab *) 0x2728050) debugformat DWARF 2 producer (null) dirname (null) blockvector ((struct blockvector *) 0x27281c0) user ((struct compunit_symtab *) (null)) } ... The includes are calculated by process_cu_includes in gdb/dwarf2/read.c. In the case of expanding all symtabs: - the CU partial symtab is expanded using psymtab_to_symtab - psymtab_to_symtab calls dwarf2_psymtab::read_symtab - dwarf2_psymtab::read_symtab calls dwarf2_psymtab::expand_psymtab - dwarf2_psymtab::read_symtab calls process_cu_includes, and we have the includes In the case of expanding the symtab for dw2-symtab-includes.h: - the dw2-symtab-includes.h partial symtab is expanded using psymtab_to_symtab - psymtab_to_symtab calls dwarf2_include_psymtab::read_symtab - dwarf2_include_psymtab::read_symtab calls dwarf2_include_psymtab::expand_psymtab - dwarf2_include_psymtab::expand_psymtab calls partial_symtab::expand_dependencies - partial_symtab::expand_dependencies calls dwarf2_psymtab::expand_psymtab for the CU partial symtab - the CU partial symtab is expanded using dwarf2_psymtab::expand_psymtab - process_cu_includes is never called Fix this by making sure in dwarf2_include_psymtab::read_symtab that read_symtab is called for the CU partial symtab. Tested on x86_64-linux, with native, and target board cc-with-dwz and cc-with-dwz-m. In addition, tested test-case with target boards cc-with-gdb-index.exp, cc-with-debug-names.exp and readnow.exp. gdb/ChangeLog: 2020-04-14 Simon Marchi <simon.marchi@polymtl.ca> Tom de Vries <tdevries@suse.de> PR symtab/25718 * psympriv.h (struct partial_symtab::read_symtab) (struct partial_symtab::expand_psymtab) (struct partial_symtab::read_dependencies): Update comments. * dwarf2/read.c (struct dwarf2_include_psymtab::read_symtab): Call read_symtab for includer. (struct dwarf2_include_psymtab::expand_psymtab): Assert false. (struct dwarf2_include_psymtab::readin_p): Call readin_p () for includer. (struct dwarf2_include_psymtab::m_readin): Remove. (struct dwarf2_include_psymtab::includer): New member function. (dwarf2_psymtab::expand_psymtab): Assert !readin. gdb/testsuite/ChangeLog: 2020-04-14 Tom de Vries <tdevries@suse.de> PR symtab/25718 * gdb.dwarf2/dw2-symtab-includes.exp: New file.
2020-04-14[gdb] Expand symbolless symtabs using maint expand-symtabsTom de Vries13-24/+165
Consider this test-case, consisting of header file hello.h: ... inline static const char* foo (void) { return "foo"; } ... and source file hello.c: ... int main (void) { printf ("hello: %s\n", foo ()); return 0; } ... compiled with -g: ... $ gcc hello.c -g ... When trying to expand the partial symtab for hello.h: ... $ gdb -batch \ -iex "set language c" \ a.out \ -ex "maint expand-symtabs hello.h" \ -ex "maint info psymtabs" ... we in fact find that the partial symtab for hello.h (and corresponding includer partial symtab hello.c) have not been expanded: ... { psymtab hello.h ((struct partial_symtab *) 0x27cf070) readin no ... { psymtab hello.c ((struct partial_symtab *) 0x2cf09e0) readin no ... This is due to the recursively_search_psymtabs call in psym_expand_symtabs_matching: ... if (recursively_search_psymtabs (ps, objfile, domain, lookup_name, symbol_matcher)) ... which always returns false for symbolless partial symtabs. The same problem occurs with CUs where the dwarf is generated by gas --gdwarf-2 for a foo.S: if we read such a test-case with -readnow, we'll have a symbolless symtab for foo.S. But if we read the test-case with partial symtabs, and expand those using "maint expand-symtabs", the foo.S psymtab remains unexpanded. Fix this by passing a NULL symbol_matcher and lookup_name to expand_symtabs_matching in maintenance_expand_symtabs, and skipping the call to recursively_search_psymtabs if symbol_matcher == NULL and lookup_name == NULL. Build and tested on x86_64-linux, with native. In addition, tested test-case with target boards cc-with-gdb-index.exp, cc-with-debug-names.exp and readnow.exp. gdb/ChangeLog: 2020-04-14 Tom de Vries <tdevries@suse.de> PR symtab/25720 * symmisc.c (maintenance_expand_symtabs): Call expand_symtabs_matching with NULL symbol_matcher and lookup_name. * psymtab.c (psym_expand_symtabs_matching): Handle NULL symbol_matcher and lookup_name. * dwarf2/read.c (dw2_expand_symtabs_matching) (dw2_debug_names_expand_symtabs_matching): Same. * symfile.h (struct quick_symbol_functions::expand_symtabs_matching): Make lookup_name a pointer. Update comment. * symtab.c (global_symbol_searcher::expand_symtabs): Handle lookup_name being a pointer. * symfile.c (expand_symtabs_matching): Same. * symfile-debug.c (debug_qf_expand_symtabs_matching): Same. * linespec.c (iterate_over_all_matching_symtabs): Same. gdb/testsuite/ChangeLog: 2020-04-14 Tom de Vries <tdevries@suse.de> PR symtab/25720 * gdb.base/maint-expand-symbols-header-file.c: New test. * gdb.base/maint-expand-symbols-header-file.exp: New file. * gdb.base/maint-expand-symbols-header-file.h: New test.
2020-04-14readelf: Consolidate --syms --use-dynamic with --dyn-symsH.J. Lu17-647/+703
When reconstructing dynamic symbol table from the PT_DYNAMIC segment, compute dynamic symbol table size from hash table. For DT_HASH, the number of dynamic symbol table entries equals the number of chains. For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols with non-STB_LOCAL indings are in hash table. Since DT_GNU_HASH/DT_MIPS_XHASH place all symbols with STB_LOCAL binding before symbols with other bindings and all undefined symbols defined ones in dynamic symbol table, the highest symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest dynamic symbol table index. Rewrite print_dynamic_symbol to dump dynamic symbol table for --dyn-syms and --syms --use-dynamic. binutils/ PR binutils/25707 * readelf.c (nbuckets): New. (nchains): Likewise. (buckets): Likewise. (chains): Likewise. (ngnubuckets): Likewise. (gnubuckets): Likewise. (gnuchains): Likewise. (mipsxlat): Likewise. (ngnuchains): Likewise. (gnusymidx): Likewise. (VALID_SYMBOL_NAME): Likewise. (VALID_DYNAMIC_NAME): Use it. (get_dynamic_data): Moved before process_dynamic_section. (get_num_dynamic_syms): New function. (process_dynamic_section): Use DT_SYMTAB, DT_SYMENT, DT_HASH, DT_GNU_HASH and DT_MIPS_XHASH to reconstruct dynamic symbol table. Use DT_STRTAB and DT_STRSZ to reconstruct dynamic string table. (get_symbol_index_type): Don't print "bad section index" when there is no section header. (print_dynamic_symbol): Rewrite. (process_symbol_table): Call print_dynamic_symbol to dump dynamic symbol table. ld/ PR binutils/25707 * testsuite/ld-arm/armthumb-lib.sym: Updated. * testsuite/ld-arm/farcall-mixed-app.sym: Likewise. * testsuite/ld-arm/farcall-mixed-app2.sym: Likewise. * testsuite/ld-arm/fdpic-main-m.sym: Likewise. * testsuite/ld-arm/fdpic-main.sym: Likewise. * testsuite/ld-arm/fdpic-shared-m.sym: Likewise. * testsuite/ld-arm/fdpic-shared.sym: Likewise. * testsuite/ld-arm/mixed-app.sym: Likewise. * testsuite/ld-arm/mixed-lib.sym: Likewise. * testsuite/ld-arm/preempt-app.sym: Likewise. * testsuite/ld-elf/hash.d: Likewise. * testsuite/ld-elf/pr13195.d: Likewise. * testsuite/ld-elfvsb/hidden2.d: Likewise. * testsuite/ld-mips-elf/hash2.d: Likewise.
2020-04-14gdb/testsuite: Move helper function into lib/dwarf.expAndrew Burgess6-57/+27
Every time I write a test making use of the DWARF assembler I end up copying in the function get_func_info. Duplicating code is bad, so lets put this function into lib/dwarf.exp and remove all of the duplicates. There should be no changes in the testsuite behaviour after this commit. gdb/testsuite/ChangeLog: * gdb.dwarf2/dw2-inline-many-frames.exp (get_func_info): Delete. * gdb.dwarf2/dw2-inline-small-func.exp: Pass options to get_func_info. (get_func_info): Delete. * gdb.dwarf2/dw2-is-stmt-2.exp (get_func_info): Delete. * gdb.dwarf2/dw2-is-stmt.exp (get_func_info): Delete. * lib/dwarf.exp (get_func_info): New function.
2020-04-14Automatic date update in version.inGDB Administrator1-1/+1
2020-04-13Remove gdb_fildes_tTom Tromey5-31/+15
gdb_fildes_t and pfildes are no longer used, so remove them. gdbserver/ChangeLog 2020-04-13 Tom Tromey <tom@tromey.com> * server.h (gdb_fildes_t): Remove typedef. * remote-utils.c (remote_desc, list_desc): Now int. (INVALID_DESCRIPTOR): Remove. (gdb_connected, remote_close) (check_remote_input_interrupt_request): Update. * utils.h (pfildes): Don't declare. * utils.c (pfildes): Remove.
2020-04-13Move gdb_notifier commentTom Tromey2-11/+12
This moves the gdb_notifier comment a bit lower in event-loop.c, to where it belongs; and removes an obsolete comment that Pedro pointed out. gdbsupport/ChangeLog 2020-04-13 Tom Tromey <tom@tromey.com> * event-loop.c: Move comment. Remove obsolete comment.