summaryrefslogtreecommitdiff
path: root/binutils
Commit message (Collapse)AuthorAgeFilesLines
* PR10368, ISO 8859 mentioned as 7bit encoding in strings documentationAlan Modra2022-11-281-1/+1
| | | | | PR 10368 * doc/binutils.texi (strings): Delete example of 7-bit encoding.
* Revert "readelf: Do not require EI_OSABI for IFUNC."Martin Liska2022-11-251-3/+5
| | | | This reverts commit ffbbab0b3a1000f862b6d4ce3d9a76ed14f08801.
* readelf: Do not require EI_OSABI for IFUNC.Martin Liska2022-11-241-5/+3
| | | | | | | | | PR 29718 binutils/ChangeLog: * readelf.c (get_symbol_type): Consider STT_GNU_IFUNC as reserved name.
* Tidy objdump printing of section sizeAlan Modra2022-11-241-2/+2
| | | | * objdump.c (load_specific_debug_section): Use PRIx64 format.
* Constify nm format arrayAlan Modra2022-11-241-2/+2
| | | | * nm.c (formats, format): Make const.
* PR22509 - Null pointer dereference on coff_slurp_reloc_tableAlan Modra2022-11-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This extends the commit 4581a1c7d304 fix to more targets, which hardens BFD a little. I think the real underlying problem was the bfd_canonicalize_reloc call in load_specific_debug_section which passed a NULL for "symbols". Fix that too. PR 22509 bfd/ * aoutx.h (swap_ext_reloc_out): Gracefully handle NULL symbols. * i386lynx.c (swap_ext_reloc_out): Likewise. * pdp11.c (pdp11_aout_swap_reloc_out): Likewise. * coff-tic30.c (reloc_processing): Likewise. * coff-tic4x.c (tic4x_reloc_processing): Likewise. * coff-tic54x.c (tic54x_reloc_processing): Likewise. * coff-z80.c (reloc_processing): Likewise. * coff-z8k.c (reloc_processing): Likewise. * ecoff.c (ecoff_slurp_reloc_table): Likewise. * som.c (som_set_reloc_info): Likewise. binutils/ * objdump.c (load_specific_debug_section): Pass syms to bfd_canonicalize_reloc.
* Don't use "long" in readelf for file offsetsAlan Modra2022-11-235-499/+532
| | | | | | | | | | | | | | | | | | | | | | | The aim here is to improve readelf handling of large 64-bit object files on LLP64 hosts (Windows) where long is only 32 bits. The patch changes more than just file offsets. Addresses and sizes are also changed to avoid "long". Most places get to use uint64_t even where size_t may be more appropriate, because that allows some overflow checks to be implemented easily (*alloc changes). * dwarf.c (cmalloc, xcmalloc, xcrealloc, xcalloc2): Make nmemb parameter uint64_t. * dwarf.h: Update prototypes. (struct dwarf_section): Make num_relocs uint64_t. * elfcomm.c (setup_archive): Update error format. * elfcomm.h (struct archive_info): Make sym_size, longnames_size, nested_member_origin, next_arhdr_offset uint64_t. * readelf.c (struct filedata): Make archive_file_offset, archive_file_size, string_table_length, dynamic_addr, dynamic_nent, dynamic_strings_length, num_dynamic_syms, dynamic_syminfo_offset uint64_t. (many functions): Replace uses of "unsigned long" with "uint64_t" or "size_t".
* Re: readelf: use fseeko64 or fseeko if possibleAlan Modra2022-11-231-51/+74
| | | | | | | | | Replace the macros with a small wrapper function that verifies the fseek offset arg isn't overlarge. * readelf.c (FSEEK_FUNC): Delete, replace uses with.. (fseek64): ..this new function. (process_program_headers): Don't cast p_offset to long.
* binutils/configure.ac: integrate last changeMichael Matz2022-11-222-2/+2
| | | | | | | | | Integrate back checks for fseeko{,64} into configure.ac, so that regeneration works. binutils/ * configure.ac: Add fseeko, fseeko64 checks. * configure: Regenerate.
* readelf: use fseeko64 or fseeko if possibleBrett Werling2022-11-223-12/+26
| | | | | | | | | | | | | | | Changes readelf to make use first of fseeko64 and then fseeko, depending on which of those is available. If neither is available, reverts to the previous behavior of using fseek. This is necessary when building readelf for LLP64 systems, where a long will only be 32 bits wide. If the elf file in question is >= 2 GiB, that is greater than the max long value and therefore fseek will fail indicating that the offset is negative. On such systems, making use of fseeko64 or fseeko will result in the ability so seek past the 2 GiB max long boundary. Note that large archive handling in readelf remains to be fixed.
* Fix ARM and AArch64 assembler tests to work in a multi-arch environment.Nick Clifton2022-11-212-0/+12
| | | | | | | | | | | | | | | | PR 29764 gas * testsuite/gas/arm/cpu-cortex-a76ae.d: Add arm prefix to the -m option passed to objdump. * testsuite/gas/arm/cpu-cortex-a77.d: Likewise. * testsuite/gas/aarch64/cpu-cortex-a76ae.d: Add aarch64 prefix to the -m option passed to objdump. * testsuite/gas/aarch64/cpu-cortex-a77.d: Likewise. bfd * cpu-arm.c (scan): Accept machine names prefixed with "arm:". * cpu-aarch64.c (scan): Accept machine names prefixed with "aarch64:". bin * doc/binutils.texi (objdump): Note that the -m option supports the <architecture>:<machine> syntax.
* PR29799 heap buffer overflow in display_gdb_index dwarf.c:10548Alan Modra2022-11-181-1/+1
| | | | | PR 29799 * dwarf.c (display_gdb_index): Typo fix.
* binutils/NEWS: add text for SFrame supportIndu Bhagat2022-11-151-0/+3
| | | | | | ChangeLog: * binutils/NEWS: Add item for SFrame support.
* readelf/objdump: support for SFrame sectionIndu Bhagat2022-11-156-8/+160
| | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for SFrame in readelf and objdump. The arguments of --sframe are optional for both readelf and objdump. include/ChangeLog: * sframe-api.h (dump_sframe): New function declaration. ChangeLog: * binutils/Makefile.am: Add dependency on libsframe for readelf and objdump. * binutils/Makefile.in: Regenerate. * binutils/doc/binutils.texi: Document --sframe=[section]. * binutils/doc/sframe.options.texi: New file. * binutils/objdump.c: Add support for SFrame format. * binutils/readelf.c: Likewise. * include/sframe-api.h: Add new API for dumping .sframe section. * libsframe/Makefile.am: Add sframe-dump.c. * libsframe/Makefile.in: Regenerate. * libsframe/sframe-dump.c: New file.
* bfd: linker: merge .sframe sectionsIndu Bhagat2022-11-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The linker merges all the input .sframe sections. When merging, the linker verifies that all the input .sframe sections have the same abi/arch. The linker uses libsframe library to perform key actions on the .sframe sections - decode, read, and create output data. This implies buildsystem changes to make and install libsframe before libbfd. The linker places the output .sframe section in a new segment of its own: PT_GNU_SFRAME. A new segment is not added, however, if the generated .sframe section is empty. When a section is discarded from the final link, the corresponding entries in the .sframe section for those functions are also deleted. The linker sorts the SFrame FDEs on start address by default and sets the SFRAME_F_FDE_SORTED flag in the .sframe section. This patch also adds support for generation of SFrame unwind information for the .plt* sections on x86_64. SFrame unwind info is generated for IBT enabled PLT, lazy/non-lazy PLT. The existing linker option --no-ld-generated-unwind-info has been adapted to include the control of whether .sframe unwind information will be generated for the linker generated sections like PLT. Changes to the linker script have been made as necessary. ChangeLog: * Makefile.def: Add install dependency on libsframe for libbfd. * Makefile.in: Regenerated. * bfd/Makefile.am: Add elf-sframe.c * bfd/Makefile.in: Regenerated. * bfd/bfd-in2.h (SEC_INFO_TYPE_SFRAME): Regenerated. * bfd/configure: Regenerate. * bfd/configure.ac: Add elf-sframe.lo. * bfd/elf-bfd.h (struct sframe_func_bfdinfo): New struct. (struct sframe_dec_info): Likewise. (struct sframe_enc_info): Likewise. (struct elf_link_hash_table): New member for encoded .sframe object. (struct output_elf_obj_tdata): New member. (elf_sframe): New access macro. (_bfd_elf_set_section_sframe): New declaration. * bfd/elf.c (get_segment_type): Handle new segment PT_GNU_SFRAME. (bfd_section_from_phdr): Likewise. (get_program_header_size): Likewise. (_bfd_elf_map_sections_to_segments): Likewise. * bfd/elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Add contents to the .sframe sections or .plt* entries. * bfd/elflink.c (elf_section_ignore_discarded_relocs): Handle SEC_INFO_TYPE_SFRAME. (_bfd_elf_default_action_discarded): Handle .sframe section. (elf_link_input_bfd): Merge .sframe section. (bfd_elf_final_link): Write the output .sframe section. (bfd_elf_discard_info): Handle discarding .sframe section. * bfd/elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Create .sframe section for .plt and .plt.sec. (_bfd_x86_elf_finish_dynamic_sections): Handle .sframe from .plt* sections. * bfd/elfxx-x86.h (PLT_SFRAME_FDE_START_OFFSET): New definition. (SFRAME_PLT0_MAX_NUM_FRES): Likewise. (SFRAME_PLTN_MAX_NUM_FRES): Likewise. (struct elf_x86_sframe_plt): New structure. (struct elf_x86_link_hash_table): New member. (struct elf_x86_init_table): New members for .sframe creation. * bfd/section.c: Add new definition SEC_INFO_TYPE_SFRAME. * binutils/readelf.c (get_segment_type): Handle new segment PT_GNU_SFRAME. * ld/ld.texi: Update documentation for --no-ld-generated-unwind-info. * ld/scripttempl/elf.sc: Support .sframe sections. * ld/Makefile.am (TESTSFRAMELIB): Use it. (check-DEJAGNU): Likewise. * ld/Makefile.in: Regenerated. * ld/configure.ac (TESTSFRAMELIB): Set to the .so or .a like TESTBFDLIB. * ld/configure: Regenerated. * bfd/elf-sframe.c: New file. include/ChangeLog: * elf/common.h (PT_GNU_SFRAME): New definition. * elf/internal.h (struct elf_segment_map): Handle new segment type PT_GNU_SFRAME. ld/testsuite/ChangeLog: * ld/testsuite/ld-bootstrap/bootstrap.exp: Add SFRAMELIB. * ld/testsuite/ld-aarch64/aarch64-elf.exp: Add new test sframe-simple-1. * ld/testsuite/ld-aarch64/sframe-bar.s: New file. * ld/testsuite/ld-aarch64/sframe-foo.s: Likewise. * ld/testsuite/ld-aarch64/sframe-simple-1.d: Likewise. * ld/testsuite/ld-sframe/sframe-empty.d: New test. * ld/testsuite/ld-sframe/sframe-empty.s: New file. * ld/testsuite/ld-sframe/sframe.exp: New testsuite. * ld/testsuite/ld-x86-64/sframe-bar.s: New file. * ld/testsuite/ld-x86-64/sframe-foo.s: Likewise. * ld/testsuite/ld-x86-64/sframe-simple-1.d: Likewise. * ld/testsuite/ld-x86-64/sframe-plt-1.d: Likewise. * ld/testsuite/ld-x86-64/sframe-simple-1.d: Likewise. * ld/testsuite/ld-x86-64/x86-64.exp: Add new tests - sframe-simple-1, sframe-plt-1. * ld/testsuite/lib/ld-lib.exp: Add new proc to check if assembler supports SFrame section. * ld/testsuite/ld-sframe/discard.d: New file. * ld/testsuite/ld-sframe/discard.ld: Likewise. * ld/testsuite/ld-sframe/discard.s: Likewise.
* libsframe: add the SFrame libraryWeimin Pan2022-11-152-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libsframe is a library that allows you to: - decode a .sframe section - probe and inspect a .sframe section - encode (and eventually write) a .sframe section. This library is currently being used by the linker, readelf, objdump. This library will also be used by the SFrame unwinder which is still to be upstream'd. The file include/sframe-api.h defines the user-facing APIs for decoding, encoding and probing .sframe sections. A set of error codes together with their error message strings are also defined. Endian flipping is performed automatically at read and write time, if cross-endianness is detected. ChangeLog: * Makefile.def: Add libsframe as new module with its dependencies. * Makefile.in: Regenerated. * binutils/Makefile.am: Add libsframe. * binutils/Makefile.in: Regenerated. * configure: Regenerated * configure.ac: Add libsframe to host_libs. * libsframe/Makefile.am: New file. * libsframe/Makefile.in: New file. * libsframe/aclocal.m4: New file. * libsframe/config.h.in: New file. * libsframe/configure: New file. * libsframe/configure.ac: New file. * libsframe/sframe-error.c: New file. * libsframe/sframe-impl.h: New file. * libsframe/sframe.c: New file. include/ChangeLog: * sframe-api.h: New file. testsuite/ChangeLog: * libsframe/testsuite/Makefile.am: New file. * libsframe/testsuite/Makefile.in: Regenerated. * libsframe/testsuite/libsframe.decode/Makefile.am: New file. * libsframe/testsuite/libsframe.decode/Makefile.in: Regenerated. * libsframe/testsuite/libsframe.decode/decode.exp: New file. * libsframe/testsuite/libsframe.encode/Makefile.am: Likewise. * libsframe/testsuite/libsframe.encode/Makefile.in: Regenerated. * libsframe/testsuite/libsframe.encode/encode.exp: New file. * libsframe/testsuite/libsframe.encode/encode-1.c: Likewise. * libsframe/testsuite/libsframe.decode/be-flipping.c: Likewise. * libsframe/testsuite/libsframe.decode/frecnt-1.c: Likewise. * libsframe/testsuite/libsframe.decode/frecnt-2.c: Likewise. * libsframe/testsuite/libsframe.decode/DATA-BE: New file. * libsframe/testsuite/libsframe.decode/DATA1: Likewise. * libsframe/testsuite/libsframe.decode/DATA2: Likewise.
* [readelf] arm: Support for new pacbti unwind opcode 0xb5.Srinath Parvathaneni2022-11-141-0/+2
| | | | | | | | | | | | | | This patch adds readelf support for decoding the exception table opcode "0xb5", which indicates to use effective vsp as modifier for PAC validation as defined by EHABI (https://github.com/ARM-software/abi-aa/releases/download/2022Q3/ehabi32.pdf Section 10.3). binutils/ChangeLog: 2022-11-07 Srinath Parvathaneni <srinath.parvathaneni@arm.com> * readelf.c (decode_arm_unwind_bytecode): Add entry to decode opcode 0xb5.
* Re: objcopy renaming section with explicit flagsAlan Modra2022-11-141-0/+1
| | | | | | | For now, xfail the new test. Some header/aux-header rewriting is required at the very least. * testsuite/binutils-all/rename-section-01.d: xfail xcoff.
* objcopy renaming section with explicit flagsAlan Modra2022-11-143-6/+17
| | | | | | | | | | | | | | | | | | This tidies SEC_RELOC handling in bfd, in the process fixing a bug with objcopy when renaming sections. bfd/ * reloc.c (_bfd_generic_set_reloc): Set/clear SEC_RELOC depending on reloc count. * elf64-sparc.c (elf64_sparc_set_reloc): Likewise. binutils/ * objcopy.c (copy_relocations_in_section): Remove now unnecessary clearing of SEC_RELOC. * testsuite/binutils-all/rename-section-01.d: New test. * testsuite/binutils-all/objcopy.exp: Run it. gas/ * write.c (size_seg): Remove unneccesary twiddle of SEC_RELOC. (write_relocs): Likewise. Always call bfd_set_reloc.
* Re: Fuzzed files in archivesAlan Modra2022-11-091-14/+7
| | | | | | | | | | Like commit ffbe89531c2e this avoids more silliness writing output that is going to be deleted. bfd_close and bfd_close_all_done differ in that only the former calls _bfd_write_contents. * objcopy.c (copy_archive): Don't call bfd_close for elements that are going to be deleted, call bfd_close_all_done instead. Do the same for the archive itself.
* configure: require libzstd >= 1.4.0Christophe Lyon2022-11-071-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | gas uses ZSTD_compressStream2 which is only available with libzstd >= 1.4.0, leading to build errors when an older version is installed. This patch updates the check libzstd presence to check its version is >= 1.4.0. However, since gas seems to be the only component requiring such a recent version this may imply that we disable ZSTD support for all components although some would still benefit from an older version. I ran 'autoreconf -f' in all directories containing a configure.ac file, using vanilla autoconf-2.69 and automake-1.15.1. I noticed several errors from autoheader in readline, as well as warnings in intl, but they are unrelated to this patch. This should fix some of the buildbots. OK for trunk? Thanks, Christophe
* binutils: Run PR binutils/26160 testH.J. Lu2022-11-042-41/+94
| | | | | | | | | Update expected PR binutils/26160 test output for readelf out change and run PR binutils/26160 test. PR binutils/26160 * testsuite/binutils-all/pr26160.r: Updated. * testsuite/binutils-all/readelf.exp: Run PR binutils/26160 test.
* Update release documentation with regard to uploading gprofng docsNick Clifton2022-11-042-0/+13
|
* opcodes/arm: add disassembler styling for armAndrew Burgess2022-11-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds disassembler styling for the ARM architecture. The ARM disassembler is driven by several instruction tables, e.g. cde_opcodes, coprocessor_opcodes, neon_opcodes, etc The type for elements in each table can vary, but they all have one thing in common, a 'const char *assembler' field. This field contains a string that describes the assembler syntax of the instruction. Embedded within that assembler syntax are various escape characters, prefixed with a '%'. Here's an example of a very simple instruction from the arm_opcodes table: "pld\t%a" The '%a' indicates a particular type of operand, the function print_insn_arm processes the arm_opcodes table, and includes a switch statement that handles the '%a' operand, and takes care of printing the correct value for that instruction operand. It is worth noting that there are many print_* functions, each function handles a single *_opcodes table, and includes its own switch statement for operand handling. As a result, every *_opcodes table uses a different mapping for the operand escape sequences. This means that '%a' might print an address for one *_opcodes table, but in a different *_opcodes table '%a' might print a register operand. Notice as well that in our example above, the instruction mnemonic 'pld' is embedded within the assembler string. Some instructions also include comments within the assembler string, for example, also from the arm_opcodes table: "nop\t\t\t@ (mov r0, r0)" here, everything after the '@' is a comment that is displayed at the end of the instruction disassembly. The next complexity is that the meaning of some escape sequences is not necessarily fixed. Consider these two examples from arm_opcodes: "ldrex%c\tr%12-15d, [%16-19R]" "setpan\t#%9-9d" Here, the '%d' escape is used with a bitfield modifier, '%12-15d' in the first instruction, and '%9-9d' in the second instruction, but, both of these are the '%d' escape. However, in the first instruction, the '%d' is used to print a register number, notice the 'r' immediately before the '%d'. In the second instruction the '%d' is used to print an immediate, notice the '#' just before the '%d'. We have two problems here, first, the '%d' needs to know if it should use register style or immediate style, and secondly, the 'r' and '#' characters also need to be styled appropriately. The final thing we must consider is that some escape codes result in more than just a single operand being printed, for example, the '%q' operand as used in arm_opcodes ends up calling arm_decode_shift, which can print a register name, a shift type, and a shift amount, this could end up using register, sub-mnemonic, and immediate styles, as well as the text style for things like ',' between the different parts. I propose a three layer approach to adding styling: (1) Basic state machine: When we start printing an instruction we should maintain the idea of a 'base_style'. Every character from the assembler string will be printed using the base_style. The base_style will start as mnemonic, as each instruction starts with an instruction mnemonic. When we encounter the first '\t' character, the base_style will change to text. When we encounter the first '@' the base_style will change to comment_start. This simple state machine ensures that for simple instructions the basic parts, except for the operands themselves, will be printed in the correct style. (2) Simple operand styling: For operands that only have a single meaning, or which expand to multiple parts, all of which have a consistent meaning, then I will simply update the operand printing code to print the operand with the correct style. This will cover a large number of the operands, and is the most consistent with how styling has been added to previous architectures. (3) New styling syntax in assembler strings: For cases like the '%d' that I describe above, I propose adding a new extension to the assembler syntax. This extension will allow me to temporarily change the base_style. Operands like '%d', will then print using the base_style rather than using a fixed style. Here are the two examples from above that use '%d', updated with the new syntax extension: "ldrex%c\t%{R:r%12-15d%}, [%16-19R]" "setpan\t%{I:#%9-9d%}" The syntax has the general form '%{X:....%}' where the 'X' character changes to indicate a different style. In the first instruction I use '%{R:...%}' to change base_style to the register style, and in the second '%{I:...%}' changes base_style to immediate style. Notice that the 'r' and '#' characters are included within the new style group, this ensures that these characters are printed with the correct style rather than as text. The function decode_base_style maps from character to style. I've included a character for each style for completeness, though only a small number of styles are currently used. I have updated arm-dis.c to the above scheme, and checked all of the tests in gas/testsuite/gas/arm/, and the styling looks reasonable. There are no regressions on the ARM gas/binutils/ld tests that I can see, so I don't believe I've changed the output layout at all. There were two binutils tests for which I needed to force the disassembler styling off. I can't guarantee that I've not missed some untested corners of the disassembler, or that I might have just missed some incorrectly styled output when reviewing the test results, but I don't believe I've introduced any changes that could break the disassembler - the worst should be some aspect is not styled correctly.
* Updated Romainain translation for the binutils sub-directory and Swedish ↵Nick Clifton2022-10-311-3051/+3250
| | | | translations for the ld and opcodes sub-directories.
* objdump: Add configure time option to enable colored disassembly output by ↵Nick Clifton2022-10-317-20/+106
| | | | | | | | | | | | default. PR 29457 * configure.ac: Add --enable-colored-disassembly. * objdump.c: Add --disassembler-color=terminal. * doc/binutils.texi (objdump): Document the new option. * NEWS: Mention new feature. * config.in: Regenerate in. * configure: Regenerate.
* Pool section entries for DWP version 1Alan Modra2022-10-301-49/+41
| | | | | | | | | | | | | | | | | Ref: https://gcc.gnu.org/wiki/DebugFissionDWP?action=recall&rev=3 Fuzzers have found a weakness in the code stashing pool section entries. With random nonsensical values in the index entries (rather than each index pointing to its own set distinct from other sets), it's possible to overflow the space allocated, losing the NULL terminator. Without a terminator, find_section_in_set can run off the end of the shndx_pool buffer. Fix this by scanning the pool directly. binutils/ * dwarf.c (add_shndx_to_cu_tu_entry): Delete range check. (end_cu_tu_entry): Likewise. (process_cu_tu_index): Fill shndx_pool by directly scanning pool, rather than indirectly from index entries.
* Fix small objcopy memory leakAlan Modra2022-10-291-0/+1
| | | | * objcopy.c (copy_archive): Free l->name.
* binutils: Update my e-mail and Yunhai's e-mailLifang Xia2022-10-281-2/+2
| | | | | binutils/ * MAINTAINERS(C-SKY): update e-mails of Lifang & Yunhai.
* Fuzzed files in archivesAlan Modra2022-10-271-0/+1
| | | | | | | | | | | | | Given a fuzzed object file in an archive with section size exceeding file size, objcopy will report an error like "section size (0xfeffffff bytes) is larger than file size (0x17a bytes)" but will create a copy of the object laid out for the large section. That means a large temporary file on disk that is read back and written to the output archive, which can take a while. The output archive is then deleted due to the error. Avoid some of this silliness. * objcopy.c (copy_section): If section contents cannot be read set output section size to zero.
* segfault in objdump.c reloc_atAlan Modra2022-10-261-2/+2
| | | | | | | bfd_canonicalize_reloc returns -1L on errors. * objdump.c (load_specific_debug_section): Properly handle error return from bfd_canonicalize_reloc.
* PR29720, objdump -S crashes if build-id is missingAlan Modra2022-10-261-9/+11
| | | | | | PR 29720 * objdump.c (slurp_file): Don't call debuginfod_find_source when build_id is NULL.
* readelf: support zstd compressed debug sections [PR 29640]Fangrui Song2022-10-213-48/+80
|
* Add a note to the binutils/NEWS file about DCO signed contributions.Nick Clifton2022-10-211-0/+2
|
* binutils: Remove unused substitution PROGRAMTsukasa OI2022-10-202-4/+2
| | | | | | | | | | | | | | | Unlike other substitution, this substitution of @PROGRAM@ was done in binutils/Makefile and it was intended for binutils/cxxfilt.man. @PROGRAM@ in binutils/cxxfilt.man is removed in the commit 0285c67df190 ("Automate generate on man pages") in 2001 and @PROGRAM@ is ineffective since then. Because PROGRAM substitution does nothing, removing this manual substitution should be completely safe. binutils/ChangeLog: * doc/local.mk: Remove unused substitution PROGRAM. * Makefile.in: Regenerate.
* Fix addr2line test for ppc64 elfv1 and mingwAlan Modra2022-10-191-27/+39
| | | | | | | * testsuite/binutils-all/addr2line.exp: Tidy. For powerpc64 arrange to pass --synthetic to nm, and extract .main and .fn symbol address for addr2line test. Handle default executable extension on cygwin/mingw compilers.
* Update MAINTAINERS file with details about accepting DCO signed contributions.Nick Clifton2022-10-192-1/+34
| | | | * MAINTAINERS: Add section on patches, copyright and DCO.
* Binutils: Adding new testcase for addr2line.rupesh potharla2022-10-192-0/+67
| | | | | * binutils/testsuite/config/default.exp: Set ADDR2LINE and ADDR2LINEFLAGS. * binutils/testsuite/binutils-all/addr2line.exp: New file.
* e200 LSP supportAlan Modra2022-10-141-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It has bothered me for a long time that we have disabled LSP (and SPE) tests. Also the LSP test comment indicating there is something wrong with get_powerpc_dialect. I don't think there is. Decoding of a VLE instruction depends on whether the processor is in VLE mode (some processors support both VLE and standard PPC) which we flag per section with SHF_PPC_VLE for decoding when disassembling. Background: Some versions of powerpc e200 have "Lightweight Signal Processing" support, examples being e200z215 and e200z425. As far as I can tell, LSP and SPE are mutually exclusive. This seems to be borne out by insn encoding, for example LSP "zvaddih" and SPE "evaddw" have the same encoding. So none of the processor descriptions in ppc_opts ought to have both PPC_OPCODE_LSP and PPC_OPCODE_SPE/2, if we want disassembly to work. I also could not find anything to suggest that the LSP insns are enabled only in VLE mode, which means the LSP insns should not be in vle_opcodes. Fix all this by moving the LSP insns to their own table, and add a new e200z2 cpu entry with LSP support, removing LSP from -me200z4 and from -mvle. (Yes, I know, as I said above some of the e200z4 processors have LSP. Others have SPE. It's hard to choose good options. Think of z2 as meaning earlier, z4 as later.) Also add -mlsp to allow adding the LSP insn set. include/ * opcode/ppc.h (lsp_opcodes, lsp_num_opcodes): Declare. (LSP_OP_TO_SEG): Define. binutils/ * doc/binutils.texi: Update ppc docs. gas/ * config/tc-ppc.c (ppc_setup_opcodes): Add lsp opcodes to ppc_hash. * doc/c-ppc.texi: Document e200 and lsp. * testsuite/gas/ppc/lsp-checks.d: Assemble with -me200z2. * testsuite/gas/ppc/lsp.d: Likewise, disassembly too. * testsuite/gas/ppc/ppc.exp: Don't xfail lsp test. opcodes/ * ppc-dis.c (ppc_opts): Add e200z2 and lsp. Don't set PPC_OPCODE_LSP for e200z4 or vle. (ppc_parse_cpu): Mutually exclude LSP and SPE. (LSP_OPCD_SEGS): Define. (lsp_opcd_indices): New array. (disassemble_init_powerpc): Init lsp_opcd_indices. (lookup_lsp): New function. (print_insn_powerpc): Call it. * ppc-opc.c: Include libiberty.h for ARRAY_SIZE and use throughout. (vle_opcodes): Move LSP opcodes to.. (lsp_opcodes): ..here, and sort. (lsp_num_opcodes): New.
* Fix objcopy's error message when it cannot add a .gnu_debuglink section ↵Nick Clifton2022-10-122-1/+7
| | | | | | | | because the section already exists. PR 29665 * objcopy.c (copy_object): Use the input filename when reporting that a .gnu_debuglink section already exists.
* Add ability to create reproducible source tarballs.Nick Clifton2022-10-101-0/+4
| | | | | | | * src-release.sh: Add "-r <date>" option to create reproducible tarballs based upon a fixed timestamp of <date>. * binutils/README-how-to-make-a-release: Add a line showing how to use -r <date> when creating a binutils release.
* PR29647, objdump -S loopingAlan Modra2022-10-051-2/+3
| | | | | | | | | Fuzzed input with this in .debug_line [0x0000003b] Special opcode 115: advance Address by 8 to 0x401180 and Line by -2 to -1 PR 29647 * objdump.c (print_line): Don't decrement line number here.. (dump_lines): ..do so here instead, ensuring loop terminates.
* readelf: DO not load section headers from file offset zeroNick Clifton2022-10-032-0/+19
| | | | | | * readelf.c (get_32bit_section_headers): Return false if the e_shoff field is zero. (get_64bit_section_headers): Likewise.
* RISC-V: Assign DWARF numbers to vector registersTsukasa OI2022-10-031-10/+18
| | | | | | | | | | | | | | | | | | | | | This commit assigns DWARF register numbers to vector registers (v0-v31: 96..127) to implement RISC-V DWARF Specification version 1.0-rc4 (now in the frozen state): https://github.com/riscv-non-isa/riscv-elf-psabi-doc/releases/tag/v1.0-rc4 binutils/ChangeLog: * dwarf.c (dwarf_regnames_riscv): Assign DWARF register numbers 96..127 to vector registers v0-v31. gas/ChangeLog: * config/tc-riscv.c (tc_riscv_regname_to_dw2regnum): Support vector registers. * testsuite/gas/riscv/dw-regnums.s: Add vector registers to the DWARF register number test. * testsuite/gas/riscv/dw-regnums.d: Likewise.
* objcopy: avoid "shadowing" of remove() function nameJan Beulich2022-09-301-4/+4
| | | | | remove() is a standard library function (declared in stdio.h), which triggers a "shadows a global declaration" warning with some gcc versions.
* LoongArch: Update ELF e_flags handling according to specification.liuzhensong2022-09-301-5/+5
| | | | | | | | | | | | | | | | | | | | | | | Update handling of e_flags according to the documentation update [1] (discussions [2][3]). Object file bitness is now represented in the EI_CLASS byte. The e_flags field is now interpreted as follows: e_flags[2:0]: Base ABI modifier - 0x1: soft-float - 0x2: single-precision hard-float - 0x3: double-precision hard-float e_flags[7:6]: ELF object ABI version - 0x0: v0 - 0x1: v1 [1]: https://github.com/loongson/LoongArch-Documentation/blob/main/docs/LoongArch-ELF-ABI-EN.adoc#e_flags-identifies-abi-type-and-version [2]: https://github.com/loongson/LoongArch-Documentation/pull/61 [3]: https://github.com/loongson/LoongArch-Documentation/pull/47
* The help document of size misses an option.Nick Clifton2022-09-283-2/+19
| | | | | | PR 29628 * size.c (usage): Add -f. * doc/binutils.texi (size): Add -f.
* Re: egrep in binutilsAlan Modra2022-09-281-5/+1
| | | | | | | | | | Multi-line patterns for grep are not supported on some old versions of grep. binutils/ * embedspu.sh: Replace multi-line grep with sed. ld/ * testsuite/ld-elfvers/vers.exp: Replace multi-line grep with sed.
* egrep in binutilsAlan Modra2022-09-282-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apparently some distros have a nagging egrep that helpfully tells you egrep is deprecated and to use "grep -E". The nag message causes a ld testsuite failure. What's more the advice isn't that good. The "-E" flag may not be available with older versions of grep. This patch fixes bare invocation of egrep within binutils, replacing it with the autoconf $EGREP or with grep. config/ * lib-ld.m4 (AC_LIB_PROG_LD_GNU): Require AC_PROG_EGREP and invoke $EGREP. (AC_LIB_PROG_LD): Likewise. binutils/ * configure: Regenerate. * embedspu.sh: Replace egrep with grep. gold/ * testsuite/Makefile.am (flagstest_compress_debug_sections.check): Replace egrep with grep. * testsuite/Makefile.in: Regenerate. * testsuite/bnd_ifunc_1.sh: Replace egrep with $EGREP. * testsuite/bnd_ifunc_2.sh: Likewise. * testsuite/bnd_plt_1.sh: Likewise. * testsuite/discard_locals_test.sh: Likewise. * testsuite/gnu_property_test.sh: Likewise. * testsuite/no_version_test.sh: Likewise. * testsuite/pr18689.sh: Likewise. * testsuite/pr26936.sh: Likewise. * testsuite/retain.sh: Likewise. * testsuite/split_i386.sh: Likewise. * testsuite/split_s390.sh: Likewise. * testsuite/split_x32.sh: Likewise. * testsuite/split_x86_64.sh: Likewise. * testsuite/ver_test_pr16504.sh: Likewise. intl/ * configure: Regenerate. ld/ * testsuite/ld-elfvers/vers.exp (test_ar): Replace egrep with grep.
* binutils, gdb: support zstd compressed debug sectionsFangrui Song2022-09-269-16/+217
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR29397 PR29563: Add new configure option --with-zstd which defaults to auto. If pkgconfig/libzstd.pc is found, define HAVE_ZSTD and support zstd compressed debug sections for most tools. * bfd: for addr2line, objdump --dwarf, gdb, etc * gas: support --compress-debug-sections=zstd * ld: support ELFCOMPRESS_ZSTD input and --compress-debug-sections=zstd * objcopy: support ELFCOMPRESS_ZSTD input for --decompress-debug-sections and --compress-debug-sections=zstd * gdb: support ELFCOMPRESS_ZSTD input. The bfd change references zstd symbols, so gdb has to link against -lzstd in this patch. If zstd is not supported, ELFCOMPRESS_ZSTD input triggers an error. We can avoid HAVE_ZSTD if binutils-gdb imports zstd/ like zlib/, but this is too heavyweight, so don't do it for now. ``` % ld/ld-new a.o ld/ld-new: a.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support ... % ld/ld-new a.o --compress-debug-sections=zstd ld/ld-new: --compress-debug-sections=zstd: ld is not built with zstd support % binutils/objcopy --compress-debug-sections=zstd a.o b.o binutils/objcopy: --compress-debug-sections=zstd: binutils is not built with zstd support % binutils/objcopy b.o --decompress-debug-sections binutils/objcopy: zstd.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support ... ```