aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2024-10-03bfd: fix unnecessary bfd.info regenAlexey Izbyshev2-2/+2
When building from an unmodified release tarball, a REGEN_TEXI invocation is supposed to create a symlink to the .texi file in the source directory and discard the newly generated .tmp file. However, after commit bd32be01c997 ("bfd: merge doc subdir up a level") it creates the symlink at the wrong level, and then a .texi with a fresh timestamp, which in turn forces bfd.info regeneration. This breaks builds in environments without makeinfo program. Fix this by creating the symlink at the level of the target stamp. Fixes: bd32be01c997 ("bfd: merge doc subdir up a level") Signed-off-by: Alexey Izbyshev <izbyshev@ispras.ru>
2024-10-03peicode.h formattingAlan Modra1-69/+76
Fix some overlong line, comment block style, whitespace issues.
2024-10-03Don't return "(null)" from bfd_elf_sym_nameAlan Modra5-21/+24
A NULL return from bfd_elf_string_from_elf_section indicates an error. That shouldn't be masked by bfd_elf_sym_name but rather passed up to callers such as group_signature. If we want to print "(null)" then that should be done at a higher level. That's what this patch does, except that I chose to print "<null>" instead, like readelf. If we see "(null)" we're probably passing a NULL to printf. I haven't changed aoutx.h or pdp11.c print_symbol functions because they already handle NULL names by omitting the name. I also haven't changed mach-o.c, mmo.c, som.c, srec.c, tekhex.c, vms-alpha.c and wasm-module.c print_symbol function because it looks like they will never have NULL symbol names. bfd/ * elf.c (bfd_elf_sym_name): Don't turn a NULL name into a pointer to "(null)". (bfd_elf_print_symbol): Print "<null>" for NULL symbol names. * coffgen.c (coff_print_symbol): Likewise. * ecoff.c (_bfd_ecoff_print_symbol): Likewise. * pef.c (bfd_pef_print_symbol): Likewise. * syms.c (bfd_symbol_info): Return "<null>" in symbol_info.name if symbol name is NULL. ld/ * ldlang.c (ld_is_local_symbol): Don't check for "(null)" symbol name.
2024-10-03Automatic date update in version.inGDB Administrator1-1/+1
2024-10-02Add support for IMPORT_NAME_EXPORTAS in ILF (MSVC style) import librariesMartin Storsjö1-7/+36
This import name type is formally yet undocumented, but MSVC produces/supports it, primarily for ARM64EC import libraries. LLVM/LLD also supports this import name type. Since recently, llvm-dlltool also uses this type for certain kinds of renamed imports (that are easy to do in the long style import libraries produced by GNU dlltool, but require this name type in short import libraries). This name type contains a third string, in addition to the symbol name and the DLL name, indicating the actual imported name to reference in the import tables - which now can be distinct different from the symbol name on the object file level. https://github.com/llvm/llvm-project/commit/8f23464a5d957242c89ca6f33d4379c42519cd81 and https://github.com/llvm/llvm-project/commit/7b275aa2438c22604505d618dd37ee60052f2800 show how this import name type was added in LLVM. Signed-off-by: Martin Storsjö <martin@martin.st>
2024-10-02Automatic date update in version.inGDB Administrator1-1/+1
2024-10-01Automatic date update in version.inGDB Administrator1-1/+1
2024-10-01segv in bfd_elf_get_str_sectionAlan Modra2-2/+3
Attempting to write a termination NUL to PROT_READ mmap'd memory was a silly idea. PR 32109 * elf.c (bfd_elf_get_str_section): Don't write terminating NUL if missing. * libbfd.c (_bfd_munmap_readonly_temporary): Correct comment.
2024-09-30Automatic date update in version.inGDB Administrator1-1/+1
2024-09-29Automatic date update in version.inGDB Administrator1-1/+1
2024-09-28Automatic date update in version.inGDB Administrator1-1/+1
2024-09-27Automatic date update in version.inGDB Administrator1-1/+1
2024-09-26Fix -Wstringop-overflow warning in ecoff_link_hash_newfuncAndreas Schwab1-1/+1
* ecoff.c (ecoff_link_hash_newfunc): Don't call memset if ret is NULL.
2024-09-26Automatic date update in version.inGDB Administrator1-1/+1
2024-09-25RISC-V: Add Smrnmi extension csrs.Jiawei1-0/+1
This patch support Smrnmi extension[1], The csrs address can be find in[2]. [1] https://github.com/riscv/riscv-isa-manual/commit/35eb3948bf0b87c83fab5a7238bd68b6211faf62 [2] https://github.com/riscv/riscv-isa-manual/blob/smrnmi-1.0/src/priv-csrs.adoc bfd/ChangeLog: * elfxx-riscv.c: New extension. gas/ChangeLog: * NEWS: Add Smrnmi extension support. * config/tc-riscv.c (enum riscv_csr_class): New extension class. (riscv_csr_address): Ditto. * testsuite/gas/riscv/csr-version-1p10.d: New csrs. * testsuite/gas/riscv/csr-version-1p10.l: Ditto. * testsuite/gas/riscv/csr-version-1p11.d: Ditto. * testsuite/gas/riscv/csr-version-1p11.l: Ditto. * testsuite/gas/riscv/csr-version-1p12.d: Ditto. * testsuite/gas/riscv/csr-version-1p12.l: Ditto. * testsuite/gas/riscv/csr.s: Ditto. * testsuite/gas/riscv/march-help.l: New extension. include/ChangeLog: * opcode/riscv-opc.h (CSR_MNSCRATCH): New csr. (CSR_MNEPC): Ditto. (CSR_MNCAUSE): Ditto. (CSR_MNSTATUS): Ditto. (DECLARE_CSR): New csr declarations.
2024-09-25Automatic date update in version.inGDB Administrator1-1/+1
2024-09-24Automatic date update in version.inGDB Administrator1-1/+1
2024-09-23Automatic date update in version.inGDB Administrator1-1/+1
2024-09-22Automatic date update in version.inGDB Administrator1-1/+1
2024-09-21Automatic date update in version.inGDB Administrator1-1/+1
2024-09-20Automatic date update in version.inGDB Administrator1-1/+1
2024-09-19Automatic date update in version.inGDB Administrator1-1/+1
2024-09-18LoongArch: Add elfNN_loongarch_mkobject to initialize LoongArch tdataXin Wang1-0/+10
LoongArch: Add elfNN_loongarch_mkobject to initialize LoongArch tdata.
2024-09-18Automatic date update in version.inGDB Administrator1-1/+1
2024-09-17Automatic date update in version.inGDB Administrator1-1/+1
2024-09-16Automatic date update in version.inGDB Administrator1-1/+1
2024-09-15Automatic date update in version.inGDB Administrator1-1/+1
2024-09-14Automatic date update in version.inGDB Administrator1-1/+1
2024-09-13Automatic date update in version.inGDB Administrator1-1/+1
2024-09-12Automatic date update in version.inGDB Administrator1-1/+1
2024-09-11arm: Handle undefweak with ST_BRANCH_UNKNOWNChristophe Lyon1-1/+6
A previous patch made ld fail early on Thumb-only where branch_type is ST_BRANCH_UNKNOWN. However, this fails erroneously when the target is undefweak: in that case the branch should be replaced by a branch to the next instruction (or nop.w on thumb2). This patch accepts this case and restores the previous behaviour in such cases. This was reported by failures in the GCC testsuite, where we fail to link executables because __deregister_frame_info is undefweak: (__deregister_frame_info): Unknown destination type (ARM/Thumb) in ...crtbegin.o crtbegin.o: in function `__do_global_dtors_aux': crtstuff.c:(.text+0x52): dangerous relocation: unsupported relocation
2024-09-11Automatic date update in version.inGDB Administrator1-1/+1
2024-09-09bfd: Pass true to ld_plugin_object_pH.J. Lu1-1/+5
Since linker calls bfd_plugin_object_p, which calls ld_plugin_object_p, only for command-line input objects, pass true to ld_plugin_object_p so that the same input IR file won't be included twice if the new LTO hook, LDPT_REGISTER_CLAIM_FILE_HOOK_V2 isn't used. PR ld/32153 * plugin.c (bfd_plugin_object_p): Pass true to ld_plugin_object_p. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-09-10Automatic date update in version.inGDB Administrator1-1/+1
2024-09-09Automatic date update in version.inGDB Administrator1-1/+1
2024-09-08Automatic date update in version.inGDB Administrator1-1/+1
2024-09-07Not append rela for absolute symbolXin Wang1-1/+18
LoongArch: Not append rela for absolute symbol Use la.global to get absolute symbol like la.abs. la.global put address of a global symbol into a got entry and append a rela for it, which will be used to relocate by dynamic linker. Dynamic linker should not relocate for got entry of absolute symbol as it stores symval not symbol's address.
2024-09-07Add macros to get opcode of instructions approriatelyXin Wang1-33/+29
LoongArch: Add macros to get opcode and register of instructions appropriately Currently, we get opcode of an instruction by manipulate the binary with it's mask, it's a bit of a pain. Now a macro is defined to do this and a macro to get the RD and RJ registers which is applicable to most instructions of LoongArch are added.
2024-09-07Automatic date update in version.inGDB Administrator1-1/+1
2024-09-06bfd: Fix GCC warning when CFLAGS="-Og" is usedShahab Vahedi1-1/+1
This patch initializes the "op" variable in skip_cfa_op() function of bfd/elf-eh-frame.c to "0" at its declaration point to avoid the "maybe-uninitialized" warning. Building binutils on a system with GCC version 13.2.0 and a configure command that sets the optimization level to "-Og" leads to a build failure because of a warning being treated as an error: --------------------------------------------------------------------- $ ./configure CFLAGS="-Og" $ make ... CC elf-eh-frame.lo /src/gdb/bfd/elf-eh-frame.c: In function 'skip_cfa_op': /src/gdb/bfd/elf-eh-frame.c:354:33: error: 'op' may be used uninitialized [-Werror=maybe-uninitialized] 354 | switch (op & 0xc0 ? op & 0xc0 : op) | ~~~~~~~~~~~~~~~~~~~~~~^~~~ /src/gdb/bfd/elf-eh-frame.c:348:12: note: 'op' was declared here 348 | bfd_byte op; | ^~ cc1: all warnings being treated as errors ... --------------------------------------------------------------------- The relevant code snippet related to this warning looks like: --------------------------------------------------------------------- static inline bool read_byte (bfd_byte **iter, bfd_byte *end, unsigned char *result) { if (*iter >= end) return false; *result = *((*iter)++); return true; } static bool skip_cfa_op (bfd_byte **iter, bfd_byte *end,...) { bfd_byte op; if (!read_byte (iter, end, &op)) return false; switch (op & 0xc0 ? op & 0xc0 : op) ... } --------------------------------------------------------------------- This warning probably happens because "-Og" results in GCC not inlining the "read_byte()" function. Therefore, GCC treats its invocation inside "skip_cfa_op()" like a black box and that ends in the aforementioned warning. Acknowledgement: Lancelot Six -- for coming with the idea behind this fix. Jan Beulich -- for reviewing. bfd/ChangeLog: * elf-eh-frame.c (skip_cfa_op): Initialize the "op" variable.
2024-09-06bfd/PE: correct SizeOfImage calculationJan Beulich1-2/+2
We don't really want to align the last section's size to object alignment (when that section may itself not be aligned as much), we want image size to be a multiple thereof.
2024-09-06Automatic date update in version.inGDB Administrator1-1/+1
2024-09-05bfd/pdb: fix -Wmaybe-uninitialized warningMark Harmstone1-1/+1
Initialize stream0_start to fix spurious -Wmaybe-uninitialized warning on some versions of gcc.
2024-09-05PR32136, Use-of-uninitialized-memory in evax_bfd_print_imageAlan Modra1-15/+31
PR 32136 * vms-alpha.c (evax_bfd_print_image): Sanity check various string lengths.
2024-09-05LoongArch: Fixed ABI v1.00 TLS dynamic relocation generation bugLulu Cai1-47/+45
Commit "b67a17aa7c0c478a" modified the logic of allocating dynamic relocation space for TLS GD/IE, but only modified the logic of generation dynamic relocations for TLS GD/IE in ABI v2.00. When linking an object file of ABI v1.00 with bfd ld of ABI v2.00, it will cause an assertion failure. Modified the dynamic relocation generation logic of TLS GD/IE in ABI v1.00 to be consistent with ABI v2.00.
2024-09-05Automatic date update in version.inGDB Administrator1-1/+1
2024-09-04arm: Do not insert stubs needing Arm code on Thumb-only cores.Christophe Lyon1-12/+87
We recently fixed a bug in libgcc (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115360) where a symbol was missing a %function .type decoration. This meant the linker would silently pick the wrong type of 'farcall stub', involving Arm-mode instructions on Thumb-only CPUs. This patch emits an error instead, and warns in some other cases, to encourage users to add the missing '.type foo,%function' directive. In practice: in arm_type_of_stub() we no longer try to infer which stub to use if the destination is of unknown type and the CPU is Thumb-only; so we won't lie to elf32_arm_size_stubs() which does not check branch_type. If branch_type is ST_BRANCH_TO_ARM but the CPU is Thumb-only, we now convert it to ST_BRANCH_TO_THUMB only if the destination is of absolute type. This is to support the case where the destination of the branch is defined by the linker script (see thumb-b-lks-sym.s and thumb-bl-lks-sym.s testcases for instance). The motivating case is covered by the new farcall-missing-type testcase, where we now emit an error message. We do not emit an error when branch_type is ST_BRANCH_UNKNOWN and the CPU supports Arm-mode: a lot of legacy code (e.g. newlib's crt0.S) lacks the corresponding '.type foo, %function' directives and even a (too verbose) warning could be perceived as a nuisance. Existing testcases where such a warning would trigger: arm-static-app.s (app_func, app_func2) arm-rel32.s (foo) arm-app.s (app_func) rel32-reject.s () main) fix-arm1176.s (func_to_branch_to) but this list is not exhaustive. For the sake of clarity, the patch replaces occurrences of sym.st_target_internal = 0; with sym.st_target_internal = ST_BRANCH_TO_ARM; enum arm_st_branch_type is defined in include/elf/arm.h, and relies on ST_BRANCH_TO_ARM==0, as sym.st_target_internal is also initialized to 0 in other target-independent parts of BFD code. (For instance, swapping the ST_BRANCH_TO_ARM and ST_BRANCH_TO_THUMB entries in the enum definition leads to 'interesting' results...) Regarding the testsuite: * new expected warning for thumb-b-lks-sym and thumb-bl-lks-sym * new testcase farcall-missing-type to check the new error case * attr-merge-arch-2b.s, branch-futures (and bfs-1.s) updated to avoid a diagnostic Tested on arm-eabi and arm-pe with no regression.
2024-09-04bfd/pdb: fix bitmap generation in pdb_write_bitmapMark Harmstone1-9/+48
MSVC 2022 is more pedantic than MSVC 2019 when it comes to loading PDB files in readonly mode, and was rejecting PDB files generated by binutils because of their invalid free-space bitmaps. It's unknown what would have happened if you tried to use MS tools to modify a PDB created by binutils, but it probably would have led to a corrupted file. This patch fixes pdb_write_bitmap so we generate files that MSVC will accept. Specifically there were three things we were doing wrong: - We weren't including the superblock (block 0) - We were setting bits in bytes backwards (MSB to LSB, rather than LSB to MSB) - We should have been marking the contents of stream 0 as free. This is because, as the comment says, it's intended to be used for the directory for the previous write, to allow atomic updates.
2024-09-04Automatic date update in version.inGDB Administrator1-1/+1
2024-09-03RISC-V: Add support for XCVsimd extension in CV32E40PMary Bennett1-0/+5
Spec: https://docs.openhwgroup.org/projects/cv32e40p-user-manual/en/latest/instruction_set_extensions.html Contributors: Mary Bennett <mary.bennett682@gmail.com> Nandni Jamnadas <nandni.jamnadas@embecosm.com> Pietra Ferreira <pietra.ferreira@embecosm.com> Charlie Keaney Jessica Mills Craig Blackmore <craig.blackmore@embecosm.com> Simon Cook <simon.cook@embecosm.com> Jeremy Bennett <jeremy.bennett@embecosm.com> Helene Chelin <helene.chelin@embecosm.com> bfd/ChangeLog: * elfxx-riscv.c (riscv_multi_subset_supports): Add `xcvsimd` instruction class. (riscv_multi_subset_supports_ext): Likewise. gas/ChangeLog: * NEWS: Updated. * config/tc-riscv.c (validate_riscv_insn): Add custom operands. (riscv_ip): Likewise. * doc/c-riscv.texi: Note XCVsimd as an additional ISA extension for CORE-V. * testsuite/gas/riscv/march-help.l: Add xcvsimd. * testsuite/gas/riscv/x-cv-simd.d: New test. * testsuite/gas/riscv/x-cv-simd.s: New test. * testsuite/gas/riscv/x-cv-simd-fail.d: New test. * testsuite/gas/riscv/x-cv-simd-fail.l: New test. * testsuite/gas/riscv/x-cv-simd-fail.s: New test. include/ChangeLog: * opcode/riscv-opc.h: Add corresponding MATCH and MASK macros for XCVsimd. * opcode/riscv.h: Add corresponding EXTRACT and ENCODE macros for XCVsimd. (enum riscv_insn_class): Add the XCVsimd instruction class. opcodes/ChangeLog: * riscv-dis.c (print_insn_args): Add custom operands. * riscv-opc.c: Add XCVsimd instructions.