aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2023-06-26Automatic date update in version.inGDB Administrator1-1/+1
2023-06-25Automatic date update in version.inGDB Administrator1-1/+1
2023-06-24Automatic date update in version.inGDB Administrator1-1/+1
2023-06-23Automatic date update in version.inGDB Administrator1-1/+1
2023-06-22Automatic date update in version.inGDB Administrator1-1/+1
2023-06-21x86: Free the symbol buffer and the relocation buffer after useH.J. Lu1-14/+28
When --no-keep-memory is used, the symbol buffer and the relocation buffer aren't cached. When packing relative relocations, we may allocate a new symbol buffer and a new relocation buffer for each eligible section in an object file. If there are many sections, memory may be exhausted. In this case, we should free the symbol buffer and the relocation buffer after use. If symbol buffer entries are used to track relative relocations against local symbols for later use, the symbol buffer should be cached. PR ld/30566 * elfxx-x86.c (elf_x86_relative_reloc_record_add): Add an argument to inform caller if the symbol buffer should be kept. (_bfd_x86_elf_link_relax_section): Call _bfd_elf_link_info_read_relocs instead of _bfd_elf_link_read_relocs. Free the symbol buffer and the relocation buffer after use. Cache the symbol buffer if it is used.
2023-06-21elf32_arm_get_synthetic_symtab memory leakAlan Modra1-15/+10
ARM get_synthetic_symtab reads .plt and caches that data. Caching the data doesn't make a lot of sense since get_synthetic_symtab is only called once per bfd, and the memory might be put to better use. It also leaks on closing the bfd. * elf32-arm.c (elf32_arm_get_synthetic_symtab): Don't cache plt contents. Free plt data before returning.
2023-06-21macho-o.c don't leak strtabAlan Modra1-0/+2
* mach-o.c (bfd_mach_o_write_symtab_content): Free strtab on success path.
2023-06-21Automatic date update in version.inGDB Administrator1-1/+1
2023-06-20Don't segfault in mips reloc special_functionsAlan Modra4-13/+30
A symbol defined in a section from a shared library will have a NULL section->output_section during linking. * elf32-mips.c (gprel32_with_gp): Don't segfault on NULL symbol->section->output_section. * elf64-mips.c (mips_elf64_gprel32_reloc): Likewise. * elfn32-mips.c (mips_elf_gprel16_reloc): Likewise. (mips_elf_literal_reloc, mips_elf_gprel32_reloc): Likewise. (gprel32_with_gp, mips16_gprel_reloc): Likewise. * elfxx-mips.c (_bfd_mips_elf_gprel16_with_gp): Likewise. (_bfd_mips_elf_generic_reloc): Likewise.
2023-06-20Automatic date update in version.inGDB Administrator1-1/+1
2023-06-19Fix illegal memory access implementing relocs in a fuzzed x86_64 object file.Nick Clifton2-0/+21
PR 30560 * elf64-x86-64.c (elf_x86_64_relocate_section): Add more checks for a valid relocation offset.
2023-06-19Automatic date update in version.inGDB Administrator1-1/+1
2023-06-18Automatic date update in version.inGDB Administrator1-1/+1
2023-06-17Automatic date update in version.inGDB Administrator1-1/+1
2023-06-16LoongArch: Fix ld "undefined reference" error with --enable-sharedmengqinggang2-0/+9
Because _bfd_read_unsigned_leb128 is hidden visibility, so it can't be referenced out of shared object. The new function loongarch_get_uleb128_length just used to call _bfd_read_unsigned_leb128. bfd/ChangeLog: * elfxx-loongarch.c (loongarch_get_uleb128_length): New function. * elfxx-loongarch.h (loongarch_get_uleb128_length): New function. gas/ChangeLog: * config/tc-loongarch.c (md_apply_fix): Use loongarch_get_uleb128_length.
2023-06-16Automatic date update in version.inGDB Administrator1-1/+1
2023-06-15Add MIPS Allegrex CPU as a MIPS2-based CPUDavid Guillen Fandos4-0/+12
The Allegrex CPU was created by Sony Interactive Entertainment to power their portable console, the PlayStation Portable. The pspdev organization maintains all sorts of tools to create software for said device including documentation. Signed-off-by: David Guillen Fandos <david@davidgf.net>
2023-06-15Revert "MIPS: default r6 if vendor is img"Maciej W. Rozycki1-1/+1
This reverts commit be0d391f22fe6009c3be907753975a984cbbcc23. It was applied unapproved.
2023-06-15vms write_archive memory leaksAlan Modra1-0/+2
This fixes two memory leaks in the vms archive handling. * vms-lib.c (_bfd_vms_lib_build_map): Free input symbols. (_bfd_vms_lib_write_archive_contents): Free archive map symbols.
2023-06-15Automatic date update in version.inGDB Administrator1-1/+1
2023-06-14asprintf memory leaksAlan Modra8-75/+96
A number of backends want to return bfd_reloc_dangerous messaqes from relocation special_function, and construct the message using asprintf. Such messages are not freed anywhere, leading to small memory leaks inside libbfd. To limit the leaks, I'd implemented a static buffer in the ppc backends that was freed before use in asprintf output. This patch extends that scheme to other backends using a shared static buffer and goes further in freeing the buffer on any bfd_close. The patch also fixes a few other cases where asprintf output was not freed after use. bfd/ * bfd.c (_input_error_msg): Make global and rename to.. (_bfd_error_buf): ..this. (bfd_asprintf): New function. (bfd_errmsg): Use bfd_asprintf. * opncls.c (bfd_close_all_done): Free _buf_error_buf. * elf32-arm.c (find_thumb_glue, find_arm_glue): Use bfd_asprintf. * elf32-nios2.c (nios2_elf32_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_unhandled_reloc): Likewise. * elf64-ppc.c (ppc64_elf_unhandled_reloc): Likewise. * elfnn-riscv.c (riscv_resolve_pcrel_lo_relocs): Likewise. (riscv_elf_relocate_section): Likewise. * libbfd.h: Regenerate. gas/ * read.c (read_end): Free current_name and current_label. (do_s_func): Likewise on error path. strdup label. ld/ * pe-dll.c (make_head, make_tail, make_one), (make_singleton_name_thunk, make_import_fixup_entry), (make_runtime_pseudo_reloc), (pe_create_runtime_relocator_reference: Free oname after use.
2023-06-14Re: bfd/elf.c strtab memory leakAlan Modra1-9/+9
There are other places that leak the strtab. * elf.c (_bfd_elf_compute_section_file_positions): Free strtab on error paths.
2023-06-14Automatic date update in version.inGDB Administrator1-1/+1
2023-06-13Automatic date update in version.inGDB Administrator1-1/+1
2023-06-12Automatic date update in version.inGDB Administrator1-1/+1
2023-06-11Automatic date update in version.inGDB Administrator1-1/+1
2023-06-10Automatic date update in version.inGDB Administrator1-1/+1
2023-06-09ecoff find_nearest_line and final link leaksAlan Modra7-83/+60
Freeing ecoff_debug_info "pointers to the unswapped symbolic info" isn't a simple matter, due to differing allocation strategies. In _bfd_ecoff_slurp_symbolic_info the pointers are to objalloc memory. In the ecoff linker they are to separately malloc'd memory. In gas we have most (obj-elf) or all (obj-ecoff) into a single malloc'd buffer. This patch fixes the leaks for binutils and ld, leaving the gas leaks for another day. The mips elf backend already had this covered, and the ecoff backend had a pointer, raw_syments used as a flag, so most of the patch is moving these around a little so they are accessible for both ecoff and elf. include/ * coff/ecoff.h (struct ecoff_debug_info): Add alloc_syments. bfd/ * libecoff.h (struct ecoff_tdata): Delete raw_syments. * elfxx-mips.c (free_ecoff_debug): Delete. Replace uses with _bfd_ecoff_free_ecoff_debug_info. (_bfd_mips_elf_final_link): Init debug.alloc_syments. * ecofflink.c (_bfd_ecoff_free_ecoff_debug_info): New function. * ecoff.c (_bfd_ecoff_bfd_free_cached_info): Call _bfd_ecoff_free_ecoff_debug_info. (_bfd_ecoff_slurp_symbolic_info): Replace uses of raw_syments with alloc_syments. (ecoff_final_link_debug_accumulate): Likewise. Use _bfd_ecoff_free_ecoff_debug_info. (_bfd_ecoff_bfd_copy_private_bfd_data): Set alloc_syments for copied output. * elf64-alpha.c (elf64_alpha_read_ecoff_info): Use _bfd_ecoff_free_ecoff_debug_info. * libbfd-in.h (_bfd_ecoff_free_ecoff_debug_info): Declare. * libbfd.h: Regenerate. gas/ * config/obj-ecoff.c (ecoff_frob_file): Set alloc_syments. * config/obj-elf.c (elf_frob_file_after_relocs): Likewise.
2023-06-09Automatic date update in version.inGDB Administrator1-1/+1
2023-06-08Re: _bfd_free_cached_infoAlan Modra3-3/+3
Oops, another leak caused by not defining the correct macro. * elf32-mips.c: Define bfd_elf32_bfd_free_cached_info. * elfn32-mips.c: Likewise. * elf64-mips.c: Define bfd_elf64_bfd_free_cached_info.
2023-06-08Re: _bfd_free_cached_infoAlan Modra2-2/+2
ELF targets with target-specific free_cache_info functions need to call _bfd_elf_free_cached_info, not _bfd_generic_bfd_free_cached_info. * elf64-ppc.c (ppc64_elf_free_cached_info): Call _bfd_elf_free_cached_info. * elfnn-aarch64.c (elfNN_aarch64_bfd_free_cached_info): Likewise.
2023-06-08Automatic date update in version.inGDB Administrator1-1/+1
2023-06-07Add extra linker warning message about discrepancies between normal and ↵Nick Clifton2-8/+26
common symbols. PR 30499 bfd * elflink.c (elf_link_add_object_symbols): Add a message indicating that alignment and size discrepancies between the definition of common symbols and normal symbols are serious and should be investigated. ld * testsuite/ld-elfcomm/elfcomm.exp: Update regexps to match new output from the linker.
2023-06-07_bfd_free_cached_infoAlan Modra31-178/+149
doc/bfdint.texi and comments in the aout and som code about this function are just wrong, and its name is not very apt. Better would be _bfd_mostly_destroy, and we certainly should not be saying anything about the possibility of later recreating anything lost by this function. What's more, if _bfd_free_cached_info is called when creating an archive map to reduce memory usage by throwing away symbols, the target _close_and_cleanup function won't have access to tdata or section bfd_user_data to tidy memory. This means most of the target _close_and_cleanup function won't do anything, and therefore sometimes will result in memory leaks. This patch fixes the documentation problems and moves most of the target _close_and_cleanup code to target _bfd_free_cached_info. Another notable change is that bfd_generic_bfd_free_cached_info is now defined as _bfd_free_cached_info rather than _bfd_bool_bfd_true, ie. the default now frees objalloc memory.
2023-06-07Memory leaks in bfd/vms-lib.cAlan Modra1-13/+28
* vms-lib.c (vms_lib_read_index): Free malloc'd memory on error return paths. (vms_write_index, _bfd_vms_lib_write_archive_contents): Likewise.
2023-06-07bfd/elf.c strtab memory leakAlan Modra1-1/+5
* elf.c (_bfd_elf_compute_section_file_positions): Free strtab on set_group_contents failure return path.
2023-06-07Automatic date update in version.inGDB Administrator1-1/+1
2023-06-06Automatic date update in version.inGDB Administrator1-1/+1
2023-06-05ELF: Don't warn an empty PT_LOAD with the program headersH.J. Lu1-0/+2
When rewriting the program headers, don't warn an empty PT_LOAD with the program headers. bfd/ PR binutils/30508 * elf.c (rewrite_elf_program_header): Don't warn if an empty PT_LOAD contains the program headers. ld/ PR binutils/30508 * testsuite/ld-elf/pr30508.d: New file. * testsuite/ld-elf/pr30508.s: Likewise.
2023-06-05bfd_error_on_input messagesAlan Modra1-4/+10
bfd_errmsg uses asprintf for bfd_error_on_input, which means we currently leak memory. Keep a static pointer to the message and free it in various places to minimise the leaks. bfd_set_input_error (NULL, bfd_error_no_error) is a way to free up the last string if that matters. * bfd.c (input_error_msg): New static var. (bfd_set_input_error): Free it here.. (bfd_init): ..and here.. (bfd_errmsg): ..and here. Use it for asprintf output.
2023-06-05Yet another ecoff fuzzed object fixAlan Modra1-3/+9
* ecoff.c (_bfd_ecoff_slurp_symbol_table): Sanity check fdr_ptr csym against remaining space for symbols. Error on out of bounds fdr_ptr fields.
2023-06-05MIPS: default r6 if vendor is imgYunQiang Su1-1/+1
This behavior is used by downstream toolchain since 2014. We also set the default ABI for mips*-img-elf to O32. The previous value is NO_ABI, which is not good default ABI. We don't support mips64*-img* due to GCC doesn't support it, and We believe that the multilib should be used for this case.
2023-06-05Automatic date update in version.inGDB Administrator1-1/+1
2023-06-04Automatic date update in version.inGDB Administrator1-1/+1
2023-06-03Re: More ecoff sanity checksAlan Modra1-1/+18
Yet another fuzzer fix. * ecoff.c (ecoff_slurp_symbolic_header <FIX>): Zero counts when associated pointer is zero. (_bfd_ecoff_slurp_symbolic_info): Remove now unnecessary check.
2023-06-03Automatic date update in version.inGDB Administrator1-1/+1
2023-06-02Re: bfd_close and target free_cached_memoryAlan Modra1-1/+1
_bfd_delete_bfd can be called early, before the target xvec is set up. * opncls.c (_bfd_delete_bfd): Don't segfault on NULL xvec.
2023-06-02Re: More ecoff sanity checksAlan Modra1-2/+4
Another fix for fuzzed object files, exhibiting as a segfault in nm.c filter_symbols when accessing a symbol name. * ecoff.c (_bfd_ecoff_slurp_symbol_table): Sanity check fdr_ptr->issBase, and tighten sym.iss check.
2023-06-02Automatic date update in version.inGDB Administrator1-1/+1