aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2022-09-07Automatic date update in version.inGDB Administrator1-1/+1
2022-09-06bfd: Add bfd_find_nearest_line_with_altAaron Merey36-17/+237
bfd_find_nearest_line_with_alt functions like bfd_find_nearest_line with the addition of a parameter for specifying the filename of a supplementary debug file such as one referenced by .gnu_debugaltlink or .debug_sup. This patch focuses on implementing bfd_find_nearest_line_with_alt support for ELF/DWARF2 .gnu_debugaltlink. For other targets this function simply sets the invalid_operation bfd_error.
2022-09-06Automatic date update in version.inGDB Administrator1-1/+1
2022-09-05Automatic date update in version.inGDB Administrator1-1/+1
2022-09-04Automatic date update in version.inGDB Administrator1-1/+1
2022-09-03Automatic date update in version.inGDB Administrator1-1/+1
2022-09-02xtensa: bfd: fix TLS relocations generated for PIEMax Filippov1-9/+10
When generating TLS dynamic relocations the existing xtensa BFD code treats linking to a PIE exactly as linking to a shared object, resulting in generation of wrong relocations for TLS entries. Fix that and add tests. bfd/ * elf32-xtensa.c (elf_xtensa_check_relocs): Use bfd_link_dll instead of bfd_link_pic. Add elf_xtensa_dynamic_symbol_p test when generating GOT entries. (elf_xtensa_relocate_section): Use bfd_link_dll instead of bfd_link_pic. ld/ * testsuite/ld-xtensa/tlspie.dd: New file. * testsuite/ld-xtensa/tlspie.rd: New file. * testsuite/ld-xtensa/tlspie.sd: New file. * testsuite/ld-xtensa/tlspie.td: New file. * testsuite/ld-xtensa/xtensa-linux.exp (TLS PIE transitions): New test.
2022-09-02Add OpenBSD ARM Little Endian BFD support.Frederic Cambus2-2/+5
* config.bfd (arm-*-openbsd*): Restore target.
2022-09-02Automatic date update in version.inGDB Administrator1-1/+1
2022-09-01Automatic date update in version.inGDB Administrator1-1/+1
2022-08-31Automatic date update in version.inGDB Administrator1-1/+1
2022-08-30BFD library: Use entry 0 in directory and filename tables of DWARF-5 debug info.Nick Clifton2-28/+70
PR 29529 * dwarf2.c (struct line_info_table): Add new field: use_dir_and_file_0. (concat_filename): Use new field to help select the correct table slot. (read_formatted_entries): Do not skip entry 0. (decode_line_info): Set new field depending upon the version of DWARF being parsed. Initialise filename based upon the setting of the new field.
2022-08-30RISC-V: Add 'Zmmul' extension in assembler.Tsukasa OI1-0/+6
Three-part patch set from Tsukasa OI to support zmmul in assembler. The 'Zmmul' is a RISC-V extension consisting of only multiply instructions (a subset of 'M' which has multiply and divide instructions). bfd/ * elfxx-riscv.c (riscv_implicit_subsets): Add 'Zmmul' implied by 'M'. (riscv_supported_std_z_ext): Add 'Zmmul' extension. (riscv_multi_subset_supports): Add handling for new instruction class. gas/ * testsuite/gas/riscv/attribute-09.d: Updated implicit 'Zmmul' by 'M'. * testsuite/gas/riscv/option-arch-02.d: Likewise. * testsuite/gas/riscv/m-ext.s: New test. * testsuite/gas/riscv/m-ext-32.d: New test (RV32). * testsuite/gas/riscv/m-ext-64.d: New test (RV64). * testsuite/gas/riscv/zmmul-32.d: New expected output. * testsuite/gas/riscv/zmmul-64.d: Likewise. * testsuite/gas/riscv/m-ext-fail-xlen-32.d: New test (failure by using RV64-only instructions in RV32). * testsuite/gas/riscv/m-ext-fail-xlen-32.l: Likewise. * testsuite/gas/riscv/m-ext-fail-zmmul-32.d: New failure test (RV32 + Zmmul but with no M). * testsuite/gas/riscv/m-ext-fail-zmmul-32.l: Likewise. * testsuite/gas/riscv/m-ext-fail-zmmul-64.d: New failure test (RV64 + Zmmul but with no M). * testsuite/gas/riscv/m-ext-fail-zmmul-64.l: Likewise. * testsuite/gas/riscv/m-ext-fail-noarch-64.d: New failure test (no Zmmul or M). * testsuite/gas/riscv/m-ext-fail-noarch-64.l: Likewise. include/ * opcode/riscv.h (enum riscv_insn_class): Added INSN_CLASS_ZMMUL. ld/ * testsuite/ld-riscv-elf/attr-merge-arch-01.d: We don't care zmmul in these testcases, so just replaced m by a. * testsuite/ld-riscv-elf/attr-merge-arch-01a.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-01b.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-02a.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-03a.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-user-ext-01.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-user-ext-rv32i2p1_a2p0.s: Renamed. * testsuite/ld-riscv-elf/attr-merge-user-ext-rv32i2p1_a2p1.s: Renamed. opcodes/ * riscv-opc.c (riscv_opcodes): Updated multiply instructions to zmmul.
2022-08-30Automatic date update in version.inGDB Administrator1-1/+1
2022-08-29Automatic date update in version.inGDB Administrator1-1/+1
2022-08-28Automatic date update in version.inGDB Administrator1-1/+1
2022-08-27bfd: Fix minor bug in read_indexed_address function.rupothar1-3/+3
read_indexed_address function is using offset_size instead of addr_size while reading addrx forms.
2022-08-27Automatic date update in version.inGDB Administrator1-1/+1
2022-08-26Automatic date update in version.inGDB Administrator1-1/+1
2022-08-25x86: Ignore protected visibility in shared libraries on SolarisH.J. Lu2-2/+4
On x86, the PLT entry in executable may be used as function address for functions in shared libraries. If functions are protected, the function address used in executable can be different from the function address used in shared library. This will lead to incorrect run-time behavior if function pointer equality is needed. By default, x86 linker issues an error in this case. On Solaris, linker issued an error for struct tm *tb = (kind == CPP_time_kind::FIXED ? gmtime : localtime) (&tt); where gmtime is a protected function in libc.so. Use gmtime's PLT entry in executable as function address is safe since function pointer equality isn't needed. Ignore protected visibility in shared libraries on Solaris to disable linker error. If function pointer equality is needed, linker will silently generate executable with incorrect run-time behavior on Solaris. PR ld/29512 * elf32-i386.c (elf_i386_scan_relocs): Ignore protected visibility in shared libraries on Solaris. * elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
2022-08-25PR11290, avr-ld "out of range error" is confusingAlan Modra3-32/+34
Don't overload bfd_reloc_outofrange with what is really a domain error (target at odd address), or an overflow. PR 11290 * reloc.c (bfd_reloc_other): Correct comment. * elf32-avr.c (avr_final_link_relocate): Return bfd_reloc_other for unaligned reloc target values. Return bfd_reloc_overflow when stubs are too far away and when R_AVR_LDS_STS_16, R_AVR_PORT6, or R_AVR_PORT5 overflow. (elf32_avr_relocate_section): Report more descriptive relocation errors. * bfd-in2.h: Regenerate.
2022-08-25Automatic date update in version.inGDB Administrator1-1/+1
2022-08-24LoongArch: ld: Fix bug not generate plt when link a dsoliuzhensong1-0/+6
Fix the bug that can not generate func@plt when linking a undefined function with cmodel=medium. Add testcase. bfd/ * elfnn-loongarch.c ld/testsuite/ld-loongarch-elf/ * cmodel-libjirl.dd * cmodel.exp * libjirl.s
2022-08-24Automatic date update in version.inGDB Administrator1-1/+1
2022-08-23SHT_RELR sh_link and sh_infoAlan Modra1-0/+1
I don't think it makes any sense for a SHT_RELR section to specify a symbol table with sh_link. SHT_RELR relocations don't use symbols. There is no real need to specify sh_info either, SHT_RELR is not for relocatable object files. Anyway, fuzzers of course don't restrict themselves to even half-sensible objects. So they found a hole in objcopy using a non-alloc SHT_RELR in an ET_EXEC. In that case BFD set up the SHT_RELR section as if it were a SHT_REL against the sh_info target section. When it came to reading in the target section relocs, the count was horribly wrong which caused a buffer overflow. * elf.c (bfd_section_from_shdr <SHT_RELR>): Always just make a normal section, don't treat it as a reloc section.
2022-08-23Re: bfd_elf_set_group_contents assertionAlan Modra1-5/+19
Further to commit 7744e3278b9f. * elf.c (bfd_elf_set_group_contents): Restrict loc in loop writing contents, and add another assertion.
2022-08-23Automatic date update in version.inGDB Administrator1-1/+1
2022-08-22Add OpenBSD AArch64 Little Endian BFD support.Frederic Cambus2-0/+9
* config.bfd (aarch64-*-openbsd*): Add target.
2022-08-22Automatic date update in version.inGDB Administrator1-1/+1
2022-08-21Automatic date update in version.inGDB Administrator1-1/+1
2022-08-21symbols for bfd_simple_get_relocated_section_contentsAlan Modra1-27/+15
If symbols are provided by the caller of this function they are passed on to bfd_get_relocated_section_contents. No surprises there. It gets a little weird if they are not provided. In that case they are read from the bfd by _bfd_generic_link_add_symbols, and global symbols are added to the generic linker hash table. Global symbols are not added to the linker hash table if symbols *are* provided. Now the linker hash table symbols are not used by the generic bfd_get_relocated_section_conents, and also not by most target versions when called from bfd_simple_get_relocated_section_contents except for symbols like "_gp". So it mostly doesn't matter whether symbols are in the linker hash table, but it's odd that there is a difference. We could always add them, but I'm inclined to think that is unnecessary work so this patch always leaves them out. Also, symbols are canonicalized and written into a malloc'd buffer. The buffer isn't freed, see commit 8e16317ca5eb. I don't know whether that matters any more, but in any case I can't see why we need another copy of the symbols when _bfd_generic_link_read_symbols has already cached symbols. * simple.c (bfd_simple_get_relocated_section_contents): If not provided, read symbols via bfd_generic_link_read_symbols. Do not create another copy of symbols. Tidy failure exits. Minor tidy of bfd_get_relocated_section_contents and bfd_get_full_section_contents arguments.
2022-08-20Automatic date update in version.inGDB Administrator1-1/+1
2022-08-19loongarch64_pei_vec garbage in objcopy'd relocsAlan Modra1-0/+4
Like commit a9c09a3667cc, but for loongarch64. * coff-loongarch64.c (SWAP_IN_RELOC_OFFSET): Define. (SWAP_OUT_RELOC_OFFSET): Define.
2022-08-19Automatic date update in version.inGDB Administrator1-1/+1
2022-08-18Automatic date update in version.inGDB Administrator1-1/+1
2022-08-17bfd_elf_set_group_contents assertionAlan Modra1-1/+6
objcopy of broken SHT_GROUP sections shouldn't write garbage. * elf.c (bfd_elf_set_group_contents): If number of entries is unexpected, fill out section with zeros.
2022-08-17timeout in mmo_get_symbolsAlan Modra1-7/+6
Fix mmo_get_byte to return a fail-safe value, not just on the first call with a read error but on subsequent calls too. * mmo.c (mmo_get_byte): Return the fail-safe value on every call after a read error.
2022-08-17mmo.c leak in mmo_make_sectionAlan Modra1-7/+5
* mmo.c (mmo_make_section): Alloc name using bfd_alloc. Use bfd_error_no_memory. (mmo_decide_section): Check for NULL return from mmo_make_section.
2022-08-17asan: heap buffer overflow in mmo_scanAlan Modra1-12/+14
mmo_get_loc needs to handle arbitrary vma and size chunks. Fuzzers found that it wasn't working so well when the end of chunks were getting close to address wrap-around. * mmo.c (mmo_get_loc): Make "size" unsigned. Avoid arithmetic overflow when calculating whether range hits an existing chunk.
2022-08-17elf.c tidyAlan Modra1-138/+160
Swap params of is_note, so they are section, segment like others used in rewrite_elf_program_header. Whitespace fixes, plus wrapping of overlong lines.
2022-08-17Automatic date update in version.inGDB Administrator1-1/+1
2022-08-16bfd: Define ___lc_codepage_func prototype for older MinGW-w64Torbjörn SVENSSON1-0/+5
In commit 68e80d96a84282d547f3b3c1234c99009521630c, the usage of ___lc_codepage_func was introduced to determine the current encoding. Prior to version 9.0 of MinGW-w64, the function prototype for ___lc_codepage_func was missing and trying to build BFD caused the following error: error: implicit declaration of function ‘___lc_codepage_func’ This changeset adds a conditonal definition of ___lc_codepage_func to allow a sucessful build with MinGW-w64. Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2022-08-16PR29495, rewrite_elf_program_header loopingAlan Modra1-65/+75
This patch, in order of significance: 1) Replaces some macros with inline functions. 2) Those inline functions catch and avoid arithmetic overflows when comparing addresses. 3) When assigning sections to segments (IS_SECTION_IN_INPUT_SEGMENT) use bed->want_p_paddr_set_to_zero to decide whether lma vs p_paddr or vma vs p_vaddr should be tested. When remapping, use the same test, and use is_note rather than the more restrictive IS_COREFILE_NOTE. It's important that the later tests not be more restrictive. If they are it can lead to the situation triggered by the testcases, where a section seemingly didn't fit and thus needed a new mapping. It didn't fit the new mapping either, and this repeated until memory exhausted. PR 29495 * elf.c (SEGMENT_END, SECTION_SIZE, IS_CONTAINED_BY_VMA): Delete. (IS_CONTAINED_BY_LMA, IS_NOTE, IS_COREFILE_NOTE): Delete. (segment_size, segment_end, section_size): New inline function. (is_contained_by, is_note): Likewise. (rewrite_elf_program_header): Use new functions.
2022-08-16Automatic date update in version.inGDB Administrator1-1/+1
2022-08-15aarch64_pei_vecAlan Modra1-0/+4
I know this target is just a skeleton, but let's not write out relocs with uninitialised garbage. * coff-aarch64.c (SWAP_IN_RELOC_OFFSET): Define. (SWAP_OUT_RELOC_OFFSET): Define.
2022-08-15Automatic date update in version.inGDB Administrator1-1/+1
2022-08-14Automatic date update in version.inGDB Administrator1-1/+1
2022-08-13PR29482 - strip: heap-buffer-overflowAlan Modra1-2/+5
PR 29482 * coffcode.h (coff_set_section_contents): Sanity check _LIB.
2022-08-13asan: NULL dereference in spu_elf_object_pAlan Modra1-1/+2
* elf32-spu.c (spu_elf_object_p): Don't dereference NULL shdr->bfd_section.
2022-08-13ubsan: undefined shift in sign_extendAlan Modra1-1/+1
* libhppa.h (sign_extend): Avoid undefined behaviour.