aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2023-03-20Reloc howto access broken for BPFCupertino Miranda1-1/+4
Forgot to change the logic to access the reloc howto from bpf_elf_relocate_section. Problem was introduced in previous BPF commit.
2023-03-20Automatic date update in version.inGDB Administrator1-1/+1
2023-03-19Enable vector register visibility in core file for AIX binutilsAditya Vidyadhar Kamath2-1/+36
This patch will enable vector register visibility when AIX FOLKS do core file analysis.
2023-03-19XCOFF archive sanity checkAlan Modra1-4/+10
XCOFF archive elements are in a linked list. Add a little more sanity checking. This of course doesn't stop the fuzzers finding a way to make a loop, but this check is cheap. * coff-rs6000.c (_bfd_xcoff_openr_next_archived_file): Sanity check that next element isn't pointing back to the header.
2023-03-19rewrite_elf_program_header and want_p_paddr_set_to_zeroAlan Modra1-7/+8
Layout in rewrite_elf_program_header is really done by lma, even if program headers are going to have their p_paddr forced to zero. Thus when not matching against an existing segment, don't try to use a "vma" from elf_segment_map. * elf.c (is_contained_by): Replace "bed" param with "use_vaddr". (IS_SECTION_IN_INPUT_SEGMENT): Adjust is_contained_by call. (rewrite_elf_program_header): Always match against lma in calls to is_contained_by using new maps.
2023-03-19Automatic date update in version.inGDB Administrator1-1/+1
2023-03-18Automatic date update in version.inGDB Administrator1-1/+1
2023-03-17mach-o: out of memory in get_dynamic_reloc_upper_boundAlan Modra1-26/+29
* mach-o.c (bfd_mach_o_canonicalize_dynamic_reloc): Move sanity checks.. (bfd_mach_o_get_dynamic_reloc_upper_bound): ..to here.
2023-03-17Automatic date update in version.inGDB Administrator1-1/+1
2023-03-16readelf: add support for QNT_STACK note subsectionsClément Chigot1-9/+4
QNX provides some .note subsections. QNT_STACK is the one controling the stack allocation. bfd/ChangeLog: * elf.c (BFD_QNT_CORE_INFO): Delete. (BFD_QNT_CORE_STATUS): Likewise. (BFD_QNT_CORE_GREG): Likewise. (BFD_QNT_CORE_FPREG): Likewise. (elfcore_grok_nto_note): Replace BFD_QNT_* by QNT_*. binutils/ChangeLog: * readelf.c (get_qnx_elfcore_note_type): New function. (print_qnx_note): New function. (process_note): Add support for QNX support. include/ChangeLog: * elf/common.h (QNT_DEBUG_FULLPATH): New define. (QNT_DEBUG_RELOC): New define. (QNT_STACK): New define. (QNT_GENERATOR): New define. (QNT_DEFAULT_LIB): New define. (QNT_CORE_SYSINFO): New define. (QNT_CORE_INFO): New define. (QNT_CORE_STATUS): New define. (QNT_CORE_GREG): New define. (QNT_CORE_FPREG): New define. (QNT_LINK_MAP): New define.
2023-03-16configure: add new target aarch64-*-nto*Clément Chigot1-1/+1
This target has its own ld emulation based on aarch64elf.em.
2023-03-16BPF relocations review / refactoringCupertino Miranda5-279/+121
- Removed not needed relocations. - Renamed relocations to match llvm and linux kernel. Relocation changes: R_BPF_INSN_64 => R_BPF_64_64 R_BPF_INSN_DISP32 => R_BPF_64_32 R_BPF_DATA_32 => R_BPF_64_ABS32 R_BPF_DATA_64 => R_BPF_64_ABS64 ChangeLog: * bfd/bpf-reloc.def: Created file with BPF_HOWTO macro entries. * bfd/reloc.c: Removed non needed relocations. * bfd/bfd-in2.h: regenerated. * bfd/libbfd.h: regenerated. * bfd/elf64-bpf.c: Changed relocations. * include/elf/bpf.h: Adapted relocation values/names. * gas/config/tc-bpf.c: Changed relocation mapping.
2023-03-16Automatic date update in version.inGDB Administrator1-1/+1
2023-03-15Automatic date update in version.inGDB Administrator1-1/+1
2023-03-14Automatic date update in version.inGDB Administrator1-1/+1
2023-03-13Automatic date update in version.inGDB Administrator1-1/+1
2023-03-12Automatic date update in version.inGDB Administrator1-1/+1
2023-03-11Automatic date update in version.inGDB Administrator1-1/+1
2023-03-10ld: Allow R_386_GOT32 for call *__tls_get_addr@GOT(%reg)Fangrui Song1-1/+2
Similar to d58854b6dd88e05dbf2a5d1c32c5acb7bd6ea274 for x86_64. _Thread_local int a; int main() { return a; } % gcc -m32 -fno-plt -fpic a.c -fuse-ld=bfd -Wa,-mrelax-relocations=no /usr/bin/ld.bfd: /tmp/ccR8Yexy.o: TLS transition from R_386_TLS_GD to R_386_TLS_IE_32 against `a' at 0x15 in section `.text' failed /usr/bin/ld.bfd: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status This commit fixes the issue. There is an argument that the -fno-plt TLS sequence was added after R_386_GOT32X was required for call *func@GOT(%ebx), so R_386_GOT32 was intended to be unsupported. Unfortunately this standpoint has caused interop difficulty: some projects specify -mrelax-relocations=no to build relocatable object files compatible with older linkers (e.g. https://github.com/IHaskell/IHaskell/issues/636) or do so by accident (e.g. https://github.com/rust-lang/rust/pull/106511 not addressed as of today). Many uses have not been cleaned up in practice, and compiling with -fno-plt will lead to the `TLS transition from R_386_TLS_GD ...` error which is hard to reason about. It seems easier to apply this simple change to prevent the footgun. PR ld/24784 * bfd/elf32-i386.c (elf_i386_check_tls_transition): Allow R_386_GOT32.
2023-03-10ld: Allow R_X86_64_GOTPCREL for call *__tls_get_addr@GOTPCREL(%rip)Fangrui Song1-1/+1
_Thread_local int a; int main() { return a; } % gcc -fno-plt -fpic a.c -fuse-ld=bfd -Wa,-mrelax-relocations=no /usr/bin/ld.bfd: /tmp/ccSSBgrg.o: TLS transition from R_X86_64_TLSGD to R_X86_64_GOTTPOFF against `a' at 0xd in section `.text' failed /usr/bin/ld.bfd: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status This commit fixes the issue. There is an argument that the -fno-plt TLS sequence was added after R_X86_64_GOTPCRELX was required for call, so R_X86_64_GOTPCREL was intended to be unsupported. Unfortunately this standpoint has caused interop difficulty: some projects specify -mrelax-relocations=no to build relocatable object files compatible with older linkers (e.g. https://github.com/IHaskell/IHaskell/issues/636) or do so by accident (e.g. https://github.com/rust-lang/rust/pull/106511 not addressed as of today). Many uses have not been cleaned up in practice, and compiling with -fno-plt will lead to the `TLS transition from R_X86_64_TLSGD ...` error which is hard to reason about. There is another argument which may be weaker but relevant to the necessity of -mrelax-relocations=no: HWAddressSanitizer x86-64 will likely need some assembler support to disable relaxation. Without the support and if the compiler needs to support many gas version, the simplest solution would be to use -Wa,-mrelax-relocations=no. PR ld/24784 * bfd/elf64-x86-64.c (elf_x86_64_check_tls_transition): Allow R_X86_64_GOTPCREL.
2023-03-10Automatic date update in version.inGDB Administrator1-1/+1
2023-03-09Automatic date update in version.inGDB Administrator1-1/+1
2023-03-08Tidy pe_ILF_build_a_bfd a littleAlan Modra1-33/+31
* peicode.h (ILF section, pe_ILF_object_p): Correct comments and update the reference to Microsoft's docs. (pe_ILF_build_a_bfd): Move all symbol creation before flipping the bfd over to in-memory.
2023-03-08z8 and z80 coff_reloc16_extra_cases sanity checksAlan Modra5-132/+182
* reloc16.c (bfd_coff_reloc16_get_relocated_section_contents): Use size_t variables. Sanity check reloc address. Handle errors from bfd_coff_reloc16_extra_cases. * coffcode.h (_bfd_coff_reloc16_extra_cases): Return bool, take size_t* args. (dummy_reloc16_extra_cases): Adjust to suit. Don't abort. * coff-z80.c (extra_case): Sanity check reloc address. Return errors. Tidy formatting. Use bfd_signed_vma temp var to check for reloc overflow. Don't abort on unexpected reloc type, instead print an error and return false. * coff-z8k.c (extra_case): Likewise. * libcoff.h: Regenerate.
2023-03-08Automatic date update in version.inGDB Administrator1-1/+1
2023-03-07Automatic date update in version.inGDB Administrator1-1/+1
2023-03-06macho null dereference readAlan Modra1-3/+3
The main problem here was not returning -1 from canonicalize_symtab on an error, leaving the vector of relocs only partly initialised and one with a null sym_ptr_ptr. * mach-o.c (bfd_mach_o_canonicalize_symtab): Return -1 on error, not 0. (bfd_mach_o_pre_canonicalize_one_reloc): Init sym_ptr_ptr to undefined section sym.
2023-03-06PR30198, Assertion and segfault when linking x86_64 elf and coffAlan Modra1-8/+12
PR 30198 * coff-x86_64.c (coff_amd64_reloc): Set *error_message when returning bfd_reloc_dangerous. Also check that __ImageBase is defined before accessing h->u.def.
2023-03-06More _bfd_ecoff_locate_line sanity checksAlan Modra1-2/+11
* ecofflink.c (mk_fdrtab): Discard fdr with negative cpd. (lookup_line): Sanity check fdr cbLineOffset and cbLine. Sanity check pdr cbLineOffset.
2023-03-06Correct odd loop in ecoff lookup_lineAlan Modra1-6/+3
I can't see why this really odd looking loop was written the way it was in commit a877f5917f90, but it can result in a buffer overrun. * ecofflink.c (lookup_line): Don't swap in pdr at pdr_end.
2023-03-06Automatic date update in version.inGDB Administrator1-1/+1
2023-03-05Automatic date update in version.inGDB Administrator1-1/+1
2023-03-04Automatic date update in version.inGDB Administrator1-1/+1
2023-03-03Automatic date update in version.inGDB Administrator1-1/+1
2023-03-02Don't write zeros to a gap in the output fileAlan Modra1-20/+6
Writing out zeros is counterproductive if a file system supports sparse files. A very large gap need not take much actual disk space, but it usually will if zeros are written. memory_bseek also supports not writing out zeros in a gap. * elf.c (write_zeros): Delete. (assign_file_positions_for_load_sections): Don't call write_zeros. Comment.
2023-03-02Automatic date update in version.inGDB Administrator1-1/+1
2023-03-01Automatic date update in version.inGDB Administrator1-1/+1
2023-02-28chew.c printf of intptr_tAlan Modra1-1/+2
Seen when building binutils with gcc -m32 on x86_64-linux. chew.c: In function ‘print’: chew.c:1434:59: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘intptr_t’ {aka ‘int’} [-Wformat=] 1434 | fprintf (stderr, "print: illegal print destination `%ld'\n", *isp); | ~~^ ~~~~ | | | | | intptr_t {aka int} | long int | %d * chew.c: Include inttypes.h. (print): Use PRIdPTR for *isp.
2023-02-28Free ecoff debug infoAlan Modra1-48/+59
This frees memory associated with the mips ecoff find_nearest_line. * elfxx-mips.x (free_ecoff_debug): New function, extracted from.. (_bfd_mips_elf_read_ecoff_info): ..here. Free ext_hdr earlier. Don't clear already NULL fdr. (struct mips_elf_find_line): Move earlier. (_bfd_mips_elf_close_and_cleanup): Call free_ecoff_debug. (_bfd_mips_elf_find_nearest_line): Likewise on error paths, and to clean up input_debug when done.
2023-02-28Add some sanity checking in ECOFF lookup_lineAlan Modra1-44/+102
More anti-fuzzer bounds checking for the ECOFF support. A lot of this is in ancient code using "long" for counts and sizes, which is why the patch uses "(long) ((unsigned long) x + 1) > 0" in a few places. The unsigned long cast is so that "x + 1" doesn't trigger ubsan warnings about signed integer overflow. It would be a good idea to replace most of the longs used in binutils with size_t, but that's more than I care to do for COFF/ECOFF. * ecofflink.c (mk_fdrtab): Sanity check string offsets. (lookup_line): Likewise, and symbol indices.
2023-02-28Another PE SEC_HAS_CONTENTS testAlan Modra1-1/+2
I'd skipped this one before, thinking "obfd, that's the linker output bfd so no need to test". Wrong, this is objcopy output. * peXXigen.c (_bfd_XX_bfd_copy_private_bfd_data_common): Test SEC_HAS_CONTENTS before reading section.
2023-02-28Automatic date update in version.inGDB Administrator1-1/+1
2023-02-27Fix missing "Core was generated by" when loading a x32 corefile.Felix Willgerodt2-2/+19
2023-02-27Automatic date update in version.inGDB Administrator1-1/+1
2023-02-26Automatic date update in version.inGDB Administrator1-1/+1
2023-02-25Automatic date update in version.inGDB Administrator1-1/+1
2023-02-24Enhance better_fit() function to prefer function symbols over non-function ↵Nick Clifton1-15/+37
symbols.
2023-02-23RISC-V: Add --[no-]relax-gp to ldFangrui Song3-2/+35
--relax enables all relaxations. --no-relax-gp disables GP relaxation to allow measuring its effect. The option can test effectiveness of GP relaxation and support some ABI variants that use GP for other purposes. Link: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/298 bfd/ * elfnn-riscv.c (struct riscv_elf_link_hash_table): Add params. (riscv_elfNN_set_options): New. (riscv_info_to_howto_rela): Check relax_gp. (_bfd_riscv_relax_section): Likewise. * elfxx-riscv.h (struct riscv_elf_params): New. (riscv_elf32_set_options): New. (riscv_elf64_set_options): New. ld/ * emultempl/riscvelf.em: Add option parsing. * testsuite/ld-riscv-elf/code-model-relax-medlow-01-norelaxgp.d: New. * testsuite/ld-riscv-elf/pcgp-relax-01-norelaxgp.d: New. * testsuite/ld-riscv-elf/pcgp-relax-02.d: Test --relax --relax-gp can be used together.
2023-02-24Automatic date update in version.inGDB Administrator1-1/+1
2023-02-23Fix _bfd_elf_find_function so that it can cope with overlapping symbolsNick Clifton1-22/+82