Age | Commit message (Collapse) | Author | Files | Lines | |
---|---|---|---|---|---|
2023-04-12 | ubsan: dwarf2.c:2232:7: runtime error: index 16 out of bounds | Alan Modra | 1 | -5/+5 | |
Except it isn't out of bounds because space for a larger array has been allocated. * dwarf2.c (struct trie_leaf): Make ranges a C99 flexible array. (alloc_trie_leaf, insert_arange_in_trie): Adjust sizing. | |||||
2023-03-27 | Duplicate DW_AT_call_file leak | Alan Modra | 1 | -2/+5 | |
When given two or more DW_AT_call_file for a given function we currently leak the concat memory. * dwarf2.c (scan_unit_for_symbols): Don't leak on duplicate DW_AT_call_file. | |||||
2023-02-24 | Enhance better_fit() function to prefer function symbols over non-function ↵ | Nick Clifton | 1 | -15/+37 | |
symbols. | |||||
2023-02-23 | Fix _bfd_elf_find_function so that it can cope with overlapping symbols | Nick Clifton | 1 | -22/+82 | |
2023-02-23 | Fix the BFD library's find_nearest_line feature to produce consistent results. | Nick Clifton | 1 | -15/+11 | |
PR 30150 * dwarf2.c (comp_unit_contains_address): Renamed to ... (comp_unit_may_contain_address): this, and added code to return true if the CU's ranges have not yet been computed. (_bfd_dwarf2_find_nearest_line_with_alt): Use the renamed function, simplifying code in the process. | |||||
2023-02-08 | Re: Resetting section vma after _bfd_dwarf2_find_nearest_line | Alan Modra | 1 | -1/+1 | |
f.bfd_ptr is set too early to be a reliable indicator of good debug info. * dwarf2.c (_bfd_dwarf2_slurp_debug_info): Correct test for debug info being previously found. | |||||
2023-02-06 | Resetting section vma after _bfd_dwarf2_find_nearest_line | Alan Modra | 1 | -42/+33 | |
There are failure paths in _bfd_dwarf2_slurp_debug_info that can result in altered section vmas. Also, when setting ET_REL section vmas it's not too difficult to handle cases where the original vma was non-zero, so do that too. This patch was really in response to an addr2line buffer overflow processing a fuzzed mips relocatable object file. The file had a number of .debug_info sections with relocations that included lo16 and hi16 relocs, and in that order. At least one section VMA was non-zero. This resulted in processing of DWARF info twice, once via the call to _bfd_dwarf2_find_nearest_line in _bfd_mips_elf_find_nearest_line, and because that failed leaving VMAs altered, the second via the call in _bfd_elf_find_nearest_line. The first call left entries on mips_hi16_list pointing at buffers allocated during the first call, the second call processed the mips_hi16_list after the buffers had been freed. (At least when running with asan and under valgrind. Under gdb with a non-asan addr2line the second call allocated exactly the same buffer and the bug didn't show.) Now I don't really care too much what happens with fuzzed files, but the logic in _bfd_dwarf2_find_nearest_line is meant to result in only one read of .debug_info, not multiple reads of the same info when there are errors. This patch fixes that problem. * dwarf2.c (struct adjusted_section): Add orig_vma. (unset_sections): Reset vma to it. (place_sections): Handle non-zero vma too. Save orig_vma. (_bfd_dwarf2_slurp_debug_info): Tidy. Correct outdated comment. On error returns after calling place_sections, call unset_sections. (_bfd_dwarf2_find_nearest_line_with_alt): Simplify call to unset_sections. | |||||
2023-01-11 | Fix a potential illegal memory access in the BFD library when parsing a ↵ | Nick Clifton | 1 | -1/+1 | |
corrupt DWARF file. PR 29988 * dwarf2.c (read_indexed_address): Fix check for an out of range offset. | |||||
2023-01-10 | Set dwarf2 stash pointer earlier | Alan Modra | 1 | -2/+1 | |
This fixes a memory leak in the vanishingly rare cases (found by fuzzers of course) when something goes wrong in the save_section_vma, htab_create_alloc or alloc_trie_leaf calls before *pinfo is written. If *pinfo is not written, _bfd_dwarf2_cleanup_debug_info won't be able to free that memory. * dwarf2.c (_bfd_dwarf2_slurp_debug_info): Save stash pointer on setting up stash. | |||||
2023-01-04 | addr2line out of memory on fuzzed file | Alan Modra | 1 | -0/+8 | |
Another case of fuzzers finding the section size sanity checks are avoided with SHT_NOBITS sections. * dwarf2.c (read_section): Check that the DWARF section being read has contents. | |||||
2023-01-01 | Update year range in copyright notice of binutils files | Alan Modra | 1 | -1/+1 | |
The newer update-copyright.py fixes file encoding too, removing cr/lf on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and embedded cr in binutils/testsuite/binutils-all/ar.exp string match. | |||||
2022-12-26 | bfd/dwarf2.c: allow use of DWARF5 directory entry 0 | Alan Modra | 1 | -13/+10 | |
I think the test for table->files[file].dir being non-zero is wrong for DWARF5 where index zero is allowed and is the current directory of the compilation. Most times this will be covered by the use of table->comp_dir (from DW_AT_comp_dir) in concat_filename but the point of putting the current dir in .debug_line was so the section could stand alone without .debug_info. Also, there is no need to check for table->dirs non-NULL, the table->num_dirs test is sufficient. * dwarf2.c (concat_filename): Correct and simplify tests of directory index. | |||||
2022-12-23 | Fix illegal memory access parsing corrupt DWARF information. | Nick Clifton | 1 | -1/+2 | |
PR 29936 * dwarf2.c (concat_filename): Fix check for a directory index off the end of the directory table. | |||||
2022-12-22 | PR29925, Memory leak in find_abstract_instance | Alan Modra | 1 | -12/+19 | |
The testcase in the PR had a variable with both DW_AT_decl_file and DW_AT_specification, where the DW_AT_specification also specified DW_AT_decl_file. This leads to a memory leak as the file name is malloced and duplicates are not expected. I've also changed find_abstract_instance to not use a temp for "name", because that can result in a change in behaviour from the usual last of duplicate attributes wins. PR 29925 * dwarf2.c (find_abstract_instance): Delete "name" variable. Free *filename_ptr before assigning new file name. (scan_unit_for_symbols): Similarly free func->file and var->file before assigning. | |||||
2022-12-21 | PR29922, SHT_NOBITS section avoids section size sanity check | Alan Modra | 1 | -3/+9 | |
PR 29922 * dwarf2.c (find_debug_info): Ignore sections without SEC_HAS_CONTENTS. | |||||
2022-11-11 | PR28834, PR26946 sanity checking section size | Alan Modra | 1 | -13/+7 | |
This patch provides a new function to sanity check section sizes. It's mostly extracted from what we had in bfd_get_full_section_contents but also handles compressed debug sections. Improvements are: - section file offset is taken into account, - added checks that a compressed section can be read from file. The function is then used when handling multiple .debug_* sections that need to be read into a single buffer, to sanity check sizes before allocating the buffer. PR 26946, PR 28834 * Makefile.am (LIBBFD_H_FILES): Add section.c. * compress.c (bfd_get_full_section_contents): Move section size sanity checks.. * section.c (_bfd_section_size_insane): ..to here. New function. * dwarf2.c (read_section): Use _bfd_section_size_insane. (_bfd_dwarf2_slurp_debug_info): Likewise. * Makefile.in: Regenerate. * libbfd.h: Regenerate. | |||||
2022-10-04 | ignore DWARF debug information for -gsplit-dwarf with dwarf-5 | Potharla, Rupesh | 1 | -1/+11 | |
Skip dwo_id for split dwarf. * dwarf2.c (parse_comp_unit): Skip DWO_id for DW_UT_skeleton. | |||||
2022-09-21 | PR29573, addr2line doesn't display file/line for local symbols | Alan Modra | 1 | -18/+16 | |
The DWARF standard is clear that DW_AT_linkage_name is optional. Compilers may not provide the attribute on functions and variables, even though the language mangles names. g++ does not for local variables and functions. Without DW_AT_linkage_name, mangled object file symbols can't be directly matched against the source-level DW_AT_name in DWARF info. One possibility is demangling the object file symbols, but that comes with its own set of problems: 1) A demangler might not be available for the compiler/language. 2) Demangling doesn't give the source function name as stored in DW_AT_name. Class and template parameters must be stripped at least. So this patch takes a simpler approach. A symbol matches DWARF info if the DWARF address matches the symbol address, and if the symbol name contains the DWARF name as a sub-string. Very likely the name matching is entirely superfluous. PR 29573 * dwarf.c (lookup_symbol_in_function_table): Match a symbol containing the DWARF source name as a substring. (lookup_symbol_in_variable_table): Likewise. (_bfd_dwarf2_find_nearest_line_with_alt): If stash_find_line_fast returns false, fall back to comp_unit_find_line. | |||||
2022-09-21 | dwarf2.c: simplify best_fit_len tests | Alan Modra | 1 | -32/+22 | |
* dwarf2.c (lookup_address_in_function_table): Simplify best_fit_len test. (info_hash_lookup_funcinfo): Likewise. (lookup_symbol_in_function_table): Likewise, also reorder tests and check "file" is set. (lookup_symbol_in_variable_table): Reorder tests. | |||||
2022-09-21 | dwarf2.c: mangle_style | Alan Modra | 1 | -11/+33 | |
non_mangled incorrectly returned "true" for Ada. Correct that, and add a few more non-mangled entries. Return a value suitable for passing to cplus_demangle to control demangling. * dwarf2.c: Include demangle.h. (mangle_style): Rename from non_mangled. Return DMGL_* value to suit lang. Adjust all callers. | |||||
2022-09-21 | dwarf2.c remove varinfo and funcinfo sec field | Alan Modra | 1 | -19/+3 | |
The "sec" field in these structures is only set and used in lookup functions. It always starts off as NULL. So the only possible effect of the field is to modify the return of the lookup, which was its purpose back in 2005 when HJ fixed PR990. Since then we solved the problem of relocatable object files with the fix for PR2338, so this field is now redundant. * dwarf.c (struct funcinfo, struct varinfo): Remove "sec" field. (lookup_symbol_in_function_table): Don't set or test "sec". (lookup_symbol_in_variable_table): Likewise. (info_hash_lookup_funcinfo, info_hash_lookup_varinfo): Likewise. | |||||
2022-09-06 | bfd: Add bfd_find_nearest_line_with_alt | Aaron Merey | 1 | -12/+55 | |
bfd_find_nearest_line_with_alt functions like bfd_find_nearest_line with the addition of a parameter for specifying the filename of a supplementary debug file such as one referenced by .gnu_debugaltlink or .debug_sup. This patch focuses on implementing bfd_find_nearest_line_with_alt support for ELF/DWARF2 .gnu_debugaltlink. For other targets this function simply sets the invalid_operation bfd_error. | |||||
2022-08-30 | BFD library: Use entry 0 in directory and filename tables of DWARF-5 debug info. | Nick Clifton | 1 | -28/+58 | |
PR 29529 * dwarf2.c (struct line_info_table): Add new field: use_dir_and_file_0. (concat_filename): Use new field to help select the correct table slot. (read_formatted_entries): Do not skip entry 0. (decode_line_info): Set new field depending upon the version of DWARF being parsed. Initialise filename based upon the setting of the new field. | |||||
2022-08-27 | bfd: Fix minor bug in read_indexed_address function. | rupothar | 1 | -3/+3 | |
read_indexed_address function is using offset_size instead of addr_size while reading addrx forms. | |||||
2022-08-08 | add splay tree for info_ptr -> CU mapping | Martin Liska | 1 | -10/+67 | |
While using perf top for MozillaThunderbird I noticed quite some slow dissably call with source code involved. E.g. time ./objdump --start-address=0x0000000004e0dcd0 --stop-address=0x0000000004e0df8b -l -d --no-show-raw-insn -S -C /usr/lib64/thunderbird/libxul.so took 2.071s and I noticed quite some time is spent in find_abstract_instance: 33.46% objdump objdump [.] find_abstract_instance 18.22% objdump objdump [.] arange_add 13.77% objdump objdump [.] read_attribute_value 4.82% objdump objdump [.] comp_unit_maybe_decode_line_info 3.10% objdump libc.so.6 [.] __memset_avx2_unaligned_erms where linked list of CU is iterated when searing for where info_ptr belongs to: : 3452 for (u = unit->prev_unit; u != NULL; u = u->prev_unit) 0.00 : 4c61f7: mov 0x10(%rbx),%rax 0.00 : 4c61fb: test %rax,%rax 0.00 : 4c61fe: je 4c6215 <find_abstract_instance+0x365> : 3453 if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr) 0.00 : 4c6200: cmp 0x60(%rax),%rdx 83.20 : 4c6204: jb 4c620c <find_abstract_instance+0x35c> 0.00 : 4c6206: cmp 0x78(%rax),%rdx 6.89 : 4c620a: jb 4c6270 <find_abstract_instance+0x3c0> : 3452 for (u = unit->prev_unit; u != NULL; u = u->prev_unit) 0.00 : 4c620c: mov 0x10(%rax),%rax 7.90 : 4c6210: test %rax,%rax 0.00 : 4c6213: jne 4c6200 <find_abstract_instance+0x350> The following scan can be replaced with search in a splay tree and with that I can get to 1.5s and there are other symbols where the difference is even bigger. bfd/ChangeLog: PR 29081 * dwarf2.c (struct addr_range): New. (addr_range_intersects): Likewise. (splay_tree_compare_addr_range): Likewise. (splay_tree_free_addr_range): Likewise. (struct dwarf2_debug_file): Add comp_unit_tree. (find_abstract_instance): Use the splay tree when searching for a info_ptr. (stash_comp_unit): Insert to the splay tree. (_bfd_dwarf2_cleanup_debug_info): Clean up the splay tree. | |||||
2022-08-08 | dwarf: use find_abstract_instance for vars and DW_AT_specification | Martin Liska | 1 | -15/+7 | |
The following simple test case fails when dwz is used: $ cat demo.C namespace std { enum { _S_fixed, _S_floatfield = _S_fixed }; struct { struct {}; } __ioinit; } int main() { return 0; } $ g++ demo.C -g && cp a.out b.out && dwz -m xxx.so a.out b.out && objdump -S a.out >/dev/null objdump: DWARF error: could not find variable specification at offset 0x3d3 As seen the reference is defined in xxx.so shared part: $ eu-readelf -w -N a.out | grep -A3 -B3 3d3 decl_column (data1) 11 sibling (ref_udata) [ 387] [ 387] variable abbrev: 30 specification (GNU_ref_alt) [ 3d3] location (exprloc) [ 0] addr 0x404019 [ 396] subprogram abbrev: 32 $ eu-readelf -w -N a.out | less ... Compilation unit at offset 920: Version: 5, Abbreviation section offset: 0, Address size: 8, Offset size: 4 Unit type: partial (3) ... [ 3d3] variable abbrev: 31 name (strp) "__ioinit" decl_file (data1) demo.C (10) decl_line (data1) 6 decl_column (data1) 3 type (ref_udata) [ 3c4] declaration (flag_present) yes With the patch the same output is emitted as before usage of dwz. bfd/ChangeLog: PR 29442 * dwarf2.c (struct varinfo): Use const char * type. (scan_unit_for_symbols): Call find_abstract_instance for DW_AT_specification for variables that can be in a different CU (e.g. done by dwz) | |||||
2022-07-29 | Stop the linker from complaining about unrecognised DW_FORM-rnglistx and ↵ | Nick Clifton | 1 | -0/+5 | |
DW_FORM_loclistx format attributes. PR 29424 * dwarf2.c (read_attribute_value): Handle DW_FORM_rnglistx and DW_FORM_loclistx. | |||||
2022-06-15 | PR29230, segv in lookup_symbol_in_variable_table | Alan Modra | 1 | -9/+42 | |
The PR23230 testcase uses indexed strings without specifying SW_AT_str_offsets_base. In this case we left u.str with garbage (from u.val) which then led to a segfault when attempting to access the string. Fix that by clearing u.str. The patch also adds missing sanity checks in the recently committed read_indexed_address and read_indexed_string functions. PR 29230 * dwarf2.c (read_indexed_address): Return uint64_t. Sanity check idx. (read_indexed_string): Use uint64_t for str_offset. Sanity check idx. (read_attribute_value): Clear u.str for indexed string forms when DW_AT_str_offsets_base is not yet read or missing. | |||||
2022-06-02 | asan: NULL deref in scan_unit_for_symbols | Alan Modra | 1 | -24/+23 | |
Since commit b43771b045 it has been possible to look up addresses that match a unit with errors, since ranges are added to a trie while the unit is being parsed. On error, parse_comp_unit leaves first_child_die_ptr NULL which results in a NULL info_ptr being passed to scan_unit_for_symbols. Fix this by setting unit->error. Also wrap some overlong lines, and fix some formatting errors. * dwarf2.c: Formatting. (parse_comp_unit): Set unit->error on err_exit path. | |||||
2022-05-27 | Remove use of bfd_uint64_t and similar | Alan Modra | 1 | -43/+40 | |
Requiring C99 means that uses of bfd_uint64_t can be replaced with uint64_t, and similarly for bfd_int64_t, BFD_HOST_U_64_BIT, and BFD_HOST_64_BIT. This patch does that, removes #ifdef BFD_HOST_* and tidies a few places that print 64-bit values. | |||||
2022-05-26 | bfd: Add Support for DW_FORM_strx* and DW_FORM_addrx* | Potharla, Rupesh | 1 | -14/+268 | |
2022-05-20 | add a trie to map quickly from address range to compilation unit | Steinar H. Gunderson | 1 | -19/+367 | |
When using perf to profile large binaries, _bfd_dwarf2_find_nearest_line() becomes a hotspot, as perf wants to get line number information (for inline-detection purposes) for each and every sample. In Chromium in particular (the content_shell binary), this entails going through 475k address ranges, which takes a long time when done repeatedly. Add a radix-256 trie over the address space to quickly map address to compilation unit spaces; for content_shell, which is 1.6 GB when some (but not full) debug information turned is on, we go from 6 ms to 0.006 ms (6 µs) for each lookup from address to compilation unit, a 1000x speedup. There is a modest RAM increase of 180 MB in this binary (the existing linked list over ranges uses about 10 MB, and the entire perf job uses between 2–3 GB for a medium-size profile); for smaller binaries with few ranges, there should be hardly any extra RAM usage at all. | |||||
2022-04-03 | Revert commit 240d6706c6a2 | Alan Modra | 1 | -62/+22 | |
PR 28592 PR 15994 PR 15935 * dwarf2.c (lookup_address_in_line_info_table): Return bool rather than a range. (comp_unit_find_nearest_line): Likewise. Return true if function info found without line info. (_bfd_dwarf2_find_nearest_line): Revert range handling code. | |||||
2022-03-29 | bfd/Dwarf2: gas doesn't mangle names | Jan Beulich | 1 | -0/+1 | |
Include the language identifier emitted by gas in the set of ones where no mangled names are expected. Even if there could be "hand-mangled" names, gas doesn't emit DW_AT_linkage_name in the first place. | |||||
2022-03-29 | bfd/Dwarf2: make find-nearest-line returned function name consistent | Jan Beulich | 1 | -2/+3 | |
Prior to entering the enclosing "else if()" the earlier associated if() checks function->is_linkage and, if set, uses function->name. The comment in patch context precedes (and explains) the setting function->is_linkage. Yet with the flag set, we should then also return the function name, just like said earlier if() would do when we came here a 2nd time for the same "addr". And indeed passing the same address twice on addr2line's command line would resolve the function for the 2nd instance, but not for the 1st (if this code path is taken). (This, obviously, is particularly relevant when there's no ELF symbol table in the first place, like would be the case - naturally - in PE/COFF binaries, for example.) | |||||
2022-03-22 | Fix return code in _bfd_dwarf2_find_nearest_line(). | Steiner H Gunderson | 1 | -1/+5 | |
* dwarf2.c (_bfd_dwarf2_find_nearest_line): if a function name is found, but no line number info, then return a result of 2. | |||||
2022-03-21 | Reduce O(n2) performance overhead when parsing DWARF unit information. | Steiner H Gunderson | 1 | -33/+60 | |
PR 28978 * dwarf2.c (scan_unit_for_symbols): When performing second pass, check to see if the function or variable being processed is the same as the previous one. | |||||
2022-02-02 | Stop the BFD library complaining about compressed dwarf debug string ↵ | Nick Clifton | 1 | -2/+6 | |
sections being too big. PR 28834 * dwarf2.c (read_section): Change the heuristic that checks for overlarge dwarf debug info sections. | |||||
2022-01-02 | Update year range in copyright notice of binutils files | Alan Modra | 1 | -1/+1 | |
The result of running etc/update-copyright.py --this-year, fixing all the files whose mode is changed by the script, plus a build with --enable-maintainer-mode --enable-cgen-maint=yes, then checking out */po/*.pot which we don't update frequently. The copy of cgen was with commit d1dd5fcc38ead reverted as that commit breaks building of bfp opcodes files. | |||||
2021-12-16 | PR28691, validate dwarf attribute form | Alan Modra | 1 | -56/+128 | |
PR28691 is a fuzzing PR that triggers a non-problem of "output changes per run" with PIEs and/or different compilers. I've closed similar PRs before as wontfix, but I guess there will be no end of this type of PR. The trigger is an attribute that usually takes one of the offset/constant reference DW_FORMs being given an indexed string DW_FORM. The bfd reader doesn't support indexed strings and returns an error string instead. The address of the string varies with PIE runs and/or compiler, and we allow that address to appear in output. Fix this by validating integer attribute forms, as we do for string form attributes. PR 28691 * dwarf2.c (is_str_attr): Rename to.. (is_str_form): ..this. Change param type. Update calls. (is_int_form): New function. (read_attribute_value): Handle DW_FORM_addrx2. (find_abstract_instance): Validate form when using attr.u.val. (scan_unit_for_symbols, parse_comp_unit): Likewise. | |||||
2021-12-10 | PR28674, objdump crash | Alan Modra | 1 | -1/+1 | |
Not returning an error indication here leaves the attribute uninitialised, which then leads to intemperate behaviour. PR 28674 * dwarf2.c (read_attribute_value): Return NULL on trying to read past end of attributes. | |||||
2021-07-10 | Tidy commit 49910fd88dcd | Alan Modra | 1 | -6/+3 | |
Pointer range checking is UB if the values compared are outside the underlying array elements (plus one). * dwarf2.c (read_address): Remove accidental commit. (read_ranges): Compare offset rather than pointers. | |||||
2021-07-02 | Fix an illegal memory access triggered by an attempt to parse a corrupt ↵ | Nick Clifton | 1 | -1/+4 | |
input file. PR 28046 * dwarf2.c (read_ranges): Check that range_ptr does not exceed range_end. | |||||
2021-06-07 | fix Dwarf2 build with certain gcc versions | Jan Beulich | 1 | -2/+2 | |
Older gcc reports: .../bfd/dwarf2.c: In function 'read_ranges': .../bfd/dwarf2.c:3107: error: comparison between signed and unsigned .../bfd/dwarf2.c: In function 'read_rnglists': .../bfd/dwarf2.c:3189: error: comparison between signed and unsigned Similarly for binutils/dwarf.c. Arrange for the left sides of the > to also be unsigned quantities. | |||||
2021-05-22 | bfd dwarf2 sanity checking | Alan Modra | 1 | -373/+233 | |
This patch is aimed at the many places in dwarf2.c that blindly increment a data pointer after calling functions that are meant to read a fixed number of bytes. The problem with that is with damaged dwarf we might increment a data pointer past the end of data, which is UB and complicates (ie. bugs likely) any further use of that data pointer. To fix those problems, I've moved incrementing of the data pointer into the functions that do the reads. _bfd_safe_read_leb128 gets the same treatment for consistency. * libbfd.c (_bfd_safe_read_leb128): Remove length_return parameter. Replace data pointer with pointer to pointer. Increment pointer over bytes read. * libbfd-in.h (_bfd_safe_read_leb128): Update prototype. * elf-attrs.c (_bfd_elf_parse_attributes): Adjust to suit. Be careful not to increment data pointer past end. Remove now redundant pr17512 check. * wasm-module.c (READ_LEB128): Adjust to suit changes to _bfd_safe_read_leb128. * dwarf2.c (read_n_bytes): New inline function, old one renamed to.. (read_blk): ..this. Allocate and return block. Increment bfd_byte** arg. (read_3_bytes): New function. (read_1_byte, read_1_signed_byte, read_2_bytes, read_4_bytes), (read_8_bytes, read_string, read_indirect_string), (read_indirect_line_string, read_alt_indirect_string): Take a byte_byte** arg which is incremented over bytes read. Remove any bytes_read return. Rewrite limit checks to compare lengths rather than pointers. (read_abbrevs, read_attribute_value, read_formatted_entries), (decode_line_info, find_abstract_instance, read_ranges), (read_rnglists, scan_unit_for_symbols, parse_comp_unit), (stash_comp_unit): Adjust to suit. Rewrite limit checks to compare lengths rather than pointers. * libbfd.h: Regenerate. | |||||
2021-05-20 | gdb/bfd: avoid crash when architecture is forced to csky or riscv | Andrew Burgess | 1 | -8/+4 | |
I built GDB with `--enable-targets=all`, then started GDB passing it an x86-64 executable, finally I ran 'maint selftest', and observed GDB crash like this: BFD: BFD (GNU Binutils) 2.36.50.20210519 assertion fail ../../src/bfd/hash.c:438 Aborted (core dumped) The problem originates from two locations, for example in csky-dis.c (csky_get_disassembler) where we do this: const char *sec_name = NULL; ... sec_name = get_elf_backend_data (abfd)->obj_attrs_section; if (bfd_get_section_by_name (abfd, sec_name) != NULL) ... We end up in here because during the selftests GDB forces the architecture to be csky, but the BFD being accessed is still of type x86-64. As a result obj_attrs_section returns NULL, which means we end up passing NULL to bfd_get_section_by_name. If we follow the function calls from bfd_get_section_by_name we eventually end up in bfd_hash_hash, which asserts that the string (i.e. the name) is not NULL. The same crash can be reproduced in GDB without using the selftests, for example: (gdb) file x86_64.elf (gdb) start (gdb) set architecture csky (gdb) disassemble main Dump of assembler code for function main: BFD: BFD (GNU Binutils) 2.36.50.20210519 assertion fail ../../src/bfd/hash.c:438 Aborted (core dumped) The fix I propose here is to have bfd_get_section_by_name return NULL if name is ever NULL. For consistency I updated bfd_get_section_by_name_if in the same way, even though I'm not hitting any problems along that code path right now. I looked through the source tree and removed two NULL checks in bfd/dwarf2.c which are no longer needed, its possible that there are additional NULL checks that could be removed, I just didn't find them. bfd/ChangeLog: * section.c (bfd_get_section_by_name): Return NULL if name is NULL. (bfd_get_section_by_name_if): Likewise. * dwarf2.c (read_section): Remove unneeded NULL check. (find_debug_info): Likewise. | |||||
2021-03-31 | Use bool in bfd | Alan Modra | 1 | -241/+241 | |
* sysdep.h: POISON_BFD_BOOLEAN: Define. * aix5ppc-core.c, * aout-cris.c, * aout-ns32k.c, * aout-target.h, * aoutx.h, * arc-got.h, * archive.c, * archive64.c, * archures.c, * bfd-in.h, * bfd.c, * bfdwin.c, * binary.c, * cache.c, * coff-alpha.c, * coff-arm.c, * coff-arm.h, * coff-bfd.c, * coff-bfd.h, * coff-go32.c, * coff-i386.c, * coff-ia64.c, * coff-mcore.c, * coff-mips.c, * coff-rs6000.c, * coff-sh.c, * coff-stgo32.c, * coff-tic30.c, * coff-tic4x.c, * coff-tic54x.c, * coff-x86_64.c, * coff-z80.c, * coff-z8k.c, * coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c, * compress.c, * corefile.c, * cpu-aarch64.c, * cpu-aarch64.h, * cpu-alpha.c, * cpu-arc.c, * cpu-arm.c, * cpu-arm.h, * cpu-avr.c, * cpu-bfin.c, * cpu-bpf.c, * cpu-cr16.c, * cpu-cris.c, * cpu-crx.c, * cpu-csky.c, * cpu-d10v.c, * cpu-d30v.c, * cpu-dlx.c, * cpu-epiphany.c, * cpu-fr30.c, * cpu-frv.c, * cpu-ft32.c, * cpu-h8300.c, * cpu-hppa.c, * cpu-i386.c, * cpu-ia64.c, * cpu-iamcu.c, * cpu-ip2k.c, * cpu-iq2000.c, * cpu-k1om.c, * cpu-l1om.c, * cpu-lm32.c, * cpu-m10200.c, * cpu-m10300.c, * cpu-m32c.c, * cpu-m32r.c, * cpu-m68hc11.c, * cpu-m68hc12.c, * cpu-m68k.c, * cpu-m9s12x.c, * cpu-m9s12xg.c, * cpu-mcore.c, * cpu-mep.c, * cpu-metag.c, * cpu-microblaze.c, * cpu-mips.c, * cpu-mmix.c, * cpu-moxie.c, * cpu-msp430.c, * cpu-mt.c, * cpu-nds32.c, * cpu-nfp.c, * cpu-nios2.c, * cpu-ns32k.c, * cpu-or1k.c, * cpu-pdp11.c, * cpu-pj.c, * cpu-powerpc.c, * cpu-pru.c, * cpu-riscv.c, * cpu-rl78.c, * cpu-rs6000.c, * cpu-rx.c, * cpu-s12z.c, * cpu-s390.c, * cpu-score.c, * cpu-sh.c, * cpu-sparc.c, * cpu-spu.c, * cpu-tic30.c, * cpu-tic4x.c, * cpu-tic54x.c, * cpu-tic6x.c, * cpu-tilegx.c, * cpu-tilepro.c, * cpu-v850.c, * cpu-v850_rh850.c, * cpu-vax.c, * cpu-visium.c, * cpu-wasm32.c, * cpu-xc16x.c, * cpu-xgate.c, * cpu-xstormy16.c, * cpu-xtensa.c, * cpu-z80.c, * cpu-z8k.c, * dwarf1.c, * dwarf2.c, * ecoff-bfd.h, * ecoff.c, * ecofflink.c, * elf-attrs.c, * elf-bfd.h, * elf-eh-frame.c, * elf-hppa.h, * elf-ifunc.c, * elf-m10200.c, * elf-m10300.c, * elf-nacl.c, * elf-nacl.h, * elf-properties.c, * elf-s390-common.c, * elf-s390.h, * elf-strtab.c, * elf-vxworks.c, * elf-vxworks.h, * elf.c, * elf32-am33lin.c, * elf32-arc.c, * elf32-arm.c, * elf32-arm.h, * elf32-avr.c, * elf32-avr.h, * elf32-bfin.c, * elf32-bfin.h, * elf32-cr16.c, * elf32-cr16.h, * elf32-cris.c, * elf32-crx.c, * elf32-csky.c, * elf32-csky.h, * elf32-d10v.c, * elf32-d30v.c, * elf32-dlx.c, * elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c, * elf32-ft32.c, * elf32-gen.c, * elf32-h8300.c, * elf32-hppa.c, * elf32-hppa.h, * elf32-i386.c, * elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, * elf32-m32c.c, * elf32-m32r.c, * elf32-m68hc11.c, * elf32-m68hc12.c, * elf32-m68hc1x.c, * elf32-m68hc1x.h, * elf32-m68k.c, * elf32-m68k.h, * elf32-mcore.c, * elf32-mep.c, * elf32-metag.c, * elf32-metag.h, * elf32-microblaze.c, * elf32-mips.c, * elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c, * elf32-nios2.c, * elf32-nios2.h, * elf32-or1k.c, * elf32-pj.c, * elf32-ppc.c, * elf32-ppc.h, * elf32-pru.c, * elf32-rl78.c, * elf32-rx.c, * elf32-s12z.c, * elf32-s390.c, * elf32-score.c, * elf32-score.h, * elf32-score7.c, * elf32-sh-relocs.h, * elf32-sh.c, * elf32-sparc.c, * elf32-spu.c, * elf32-spu.h, * elf32-tic6x.c, * elf32-tic6x.h, * elf32-tilegx.c, * elf32-tilepro.c, * elf32-v850.c, * elf32-v850.h, * elf32-vax.c, * elf32-visium.c, * elf32-wasm32.c, * elf32-xc16x.c, * elf32-xgate.c, * elf32-xstormy16.c, * elf32-xtensa.c, * elf32-z80.c, * elf64-alpha.c, * elf64-bpf.c, * elf64-gen.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mips.c, * elf64-mmix.c, * elf64-nfp.c, * elf64-ppc.c, * elf64-ppc.h, * elf64-s390.c, * elf64-sparc.c, * elf64-tilegx.c, * elf64-x86-64.c, * elfcode.h, * elfcore.h, * elflink.c, * elfn32-mips.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfnn-riscv.c, * elfxx-aarch64.c, * elfxx-aarch64.h, * elfxx-ia64.c, * elfxx-ia64.h, * elfxx-mips.c, * elfxx-mips.h, * elfxx-riscv.c, * elfxx-riscv.h, * elfxx-sparc.c, * elfxx-sparc.h, * elfxx-target.h, * elfxx-tilegx.c, * elfxx-tilegx.h, * elfxx-x86.c, * elfxx-x86.h, * format.c, * genlink.h, * hash.c, * i386aout.c, * i386lynx.c, * i386msdos.c, * ihex.c, * libaout.h, * libbfd-in.h, * libbfd.c, * libcoff-in.h, * libecoff.h, * libpei.h, * libxcoff.h, * linker.c, * mach-o-aarch64.c, * mach-o-arm.c, * mach-o-i386.c, * mach-o-x86-64.c, * mach-o.c, * mach-o.h, * merge.c, * mmo.c, * netbsd.h, * opncls.c, * pc532-mach.c, * pdp11.c, * pe-arm.c, * pe-i386.c, * pe-mcore.c, * pe-sh.c, * pe-x86_64.c, * peXXigen.c, * pef.c, * pei-arm.c, * pei-i386.c, * pei-ia64.c, * pei-mcore.c, * pei-sh.c, * pei-x86_64.c, * peicode.h, * plugin.c, * plugin.h, * ppcboot.c, * reloc.c, * reloc16.c, * rs6000-core.c, * section.c, * simple.c, * som.c, * som.h, * srec.c, * stabs.c, * syms.c, * targets.c, * tekhex.c, * verilog.c, * vms-alpha.c, * vms-lib.c, * vms-misc.c, * vms.h, * wasm-module.c, * xcofflink.c, * xcofflink.h, * xsym.c, * xsym.h: Replace bfd_boolean with bool, FALSE with false, and TRUE with true throughout. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * libcoff.h: Regenerate. | |||||
2021-03-23 | bfd: avoid "shadowing" of glibc function name | Jan Beulich | 1 | -1/+1 | |
Old enough glibc has an (unguarded) declaration of index() in string.h, which triggers a "shadows a global declaration" warning. | |||||
2021-03-22 | Add startswith function and use it instead of CONST_STRNEQ. | Martin Liska | 1 | -4/+4 | |
bfd/ChangeLog: * bfd-in.h (startswith): Add startswith function. (CONST_STRNEQ): Remove. * bfd-in2.h (startswith): Regenerate with make headers. * archive.c (bfd_slurp_armap): Replace usage of CONST_STRNEQ with startswith. (_bfd_slurp_extended_name_table): Likewise. * archive64.c (_bfd_archive_64_bit_slurp_armap): Likewise. * bfd.c (bfd_get_sign_extend_vma): Likewise. (bfd_convert_section_size): Likewise. (bfd_convert_section_contents): Likewise. * coff-stgo32.c (go32exe_create_stub): Likewise. (go32exe_check_format): Likewise. * coffcode.h (styp_to_sec_flags): Likewise. (GNU_DEBUGALTLINK): Likewise. * coffgen.c (_bfd_coff_section_already_linked): Likewise. (coff_gc_sweep): Likewise. (bfd_coff_gc_sections): Likewise. * cofflink.c (coff_link_add_symbols): Likewise. (process_embedded_commands): Likewise. * compress.c (bfd_is_section_compressed_with_header): Likewise. (bfd_init_section_decompress_status): Likewise. * dwarf2.c (find_debug_info): Likewise. (place_sections): Likewise. * ecoff.c (_bfd_ecoff_slurp_armap): Likewise. * elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_make_section_from_shdr): Likewise. (assign_section_numbers): Likewise. (elfcore_grok_win32pstatus): Likewise. * elf32-arm.c (cmse_scan): Likewise. (elf32_arm_gc_mark_extra_sections): Likewise. (elf32_arm_size_dynamic_sections): Likewise. (is_arm_elf_unwind_section_name): Likewise. * elf32-bfin.c (bfin_size_dynamic_sections): Likewise. * elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise. * elf32-cris.c (elf_cris_size_dynamic_sections): Likewise. * elf32-csky.c (csky_elf_size_dynamic_sections): Likewise. * elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise. * elf32-iq2000.c (iq2000_elf_check_relocs): Likewise. * elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise. * elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise. * elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise. * elf32-metag.c (elf_metag_size_dynamic_sections): Likewise. * elf32-msp430.c (msp430_elf_relax_delete_bytes): Likewise. * elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise. * elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise. * elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise. * elf32-s390.c (elf_s390_size_dynamic_sections): Likewise. * elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise. * elf32-score7.c (s7_bfd_score_elf_size_dynamic_sections): Likewise. * elf32-sh.c (sh_elf_size_dynamic_sections): Likewise. * elf32-tic6x.c (is_tic6x_elf_unwind_section_name): Likewise. (elf32_tic6x_size_dynamic_sections): Likewise. * elf32-vax.c (elf_vax_size_dynamic_sections): Likewise. * elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Likewise. (xtensa_is_insntable_section): Likewise. (xtensa_is_littable_section): Likewise. (xtensa_is_proptable_section): Likewise. (xtensa_property_section_name): Likewise. (xtensa_callback_required_dependence): Likewise. * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise. * elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise. * elf64-ia64-vms.c (is_unwind_section_name): Likewise. (get_reloc_section): Likewise. (elf64_ia64_size_dynamic_sections): Likewise. (elf64_ia64_object_p): Likewise. * elf64-mmix.c (mmix_elf_add_symbol_hook): Likewise. * elf64-ppc.c (ppc64_elf_size_dynamic_sections): Likewise. * elf64-s390.c (elf_s390_size_dynamic_sections): Likewise. * elflink.c (elf_link_add_object_symbols): Likewise. (_bfd_elf_gc_mark_extra_sections): Likewise. (bfd_elf_parse_eh_frame_entries): Likewise. (_bfd_elf_section_already_linked): Likewise. * elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Likewise. * elfnn-ia64.c (is_unwind_section_name): Likewise. (elfNN_ia64_size_dynamic_sections): Likewise. (elfNN_ia64_object_p): Likewise. * elfxx-mips.c (FN_STUB_P): Likewise. (CALL_STUB_P): Likewise. (CALL_FP_STUB_P): Likewise. (_bfd_mips_elf_section_from_shdr): Likewise. (_bfd_mips_elf_fake_sections): Likewise. (_bfd_mips_elf_size_dynamic_sections): Likewise. (_bfd_mips_final_write_processing): Likewise. (_bfd_mips_elf_final_link): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise. * elfxx-x86.c (elf_i386_is_reloc_section): Likewise. (elf_x86_64_is_reloc_section): Likewise. * hpux-core.c (thread_section_p): Likewise. * libcoff.h (bfd_pei_p): Likewise. * linker.c (REAL): Likewise. (unwrap_hash_lookup): Likewise. (_bfd_generic_link_add_one_symbol): Likewise. * mmo.c (mmo_internal_write_section): Likewise. * osf-core.c (osf_core_core_file_p): Likewise. * pef.c (bfd_pef_print_symbol): Likewise. * pei-x86_64.c (pex64_print_all_pdata_sections): Likewise. * som.c (som_slurp_symbol_table): Likewise. (som_slurp_armap): Likewise. * wasm-module.c (wasm_compute_custom_section_file_position): Likewise. binutils/ChangeLog: * dlltool.c (scan_drectve_symbols): Replace usage of CONST_STRNEQ with startswith. * emul_aix.c (ar_emul_aix_parse_arg): Likewise. * objcopy.c (is_mergeable_note_section): Likewise. * objdump.c (dump_dwarf_section): Likewise. * prdbg.c (pr_method_type): Likewise. (pr_class_baseclass): Likewise. (tg_class_baseclass): Likewise. * readelf.c (process_lto_symbol_tables): Likewise. * stabs.c (ULLHIGH): Likewise. (parse_stab_argtypes): Likewise. (stab_demangle_function_name): Likewise. gas/ChangeLog: * config/tc-i386.c (md_parse_option): Replace usage of CONST_STRNEQ with startswith. (x86_64_section_word): Likewise. * config/tc-sparc.c (md_parse_option): Likewise. gdb/ChangeLog: * arm-tdep.c (show_disassembly_style_sfunc): Replace usage of CONST_STRNEQ with startswith. (_initialize_arm_tdep): Likewise. ld/ChangeLog: * emultempl/aix.em: Replace usage of CONST_STRNEQ with startswith. * emultempl/beos.em: Likewise. * emultempl/elf.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * emultempl/xtensaelf.em: Likewise. * ldctor.c (ctor_prio): Likewise. * ldelf.c (ldelf_try_needed): Likewise. (ldelf_parse_ld_so_conf): Likewise. (ldelf_after_open): Likewise. (output_rel_find): Likewise. (ldelf_place_orphan): Likewise. * ldfile.c (ldfile_add_library_path): Likewise. * ldlang.c (lang_add_input_file): Likewise. * ldmain.c (get_sysroot): Likewise. (get_emulation): Likewise. (add_archive_element): Likewise. * ldwrite.c (unsplittable_name): Likewise. (clone_section): Likewise. * lexsup.c (parse_args): Likewise. * pe-dll.c (is_import): Likewise. (pe_implied_import_dll): Likewise. opcodes/ChangeLog: * aarch64-dis.c (parse_aarch64_dis_option): Replace usage of CONST_STRNEQ with startswith. * arc-dis.c (parse_option): Likewise. * arm-dis.c (parse_arm_disassembler_options): Likewise. * cris-dis.c (print_with_operands): Likewise. * h8300-dis.c (bfd_h8_disassemble): Likewise. * i386-dis.c (print_insn): Likewise. * ia64-gen.c (fetch_insn_class): Likewise. (parse_resource_users): Likewise. (in_iclass): Likewise. (lookup_specifier): Likewise. (insert_opcode_dependencies): Likewise. * mips-dis.c (parse_mips_ase_option): Likewise. (parse_mips_dis_option): Likewise. * s390-dis.c (disassemble_init_s390): Likewise. * wasm32-dis.c (parse_wasm32_disassembler_options): Likewise. | |||||
2021-03-18 | DWARF: Check version >= 3 for DW_FORM_ref_addr | H.J. Lu | 1 | -1/+1 | |
Check version >= 3, instead of version == 3 || version == 4, for DW_FORM_ref_addr. bfd/ PR ld/27587 * dwarf2.c (read_attribute_value): Check version >= 3 for DW_FORM_ref_addr. ld/ PR ld/27587 * testsuite/ld-x86-64/pr27587.err: New file. * testsuite/ld-x86-64/pr27587a.obj.bz2: Likewise. * testsuite/ld-x86-64/pr27587b.obj.bz2: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run PR ld/27587 test. |