aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2023-11-03Automatic date update in version.inGDB Administrator1-1/+1
2023-11-02Automatic date update in version.inGDB Administrator1-1/+1
2023-11-01Automatic date update in version.inGDB Administrator1-1/+1
2023-10-31Automatic date update in version.inGDB Administrator1-1/+1
2023-10-30Accept and ignore the R_BPF_64_NODLYD32 relocation.Nick Clifton2-0/+21
2023-10-30Automatic date update in version.inGDB Administrator1-1/+1
2023-10-29Automatic date update in version.inGDB Administrator1-1/+1
2023-10-28Automatic date update in version.inGDB Administrator1-1/+1
2023-10-27RISC-V: Clarify the behaviors of SET/ADD/SUB relocations.Nelson Chu1-6/+16
We are used to generate these kinds of relocations by data directives. Considering the following example, .word (A + 3) - (B + 2) The GAS will generate a pair of ADD/SUB for this, R_RISCV_ADD, A + 1 R_RISCV_SUB, 0 The addend of R_RISCV_SUB will always be zero, and the summary of the constants will be stored in the addend of R_RISCV_ADD/SET. Therefore, we can always add the addend of these data relocations when doing relocations. But unfortunately, I had heard that if we are using .reloc to generate the data relocations will make the relocations failed. Refer to this, .reloc offset, R_RISCV_ADD32, A + 3 .reloc offset, R_RISCV_SUB32, B + 2 .word 0 Then we can get the relocations as follows, R_RISCV_ADD, A + 3 R_RISCV_SUB, B + 2 Then... Current LD does the relocation, B - A + 3 + 2, which is wrong obviously... So first of all, this patch fixes the wrong relocation behavior of R_RISCV_SUB* relocations. Afterwards, considering the uleb128 direcitve, we will get a pair of SET_ULEB128/SUB_ULEB128 relocations for it for now, .uleb128 (A + 3) - (B + 2) R_RISCV_SET_ULEB128, A + 1 R_RISCV_SUB_ULEB128, B + 1 Which looks also wrong obviously, the summary of the constants should only be stored into the addend of SET_ULEB128, and the addend of SUB_ULEB128 should be zero like other SUB relocations. But the current LD will still get the right relocation values since we only add the addend of SUB_ULEB128 by accident... Anyway, this patch also fixes the behaviors above, to make sure that no matter using .uleb128 or .reloc directives, we should always get the right values. bfd/ * elfnn-riscv.c (perform_relocation): Clarify that SUB relocations should substract the addend, rather than add. (riscv_elf_relocate_section): Since SET_ULEB128 won't go into perform_relocation, we should add it's addend here in advance. gas/ * config/tc-riscv.c (riscv_insert_uleb128_fixes): Set the addend of SUB_ULEB128 to zero since it should already be added into the addend of SET_ULEB128.
2023-10-27Automatic date update in version.inGDB Administrator1-1/+1
2023-10-26Automatic date update in version.inGDB Administrator1-1/+1
2023-10-25asan: _bfd_elf_slurp_version_tables memory leakAlan Modra1-2/+3
Extends commit 6136093c0d00 to handle verdefs as well as verrefs. PR 30886 * elf.c (_bfd_elf_slurp_version_tables): See free_contents for verdefs too. Use free_contents rather than elf_tdata fields.
2023-10-25asan: out of memory in som_set_reloc_infoAlan Modra1-18/+20
Sections without SEC_HAS_CONTENTS avoid the file size checks, and of course it doesn't make sense to read such as the contents are all zero. * som.c (som_set_reloc_info): Don't read sections without contents.
2023-10-25asan: NULL deref in alpha_ecoff_get_relocated_section_contentsAlan Modra1-9/+47
This fixes some holes found by fuzzers, and removes aborts that can be triggered by user input to objdump. Abort should only be used within bfd to show programming errors in bfd. * coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Handle NULL howto. Don't abort on stack errors or on unexpected relocs. Show more bfd reloc status messages.
2023-10-25Automatic date update in version.inGDB Administrator1-1/+1
2023-10-24as: fixed internal error when immediate value of relocation overflow.Lulu Cai1-6/+16
The as and ld use _bfd_error_handler to output error messages when checking relocation alignment and relocation overflow. However, the abfd value passed by as to the function is NULL, resulting in an internal error. The ld passes a non-null value to the function, so it can output an error message normally.
2023-10-24Automatic date update in version.inGDB Administrator1-1/+1
2023-10-23Automatic date update in version.inGDB Administrator1-1/+1
2023-10-23bfd-in2.h BFD_RELOC_* commentsAlan Modra5-1647/+1576
I noticed the regenerated BFD_RELOC_MICROBLAZE_32_NONE comment didn't match that committed to bfd-in2.h, and was just going to regen bfd-in2.h but then decided to do something about the silly formatting of these comments in bfd-in2.h. eg. the BFD_RELOC_MICROBLAZE_32_NONE comment: -/* This is a 32 bit reloc that stores the 32 bit pc relative -value in two words (with an imm instruction).No relocation is -done here - only used for relaxing */ + /* This is a 32 bit reloc that stores the 32 bit pc relative value in + two words (with an imm instruction). No relocation is done here - + only used for relaxing. */ BFD_RELOC_MICROBLAZE_32_NONE, You'll notice how the second and third line of the original comment aren't indented properly relative to the first line, and the whole comment needs to be indented to match the code. I've also edited reloc.c ENUMDOC paragraphs. Some of these had excess indentation, presumably in an attempt to properly indent bfd-in2.h comments but that fails due to chew.c removing leading whitespace early by skip_white_and_stars. COMMENT was used in reloc.c to add extra blank lines in bfd-in2.h. I've removed them too as I don't think they add anything to readability of that file. (Perhaps more usefully, they also add blank lines to libbfd.h separating relocs for one target from others, but this isn't done consistently.) * doc/chew.c (drop, idrop): Move earlier. (strip_trailing_newlines): Check index before accessing array, not after. (wrap_comment): New function. (main): Add "wrap_comment" intrinsic. * doc/proto.str (ENUMDOC): Use wrap_comment. (make_enum_header, ENDSENUM): Put start and end braces on separate lines. * reloc.c: Remove uses of COMMENT and edit ENUMDOC paragraphs. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate.
2023-10-22Automatic date update in version.inGDB Administrator1-1/+1
2023-10-21Automatic date update in version.inGDB Administrator1-1/+1
2023-10-20bfd: microblaze: Add 32_NONE reloc typeNeal Frager4-2/+34
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-20Automatic date update in version.inGDB Administrator1-1/+1
2023-10-19RISC-V: Don't do undefweak relaxations for the linker_def symbols.Nelson Chu1-0/+6
I get the following truncated errors recently when running riscv-gnu-toolchain regressions, /scratch/riscv-gnu-toolchain/regression/build/linux-rv32imafdc-ilp32d-medlow/build-glibc-linux-rv32imafdc-ilp32d/libc.a(libc-start.o): in function `elf_irela': /scratch/riscv-gnu-toolchain/glibc/csu/../sysdeps/riscv/dl-irel.h:47:(.text+0x88): relocation truncated to fit: R_RISCV_GPREL_I against symbol `__ehdr_start' defined in .note.ABI-tag section in /scratch/riscv-gnu-toolchain/regression/build/linux-rv32imafdc-ilp32d-medlow/build-glibc-linux-rv32imafdc-ilp32d/elf/sln The linker_def symbols like __ehdr_start that may be undefweak in early stages of linking, including relax stage, but are guaranteed to be defined later. Therefore, it seems like we shouldn't do the undefweak relaxations for these kinds of symbols since they may be defined after relaxations. bfd/ * elfnn-riscv.c (_bfd_riscv_relax_section): Don't do undefweak relaxations for the linker_def symbols.
2023-10-19Automatic date update in version.inGDB Administrator1-1/+1
2023-10-18LoongArch: Correct comments.caiyinyu1-1/+1
2023-10-18Automatic date update in version.inGDB Administrator1-1/+1
2023-10-17LoongArch: readelf -d RELASZ excludes .rela.plt sizemengqinggang1-0/+2
Before, readelf -d RELASZ is the sum of .rela.dyn size and .rela.plt size. To consistent with LoongArch lld, RELASZ chang to only the size of .rela.dyn.
2023-10-17asan: Invalid free in alpha_ecoff_get_relocated_section_contentsAlan Modra1-2/+2
This fixes an ancient bug in commit a3a33af390 (which makes me think this code has never been used). * coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Iterate through reloc_vector using a temp.
2023-10-17Automatic date update in version.inGDB Administrator1-1/+1
2023-10-16Fix: GNU-ld: ARM: Issues when trying to set target output architectureNick Clifton2-9/+16
PR 28910 * elf32-arm.c (elf32_arm_merge_private_bfd_data): Do not set output flags if the input flags have not been set.
2023-10-16RISC-V: Remove RV64E conflictTsukasa OI1-7/+0
Since RV32E *and* RV64E are ratified, RV64E is no longer invalid. This commit removes a restriction that prevents making base ISA with reduced GPRs with XLEN > 32. bfd/ChangeLog: * elfxx-riscv.c (riscv_parse_check_conflicts): Remove RV64E conflict since the ratified 'E' base ISAs include RV64E. gas/ChangeLog: * testsuite/gas/riscv/march-fail-base-02.d: Removed. * testsuite/gas/riscv/march-fail-base-02.l: Removed.
2023-10-16Automatic date update in version.inGDB Administrator1-1/+1
2023-10-15Automatic date update in version.inGDB Administrator1-1/+1
2023-10-14Automatic date update in version.inGDB Administrator1-1/+1
2023-10-13Automatic date update in version.inGDB Administrator1-1/+1
2023-10-12bfd: add new bfd_cache_size() functionAndrew Burgess2-0/+19
In GDB we have a problem with the BFD cache. As GDB runs for a potentially extended period of time, if the BFD cache holds a file descriptor for an open on-disk file, this can, on some targets (e.g. Win32) prevent the OS writing to the file. This might, for example, prevent a user from recompiling their executable as GDB is (via the BFD cache) holding an open reference to that file. Another problem, relates to bfd_stat, for BFDs that are using the BFD cache (i.e. they call cache_bstat to implement bfd_stat). The cache_bstat function finds the BFD in the cache, opening the file if needed, and then uses fstat on the open file descriptor. What this means is that, if the on-disk file changes, but the cache was holding an open reference to the file, the bfd_stat will return the 'struct stat' for the old file, not the new file. Now, for this second problem, we might be tempted to make use of an actual stat call, instead of calling bfd_stat, however, this isn't ideal as we have some BFDs that use a custom iovec, and implement the various functions over GDB's remote protocol. By using bfd_stat we can have a single call that should work for both local files, and for remote files. To solve both of these problems GDB has calls to bfd_cache_close_all sprinkled around its code base. And in theory this should work fine. However, I recently ran into a case where we had missed a bfd_cache_close_all call, and as a result some BFDs were held open. This caused a bfd_stat call to return an unexpected result (old file vs new file). What I'd like is some way within GDB that I can do: gdb_assert ( /* Nothing is held open in the cache. */ ); As this would allow GDB to quickly identify when we've missed some bfd_cache_close_all calls. And so, to support this, I would like to add a new bfd_cache_size function. This function returns an integer, which is the number of open files in the cache. I can then start adding: gdb_assert (bfd_cache_size() == 0); to GDB in some strategic spots, and start fixing all of the missing bfd_cache_close_all calls that crop up as a result.
2023-10-12bfd/cache: change type used to track cached BFDs from int to unsignedAndrew Burgess1-3/+4
Within bfd/cache.c change the type for max_open_files and open_files variables from int to unsigned. As a consequence of this, the return type for bfd_cache_max_open() is also changed from int to unsigned. Within bfd_cache_max_open I've left the local 'max' variable as an int, this should ensure that if the sysconf call fails, and returns -1, then the computed max value will be less than 10, which means max_open_files will be set to 10. If 'max' was changed to unsigned then, should the sysconf call fail, we'd end up with max becoming a very large positive number ... which is clearly not what we want. And, while I was auditing how open_files is used, I added an assert within bfd_cache_delete to ensure that we don't try to reduce open_files below zero. There should be no user visible change with this commit.
2023-10-12Automatic date update in version.inGDB Administrator1-1/+1
2023-10-11Automatic date update in version.inGDB Administrator1-1/+1
2023-10-10asan: buffer overflow in elf32_arm_get_synthetic_symtabAlan Modra1-8/+16
Guard against fuzzed files where .plt size isn't commensurate with plt relocations. * elf32-arm.c (elf32_arm_plt0_size): Add data_size param. Return -1 if data_size is too small. (elf32_arm_plt_size): Likewise. Delete temp var. Formatting. (elf32_arm_get_synthetic_symtab): Adjust to suit.
2023-10-10asan: invalid free in bfd_init_section_compress_statusAlan Modra1-8/+8
With specially crafted compressed sections, it's possible to tickle a problem when decompressing: If the compression headers says the uncompressed size is zero, this will be seen as an error return from bfd_compress_section_contents. On errors the caller should free any malloc'd input buffers, but this isn't really an error and the section contents have been updated to a bfd_alloc'd buffer which can't be freed. * compress.c (bfd_compress_section_contents): Return -1 as error rather than 0. (bfd_init_section_compress_status, bfd_compress_section): Adjust.
2023-10-10Automatic date update in version.inGDB Administrator1-1/+1
2023-10-09Fix: Null pointer dereference in elf32-i386.cNick Clifton2-0/+10
PR 30950 * elf32-i386.c (elf_i386_convert_load_reloc): Check for elf_x86_hash_table returning a NULL pointer.
2023-10-09Fix: A potential bug of null pointer dereferenceNick Clifton2-1/+7
PR 30949 * elflink.c (elf_gc_mark_debug_section): Check for bfd_section_from_elf_index returning a NULL pointer.
2023-10-09Automatic date update in version.inGDB Administrator1-1/+1
2023-10-08Automatic date update in version.inGDB Administrator1-1/+1
2023-10-07Revert "opcodes: microblaze: Add new bit-field instructions"Michael J. Eager4-83/+2
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-07Automatic date update in version.inGDB Administrator1-1/+1
2023-10-06opcodes: microblaze: Add new bit-field instructionsNeal Frager4-2/+83
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>