summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-06-06gdb/configure.ac: Add option --with-additional-debug-dirsgdb-debug-file-directoryThiago Jung Bauermann
2023-06-06Re: loongarch readelf supportAlan Modra
Commit 89c70cd358b8 apparently results in a bogus "value may be used uninitialized" warning with some combination of compiler and optimisation options. * readelf.c (target_specific_reloc_handling): Init value.
2023-06-06Automatic date update in version.inGDB Administrator
2023-06-05libsframe: avoid unnecessary type castsIndu Bhagat
Change the data type of some of the members of the sframe_decoder_ctx and sframe_encoder_ctx data structures to use the applicable data types explicitly. Current implementation in libsframe does type casts, which seem unnecessary. libsframe/ * libsframe/sframe-impl.h (struct sframe_decoder_ctx): Use applicable data type explicitly. (struct sframe_encoder_ctx): Likewise. Use same style of comments consistently. * libsframe/sframe.c (struct sf_fde_tbl): Define without typedef. (struct sf_fre_tbl): Likewise. (sframe_decode): Remove unnecessary type casts. (sframe_encoder_get_funcdesc_at_index): Likewise. (sframe_encoder_add_fre): Likewise. (sframe_encoder_add_funcdesc): Likewise. (sframe_sort_funcdesc): Likewise. (sframe_encoder_write_sframe): Likewise.
2023-06-05ELF: Add "#pass" to ld-elf/pr30508.dH.J. Lu
Add "#pass" to ld-elf/pr30508.d to allow extra segments. PR binutils/30508 * testsuite/ld-elf/pr30508.d: Add "#pass".
2023-06-05Use unrelocated_addr in dwarf2_fdeTom Tromey
This changes dwarf2_fde to use the unrelocated_addr type. This pointed out a latent bug in dwarf2_frame_cache, where a relocated address is compared to an unrelocated address.
2023-06-05Use local "text offset" variable in dwarf2_frame_cacheTom Tromey
A few spots in dwarf2_frame_cache use: cache->per_objfile->objfile->text_section_offset () ... and a subsequent patch will add more, so move this into a local variable.
2023-06-05Constify dwarf2_cie::augmentationTom Tromey
I noticed that dwarf2_cie::augmentation could be 'const'.
2023-06-05Use "unrelocated" terminology in linetable_entryTom Tromey
I forgot to convert struct linetable_entry to use the "unrelocated" (as opposed to "raw") terminology. This patch corrects the oversight.
2023-06-05Fix comment in address_classTom Tromey
enum address_class has a stale comment referring to MSYMBOL_VALUE_RAW_ADDRESS, which no longer exists. This patch updates the comment.
2023-06-05Use unrelocated_addr in dwarf_decode_linesTom Tromey
This changes dwarf_decode_lines to accept an unrelocated_addr and fixes up the fallout.
2023-06-05Use unrelocated_addr in the DWARF readerTom Tromey
This changes various spots in the DWARF reader to use unrelocated_addr.
2023-06-05Move unrelocated_addr to common-types.hTom Tromey
unrelocated_addr is currently defined in symtab.h, but in order to avoid having to include that in more places, I wanted to move the type elsewhere. I considered defs.h, but it seemed reasonable to have it next to CORE_ADDR, which is what this patch does.
2023-06-05Minor cleanup in loclist_describe_locationTom Tromey
loclist_describe_location already has a per_objfile local variable, so use it consistently.
2023-06-05Remove baseaddr parameter from dwarf2_record_block_rangesTom Tromey
dwarf2_record_block_ranges is only ever called with the text section offset, so this patch removes the parameter entirely. This makes a subsequent patch a little simpler.
2023-06-05ELF: Don't warn an empty PT_LOAD with the program headersH.J. Lu
When rewriting the program headers, don't warn an empty PT_LOAD with the program headers. bfd/ PR binutils/30508 * elf.c (rewrite_elf_program_header): Don't warn if an empty PT_LOAD contains the program headers. ld/ PR binutils/30508 * testsuite/ld-elf/pr30508.d: New file. * testsuite/ld-elf/pr30508.s: Likewise.
2023-06-05gdb: building inferior strings from within GDBAndrew Burgess
History Of This Patch ===================== This commit aims to address PR gdb/21699. There have now been a couple of attempts to fix this issue. Simon originally posted two patches back in 2021: https://sourceware.org/pipermail/gdb-patches/2021-July/180894.html https://sourceware.org/pipermail/gdb-patches/2021-July/180896.html Before Pedro then posted a version of his own: https://sourceware.org/pipermail/gdb-patches/2021-July/180970.html After this the conversation halted. Then in 2023 I (Andrew) also took a look at this bug and posted two versions: https://sourceware.org/pipermail/gdb-patches/2023-April/198570.html https://sourceware.org/pipermail/gdb-patches/2023-April/198680.html The approach taken in my first patch was pretty similar to what Simon originally posted back in 2021. My second attempt was only a slight variation on the first. Pedro then pointed out his older patch, and so we arrive at this patch. The GDB changes here are mostly Pedro's work, but updated by me (Andrew), any mistakes are mine. The tests here are a combinations of everyone's work, and the commit message is new, but copies bits from everyone's earlier work. Problem Description =================== Bug PR gdb/21699 makes the observation that using $_as_string with GDB's printf can cause GDB to print unexpected data from the inferior. The reproducer is pretty simple: #include <stddef.h> static char arena[100]; /* Override malloc() so value_coerce_to_target() gets a known pointer, and we know we"ll see an error if $_as_string() gives a string that isn't null terminated. */ void *malloc (size_t size) { memset (arena, 'x', sizeof (arena)); if (size > sizeof (arena)) return NULL; return arena; } int main () { return 0; } And then in a GDB session: $ gdb -q test Reading symbols from /tmp/test... (gdb) start Temporary breakpoint 1 at 0x4004c8: file test.c, line 17. Starting program: /tmp/test Temporary breakpoint 1, main () at test.c:17 17 return 0; (gdb) printf "%s\n", $_as_string("hello") "hello"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (gdb) quit The problem above is caused by how value_cstring is used within py-value.c, but once we understand the issue then it turns out that value_cstring is used in an unexpected way in many places within GDB. Within py-value.c we have a null-terminated C-style string. We then pass a pointer to this string, along with the length of this string (so not including the null-character) to value_cstring. In value_cstring GDB allocates an array value of the given character type, and copies in requested number of characters. However value_cstring does not add a null-character of its own. This means that the value created by calling value_cstring is only null-terminated if the null-character is included in the passed in length. In py-value.c this is not the case, and indeed, in most uses of value_cstring, this is not the case. When GDB tries to print one of these strings the value contents are pushed to the inferior, and then read back as a C-style string, that is, GDB reads inferior memory until it finds a null-terminator. For the py-value.c case, no null-terminator is pushed into the inferior, so GDB will continue reading inferior memory until a null-terminator is found, with unpredictable results. Patch Description ================= The first thing this patch does is better define what the arguments for the two function value_cstring and value_string should represent. The comments in the header file are updated to describe whether the length argument should, or should not, include a null-character. Also, the data argument is changed to type gdb_byte. The functions as they currently exist will handle wide-characters, in which case more than one 'char' would be needed for each character. As such using gdb_byte seems to make more sense. To avoid adding casts throughout GDB, I've also added an overload that still takes a 'char *', but asserts that the character type being used is of size '1'. The value_cstring function is now responsible for adding a null character at the end of the string value it creates. However, once we start looking at how value_cstring is used, we realise there's another, related, problem. Not every language's strings are null terminated. Fortran and Ada strings, for example, are just an array of characters, GDB already has the function value_string which can be used to create such values. Consider this example using current GDB: (gdb) set language ada (gdb) p $_gdb_setting("arch") $1 = (97, 117, 116, 111) (gdb) ptype $ type = array (1 .. 4) of char (gdb) p $_gdb_maint_setting("test-settings string") $2 = (0) (gdb) ptype $ type = array (1 .. 1) of char This shows two problems, first, the $_gdb_setting and $_gdb_maint_setting functions are calling value_cstring using the builtin_char character, rather than a language appropriate type. In the first call, the 'arch' case, the value_cstring call doesn't include the null character, so the returned array only contains the expected characters. But, in the $_gdb_maint_setting example we do end up including the null-character, even though this is not expected for Ada strings. This commit adds a new language method language_defn::value_string, this function takes a pointer and length and creates a language appropriate value that represents the string. For C, C++, etc this will be a null-terminated string (by calling value_cstring), and for Fortran and Ada this can be a bounded array of characters with no null terminator. Additionally, this new language_defn::value_string function is responsible for selecting a language appropriate character type. After this commit the only calls to value_cstring are from the C expression evaluator and from the default language_defn::value_string. And the only calls to value_string are from Fortan, Ada, and ObjectC related code. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21699 Co-Authored-By: Simon Marchi <simon.marchi@efficios.com> Co-Authored-By: Andrew Burgess <aburgess@redhat.com> Co-Authored-By: Pedro Alves <pedro@palves.net> Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-06-05[gdb] Fix grammar in comments and docsTom de Vries
Fix grammar in some comments and docs: - machines that doesn't -> machines that don't - its a -> it's a - its the -> it's the - if does its not -> if it does it's not - one more instructions if doesn't match -> one more instruction if it doesn't match - it's own -> its own - it's first -> its first - it's pointer -> its pointer I also came across "it's performance" in gdb/stubs/*-stub.c in the HP public domain notice, I've left that alone. Tested on x86_64-linux.
2023-06-05[gdb] Fix more typosTom de Vries
Fix some more typos: - distinquish -> distinguish - actualy -> actually - singe -> single - frash -> frame - chid -> child - dissassembler -> disassembler - uninitalized -> uninitialized - precontidion -> precondition - regsiters -> registers - marge -> merge - sate -> state - garanteed -> guaranteed - explictly -> explicitly - prefices (nonstandard plural) -> prefixes - bondary -> boundary - formated -> formatted - ithe -> the - arrav -> array - coresponding -> corresponding - owend -> owned - fials -> fails - diasm -> disasm - ture -> true - tpye -> type There's one code change, the name of macro SIG_CODE_BONDARY_FAULT changed to SIG_CODE_BOUNDARY_FAULT. Tested on x86_64-linux.
2023-06-05bfd_error_on_input messagesAlan Modra
bfd_errmsg uses asprintf for bfd_error_on_input, which means we currently leak memory. Keep a static pointer to the message and free it in various places to minimise the leaks. bfd_set_input_error (NULL, bfd_error_no_error) is a way to free up the last string if that matters. * bfd.c (input_error_msg): New static var. (bfd_set_input_error): Free it here.. (bfd_init): ..and here.. (bfd_errmsg): ..and here. Use it for asprintf output.
2023-06-05Yet another ecoff fuzzed object fixAlan Modra
* ecoff.c (_bfd_ecoff_slurp_symbol_table): Sanity check fdr_ptr csym against remaining space for symbols. Error on out of bounds fdr_ptr fields.
2023-06-05MIPS: sync oprand char usage between mips and micromipsYunQiang Su
We should try our best to make mips32 using the same oprand char with micromips. So for mips32, we use: ^ is added for 5bit sa oprand for some new DSPr2 instructions: APPEND, PREPEND, PRECR_SRA[_R].PH.W the LSB bit is 11, like RD. +t is removed for coprocessor 0 destination register. 'E' does the samething. +t is now used for RX oprand for MFTR/MTTR (MT ASE) ? is added for sel oprand for MFTR/MTTR (MT ASE) For mips32, the position of sel in MFTR/MTTR is same with mfc0 etc, while for micromips, they are different. We also add an extesion format of cftc2/cttc2/mftc2/mfthc2/mttc2/mtthc2: concatenating rs with rx as the index of control or data.
2023-06-05MIPS: add MT ASE support for micromips32YunQiang Su
These instructions are descripted in MD00768. MIPS® Architecture for Programmers Volume IV-f: The MIPS® MT Module for the microMIPS32™ Architecture Document Number: MD00768 Revision 1.12 July 16, 2013 https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00768-1C-microMIPS32MT-AFP-01.12.pdf
2023-06-05Revert "MIPS: add MT ASE support for micromips32"YunQiang Su
This reverts commit 783a5f46b0583e9ed3a63acd3361009f46de5c17.
2023-06-05MIPS: add MT ASE support for micromips32YunQiang Su
These instructions are descripted in MD00768. MIPS® Architecture for Programmers Volume IV-f: The MIPS® MT Module for the microMIPS32™ Architecture Document Number: MD00768 Revision 1.12 July 16, 2013 https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00768-1C-microMIPS32MT-AFP-01.12.pdf
2023-06-05MIPS: fix some ld testcases with compilerYunQiang Su
1. config/default.exp: use -mabi=32 not for -gnuabi64 xfail_from_runlist: remove an element and mark it xfail. 2. ld-elf/indirect.exp: xfail indirect5a indirect5b indirect6a indirect6b indirect5c indirect5d indirect6c indirect6d 3. ld-elf/pr23658-2: mips output is not common 4. ld-elf/shared.exp: non-run on mips: Build libpr16496b.so 5. ld-elfvers/vers.exp: xfail vers4, vers4b no-run on mips: vers24a, vers24b, vers24c 6. ld-gc/gc.exp: add -KPIC into asflags for pr13683, pr14265, pr19161 7. ld-mips-elf/mips-elf.exp: use noarch for mips16-local-stubs-1, since it use -mips4 8. ld-plugin/lto.exp: no-run on mips/linux: PR ld/12982 add -KPIC into asflags for lto-3r, lto-5r, PR ld/19317 (2) xfail PR ld/15323 (4), PR ld/19317 (3) 9. ld-plugin/plugin.exp: xfail plugin claimfile lost symbol plugin claimfile replace symbol plugin claimfile replace symbol plugin claimfile lost symbol with source plugin claimfile replace symbol with source plugin claimfile resolve symbol with source plugin 2 with source lib load plugin 2 with source plugin 3 with source lib load plugin 3 with source 11. ld-selective/selective.exp: add -fno-PIC, which is needed for -mno-abicalls 12. ld-shared/shared.exp: xfail shared (non PIC), shared (PIC main, non PIC so)
2023-06-05MIPS: fix -gnuabi64 testsuiteYunQiang Su
Test on: mips64-linux-gnuabi64 mips64el-linux-gnuabi64 mipsisa64-linux-gnuabi64 mipsisa64el-linux-gnuabi64 mipsisa64r2-linux-gnuabi64 mipsisa64r2el-linux-gnuabi64 mipsisa64r6-linux-gnuabi64 mipsisa64r6el-linux-gnuabi64
2023-06-05MIPS: fix r6 testsuitesYunQiang Su
Introduce run_dump_test_o32l run_dump_test_n32l run_dump_test_n64l Which use `-march=from-abi` for pre-R6 testcases, like micromips/mips16e etc. For cases doesn't use run_dump_test_*, we use -mips32r2 for micromips32 -mips1 for mips16-32 -march=from-abi for testcases to o32/n32/n64 both/all. Replace `addi` with `addiu` for some cases for both r6 and pre-R6. Introduce some new testcases for r6 with FPXX/FP64. Introduce new testcase: comdat-reloc-r6. Skip `default` in mips_arch_list_matching if triple is mipsisa*, due to: 1)it will cannot match mipsr6@*.d: since mips32rN/mips64rN will always be used, it won't be a problem. 2)some test think -march=mips64rN will alway true for mipsisa64rN, which is not true now. This patch fix testsuite for all r6-default gnu triples: mipsisa32r6-linux-gnu mipsisa32r6el-linux-gnu mips-img-linux-gnu mipsel-img-linux-gnu mipsisa64r6-linux-gnu mipsisa64r6el-linux-gnu
2023-06-05MIPS: default r6 if vendor is imgYunQiang Su
This behavior is used by downstream toolchain since 2014. We also set the default ABI for mips*-img-elf to O32. The previous value is NO_ABI, which is not good default ABI. We don't support mips64*-img* due to GCC doesn't support it, and We believe that the multilib should be used for this case.
2023-06-05MIPS: gas: alter 64 or 32 for mipsisa triples if march is implicitYunQiang Su
When configure with triples mipsisa[32,64]rN[el,], the march value is pinned to a fix value if not given explicitly. for example 1) mipsisa32r6-linux-gnu -n32 xx.s will complains that: -march=mips32r6 is not compatible with the selected ABI 2) mipsisa64r2el-linux-gnu -o32 generates objects with 64bit CPU: ELF 32-bit LSB relocatable, MIPS, MIPS64 rel2 version 1 (SYSV) They are not good default behaviors: Let's alter the CPU info Since we are using these triples as a regular linux distributions, let's alter march according to ABI.
2023-06-05Automatic date update in version.inGDB Administrator
2023-06-04Automatic date update in version.inGDB Administrator
2023-06-03[gdb] Fix typosTom de Vries
Fix a few typos: - implemention -> implementation - convertion(s) -> conversion(s) - backlashes -> backslashes - signoring -> ignoring - (un)ambigious -> (un)ambiguous - occured -> occurred - hidding -> hiding - temporarilly -> temporarily - immediatelly -> immediately - sillyness -> silliness - similiar -> similar - porkuser -> pokeuser - thats -> that - alway -> always - supercede -> supersede - accomodate -> accommodate - aquire -> acquire - priveleged -> privileged - priviliged -> privileged - priviledges -> privileges - privilige -> privilege - recieve -> receive - (p)refered -> (p)referred - succesfully -> successfully - successfuly -> successfully - responsability -> responsibility - wether -> whether - wich -> which - disasbleable -> disableable - descriminant -> discriminant - construcstor -> constructor - underlaying -> underlying - underyling -> underlying - structureal -> structural - appearences -> appearances - terciarily -> tertiarily - resgisters -> registers - reacheable -> reachable - likelyhood -> likelihood - intepreter -> interpreter - disassemly -> disassembly - covnersion -> conversion - conviently -> conveniently - atttribute -> attribute - struction -> struct - resonable -> reasonable - popupated -> populated - namespaxe -> namespace - intialize -> initialize - identifer(s) -> identifier(s) - expection -> exception - exectuted -> executed - dungerous -> dangerous - dissapear -> disappear - completly -> completely - (inter)changable -> (inter)changeable - beakpoint -> breakpoint - automativ -> automatic - alocating -> allocating - agressive -> aggressive - writting -> writing - reguires -> requires - registed -> registered - recuding -> reducing - opeartor -> operator - ommitted -> omitted - modifing -> modifying - intances -> instances - imbedded -> embedded - gdbaarch -> gdbarch - exection -> execution - direcive -> directive - demanged -> demangled - decidely -> decidedly - argments -> arguments - agrument -> argument - amespace -> namespace - targtet -> target - supress(ed) -> suppress(ed) - startum -> stratum - squence -> sequence - prompty -> prompt - overlow -> overflow - memember -> member - languge -> language - geneate -> generate - funcion -> function - exising -> existing - dinking -> syncing - destroh -> destroy - clenaed -> cleaned - changep -> changedp (name of variable) - arround -> around - aproach -> approach - whould -> would - symobl -> symbol - recuse -> recurse - outter -> outer - freeds -> frees - contex -> context Tested on x86_64-linux. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-06-03[gdb/tdep] Fix typo in debug messageTom de Vries
In microblaze_analyze_prologue in gdb/microblaze-tdep.c I came across: ... microblaze_debug ("got addi r1,r1,%d; contnuing\n", imm); ... Fix this by using "continuing". Reviewed-By: Tom Tromey <tom@tromey.com>
2023-06-03[gdb/python] Fix doc string of valpy_const_valueTom de Vries
In gdb/python/py-value.c, in the value_object_methods array I noticed: ... { "const_value", valpy_const_value, METH_NOARGS, "Return a 'const' qualied version of the same value." }, ... Fix the qualied -> qualified typo. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-06-03[gdb/guile] Fix doc string for value-optimized-out?Tom de Vries
In gdb/guile/scm-value.c, I noticed in the value_functions array initializer: ... { "value-optimized-out?", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_optimized_out_p), "\ Return #t if the value has been optimizd out." }, ... There's a typo in the doc string. Fix this by using "optimized". Reviewed-By: Tom Tromey <tom@tromey.com>
2023-06-03[gdb/tui] Fix help text of show tui tab-widthTom de Vries
I noticed: ... (gdb) help show tui tab-width Show the tab witdh, in characters, for the TUI. This variable controls how many spaces are used to display a tab character. ... a typo: "witdh". Fix this by using "width" instead. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-06-03[gdb/cli] Fix help text of maint info target-sectionsTom de Vries
I noticed a typo: ... (gdb) help maint info target-sections List GDB's internal section table. Print the current targets section list. This is a sub-set of all sections, from all objects currently loaded. Usually the ALLOC sectoins. ... Fix this by using "sections". Reviewed-By: Tom Tromey <tom@tromey.com>
2023-06-03[gdb/cli] Fix help text of maint set ignore-prologue-end-flagTom de Vries
I noticed here: ... (gdb) help maint set ignore-prologue-end-flag Set if the PROLOGUE-END flag is ignored. The PROLOGUE-END flag from the line-table entries is used to place \ breakpoints past the prologue of functions. Disabeling its use use forces \ the use of prologue scanners. ... a typo in "Disabeling" and accidental word repetition "use use". Fix by replacing with "Disabling" and "use". Reviewed-By: Tom Tromey <tom@tromey.com>
2023-06-03[gdb/compile] Fix typo in debug messageTom de Vries
In compile_object_load in gdb/compile/compile-object-load.c I came across: ... "Connectiong ELF symbol \"%s\" to the .toc section (%s)\n", ... Fix this typo by using "Connecting" instead. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-06-03[gdbserver] Fix typo in debug messageTom de Vries
I noticed in emit_ops_insns in gdbserver/linux-aarch64-low.cc: ... threads_debug_printf ("Adding %d instrucions at %s", ... Fix the typo by using "instructions" instead. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-06-03[gdb/ada] Fix argument name misspellingTom de Vries
Two functions use the argument name bounds_prefered_p. This misspells "preferred". Fix this by using bounds_preferred_p instead. Tested on x86_64-linux. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-06-03Re: loongarch readelf supportAlan Modra
Another segfault. * readelf.c (target_specific_reloc_handling): Sanity check loongarch reloc r_offset.
2023-06-03Re: More ecoff sanity checksAlan Modra
Yet another fuzzer fix. * ecoff.c (ecoff_slurp_symbolic_header <FIX>): Zero counts when associated pointer is zero. (_bfd_ecoff_slurp_symbolic_info): Remove now unnecessary check.
2023-06-03Automatic date update in version.inGDB Administrator
2023-06-02[AArch64] Fix architecture debug version constant thinkosLuis Machado
Caught this during emulator testing. Fix the constants. They should be 0xa and 0xb as opposed to 0x10 and 0x11. There was a thinko while defining them. Obvious enough. Tested on aarch64-linux Ubuntu 20.04/22.04.
2023-06-02Re: bfd_close and target free_cached_memoryAlan Modra
_bfd_delete_bfd can be called early, before the target xvec is set up. * opncls.c (_bfd_delete_bfd): Don't segfault on NULL xvec.
2023-06-02Re: More ecoff sanity checksAlan Modra
Another fix for fuzzed object files, exhibiting as a segfault in nm.c filter_symbols when accessing a symbol name. * ecoff.c (_bfd_ecoff_slurp_symbol_table): Sanity check fdr_ptr->issBase, and tighten sym.iss check.
2023-06-02loongarch readelf supportAlan Modra
This fixes two buffer overflows found by fuzzers. * readelf.c (target_specific_reloc_handling): Sanity check loongarch reloc symbol index. Don't apply reloc after errors. Reduce translation work of "invalid symbol index" error message.
2023-06-02Minor objcopy optimisation for copy_relocations_in_sectionAlan Modra
* objcopy (copy_relocations_in_section): Don't read the relocs for STRIP_ALL if keep_specific_htab is empty.