aboutsummaryrefslogtreecommitdiff
path: root/binutils
AgeCommit message (Collapse)AuthorFilesLines
2021-05-15display_debug_rangesAlan Modra2-10/+12
* dwarf.c (display_debug_ranges): Delete initial_length_size. Correct fallback size calculated on finding a reloc. Constrain data reads to length given in header. Avoid pointer UB.
2021-05-15display_debug_rnglists_listAlan Modra2-1/+5
* dwarf.c (display_debug_rnglists_list): Avoid pointer UB.
2021-05-15display_debug_str_offsetsAlan Modra2-2/+7
* dwarf.c (display_debug_str_offsets): Constrain reads to length given in header.
2021-05-15display_debug_arangesAlan Modra2-18/+21
* dwarf.c (display_debug_aranges): Delete initial_length_size. Use end_ranges to constrain data reads to header length. Avoid pointer UB.
2021-05-15display_loc_listAlan Modra2-7/+18
* dwarf.c (display_loc_list): Avoid pointer UB. Correct check before reading uleb length. Warn on excess length.
2021-05-15display_debug_macroAlan Modra2-6/+15
* dwarf.c (display_debug_macro): Print strings that might not be zero terminated with %*s. Don't bump curr if unterminated.
2021-05-15get_line_filename_and_dirnameAlan Modra2-15/+28
* dwarf.c (get_line_filename_and_dirname): Delete initial_length_size. Simplify length sanity check, and check for too small lengths. Constrain data reads to header length. Avoid pointer UB.
2021-05-15display_debug_macinfoAlan Modra2-9/+20
The existing code went to the bother of using strnlen for scanning but went wild when printing, and possibly incremented curr past end. * dwarf.c (display_debug_macinfo): Print strings that might not be zero terminated with %*s. Don't bump curr if unterminated.
2021-05-15display_debug_pubnames_workerAlan Modra2-20/+19
* dwarf.c (display_debug_pubnames_worker): Delete initial_length_size. Simplify length check. Constrain reads to length given by header.
2021-05-15display_debug_lines_decodedAlan Modra2-4/+9
The directory_table strnlen used the negative of the proper size. After fixing that I realised we don't need strnlen here. * dwarf.c (display_debug_lines_decoded): Don't use strnlen when we have already checked for NUL termination.
2021-05-15read_debug_line_headerAlan Modra2-18/+11
This patch also better constrains the data read, and removes pointer UB. * dwarf.c (read_debug_line_header): Delete initial_length_size. Avoid pointer UB. Keep within length specified by header. Delete dead code.
2021-05-15process_debug_infoAlan Modra2-82/+68
This patch constrains process_debug_info to stay within the data specified by the CU length rather than allowing access up to the end of the section. * dwarf.c (process_debug_info): Always do the first CU length scan for sanity checks. Remove initial_length_size var and instead calculate end_cu. Use end_cu to limit data reads. Delete now dead code checking length.
2021-05-15SAFE_BYTE_GET_INTERNALAlan Modra2-1/+8
We won't want this assert triggering in the next release. * dwarf.c (SAFE_BYTE_GET_INTERNAL): Assert only when ENABLE_CHECKING.
2021-05-15_mul_overflow and get_encoded_valueAlan Modra3-1/+14
A sufficiently mad compiler optimiser can take undefined behaviour according to the C standard as an opportunity to remove code. Since "data + size" might be seen to be past the end of an array, calculating such an expression is UB. _mul_overflow is infrastructure for later patches. * bucomm.h (_mul_overflow): Define. * dwarf.c (get_encoded_value): Avoid pointer UB.
2021-05-13revert previous deltaNick Clifton2-13/+0
2021-05-13Fix an infinite loop in the DWARF decoder when parsing a corrupt string table.Nick Clifton2-1/+14
PR 27861 * dwarf.c (display_debug_str_offsets): Warn if the length field is larger than the amount of data remaining in the section.
2021-05-13PR27861, Infinite loop in dwarf.c:7507-7526Alan Modra2-1/+14
PR 27861 * dwarf.c (display_debug_str_offsets): Sanity check dwarf5 header length.
2021-05-13PR27860, Segmentation fault on readelf -wAlan Modra2-0/+8
Well it didn't take long for the SAFE_BYTE_GET assert to trigger. PR 27860 * dwarf.c (display_debug_frames): Sanity check cie_off before attempting to read cie.
2021-05-12Ensure data pointer kept within boundsAlan Modra2-40/+72
* dwarf.c (process_extended_line_op): Don't bump data pointer past end when strnlen doesn't find string terminator. (decode_location_expression): Remove dead code. (skip_attr_bytes): Remove const from end param. Ensure data pointer doesn't pass end. (get_type_signedness): Remove const from end param. (read_and_display_attr_value): Ensure data pointer doesn't pass end. (display_debug_lines_raw, display_debug_lines_decoded): Likewise. (display_debug_pubnames_worker): Likewise. (display_debug_pubnames_worker): Use SAFE_BYTE_GET_AND INC rather than blindly incrementing data pointer. (display_debug_addr, display_debug_str_offsets): Likewise. Don't compare pointers, compare lengths.
2021-05-12SAFE_BYTE_GETAlan Modra2-82/+73
This rearranges SAFE_BYTE_GET* macros, eliminating some duplication, and making sure that the _INC variants never increment their PTR arg past END. I've added an assertion that should show us places where we use them improperly with user derived PTR args, which I'm sure the fuzzers will find for us. * dwarf.c (SAFE_BYTE_GET_INTERNAL): Define. (SAFE_BYTE_GET, SAFE_BYTE_GET_AND_INC): Define using the above. (SAFE_SIGNED_BYTE_GET, SAFE_SIGNED_BYTE_GET_AND_INC): Likewise. (display_discr_list): Use SAFE_BYTE_GET_AND_INC rather than SAFE_BYTE_GET followed by increment. (process_debug_info): Likewise, and test bytes remaining before incrementing section_begin rather than using pointer comparison. (display_debug_names): Pass lvalue as SAFE_BYTE_GET PTR. (process_cu_tu_index): Likewise for SAFE_BYTE_GET_AND_INC.
2021-05-12SAFE_BYTE_GET64Alan Modra4-274/+85
Functions dealing with lack of a 64-bit integer type can disappear now that we require C99. Printing using dwarf_vmatoa is better too. binutils/ * dwarf.c (dwarf_vmatoa64, SAFE_BYTE_GET64, add64): Delete. (skip_attr_bytes): Replace use of SAFE_BYTE_GET64 with SAFE_BYTE_GET_AND_INC. (read_and_display_attr_value): Likewise. Print using dwarf_vmatoa. (process_debug_info, process_cu_tu_index): Likewise. * elfcomm.c (byte_put, byte_put_little_endian, byte_put_big_endian), (byte_get, byte_get_little_endian, byte_get_big_endian), (byte_get_signed): Make size param unsigned. Remove code dealing with 4-byte elf_vma. (byte_get_64): Delete. * elfcomm.h (byte_put, byte_put_little_endian, byte_put_big_endian), (byte_get, byte_get_little_endian, byte_get_big_endian), (byte_get_signed): Update prototypes. (byte_get_64): Delete. gas/ * testsuite/gas/elf/dwarf-5-file0.d: Update. * testsuite/gas/i386/dwarf5-line-1.d: Update.
2021-05-12PR27836, readelf -w pointer comparison UBAlan Modra2-4/+12
PR 27836 * dwarf.c (display_debug_frames): Don't compare pointers derived from user input. Test offset against bounds instead.
2021-05-12PR27853, Infinite loop in dwarf.cAlan Modra2-12/+21
Not quite infinite but much longer than it need be. The problem is triggered by read_and_display_attr_value incrementing "data" past "end". read_and_display_attr_value shouldn't do that, but be defensive. PR 27853 * dwarf.c (display_formatted_table): Test for data >= end rather than data == end. (process_extended_line_op): Likewise. (display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise.
2021-05-12PR27849, heap-buffer-overflow on readelf -wAlan Modra2-8/+31
PR 27849 * dwarf.c (fetch_indexed_string): Correct length sanity checks. Sanity check section size for version and padding too. Correct index sanity check. Handle multiple tables in .debug_str_offsets.
2021-05-11dwarf.c (process_abbrev_set): Properly parenthesize, fix falloutHans-Peter Nilsson2-1/+6
Building as ILP32 shows: gcc -m32 -DHAVE_CONFIG_H -I. -I/checkout/binutils -I. -I/checkout/binutils -I../bfd -I/checkout/binutils/../bfd -I/checkout/binutils/../include -DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -I/checkout/binutils/../zlib -g -O2 -MT dwarf.o -MD -MP -MF $depbase.Tpo -c -o dwarf.o /checkout/binutils/dwarf.c &&\ mv -f $depbase.Tpo $depbase.Po In file included from /checkout/binutils/sysdep.h:101:0, from /checkout/binutils/dwarf.c:21: /checkout/binutils/dwarf.c: In function 'process_abbrev_set': /checkout/binutils/dwarf.c:1072:15: error: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'dwarf_vma {aka long long unsigned int}' [-Werror=format=] warn (_("Debug info is corrupted, abbrev size (%lx) is larger than " ^ /checkout/binutils/dwarf.c:1072:13: note: in expansion of macro '_' warn (_("Debug info is corrupted, abbrev size (%lx) is larger than " ^ cc1: all warnings being treated as errors Makefile:1101: recipe for target 'dwarf.o' failed The recent commit, casting one of the terms, has an obvious typo. To wit, the (non-cast) term abbrev_size is a dwarf_vma and causes the whole expression to (still) be 64 bits. binutils: * dwarf.c (process_abbrev_set): Properly parenthesize before casting to unsigned long.
2021-05-11PR27845, readelf heap-buffer-overflowAlan Modra2-38/+51
PR 27845 * dwarf.c (process_abbrev_set): Replace start and end parameters with section, abbrev_base, abbrev_size, abbrev_offset. Update all callers. Sanity check parameters correctly and emit warnings here rather than.. (process_debug_info): ..here.
2021-05-10Restore old behaviour of windres so that options containing spaces are not ↵Thomas Wolff3-29/+14
enclosed in double quotes. PR 4356 PR 26865 PR 27594 * windres.c (quot): Revert previous delta. Do not use double quotes when spaces are detected in options. * doc/binutils.texi (windres): Remove suggestion that the --preprocessor option can take arguments.
2021-05-10Avoid possible pointer wrapAlan Modra2-3/+9
PTR supplied to these macros can be read from user input, END is an end of buffer pointer. It's safer to do arithmetic on END than on PTR. * dwarf.c (SAFE_BYTE_GET): Check bounds by subtracting amount from END rather than adding amount to PTR. (SAFE_SIGNED_BYTE_GET, SAFE_BYTE_GET64): Likewise.
2021-05-09Use htab_eq_string in binutilsAlan Modra2-9/+7
A quick check says this is the only place in all of bfd, opcodes, binutils, gas, ld, gprof that duplicates the new libiberty htab_eq_string. * objcopy.c (eq_string): Delete. (create_symbol_htab): Use htab_eq_string.
2021-05-08binutils: update release docs processMike Frysinger2-16/+26
Now that we generate multiple html & pdf forms, update the release process to show how they get updated.
2021-05-08support generating multi-html pages in parallelMike Frysinger3-2/+17
Use the pattern from other projects where we generate the html pages in a dir named the same as the project. So now we have: gas/doc/gas.html - single html page gas/doc/gas/ - multiple html pages This works for projects that have a doc/ subdir already, but gprof & ld require a little tweaking since they generate their docs in their respective toplevels.
2021-05-08generate single html manual page by defaultMike Frysinger3-2/+9
This better matches other GNU projects like autoconf/automake where the html manual is the single page form. We'll support the multi-page form in a follow up change.
2021-05-07Srop readelf's unwind decoder from complaining about x86 binaries.Nick Clifton2-0/+15
* readelf.c (no_processor_specific_unwind): New function. (process_unwind): Use no_processor_specific_unwind for X86 targets.
2021-05-07dwarf: Don't omit second operand of '?' operatorMichael Forney2-3/+11
This is a GNU C extension and is not valid in ISO C. * dwarf.c: Don't omit second operand of '?' operator.
2021-04-30Fix attempt to free non-allocated pointer when parsing .debug_sup sections.Nick Clifton2-9/+34
PR 27796 * dwarf.c (load_debug_sup_file): Allocate memory for filename in .debug_sup section.
2021-04-29Correct the text describing windres's --processor option.Nick Clifton2-1/+12
PR 27594 * doc/binutils.texi (windres): Correct the description of the default value of the --preprocessor argument.
2021-04-27Reject debuglink sections with no associated filename.Nick Clifton2-0/+10
PR 27779 * dwarf.c (parse_gnu_debuglink): Reject empty names. (parse_gnu_debugaltlink): Likewise.
2021-04-22Harmonize and improve auxiliary entries support for XCOFFCl?ment Chigot2-5/+10
bfd/ChangeLog: * coff-rs6000.c (_bfd_xcoff_swap_aux_in): Add errors for unsupported storage class or auxialiry entries. Improve and adapt to new aux structures. Add C_DWARF support. (_bfd_xcoff_swap_aux_out): Likewise. * coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Likewise. (_bfd_xcoff64_swap_aux_out): Likewise. binutils/ChangeLog: * od-xcoff.c (dump_xcoff32_symbols): Adapt to new aux structures. include/ChangeLog: * coff/internal.h (union internal_auxent): Add x_sect structure. * coff/rs6000.h (union external_auxent): Rework to match official documentation. * coff/rs6k64.h (union external_auxent): Likewise. (_AUX_SECT): New define.
2021-04-21Add ability to select numeric base when displaying symbol values in readelf.Nick Lott4-9/+110
PR 27672 * readelf.c (sym_base): New variable. (enum print_mode): Add more modes. (print_vma): Add suport for new modes. (options): Add sym-base. (usage): Add sym-base. (parse_args): Add support for --sym-base. (print_dynamic_symbol_size): New function. (print_dynamic_symbol): Use new function. * doc/binutils.texi: Document the new feature. * NEWS: Mention the new feature.
2021-04-21Adjust readelf's output so that section symbols without a name as shown with ↵Nick Clifton8-27/+57
their section name. binutils* readelf.c (print_dynamic_symbol): Print the section name for section symbols without a name of their own. * testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d: Adjust expected output to allow for named section symbols. * testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d: Likewise. * testsuite/binutils-all/readelf.s-64: Likewise. * testsuite/binutils-all/readelf.ss-64-unused: Likewise. * testsuite/binutils-all/readelf.ss-tmips: Likewise. * testsuite/binutils-all/readelf.ss-unused: Likewise. ld * testsuite/ld-aarch64/variant_pcs-now.d: Adjust expected output to allow for named section symbols. * testsuite/ld-aarch64/variant_pcs-r.d: Likewise. * testsuite/ld-aarch64/variant_pcs-shared.d: Likewise. * testsuite/ld-alpha/tlsbin.rd: Likewise. * testsuite/ld-alpha/tlsbinr.rd: Likewise. * testsuite/ld-alpha/tlspic.rd: Likewise. * testsuite/ld-arm/rodata-merge-map.sym: Likewise. * testsuite/ld-arm/script-type.sym: Likewise. * testsuite/ld-cris/libdso-2.d: Likewise. * testsuite/ld-cris/pr16044.d: Likewise. * testsuite/ld-elf/sec64k.exp: Likewise. * testsuite/ld-ia64/tlsbin.rd: Likewise. * testsuite/ld-ia64/tlspic.rd: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: Likewise. * testsuite/ld-mmix/bspec1.d: Likewise. * testsuite/ld-mmix/bspec2.d: Likewise. * testsuite/ld-mmix/local1.d: Likewise. * testsuite/ld-mmix/local3.d: Likewise. * testsuite/ld-mmix/local5.d: Likewise. * testsuite/ld-mmix/local7.d: Likewise. * testsuite/ld-mmix/undef-3.d: Likewise. * testsuite/ld-powerpc/tlsso.r: Likewise. * testsuite/ld-powerpc/tlsso32.r: Likewise. * testsuite/ld-powerpc/tlstocso.r: Likewise. * testsuite/ld-s390/tlsbin.rd: Likewise. * testsuite/ld-s390/tlsbin_64.rd: Likewise. * testsuite/ld-s390/tlspic.rd: Likewise. * testsuite/ld-s390/tlspic_64.rd: Likewise. * testsuite/ld-sparc/gotop32.rd: Likewise. * testsuite/ld-sparc/gotop64.rd: Likewise. * testsuite/ld-sparc/tlssunbin32.rd: Likewise. * testsuite/ld-sparc/tlssunbin64.rd: Likewise. * testsuite/ld-sparc/tlssunnopic32.rd: Likewise. * testsuite/ld-sparc/tlssunnopic64.rd: Likewise. * testsuite/ld-sparc/tlssunpic32.rd: Likewise. * testsuite/ld-sparc/tlssunpic64.rd: Likewise. * testsuite/ld-tic6x/common.d: Likewise. * testsuite/ld-tic6x/shlib-1.rd: Likewise. * testsuite/ld-tic6x/shlib-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-noindex.rd: Likewise. * testsuite/ld-tic6x/static-app-1.rd: Likewise. * testsuite/ld-tic6x/static-app-1b.rd: Likewise. * testsuite/ld-tic6x/static-app-1r.rd: Likewise. * testsuite/ld-tic6x/static-app-1rb.rd: Likewise. gas * testsuite/gas/aarch64/dwarf.d: Adjust expected output to allow for named section symbols. * testsuite/gas/arm/thumbver.d: Likewise. * testsuite/gas/bfin/loop_temps.d: Likewise. * testsuite/gas/elf/section2.e-arc: Likewise. * testsuite/gas/elf/section2.e-arm: Likewise. * testsuite/gas/elf/section2.e-csky: Likewise. * testsuite/gas/elf/section2.e-m32r: Likewise. * testsuite/gas/elf/section2.e-mips: Likewise. * testsuite/gas/elf/section2.e-msp430: Likewise. * testsuite/gas/elf/section2.e-riscv: Likewise. * testsuite/gas/elf/section2.e-rl78: Likewise. * testsuite/gas/elf/section2.e-rx: Likewise. * testsuite/gas/elf/section2.e-score: Likewise. * testsuite/gas/elf/section2.e-tic6x: Likewise. * testsuite/gas/elf/section2.e-unused: Likewise. * testsuite/gas/elf/section2.e-v850: Likewise. * testsuite/gas/elf/section2.e-xtensa: Likewise. * testsuite/gas/ia64/alias-ilp32.d: Likewise. * testsuite/gas/ia64/alias.d: Likewise. * testsuite/gas/ia64/global.d: Likewise. * testsuite/gas/microblaze/relax_size.elf: Likewise. * testsuite/gas/microblaze/relax_size2.elf: Likewise. * testsuite/gas/mips/global-local-symtab-sort-n64t.d: Likewise. * testsuite/gas/mips/global-local-symtab-sort-o32t.d: Likewise. * testsuite/gas/mmix/bspec-1.d: Likewise. * testsuite/gas/mmix/byte-1.d: Likewise. * testsuite/gas/mmix/comment-1.d: Likewise. * testsuite/gas/mmix/loc-1.d: Likewise. * testsuite/gas/mmix/loc-2.d: Likewise. * testsuite/gas/mmix/loc-3.d: Likewise. * testsuite/gas/mmix/loc-4.d: Likewise. * testsuite/gas/mmix/loc-5.d: Likewise. * testsuite/gas/tic6x/scomm-directive-4.d: Likewise.
2021-04-20MAINTAINERS: Remove Martin Schwidefsky as s390 maintainerAndreas Krebbel2-2/+8
https://lwn.net/ml/linux-kernel/20190521162350.GA17107@osiris/ ChangeLog: 2021-04-20 Andreas Krebbel <krebbel@linux.ibm.com> * MAINTAINERS: Remove Martin Schwidefsky as s390 maintainer and add him to Past Maintainers. Update my email address.
2021-04-19Fix a problem running the archiver program in MRI mode on archives ↵Nick Clifton2-0/+9
containing LTO compiled objects. PR 21702 * arsup.c (ar_addmod): Enable plugin support, if available.
2021-04-19Fix compile time warning about unused functions.Nick Clifton2-0/+8
binutils * rename.c: (get_stat_atime_ns): Add prototype. (get_stat_mtime_ns): Add prototype.
2021-04-16undefined reference to get_stat_atimeAlan Modra2-4/+10
PR 27725 * rename.c (get_stat_atime, get_stat_mtime): Make static. (get_stat_atime_ns, get_stat_mtime_ns): Likewise.
2021-04-16PR27734, get_stat_atime_ns/get_stat_mtime_ns might not use parameterPekka Seppänen2-2/+8
PR 27725 * rename.c (get_stat_atime_ns): Add ATTRIBUTE_UNUSED. (get_stat_mtime_ns): Likewise.
2021-04-15PR27725, better objcopy -p timesAlan Modra6-49/+347
Nanosecond rather than second resolution. PR 27725 * configure.ac: Check for sys/time.h and utimensat. Use standard checks for mkstemp and mkdtemp. Whitespace. Check for nanosecond members of struct stat. * rename.c: Prefer sys/time.h for utimes over utime.h for utime. (STAT_TIMESPEC, STAT_TIMESPEC_NS): Define (get_stat_atime_ns, get_stat_mtime_ns): New inline functions. (get_stat_atime, get_stat_mtime): Likewise. (set_times): Choose first available of utimensat, utimes, utime. Use above inline functions to set timespec and timeval values. * configure: Regenerate. * config.in: Regenerate. * testsuite/binutils-all/objcopy.exp (objcopy_test): Add test of file timestamp when --preserve-dates is used.
2021-04-15Make objcopy -p work when an output file is specifiedAlan Modra3-13/+22
More fallout from the PR27456 fixes. PR 27456 * rename.c (smart_rename): When TO and FROM are equal, just set file timestamp. * objcopy.c (strip_main, copy_main): Always call smart_rename.
2021-04-14elf: Set p_memsz to p_filesz for loadable PT_NOTE segmentH.J. Lu4-0/+79
Since p_memsz of the loadable PT_NOTE segment should be the same as p_filesz, set p_memsz on the loadable PT_NOTE segment when updating p_filesz. bfd/ PR binutils/27708 * elf.c (assign_file_positions_for_non_load_sections): Set p_memsz to p_filesz for the loadable PT_NOTE segment. binutils/ PR binutils/27708 * testsuite/binutils-all/x86-64/pr27708.dump: New file. * testsuite/binutils-all/x86-64/pr27708.exe.bz2: Likewise. * testsuite/binutils-all/x86-64/x86-64.exp: Run binutils/27708 test.
2021-04-14Ignore trailing bytes at the end of a Windows Resource Version structure.Mark Harmstone2-0/+9
PR 27686 * resbin.c (bin_to_res_version): Ignore any trailing bytes at the end of the structure.
2021-04-14Remove unneeded tests for definitions of NT_BSDNETCORE values.Frederic Cambus2-4/+5
binutils* readelf.c (get_netbsd_elfcore_note_type): Remove unneeded #ifdef checks for NT_NETBSDCORE_AUXV and NT_NETBSDCORE_LWPSTATUS. bfd * elf.c (elfcore_grok_netbsd_note): Remove unneeded #ifdef checks for NT_NETBSDCORE_AUXV and NT_NETBSDCORE_LWPSTATUS.