aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
9 daysAutomatic date update in version.inHEADmasterGDB Administrator1-1/+1
10 daysAutomatic date update in version.inGDB Administrator1-1/+1
11 daysAutomatic date update in version.inGDB Administrator1-1/+1
11 daysaarch64: Support for FEAT_CMPBREzra Sitorus4-0/+15
FEAT_CMPBR - Compare and branch instructions. This patch adds these instructions: - CB<CC> (register) - CB<CC> (immediate) - CBH<CC> - CBB<CC> where CC is one of the following: - EQ - NE - GT - GE - LT - LE - HI - HS - LO - LS
12 daysAutomatic date update in version.inGDB Administrator1-1/+1
13 daysLoongArch: Batch-delete bytes at the end of each relax tripWANG Xuerui1-52/+298
Previously, memmove and reloc/symbol adjustments happened at each loongarch_relax_delete_bytes() call, which is O(n^2) time complexity and leads to unacceptable (multiple hours) linking times for certain inputs with huge number of relaxable sites -- see the linked issue for details. To get rid of the quadratic behavior, defer all delete ops to the end of each relax trip, with the buffer implemented with the splay tree from libiberty. The individual relaxation handlers are converted to handle symbol values and relocation offsets as if all preceding deletions actually happened, by querying a cumulative offset from the splay tree; the accesses should be efficient because they are mostly sequential during a relaxation trip. The exact relaxation behavior remains largely unchanged. Example running times before and after the change with the test case in the linked issue (mypy transpiled C), cross-linking on Threadripper 3990X: Before: 4192.80s user 1.09s system 98% cpu 1:10:53.52 total After: 1.76s user 0.74s system 98% cpu 2.539 total - ~1/2382 the time! Also tested with binutils (bootstrapping self), CPython 3.14 and LLVM 20.1.6; all passed the respective test suites. Link: https://github.com/loongson-community/discussions/issues/56 Signed-off-by: WANG Xuerui <git@xen0n.name>
13 daysAutomatic date update in version.inGDB Administrator1-1/+1
2025-06-17Automatic date update in version.inGDB Administrator1-1/+1
2025-06-16bfd: fix a minor typoIndu Bhagat1-1/+1
2025-06-16Automatic date update in version.inGDB Administrator1-1/+1
2025-06-15Automatic date update in version.inGDB Administrator1-1/+1
2025-06-14Automatic date update in version.inGDB Administrator1-1/+1
2025-06-13elf: Return false if output_section is NULLH.J. Lu1-1/+5
Return false if output_section is NULL so that on input https://sourceware.org/bugzilla/attachment.cgi?id=16131 objcopy generates objcopy: /tmp/objcopy-poc(OrcError.cpp.o): invalid entry (0x22000000) in group [3] objcopy: /tmp/objcopy-poc(OrcError.cpp.o): invalid entry (0x21000000) in group [3] objcopy: /tmp/objcopy-poc(OrcError.cpp.o)(.text._ZNK12_GLOBAL__N_116OrcErrorCategory7messageB5cxx11Ei): relocation 29 has invalid symbol index 1160982879 objcopy: /tmp/stv73zYw/OrcError.cpp.o[.text._ZN4llvm3orc8orcErrorENS0_12OrcErrorCodeE]: bad value instead of objcopy: /tmp/objcopy-poc(OrcError.cpp.o): invalid entry (0x22000000) in group [3] objcopy: /tmp/objcopy-poc(OrcError.cpp.o): invalid entry (0x21000000) in group [3] objcopy: /tmp/objcopy-poc(OrcError.cpp.o)(.text._ZNK12_GLOBAL__N_116OrcErrorCategory7messageB5cxx11Ei): relocation 29 has invalid symbol index 1160982879 Segmentation fault (core dumped) PR binutils/33075 * elf.c (elf_map_symbols): Return false if output_section is NULL. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-06-13bfd: populate delay import directory in PE headerJeremy Drake1-1/+49
Previously, the delay import table was constructed but its rva and size were never put into the PE optional header. Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
2025-06-13bfd,ld,dlltool: Emit delay-load import data into its own sectionLIU Hao13-0/+37
A delay-import symbol (of a function) is resolved when a call to it is made. The delay loader may overwrite the `__imp_` pointer to the actual function after it has been resolved, which requires the pointer itself be in a writeable section. Previously it was placed in the ordinary Import Address Table (IAT), which is emitted into the `.idata` section, which had been changed to read-only in db00f6c3aceabbf03acdb69e74b59b2d2b043cd7, which caused segmentation faults when functions from delay-import library were called. This is PR 32675. This commit makes DLLTOOL emit delay-import IAT into `.didat`, as specified by Microsoft. Most of the code is copied from `.idata`, except that this section is writeable. As a side-effect of this, PR 14339 is also fixed. Using this DEF: ``` ; ws2_32.def LIBRARY "WS2_32.DLL" EXPORTS WSAGetLastError ``` and this C program: ``` // delay.c #define WIN32_LEAN_AND_MEAN 1 #include <windows.h> #include <stdio.h> ///////////////////////////////////////////////////////// // User code ///////////////////////////////////////////////////////// DWORD WINAPI WSAGetLastError(void); extern PVOID __imp_WSAGetLastError; int main(void) { fprintf(stderr, "before delay load, __imp_WSAGetLastError = %p\n", __imp_WSAGetLastError); SetLastError(123); fprintf(stderr, "WSAGetLastError() = %d\n", WSAGetLastError()); fprintf(stderr, "after delay load, __imp_WSAGetLastError = %p\n", __imp_WSAGetLastError); __imp_WSAGetLastError = (PVOID) 1234567; fprintf(stderr, "after plain write, __imp_WSAGetLastError = %p\n", __imp_WSAGetLastError); } ///////////////////////////////////////////////////////// // Overridden `__delayLoadHelper2` facility ///////////////////////////////////////////////////////// extern char __ImageBase[]; PVOID WINAPI ResolveDelayLoadedAPI(PVOID ParentModuleBase, LPCVOID DelayloadDescriptor, PVOID FailureDllHook, PVOID FailureSystemHook, FARPROC* ThunkAddress, ULONG Flags); FARPROC WINAPI DelayLoadFailureHook(LPCSTR name, LPCSTR function); FARPROC WINAPI __delayLoadHelper2(LPCVOID pidd, FARPROC* ppfnIATEntry) { return ResolveDelayLoadedAPI(&__ImageBase, pidd, NULL, (PVOID) DelayLoadFailureHook, ppfnIATEntry, 0); } ``` This program used to crash: ``` $ dlltool -nn -d ws2_32.def -y delay_ws2_32.a $ gcc -g delay.c delay_ws2_32.a -o delay.exe $ ./delay.exe before delay load, __imp_WSAGetLastError = 00007FF6937215C6 Segmentation fault ``` After this commit, it loads and calls `WSAGetLastError()` properly, and `__imp_WSAGetLastError` is writeable: ``` $ dlltool -nn -d ws2_32.def -y delay_ws2_32.a $ gcc -g delay.c delay_ws2_32.a -o delay.exe $ ./delay.exe before delay load, __imp_WSAGetLastError = 00007FF76E2215C6 WSAGetLastError() = 123 after delay load, __imp_WSAGetLastError = 00007FFF191FA720 after plain write, __imp_WSAGetLastError = 000000000012D687 ``` Reference: https://learn.microsoft.com/en-us/windows/win32/secbp/pe-metadata#import-handling Co-authored-by: Jeremy Drake <sourceware-bugzilla@jdrake.com> Signed-off-by: LIU Hao <lh_mouse@126.com> Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
2025-06-13Automatic date update in version.inGDB Administrator1-1/+1
2025-06-12Automatic date update in version.inGDB Administrator1-1/+1
2025-06-11ld: arm32: fix segfault when linking foreign BFDs [PR32870]dongjianqiang (A)1-0/+3
PR ld/32870 The linker may occasionally need to process a BFD that is from a non-Arm architecture. There will not be any Arm-specific tdata in that case, so skip such BFDs when looking for iplt information as the necessary tdata will not be present.
2025-06-11Automatic date update in version.inGDB Administrator1-1/+1
2025-06-10RISC-V: Add Smrnmi extension imply relation.Jiawei1-0/+1
This patch adds the dependency of Smrnmi extension on Zicsr extension. bfd/ChangeLog: * elfxx-riscv.c: New imply. gas/ChangeLog: * testsuite/gas/riscv/imply.d: New test check. * testsuite/gas/riscv/imply.s: New imply test. Signed-off-by: Jiawei <jiawei@iscas.ac.cn>
2025-06-10RISC-V: Add support for svvptc extension.Dongyan Chen1-0/+1
This implements the svvptc extensons, version 1.0[1]. [1] https://github.com/riscv/riscv-svvptc bfd/ChangeLog: * elfxx-riscv.c: New extension. gas/ChangeLog: * NEWS: Updated. * testsuite/gas/riscv/march-help.l: Ditto.
2025-06-10Automatic date update in version.inGDB Administrator1-1/+1
2025-06-09Automatic date update in version.inGDB Administrator1-1/+1
2025-06-08Automatic date update in version.inGDB Administrator1-1/+1
2025-06-07Automatic date update in version.inGDB Administrator1-1/+1
2025-06-06bfd: sframe: fix typo in commentsIndu Bhagat1-3/+3
bfd/ * elflink.c (elf_link_input_bfd): Replace ctf frame with SFrame.
2025-06-06Automatic date update in version.inGDB Administrator1-1/+1
2025-06-05Automatic date update in version.inGDB Administrator1-1/+1
2025-06-04Reject compressed sections exceding 4 GiB on LLP64 machinesRui Ueyama1-4/+12
According to the zlib FAQ (*1), zlib does not support compressed data larger than 4 GiB when the compiler's long type is 32 bits. Therefore, we need to report an error if a zlib-compressed debug section exceeds 4 GiB on LLP64 machines. (*1) https://zlib.net/zlib_faq.html#faq32 Signed-off-by: Rui Ueyama <rui314@gmail.com>
2025-06-04Automatic date update in version.inGDB Administrator1-1/+1
2025-06-03Add checks for illegal symbol binding and type values when reading ELF symbols.Nick Clifton1-11/+38
PR 33019
2025-06-03Automatic date update in version.inGDB Administrator1-1/+1
2025-06-02Automatic date update in version.inGDB Administrator1-1/+1
2025-06-01Have bfd_thread_init fail when thread-local storage is unavailableTom Tromey1-13/+21
If thread-local storage is unavailable, bfd_thread_init should fail, because in this case BFD can't be used from multiple threads -- it relies on TLS working.
2025-06-01decompress_contents: fuss over 32-bit longAlan Modra1-2/+4
Some 64-bit compilers have a 32-bit long, which could result in an endless loop if uncompressed_size is larger than 4G.
2025-06-01PR 33033, Support compressed debug sections larger than 4 GiBRui Ueyama1-39/+12
z_stream's avail_in and avail_out are defined as "unsigned int", so it cannot decode an entire compressed stream in one pass if the stream is larger than 4 GiB. The simplest solution to this problem is to use zlib's convenient uncompress2() function, which handles the details for us. Signed-off-by: Rui Ueyama <rui314@gmail.com>
2025-06-01Automatic date update in version.inGDB Administrator1-1/+1
2025-05-31Define TLS in bfd.c if not already definedTom Tromey1-0/+6
If configure decides that thread-local storage isn't available, it does not define "TLS". However, this is used unconditionally in a definition. So, define it if it isn't already defined.
2025-05-31Automatic date update in version.inGDB Administrator1-1/+1
2025-05-31PR 33020 segv in _bfd_elf_strtab_offsetAlan Modra1-8/+9
The PR fuzzer testcase creates a SHT_NOBITS .debug_info section, then triggers a bug in --compress-debug-sections=zlib whereby sh_name is set to -1 in elf_fake_sections as a flag to indicate the name is not set yet (may change to zdebug_*), but the section never hits the debug compression code in assign_file_positions_for_non_load_sections that is responsible for setting sh_name. PR 33020 * elf.c (_bfd_elf_init_reloc_shdr): Rename delay_st_name_p param to delay_sh_name_p. (elf_fake_sections): Rename delay_st_name_p to delay_sh_name_p. Don't set delay_sh_name_p for no contents debug sections.
2025-05-31Revert "Replace assertions with error return values, thus ensuring an ↵Alan Modra2-9/+7
illegal memory access does not occur." This reverts commit 429fb15134cfbdafe2b203086ee05d827726b63b.
2025-05-30Prevent illegal memory access when generating map file entries for ifuncs ↵Nick Clifton1-0/+6
removed by garbage collection
2025-05-30Replace assertions with error return values, thus ensuring an illegal memory ↵Nick Clifton2-7/+9
access does not occur. PR 33020
2025-05-30Updated Malay translation for the bfd/ sub-directoryNick Clifton1-1246/+1424
2025-05-30Automatic date update in version.inGDB Administrator1-1/+1
2025-05-29Automatic date update in version.inGDB Administrator1-1/+1
2025-05-28PR 33021, buffer overflow in write_dwarf_eh_frame_hdrAlan Modra1-1/+1
* elf-eh-frame.c (write_dwarf_eh_frame_hdr): Use size of contents, not section size, in bfd_set_section_contents call.
2025-05-28PR 33018 segv in elf_x86_64_scan_relocsAlan Modra1-1/+7
* elf64-x86-64.c (elf_x86_64_scan_relocs): Error on NULL howto. Use bfd_reloc_offset_in_range.
2025-05-28Automatic date update in version.inGDB Administrator1-1/+1
2025-05-27Automatic date update in version.inGDB Administrator1-1/+1