aboutsummaryrefslogtreecommitdiff
path: root/binutils/readelf.c
AgeCommit message (Collapse)AuthorFilesLines
2024-07-26Fix "Untranslated plural in readelf.c"Nick Clifton1-9/+10
PR 32002
2024-05-29readelf: Use section names for displaying RELR relocsSzabolcs Nagy1-8/+24
In some cases using section names instead of symbol names for displaying an address is more useful. If the symbol falls outside the section where the address is then likely it is not useful to display the address relative to. And if symbols are stripped from a binary then printing the section that contains the address is more useful than printing <no sym>.
2024-05-29readelf: Fix symbol display for RELR relocsSzabolcs Nagy1-17/+125
Filter symbols before binary searching for the right symbol to display for a given address, such that only displayable symbols are present and at most one per address. The current logic does not handle multiple symbols for the same address well if some of them are empty, the selected symbol is not stable with respect to an unrelated symbol table change and on aarch64 often mapping symbols are displayed which is not useful. Filtering solves these problems at the cost of a linear scan of the sorted symbol table. The heuristic to select the best symbol likely could be improved, this patch aims to improve symbol display for RELR without complex logic such that the output is useful and stable for ld tests.
2024-05-28Add new ELF section and segment types to readelf.Nick Clifton1-234/+383
2024-05-20readelf: add pretty printing for FDO Dlopen Metadata noteLuca Boccassi1-0/+7
2024-05-14arm: binutils: drop Maverick support.Richard Earnshaw1-4/+0
Remove the decoding of the Maverick flag from readelf.
2024-04-24Update readelf's display of RELR sections to include the number of locations ↵Nick Clifton1-20/+115
relocated
2024-04-16Simplify readelf's RELR relocation display.Fangrui Song1-17/+3
2024-04-11Improve readelf's display of RELR relocs.Nick Clifton1-129/+285
2024-04-11Add -j/--display-section option to readelf.Nick Clifton1-133/+238
2024-03-25bfd: make _bfd_section_size_insane part of the public APIAndrew Burgess1-1/+1
If a BFD user is making use of a function like bfd_get_section_contents to read a section into a pre-allocated buffer, then that BFD user might also want to make use of _bfd_section_size_insane prior to allocating the buffer they intend to use in order to validate that the buffer size that plan to allocate is sane. This commit makes _bfd_section_size_insane public, by renaming it to bfd_section_size_insane. I've updated the existing uses within bfd/, I don't believe this function is used outside of bfd/ currently. One place that I plan to make use of this function is in gdb/gdb_bfd.c, in the function gdb_bfd_get_full_section_contents. This change isn't included in this commit, but will come later if/when this has been merged into bfd. There should be no change in behaviour after this commit. bfd/ * bfd-in2.h (bfd_section_size_insane): Add declaration. * compress.c (bfd_get_full_section_contents): Update for new name of _bfd_section_size_insane. (bfd_init_section_compress_status): Likewise. * dwarf2.c (read_section): Likewise. (_bfd_dwarf2_slurp_debug_info): Likewise. * libbfd.h (_bfd_section_size_insane): Remove declaration. * section.c (_bfd_section_size_insane): Rename to ... (bfd_section_size_insane): ... this. binutils/ * readelf.c (uncompress_section_contents): Update comment to account for new name of _bfd_section_size_insane.
2024-03-19Remove redunant test of ELF size in core note decoder.Nick Clifton1-7/+0
PR 31469
2024-02-12Add support to readelf for the PT_OPENBSD_SYSCALLS segment type.Frederic Cambus1-0/+1
binutils * readelf.c (get_segment_type): Handle PT_OPENBSD_SYSCALLS segment type. include * elf/common.h (PT_OPENBSD_SYSCALLS): Define.
2024-01-19Update readelf's and objdump's debug frame displaying feature to include the ↵Nick Clifton1-0/+2
contents of the .eh_frame_hdr section, if present.
2024-01-04Update year range in copyright notice of binutils filesAlan Modra1-1/+1
Adds two new external authors to etc/update-copyright.py to cover bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then updates copyright messages as follows: 1) Update cgen/utils.scm emitted copyrights. 2) Run "etc/update-copyright.py --this-year" with an extra external author I haven't committed, 'Kalray SA.', to cover gas testsuite files (which should have their copyright message removed). 3) Build with --enable-maintainer-mode --enable-cgen-maint=yes. 4) Check out */po/*.pot which we don't update frequently.
2023-12-28x86: Add NT_X86_SHSTK noteSchimpe, Christina1-0/+2
Define NT_X86_SHSTK which is the note for x86 Shadow Stack (SHSTK) to support Intel SHSTK in Linux kernel. For now only userspace shadow stack and kernel IBT are supported by the linux kernel. This note should be used instead of NT_X86_CET introduced in the commit "x86: Add NT_X86_CET note", as it is outdated and only used by old binutils versions.
2023-11-14Improve objdump's handling of compressed sections.Nick Clifton1-146/+84
PR 31062 * objdump.c (decompressed_dumps): New local variable. (usage): Mention the -z/--decompress option. (long_options): Add --decompress. (dump_section_header): Add "COMPRESSED" to the Flags field of any compressed section. (dump_section): Warn users when dumping a compressed section. (display_any_bfd): Decompress the section if decompressed_dumps is true. (main): Handle the -z/--decompress option. * NEWS: Mention the new feature. * doc/binutils.texi: Document the new feature. * testsuite/binutils-all/objdump.s: Update expected output. * testsuite/binutils-all/objdump.exp: Add test of -Z -s. * testsuite/binutils-all/objdump.Zs: New file. * readelf.c (maybe_expand_or_relocate_section): New function. Contains common code found in dump functions. Adds a note message if a compressed section is not being decompressed. (dump_section_as_strings): Use new function. (dump_section_as_bytes): Likewise.
2023-11-10bfd, binutils: add gfx11 amdgpu architecturesSimon Marchi1-0/+3
Teach bfd and readelf about some recent gfx11 architectures. This code is taken from the rocgdb 5.7.x branch [1]. [1] https://github.com/rocm-Developer-Tools/rocgdb/tree/rocm-5.7.x bfd/ChangeLog: * archures.c (bfd_mach_amdgcn_gfx1100, bfd_mach_amdgcn_gfx1101, bfd_mach_amdgcn_gfx1102): New. * bfd-in2.h (bfd_mach_amdgcn_gfx1100, bfd_mach_amdgcn_gfx1101, bfd_mach_amdgcn_gfx1102): New. * cpu-amdgcn.c (arch_info_struct): Add entries for bfd_mach_amdgcn_gfx1100, bfd_mach_amdgcn_gfx1101, bfd_mach_amdgcn_gfx1102. binutils/ChangeLog: * readelf.c (decode_AMDGPU_machine_flags): Handle gfx1100, gfx1101, gfx1102. include/ChangeLog: * elf/amdgpu.h (EF_AMDGPU_MACH_AMDGCN_GFX1100, EF_AMDGPU_MACH_AMDGCN_GFX1101, EF_AMDGPU_MACH_AMDGCN_GFX1102): New. Change-Id: I95a8a62942e359781a1c9fa2079950fbcf2a78b8 Co-Authored-By: Laurent Morichetti <laurent.morichetti@amd.com> Cc: Lancelot Six <lancelot.six@amd.com>
2023-11-10MIPS: Change all E_MIPS_* to EF_MIPS_*Ying Huang1-38/+38
2023-10-20bfd: microblaze: Add 32_NONE reloc typeNeal Frager1-0/+4
This patch adds the R_MICROBLAZE_32_NONE relocation type. This is a 32-bit reloc that stores the 32-bit pc relative value in two words (with an imm instruction). Add test case to gas test suite. Signed-off-by: Neal Frager <neal.frager@amd.com> Signed-off-by: Michael J. Eager <eager@eagercon.com>
2023-10-07Revert "opcodes: microblaze: Add new bit-field instructions"Michael J. Eager1-4/+0
This reverts commit 6bbf249557ba17cfebe01c67370df4da9e6a56f9. Maciej W. Rozycki <macro@orcam.me.uk>: Yet it has caused numerous regressions: microblaze-elf +FAIL: unordered .debug_info references to .debug_ranges microblaze-elf +FAIL: binutils-all/pr26548 microblaze-elf +FAIL: readelf -Wwi pr26548e (reason: unexpected output) microblaze-elf +FAIL: readelf --debug-dump=loc locview-1 (reason: unexpected output) Yet it has caused numerous regressions: microblaze-elf +FAIL: unordered .debug_info references to .debug_ranges microblaze-elf +FAIL: binutils-all/pr26548 microblaze-elf +FAIL: readelf -Wwi pr26548e (reason: unexpected output) ...
2023-10-06opcodes: microblaze: Add new bit-field instructionsNeal Frager1-0/+4
This patches adds new bsefi and bsifi instructions. BSEFI- The instruction shall extract a bit field from a register and place it right-adjusted in the destination register. The other bits in the destination register shall be set to zero. BSIFI- The instruction shall insert a right-adjusted bit field from a register at another position in the destination register. The rest of the bits in the destination register shall be unchanged. Further documentation of these instructions can be found here: https://docs.xilinx.com/v/u/en-US/ug984-vivado-microblaze-ref This patch has been tested for years of AMD Xilinx Yocto releases as part of the following patch set: https://github.com/Xilinx/meta-xilinx/tree/master/meta-microblaze/recipes-devtools/binutils/binutils Signed-off-by: nagaraju <nagaraju.mekala@amd.com> Signed-off-by: Ibai Erkiaga <ibai.erkiaga-elorza@amd.com> Signed-off-by: Neal Frager <neal.frager@amd.com> Signed-off-by: Michael J. Eager <eager@eagercon.com>
2023-09-29x86-64: Add -z mark-plt and -z nomark-pltH.J. Lu1-0/+19
The PLT entry in executables and shared libraries contains an indirect branch, like jmp *foo@GOTPCREL(%rip) push $index_foo jmp .PLT0 or endbr64 jmp *foo@GOTPCREL(%rip) NOP padding which is used to branch to the function, foo, defined in another object. Each R_X86_64_JUMP_SLOT relocation has a corresponding PLT entry. The dynamic tags have been added to the x86-64 psABI to mark such PLT entries: https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/6d824a52a42d173eb838b879616c1be5870b593e Add an x86-64 linker option, -z mark-plt, to mark PLT entries with #define DT_X86_64_PLT (DT_LOPROC + 0) #define DT_X86_64_PLTSZ (DT_LOPROC + 1) #define DT_X86_64_PLTENT (DT_LOPROC + 3) 1. DT_X86_64_PLT: The address of the procedure linkage table. 2. DT_X86_64_PLTSZ: The total size, in bytes, of the procedure linkage table. 3. DT_X86_64_PLTENT: The size, in bytes, of a procedure linkage table entry. and set the r_addend field of the R_X86_64_JUMP_SLOT relocation to the memory offset of the indirect branch instruction. The dynamic linker can use these tags to update the PLT section to direct branch. bfd/ * elf-linker-x86.h (elf_linker_x86_params): Add mark_plt. * elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Set the r_addend of R_X86_64_JUMP_SLOT to the indirect branch offset in PLT entry for -z mark-plt. * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Add DT_X86_64_PLT, DT_X86_64_PLTSZ and DT_X86_64_PLTENT for -z mark-plt. (_bfd_x86_elf_finish_dynamic_sections): Set DT_X86_64_PLT, DT_X86_64_PLTSZ and DT_X86_64_PLTENT. (_bfd_x86_elf_get_synthetic_symtab): Ignore addend for JUMP_SLOT relocation. (_bfd_x86_elf_link_setup_gnu_properties): Set plt_indirect_branch_offset. * elfxx-x86.h (elf_x86_plt_layout): Add plt_indirect_branch_offset. binutils/ * readelf.c (get_x86_64_dynamic_type): New function. (get_dynamic_type): Call get_x86_64_dynamic_type. include/ * elf/x86-64.h (DT_X86_64_PLT): New. (DT_X86_64_PLTSZ): Likewise. (DT_X86_64_PLTENT): Likewise. ld/ * ld.texi: Document -z mark-plt and -z nomark-plt. * emulparams/elf32_x86_64.sh: Source x86-64-plt.sh. * emulparams/elf_x86_64.sh: Likewise. * emulparams/x86-64-plt.sh: New file. * testsuite/ld-x86-64/mark-plt-1.s: Likewise. * testsuite/ld-x86-64/mark-plt-1a-x32.d: Likewise. * testsuite/ld-x86-64/mark-plt-1a.d: Likewise. * testsuite/ld-x86-64/mark-plt-1b-x32.d: Likewise. * testsuite/ld-x86-64/mark-plt-1b.d: Likewise. * testsuite/ld-x86-64/mark-plt-1c-x32.d: Likewise. * testsuite/ld-x86-64/mark-plt-1c.d: Likewise. * testsuite/ld-x86-64/mark-plt-1d-x32.d: Likewise. * testsuite/ld-x86-64/mark-plt-1d.d: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run -z mark-plt tests.
2023-09-28Add support to readelf for the PT_OPENBSD_NOBTCFI segment type.Frederic Cambus1-0/+1
2023-09-20readelf.c 'ext' may be used uninitializedAlan Modra1-1/+1
* readelf.c (display_lto_symtab): Init ext.
2023-09-05readelf: Add option to display the names of sections referenced by symbols.Nick Clifton1-195/+320
PR 30684 * readelf.c (extra_sym_info): New variable. (section_name_valid): Also check for filedata being NULL. (section_name_print): Delete. (section_index_real): New function. Returns true if the given section index references a real section. (print_symbol): Rename to print_sumbol_name. (printable_section_name): Use a rotating array of static buffers for the return string. (printable_section_name_from_index): Merge code from dump_relocations and get_symbol_index_type into here. (long_option_values): Add OPTION_NO_EXTRA_SYM_INFO. (options): Add "extra-sym-info" and "no-extra-sym-info". (usage): Mention new options. (parse_args): Parse new options. (get_symbol_index_type): Delete. (print_dynamic_symbol_size): Rename to print_symbol_size. (print_dynamic_symbol): Rename to print_symbol. (print_symbol_table_heading): New function. (process_symbol_table): Use new function. * doc/binutils.texi: Document the new option. * NEWS: Mention the new feature.
2023-08-29readelf: typos in user messagesNicolas Boulenguez1-2/+2
2023-08-21aarch64/sme2: Teach binutils/BFD about the NT_ARM_ZT register setLuis Machado1-0/+2
The Scalable Matrix Extension v2 (SME2) defines a new register, ZT0, that the Linux Kernel handles through a new NT_ARM_ZT register set. Teach binutils/BFD about it so that gdb can make use of it for reading and writing core files. This also enables readelf/objdump to show the correct identification for the NT_ARM_ZT register set. Validated under Fast Models.
2023-08-16kvx: New port.Paul Iannetta1-0/+26
2023-08-03readelf sprintf optimisationAlan Modra1-721/+1050
This replaces sprintf and strcat calls with stpcpy, and makes use of sprintf return value rather than using strlen, for get_machine_flags. decode_NDS32_machine_flags made use of snprintf, which is arguably the "correct" way to do things if there can be a buffer overflow. In this case I don't think there can be, the buffer is 1k in size which is at least 5 times more than needed. What's more, snprintf returns the count of chars that would be output given no buffer limit, which means code like r += snprintf (buf + r, size - r, ...); r += snprintf (buf + r, size - r, ...); is just wrong. There needs to be a check on the return value in order to prevent buf + r being out of bounds for the second snprintf call. BTW, if you look closely you'll see the return value of the decode functions is unused. I admit to getting a little carried away with writing "out = stpcpy (out, ...):" in each of the decode functions and didn't notice that until get_machine_flags was trimmed down to a much smaller size. When I did notice, I decided it's not such a bad thing. * readelf.c (decode_ARC_machine_flags, decode_ARM_machine_flags), (decode_AVR_machine_flags, decode_NDS32_machine_flags), (decode_AMDGPU_machine_flags): Use stpcpy and sprintf return value. Return end of string. (decode_BLACKFIN_machine_flags, decode_FRV_machine_flags), (decode_IA64_machine_flags, decode_LOONGARCH_machine_flags), (decode_M68K_machine_flags, decode_MeP_machine_flags), (decode_MIPS_machine_flags, decode_MSP430_machine_flags), (decode_PARISC_machine_flags, decode_RISCV_machine_flags), (decode_RL78_machine_flags, decode_RX_machine_flags), (decode_SH_machine_flags, decode_SPARC_machine_flags), (decode_V800_machine_flags, decode_V850_machine_flags), (decode_Z80_machine_flags): New functions, split out from.. (get_machine_flags): ..here. Similarly use stpcpy.
2023-08-02Revert "2.41 Release sources"Sam James1-2/+34
This reverts commit 675b9d612cc59446e84e2c6d89b45500cb603a8d. See https://sourceware.org/pipermail/binutils/2023-August/128761.html.
2023-08-022.41 Release sourcesbinutils-2_41-releaseNick Clifton1-34/+2
2023-07-30bpf: include, bfd, opcodes: add EF_BPF_CPUVER ELF header flagsJose E. Marchesi1-0/+6
This patch adds support for EF_BPF_CPUVER bits in the ELF machine-dependent header flags. These bits encode the BPF CPU version for which the object file has been compiled for. The BPF assembler is updated so it annotates the object files it generates with these bits. The BPF disassembler is updated so it honors EF_BPF_CPUVER to use the appropriate ISA version if the user didn't specify an explicit ISA version in the command line. Note that a value of zero in EF_BPF_CPUVER is interpreted by the disassembler as "use the later supported version" (the BPF CPU versions start with v1.) The readelf utility is updated to pretty print EF_BPF_CPUVER when it prints out the ELF header: $ readelf -h a.out ELF Header: ... Flags: 0x4, CPU Version: 4 Tested in bpf-unknown-none. include/ChangeLog: 2023-07-30 Jose E. Marchesi <jose.marchesi@oracle.com> * elf/bpf.h (EF_BPF_CPUVER): Define. * opcode/bpf.h (BPF_XBPF): Change from 0xf to 0xff so it fits in EF_BPF_CPUVER. binutils/ChangeLog: 2023-07-30 Jose E. Marchesi <jose.marchesi@oracle.com> * readelf.c (get_machine_flags): Recognize and pretty print BPF machine flags. opcodes/ChangeLog: 2023-07-30 Jose E. Marchesi <jose.marchesi@oracle.com> * bpf-dis.c: Initialize asm_bpf_version to -1. (print_insn_bpf): Set BPF ISA version from the cpu version ELF header flags if no explicit version set in the command line. * disassemble.c (disassemble_init_for_target): Remove unused code. gas/ChangeLog: 2023-07-30 Jose E. Marchesi <jose.marchesi@oracle.com> * config/tc-bpf.h (elf_tc_final_processing): Define. * config/tc-bpf.c (bpf_elf_final_processing): New function.
2023-07-07arc: Update/Add ARCv3 support.Claudiu Zissulescu1-2/+28
The ARC HS5x and ARC HS6x processors are based on the new ARCv3 ISA that implements a full range of 32-bit and 64-bit instructions. These processors feature a high-speed 10-stage, dual-issue pipeline that offers increased utilization of functional units with a limited increase in power and area. The HS5x processors feature a 32-bit pipeline that can execute all ARCv3 32-bit instructions, while the HS6x processors feature a full 64-bit pipeline and register file that can execute both 32-bit and 64-bit instructions. In addition, the ARC HS6x supports 64-bit virtual and 52-bit physical address spaces to enable direct addressing of current and future large memories, as well as 128-bit loads and stores for efficient data movement. This readelf patch updates/adds Synopsys ARCv3 machine name fileds and supported relocations. Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-06-15Add MIPS Allegrex CPU as a MIPS2-based CPUDavid Guillen Fandos1-0/+1
The Allegrex CPU was created by Sony Interactive Entertainment to power their portable console, the PlayStation Portable. The pspdev organization maintains all sorts of tools to create software for said device including documentation. Signed-off-by: David Guillen Fandos <david@davidgf.net>
2023-06-06Re: loongarch readelf supportAlan Modra1-1/+1
Commit 89c70cd358b8 apparently results in a bogus "value may be used uninitialized" warning with some combination of compiler and optimisation options. * readelf.c (target_specific_reloc_handling): Init value.
2023-06-03Re: loongarch readelf supportAlan Modra1-2/+3
Another segfault. * readelf.c (target_specific_reloc_handling): Sanity check loongarch reloc r_offset.
2023-06-02loongarch readelf supportAlan Modra1-29/+34
This fixes two buffer overflows found by fuzzers. * readelf.c (target_specific_reloc_handling): Sanity check loongarch reloc symbol index. Don't apply reloc after errors. Reduce translation work of "invalid symbol index" error message.
2023-05-30LoongArch: binutils: Add support for linker relaxation.mengqinggang1-2/+82
Add support for relocs related to relax to readelf. binutils/ChangeLog: * readelf.c (target_specific_reloc_handling): Handle ULEB128 reloc. (is_32bit_inplace_add_reloc): Handle new reloc. (is_32bit_inplace_sub_reloc): Likewise. (is_64bit_inplace_add_reloc): Likewise. (is_64bit_inplace_sub_reloc): Likewise. (is_16bit_inplace_add_reloc): Likewise. (is_16bit_inplace_sub_reloc): Likewise. (is_8bit_inplace_add_reloc): Likewise. (is_8bit_inplace_sub_reloc): Likewise. (is_6bit_inplace_sub_reloc): Likewise. (is_6bit_inplace_add_reloc): New function. (apply_relocations): Handle new reloc. * testsuite/binutils-all/readelf.exp: Add -mno-relax option for LoongArch.
2023-05-22Re: readelf: Support SHT_RELR/DT_RELR for -rAlan Modra1-1/+1
Revert value of DT_ENCODING to as it was before commit a7fd118627, and adjust readelf. include/ * elf/common.h (DT_ENCODING): Set back to 32. binutils/ * readelf.c (struct filedata): Don't size dynamic_info array using DT_ENCODING.
2023-04-11Fix an attempt to allocate an overlarge amount of memory when decoding a ↵Nick Clifton1-6/+21
corrupt ELF format file. PR 30311 * readelf.c (uncompress_section_contents): Check for a suspiciously large uncompressed size.
2023-03-23Add support to readelf for the PT_OPENBSD_MUTABLE segment type.Frederic Cambus1-0/+1
binutils * readelf.c (get_segment_type): Handle PT_OPENBSD_MUTABLE segment type. include * elf/common.h (PT_OPENBSD_MUTABLE): Define.
2023-03-16readelf: add support for QNT_STACK note subsectionsClément Chigot1-0/+67
QNX provides some .note subsections. QNT_STACK is the one controling the stack allocation. bfd/ChangeLog: * elf.c (BFD_QNT_CORE_INFO): Delete. (BFD_QNT_CORE_STATUS): Likewise. (BFD_QNT_CORE_GREG): Likewise. (BFD_QNT_CORE_FPREG): Likewise. (elfcore_grok_nto_note): Replace BFD_QNT_* by QNT_*. binutils/ChangeLog: * readelf.c (get_qnx_elfcore_note_type): New function. (print_qnx_note): New function. (process_note): Add support for QNX support. include/ChangeLog: * elf/common.h (QNT_DEBUG_FULLPATH): New define. (QNT_DEBUG_RELOC): New define. (QNT_STACK): New define. (QNT_GENERATOR): New define. (QNT_DEFAULT_LIB): New define. (QNT_CORE_SYSINFO): New define. (QNT_CORE_INFO): New define. (QNT_CORE_STATUS): New define. (QNT_CORE_GREG): New define. (QNT_CORE_FPREG): New define. (QNT_LINK_MAP): New define.
2023-01-08PR29972, inconsistent format specification in singular formAlan Modra1-1/+1
PR 29972 * readelf.c (process_dynamic_section): Correct format string.
2023-01-03Add new NT_ARM_ZA and NT_ARM_SSVE register set constants.Luis Machado1-0/+4
2023-01-01Update year range in copyright notice of binutils filesAlan Modra1-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-06Compression header enumAlan Modra1-8/+8
Define an enum instead of using ELFCOMPRESS_ZLIB and ELFCOMPRESS_ZSTD in bfd and binutils, and move some functions from bfd.c to compress.c. When looking at the COFF/PE debug compression support, I wondered about extending it to support zstd. I likely won't do that, but the compression header ch_type field isn't just ELF specific if these headers are to be used in COFF/PE too. bfd/ * bfd.c (bfd_update_compression_header), (bfd_check_compression_header, bfd_get_compression_header_size), (bfd_convert_section_size, bfd_convert_section_contents): Move to.. * compress.c: ..here. (enum compression_type): New. Use it throughout file. * elf.c (_bfd_elf_make_section_from_shdr): Replace uses of ELFCOMPRESS_ZLIB and ELFCOMPRESS_ZSTD with ch_compress_zlib and ch_compress_zstd. * bfd-in2.h: Regenerate. binutils/ * readelf.c (process_section_headers, dump_section_as_strings), (dump_section_as_bytes, load_specific_debug_section): Replace uses of ELFCOMPRESS_ZLIB and ELFCOMPRESS_ZSTD with ch_compress_zlib and ch_compress_zstd.
2022-11-25Revert "readelf: Do not require EI_OSABI for IFUNC."Martin Liska1-3/+5
This reverts commit ffbbab0b3a1000f862b6d4ce3d9a76ed14f08801.
2022-11-24readelf: Do not require EI_OSABI for IFUNC.Martin Liska1-5/+3
PR 29718 binutils/ChangeLog: * readelf.c (get_symbol_type): Consider STT_GNU_IFUNC as reserved name.
2022-11-23Don't use "long" in readelf for file offsetsAlan Modra1-472/+505
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".