aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2024-10-04is_target_special_symbol fixes for commit 68bbe1183379Alan Modra3-3/+13
* elf.c (_bfd_elf_is_local_label_name): Don't segv on NULL name. * elf32-v850.c (v850_elf_is_local_label_name): Likewise. * elfnn-riscv.c (riscv_elf_is_target_special_symbol): Likewise.
2024-10-04get_synthetic_symtab fixes for commit 68bbe1183379Alan Modra6-132/+158
Given that relocation symbol name can now be NULL for ELF, adjust various get_synthetic_symtab routines so they don't segfault. * elf.c (_bfd_elf_get_synthetic_symtab): Cope with sym->name possibly being NULL. * elf32-arm.c (elf32_arm_get_synthetic_symtab): Likewise. * elf32-ppc.c (ppc_elf_get_synthetic_symtab): Likewise. * elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Likewise. * elfxx-mips.c (_bfd_mips_elf_get_synthetic_symtab): Likewise. * elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Likewise.
2024-10-04bfd_elf_sym_name_rawAlan Modra4-10/+21
Many uses of bfd_elf_sym_name report errors. They ought to not return a NULL, as was the case prior to commit 68bbe1183379. Introduce a new function for cases where we'd like to know there is a problem with a symbol st_name. * elf-bfd.h (bfd_elf_sym_name_raw): Declare. * elf.c (bfd_elf_sym_name_raw): New function. (bfd_elf_sym_name): Revert to behaviour prior to 68bbe1183379, but returning "<null>" rather than "(null)" for st_name errors. (group_signature): Use bfd_elf_sym_name_raw. * elfcode.h (elf_slurp_symbol_table): Likewise. * elf32-i386.c (elf_i386_scan_relocs): Whitespace.
2024-10-04Automatic date update in version.inGDB Administrator1-1/+1
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