aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2020-03-11asan: som: unknown readAlan Modra2-0/+7
* som.c (setup_sections): Sanity check subspace.name.
2020-03-11powerpc64-ld infinite loopAlan Modra2-1/+5
If this code dealing with possible conversion of inline plt sequences is ever executed, ld will hang. A binary with such sequences and of code size larger than approximately 90% the reach of an unconditional branch is the trigger. Oops. * elf64-ppc.c (ppc64_elf_inline_plt): Do increment rel in for loop.
2020-03-10PR25648, objcopy SIGSEGV in ihex_write_recordAlan Modra2-5/+10
ihex_set_section_contents sorts records stored on the tdata.ihex_data list by address, but ihex_write_object_contents went too far in assuming they were not overlapping. This patch fixes the problem by not assuming anything about addresses in ihex_write_object_contents. PR 25648 * ihex.c (ihex_write_object_contents): Don't assume ordering of addresses here. Remove dead code.
2020-03-09asan: wasm: Out-of-memoryAlan Modra2-12/+21
* wasm-module.c (wasm_scan): Sanity check file name length before allocating memory. Move common section setup code. Do without bfd_tell to calculate section size.
2020-03-07Automatic date update in version.inGDB Administrator1-1/+1
2020-03-06Fix an abort triggered when objcopy is used to set the "share" section flag ↵Nick Clifton2-7/+38
on an ELF section. binutils* objcopy.c (check_new_section_flags): New function. Reject the SEC_COFF_SHARED flag if the target is not a COFF binary. (copy_object): Call check_new_section_flags. (setup_section): Likewise. * doc/binutils.texi (objcopy): Add a note that the 'share' section flag cannot be applied to ELF binaries. bfd * elf.c (_bfd_elf_set_section_contents): Replace call to abort with error messages and failure return values.
2020-03-05bfd: xtensa: fix PR ld/25630Max Filippov2-4/+8
bfd/ 2020-03-05 Max Filippov <jcmvbkbc@gmail.com> * elf32-xtensa.c (shrink_dynamic_reloc_sections): Shrink dynamic relocation sections for any removed reference to a dynamic symbol.
2020-03-06Automatic date update in version.inGDB Administrator1-1/+1
2020-03-05Add support for ELF files which contain multiple reloc sections which all ↵Nick Clifton7-13/+465
target the same section. * elf-bfd.h (struct elf_backend_data): Add new fields: init_secondary_reloc_section, slurp_secondary_reloc_section, write_secondary_reloc_section. (_bfd_elf_init_secondary_reloc_section): Prototype. (_bfd_elf_slurp_secondary_reloc_section): Prototype. (_bfd_elf_write_secondary_reloc_section): Prototype. * elf.c ( bfd_section_from_shdr): Invoke the new init_secondary_reloc_section backend function, if defined, when a second reloc section is encountered. (swap_out_syms): Invoke the new symbol_section_index function, if defined, when computing the section index of an OS/PROC specific symbol. (_bfd_elf_init_secondary_reloc_section): New function. (_bfd_elf_slurp_secondary_reloc_section): New function. (_bfd_elf_write_secondary_reloc_section): New function. (_bfd_elf_copy_special_section_fields): New function. * elfcode.h (elf_write_relocs): Invoke the new write_secondary_relocs function, if defined, in order to emit secondary relocs. (elf_slurp_reloc_table): Invoke the new slurp_secondary_relocs function, if defined, in order to read in secondary relocs. * elfxx-target.h (elf_backend_copy_special_section_fields): Provide a non-NULL default definition. (elf_backend_init_secondary_reloc_section): Likewise. (elf_backend_slurp_secondary_reloc_section): Likewise. (elf_backend_write_secondary_reloc_section): Likewise. (struct elf_backend_data elfNN_bed): Add initialisers for the new fields. * configure.ac (score_elf32_[bl]e_vec): Add elf64.lo * configure: Regenerate.
2020-03-05Large memory allocation reading fuzzed 64-bit archiveAlan Modra2-1/+15
This patch adds a sanity check for the size of an armap. * archive64.c (_bfd_archive_64_bit_slurp_armap): Check parsed_size against file size before allocating memory. Use bfd_alloc rather than bfd_zalloc for carsym/strings memory.
2020-03-05Automatic date update in version.inGDB Administrator1-1/+1
2020-03-04sh_addralign inconsistent with sh_addrAlan Modra2-1/+10
The ELF gABI says in part of sh_addralign: "The value of sh_addr must be congruent to 0, modulo the value of sh_addralign." * elf.c (elf_fake_sections): Ensure sh_addralign is such that sh_addr mod sh_addalign is zero.
2020-03-04Call cleanup on bfd_check_format_matches error exitAlan Modra2-0/+8
* format.c (bfd_check_format_matches): Call cleanup on error exit.
2020-03-04Automatic date update in version.inGDB Administrator1-1/+1
2020-03-03bfd_check_format_matches preserving matches vs. cleanupsAlan Modra2-5/+29
It didn't take long for oss-fuzz to find double frees due to a bug in the cleanup logic. It's seen when reading in any alpha-vms object file except when alpha_vms_vec is the default. But alpha_vms_vec is of course the default when building for --target=alpha-dec-vms (and naturally what I used to test the cleanup support since that is the only target with a cleanup that does anything currently). Anyway, the bug is that if bfd_check_format_matches is to preserve a match the cleanup for that match can't be run. Quite obviously that would destroy part of the match state. * format.c (struct bfd_preserve): Add cleanup field. (bfd_preserve_save): Add cleanup param and save. (bfd_preserve_restore): Return cleanup. (bfd_preserve_finish): Call the cleanup for the discarded match. (bfd_check_format_matches): Pass cleanup to bfd_preserve_save, and clear when preserving a match. Restore cleanup too when restoring that match.
2020-03-03Automatic date update in version.inGDB Administrator1-1/+1
2020-03-03Re: bfd_cleanup for object_pAlan Modra4-12/+23
I hate files that you can't compile. * cisco-core.c (cisco_core_file_p): Return bfd_cleanup. * hpux-core.c (hpux_core_core_file_p): Update prototype. * sco5-core.c (sco5_core_file_p): Return bfd_cleanup. (core_sco5_vec): Correct initialisers.
2020-03-02Re: bfd_cleanup for object_pAlan Modra12-38/+51
More missing core file support changes. * aix386-core.c (aix386_core_file_p): Return bfd_cleanup. * aix5ppc-core.c (xcoff64_core_p): Likewise. * cisco-core.c (cisco_core_file_validate): Likewise. * hppabsd-core.c (hppabsd_core_core_file_p): Likewise. * hpux-core.c (hpux_core_core_file_p): Likewise. * irix-core.c (irix_core_core_file_p): Likewise. * lynx-core.c (lynx_core_file_p): Likewise. * netbsd-core.c (netbsd_core_file_p): Likewise. * osf-core.c (osf_core_core_file_p): Likewise. * ptrace-core.c (ptrace_unix_core_file_p): Likewise. * sco5-core.c (sco5_core_file_p): Likewise.
2020-03-02trad_unix_core_file_p: Return bfd_cleanupH.J. Lu2-2/+6
* trad-core.c (trad_unix_core_file_p): Return bfd_cleanup.
2020-03-02bfd_cleanup for object_pAlan Modra49-156/+233
The object_p (and archive_p, core_file_p) functions are not supposed to have any target specific malloc'd memory attached to the bfd on their return. This should be obvious on a failure return, but it's also true for a successful return. The reason is that even though the object_p recognises the file, that particular target may not be used and thus the bfd won't be closed calling close_and_cleanup for the target that allocated the memory. It turns out that the object_p bfd_target* return value isn't needed. In all cases except ld/plugin.c the target is abfd->xvec and with ld/plugin.c the target isn't used. So this patch returns a cleanup function from object_p instead, called in bfd_check_format_matches to tidy the bfd before trying a different target match. The only cleanup that does anything at this stage is the alpha-vms one. bfd/ * targets.c (bfd_cleanup): New typedef. (struct bfd <_bfd_check_format>): Return a bfd_cleanup. * libbfd-in.h (_bfd_no_cleanup): Define. * format.c (bfd_reinit): Add cleanup parameter, call it. (bfd_check_format_matches): Set cleanup from _bfd_check_format call and pass to bfd_reinit. Delete temp, use abfd->xvec instead. * aout-target.h (callback, object_p): Return bfd_cleanup. * aout-tic30.c (tic30_aout_callback, tic30_aout_object_p): Likewise. * archive.c (bfd_generic_archive_p): Likewise. * binary.c (binary_object_p): Likewise. * coff-alpha.c (alpha_ecoff_object_p): Likewise. * coff-ia64.c (ia64coff_object_p): Likewise. * coff-rs6000.c (_bfd_xcoff_archive_p, rs6000coff_core_p): Likewise. * coff-sh.c (coff_small_object_p): Likewise. * coff-stgo32.c (go32_check_format): Likewise. * coff64-rs6000.c (xcoff64_archive_p, rs6000coff_core_p), (xcoff64_core_p): Likewise. * coffgen.c (coff_real_object_p, coff_object_p): Likewise. * elf-bfd.h (bfd_elf32_object_p, bfd_elf32_core_file_p), (bfd_elf64_object_p, bfd_elf64_core_file_p): Likewise. * elfcode.h (elf_object_p): Likewise. * elfcore.h (elf_core_file_p): Likewise. * i386msdos.c (msdos_object_p): Likewise. * ihex.c (ihex_object_p): Likewise. * libaout.h (some_aout_object_p): Likewise. * libbfd-in.h (bfd_generic_archive_p, _bfd_dummy_target), (_bfd_vms_lib_alpha_archive_p, _bfd_vms_lib_ia64_archive_p): Likewise. * libbfd.c (_bfd_dummy_target): Likewise. * libcoff-in.h (coff_object_p): Likewise. * mach-o-aarch64.c (bfd_mach_o_arm64_object_p), (bfd_mach_o_arm64_core_p): Likewise. * mach-o-arm.c (bfd_mach_o_arm_object_p), (bfd_mach_o_arm_core_p): Likewise. * mach-o-i386.c (bfd_mach_o_i386_object_p), (bfd_mach_o_i386_core_p): Likewise. * mach-o-x86-64.c (bfd_mach_o_x86_64_object_p), (bfd_mach_o_x86_64_core_p): Likewise. * mach-o.c (bfd_mach_o_header_p, bfd_mach_o_gen_object_p), (bfd_mach_o_gen_core_p, bfd_mach_o_fat_archive_p): Likewise. * mach-o.h (bfd_mach_o_object_p, bfd_mach_o_core_p), (bfd_mach_o_fat_archive_p, bfd_mach_o_header_p): Likewise. * mmo.c (mmo_object_p): Likewise. * pef.c (bfd_pef_object_p, bfd_pef_xlib_object_p): Likewise. * peicode.h (coff_real_object_p, pe_ILF_object_p), (pe_bfd_object_p): Likewise. * plugin.c (ld_plugin_object_p, bfd_plugin_object_p): Likewise. * ppcboot.c (ppcboot_object_p): Likewise. * rs6000-core.c (rs6000coff_core_p): Likewise. * som.c (som_object_setup, som_object_p): Likewise. * srec.c (srec_object_p, symbolsrec_object_p): Likewise. * tekhex.c (tekhex_object_p): Likewise. * vms-alpha.c (alpha_vms_object_p): Likewise. * vms-lib.c (_bfd_vms_lib_archive_p, _bfd_vms_lib_alpha_archive_p), (_bfd_vms_lib_ia64_archive_p, _bfd_vms_lib_txt_archive_p): Likewise. * wasm-module.c (wasm_object_p): Likewise. * xsym.c (bfd_sym_object_p): Likewise. * xsym.h (bfd_sym_object_p): Likewise. * aoutx.h (some_aout_object_p): Likewise, and callback parameter return type. * pdp11.c (some_aout_object_p): Likewise. * plugin.c (register_ld_plugin_object_p): Update object_p parameter type. * plugin.h (register_ld_plugin_object_p): Likewise. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * libcoff.h: Regenerate. ld/ * plugin.c (plugin_object_p): Return a bfd_cleanup. (plugin_cleanup): New function.
2020-03-02miscellaneous SEC_SMALL_DATAAlan Modra5-12/+40
This patch arranges for symbols defined in .sdata and .sbss to be reported by nm with 'g' and 's' flags, for coff targets that support .sdata and .sbss. The assembler changes regarding SEC_SMALL_DATA are really just documentation. As far as I'm aware, this won't change any assembler output. bfd/ * coff-alpha.c (alpha_ecoff_le_vec): Add SEC_SMALL_DATA to applicable section flags. * coff-mips.c (mips_ecoff_le_vec, mips_ecoff_be_vec): Likewise. (mips_ecoff_bele_vec): Likewise. * coffcode.h (sec_to_styp_flags): Set SEC_SMALL_DATA for .sdata and .sbss sections. * ecoff.c (_bfd_ecoff_new_section_hook): Likewise. (_bfd_ecoff_styp_to_sec_flags): Likewise. gas/ * config/tc-m32r.c (md_begin): Set SEC_SMALL_DATA on .scommon section. * config/tc-mips.c (s_change_sec): Set SEC_SMALL_DATA for .sdata and .sbss sections. * config/tc-score.c: Delete !BFD_ASSEMBLER code throughout. (s3_s_change_sec): Set SEC_SMALL_DATA for .sbss section. (s3_s_score_lcomm): Likewise. * config/tc-score7.c: Similarly. * read.c (bss_alloc): Set SEC_SMALL_DATA for .sbss section.
2020-03-02ELF SEC_SMALL_DATAAlan Modra9-16/+85
For those ELF targets that have .sdata or .sbss sections, or similar sections, arrange to mark the sections with the SEC_SMALL_DATA flag. This fixes regressions in nm symbol type caused by removing .sdata and .sbss from coff_section_type with commit 49d9fd42ac. * elf32-m32r.c (m32r_elf_section_flags): New function. (elf_backend_section_flags): Define. * elf32-nds32.c (nds32_elf_section_flags): New function. (elf_backend_section_flags): Define. * elf32-ppc.c (ppc_elf_section_from_shdr): Set SEC_SMALL_DATA for .sbss and .sdata sections. * elf32-v850.c (v850_elf_section_from_shdr): Set SEC_SMALL_DATA for SHF_V850_GPREL sections. * elf64-alpha.c (elf64_alpha_section_from_shdr): Delete outdated FIXME. * elf64-hppa.c (elf64_hppa_section_from_shdr): Set SEC_SMALL_DATA for SHF_PARISC_SHORT sections. * elf64-ppc.c (ppc64_elf_section_flags): New function. (elf_backend_section_flags): Define. * elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Set SEC_SMALL_DATA for SHF_MIPS_GPREL sections. Delete FIXME.
2020-03-02elf_backend_section_flags and _bfd_elf_init_private_section_dataAlan Modra10-52/+78
I was looking at elf_backend_section_flags as a means of setting SEC_SMALL_DATA for .sdata, .sbss and the like, and condidered adding an asection* parameter to access the section name easily before realising that hdr->bfd_section of course makes the section available. So no new parameter needed. In fact the flagword* parameter isn't needed either, so out it goes. The patch also tidies some horrible code in _bfd_elf_new_section_hook that can change whether known ABI sections have sh_type and sh_flags set up depending on which of the bfd_make_section functions is used. (Some of those set section flags before _bfd_elf_new_section_hook is called, others leave the flags zero.) The function also had some hacks for .init_array and .fini_array to affect how _bfd_elf_init_private_section_data behaved for those sections. It's cleaner to do that in _bfd_elf_init_private_section_data. So that all goes and we now init sh_type and sh_flags for all known ABI sections in _bfd_elf_new_section_hook. _bfd_elf_init_private_section_data is changed to suit, and now doesn't just single out SHT_INIT_ARRAY and SHT_FINI_ARRAY but rather any of the special section types. The _bfd_elf_new_section_hook change resulting in +FAIL: ld-aarch64/erratum835769-843419 exposing some errors in the aarch64 backend. elfNN_aarch64_size_stubs should not be looking at linker created sections in the stub bfd. Nor should code like "symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr" be run without first checking that input_bfd is ELF. * elf-bfd.h (elf_backend_section_flags): Remove flagword* param. * elf.c (_bfd_elf_make_section_from_shdr): Set section flags before calling elf_backend_section_flags with adjusted params. Use newsect->flags past that point. (_bfd_elf_new_section_hook): Always set sh_type and sh_flags for special sections. (_bfd_elf_init_private_section_data): Allow normal sh_type sections to have their type overridden, and all sh_flags but processor and os specific. * elf32-arm.c (elf32_arm_section_flags): Adjust for changed params. * elf32-mep.c (mep_elf_section_flags): Likewise. * elf32-nios2.c (nios2_elf32_section_flags): Likewise. * elf64-alpha.c (elf64_alpha_section_flags): Likewise. * elf64-ia64-vms.c (elf64_ia64_section_flags): Likewise. * elfnn-ia64.c (elfNN_ia64_section_flags): Likewise. * elfnn-aarch64.c (elfNN_aarch64_size_stubs): Exclude the linker stub BFD and non-aarch64 input files when scanning for stubs.
2020-03-02alpha-coff: large memory allocationAlan Modra2-0/+14
* coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Provide an upper limit to decompressed element size.
2020-03-02alpha-vms: prevent endless recursionAlan Modra2-3/+15
* vms-lib.c (vms_traverse_index): Add recur_count param and update calls. Fail on excessive recursion.
2020-03-02alpha-vms: error paths not freeing memory and malloc result checksAlan Modra2-14/+36
When realloc fails it doesn't free the old memory. In BFD we usually will exit with an error on a realloc fail, so want to tidy up memory on error paths. That's done by bfd_realloc_or_free. * vms-alpha.c (vms_get_remaining_object_record): Use bfd_realloc_or_free rather than bfd_realloc. (add_symbol_entry, vector_grow1, alpha_vms_slurp_relocs): Likewise. (dst_define_location, parse_module): Likewise, and check realloc return status before using memory. Return status from function adjusting all callers.
2020-03-02Automatic date update in version.inGDB Administrator1-1/+1
2020-03-01Automatic date update in version.inGDB Administrator1-1/+1
2020-02-29Automatic date update in version.inGDB Administrator1-1/+1
2020-02-28alpha-vms: memory leakAlan Modra2-6/+14
* vms-lib.c (_bfd_vms_lib_archive_p): Free memory on error paths.
2020-02-28alpha-vms: large memory allocationAlan Modra2-44/+20
This patch simplifies reading of image headers. It's really not worth trying to avoid re-reading a 12 byte buffer and then read in VMS_BLOCK_SIZE chunks, better just to throw the buffer away and use _bfd_malloc_and_read which does checks against file size. * vms-alpha.c (alpha_vms_object_p): Use _bfd_malloc_and_read. Remove duplicate undersize check.
2020-02-28Automatic date update in version.inGDB Administrator1-1/+1
2020-02-28mmix-mmo set SEC_DATA for .data sectionAlan Modra2-1/+6
With the bfd_decode_symclass change, ld SIZEOF test fails due to data_end being reported as type '?'. bfd/ PR 24511 * mmo.c (mmo_scan): Set SEC_DATA for .data. ld/ PR 24511 * testsuite/ld-mmix/b-fixo2.d: Adjust for .data change. * testsuite/ld-mmix/sec-2.d: Likewise. * testsuite/ld-mmix/sec-3.d: Likewise. * testsuite/ld-mmix/sec-4.d: Likewise. * testsuite/ld-mmix/spec802.d: Likewise. * testsuite/ld-mmix/spec803.d: Likewise. * testsuite/ld-mmix/spec804.d: Likewise. * testsuite/ld-mmix/spec805.d: Likewise. * testsuite/ld-mmix/spec806.d: Likewise. * testsuite/ld-mmix/spec807.d: Likewise. * testsuite/ld-mmix/spec808.d: Likewise.
2020-02-28.idata symbols should be reported with i or I flag by nmAlan Modra2-22/+21
PR 24511 * syms.c (stt): Trim off all but 'e', 'i' and 'p' entries. (coff_section_type): Adjust comment. (decode_section_type): Likewise. Call coff_section_type before decode_section_type. (bfd_decode_symclass): Use 'c' for common sections other than the standard one.
2020-02-27_bfd_xcoff_read_ar_hdr tidyAlan Modra2-31/+22
* coff-rs6000.c (_bfd_xcoff_read_ar_hdr): Put all data in one malloc'd block.
2020-02-27bfd_stat_arch_elt buffer overflowAlan Modra3-2/+10
If you manage to put an xcoff object file into a non-xcoff archive (created by first putting a non-xcoff object file into it), and have xcoff support compiled into libbfd, then objdump -x on the archive can segfault. The problem is that _bfd_xcoff_stat_arch_elt expects abfd->arelt_data->arch_header to be one of the xcoff variants, but arelt_data is generated depending on the archive format, *not* the element format. * bfd.c (bfd_stat_arch_elt): Use vector of containing archive, if file is an archive element. * bfd-in2.h: Regenerate.
2020-02-27Automatic date update in version.inGDB Administrator1-1/+1
2020-02-26Archive sanity checksAlan Modra2-68/+103
Adds some sanity checking to size values read from file. * archive.c (do_slurp_bsd_armap): Increase minimum parsed_size, and bfd_set_error on failing test. Don't bother changing bfd_error on file read error. Check symdef_count is multiple of BSD_SYMDEF_SIZE. Check sym name is within string buffer. Use size_t for some vars. (do_slurp_coff_armap): Use size_t for some variables, fix size of int_buf. Don't change bfd_error on file read error. Use _bfd_mul_overflow when calculating carsym buffer size. Reorder calculations to catch overflows before they occur. malloc and free raw armap rather than using bfd_alloc. Read raw armap before allocating carsym+strings buffer. (_bfd_slurp_extended_name_table): Localize variables. Check name size against file size.
2020-02-26Re: vms buffer overflows and large memory allocationAlan Modra2-4/+8
git commit c893ce360a changed buffer management, in the process introducing a bug on an error return path. * vms-lib.c (vms_lib_read_index): Release correct buffer.
2020-02-26rx: memory allocation without checking for NULL returnAlan Modra2-23/+39
* elf32-rx.c (rx_elf_relocate_section): Use bfd_malloc rather than malloc. Check for NULL return from bfd_malloc. (rx_table_find, rx_table_map): Likewise. (rx_set_section_contents): Check bfd_alloc return. (rx_dump_symtab): Don't alloc internal_syms or external_syms.
2020-02-26Indent labelsAlan Modra41-129/+180
Labels don't go in the first column according to standard emacs C indent rules, and I got annoyed enough at seeing diff -p show a label rather than the function name to fix this. bfd/ * aoutx.h: Indent labels correctly. Format error strings. * archive.c: Likewise. * archive64.c: Likewise. * coff-arm.c: Likewise. * coff-rs6000.c: Likewise. * coff-stgo32.c: Likewise. * cpu-arm.c: Likewise. * dwarf2.c: Likewise. * elf-ifunc.c: Likewise. * elf-properties.c: Likewise. * elf-s390-common.c: Likewise. * elf-strtab.c: Likewise. * elf.c: Likewise. * elf32-arm.c: Likewise. * elf32-bfin.c: Likewise. * elf32-cr16.c: Likewise. * elf32-csky.c: Likewise. * elf32-i386.c: Likewise. * elf32-m68k.c: Likewise. * elf32-msp430.c: Likewise. * elf32-nds32.c: Likewise. * elf32-nios2.c: Likewise. * elf32-pru.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-ia64-vms.c: Likewise. * elf64-x86-64.c: Likewise. * elfcode.h: Likewise. * elfcore.h: Likewise. * elflink.c: Likewise. * elfnn-aarch64.c: Likewise. * elfnn-ia64.c: Likewise. * elfnn-riscv.c: Likewise. * elfxx-mips.c: Likewise. * elfxx-sparc.c: Likewise. * elfxx-x86.c: Likewise. * i386lynx.c: Likewise. * merge.c: Likewise. * pdp11.c: Likewise. * plugin.c: Likewise. * reloc.c: Likewise. binutils/ * elfedit.c: Indent labels correctly. * readelf.c: Likewise. * resres.c: Likewise. gas/ * config/obj-elf.c: Indent labels correctly. * config/obj-macho.c: Likewise. * config/tc-aarch64.c: Likewise. * config/tc-alpha.c: Likewise. * config/tc-arm.c: Likewise. * config/tc-cr16.c: Likewise. * config/tc-crx.c: Likewise. * config/tc-frv.c: Likewise. * config/tc-i386-intel.c: Likewise. * config/tc-i386.c: Likewise. * config/tc-ia64.c: Likewise. * config/tc-mn10200.c: Likewise. * config/tc-mn10300.c: Likewise. * config/tc-nds32.c: Likewise. * config/tc-riscv.c: Likewise. * config/tc-s12z.c: Likewise. * config/tc-xtensa.c: Likewise. * config/tc-z80.c: Likewise. * read.c: Likewise. * symbols.c: Likewise. * write.c: Likewise. ld/ * emultempl/cskyelf.em: Indent labels correctly. * ldfile.c: Likewise. * ldlang.c: Likewise. * plugin.c: Likewise. opcodes/ * aarch64-asm.c: Indent labels correctly. * aarch64-dis.c: Likewise. * aarch64-gen.c: Likewise. * aarch64-opc.c: Likewise. * alpha-dis.c: Likewise. * i386-dis.c: Likewise. * nds32-asm.c: Likewise. * nfp-dis.c: Likewise. * visium-dis.c: Likewise.
2020-02-26PR25593, --as-needed breaks DT_NEEDED order with linker pluginAlan Modra4-45/+74
This patch delays setting up DT_NEEDED dynamic tags until all object files and libraries have been opened and their symbols processed, rather than adding the tags while processing symbols. Tags are ordered according to the position of the associated library on the command line and linker scripts. It is still possible with --as-needed libs that are mentioned more than once for tags to be ordered according to which mention was needed. For example with "--as-needed a.so b.so c.so b.so" when b.so is not needed by a.so or any other prior object file but is needed by c.so, the order of tags will be "A C B". bfd/ PR 25593 * elf-bfd.h (struct elf_link_hash_table): Rename "loaded" to "dyn_loaded". (bfd_elf_add_dt_needed_tag): Declare. * elf-strtab.c (_bfd_elf_strtab_restore): Handle NULL buf. * elflink.c (bfd_elf_add_dt_needed_tag): Make global and rename from elf_add_dt_needed_tag. Remove soname and doit param. (elf_link_add_object_symbols): Don't use elf_add_dt_needed_tag to see whether as-needed lib is already loaded, use dyn_loaded list instead. When saving and restoring around as-needed lib handle possibility that dynstr has not been initialised. Don't add DT_NEEDED tags here. Limit dyn_loaded list to dynamic libs. Mark libs loaded via DT_NEEDED entries of other libs with DYN_NO_NEEDED if they should not be mentioned in DT_NEEDED of the output. (elf_link_check_versioned_symbol): Remove now unneccesary DYNAMIC check when traversing dyn_loaded list. ld/ PR 25593 * ldelf.c (ldelf_try_needed): Add DT_NEEDED lib to input_bfds. (ldelf_after_open): Save state of input_bfds list before loading DT_NEEDED libs. Traverse input_bfds list adding DT_NEEDED tags. Restore input_bfds list. * testsuite/ld-cris/gotplt1.d: Adjust for changed .dynstr order.
2020-02-26Limit bogus archive parsed_sizeAlan Modra2-2/+20
Archive element size is given by data in the archive, and thus is subject to attack by fuzzers. The only harm this allows is allocation of huge amounts of memory, but some systems don't handle that well. So limit archive element size to archive file size. * bfdio.c (bfd_get_file_size): Ignore bogus archive element sizes.
2020-02-26Automatic date update in version.inGDB Administrator1-1/+1
2020-02-25Don't call lto-wrapper for ar and ranlibH.J. Lu3-9/+25
Since ar and ranlib don't need to know symbol types to work properly, we should avoid calling lto-wrapper for them to speed them up. bfd/ PR binutils/25584 * plugin.c (need_lto_wrapper_p): New. (bfd_plugin_set_program_name): Add an int argument to set need_lto_wrapper_p. (get_lto_wrapper): Return FALSE if need_lto_wrapper_p isn't set. * plugin.h (bfd_plugin_set_program_name): Add an int argument. binutils/ PR binutils/25584 * ar.c (main): Pass 0 to bfd_plugin_set_program_name. * nm.c (main): Pass 1 to bfd_plugin_set_program_name.
2020-02-25Automatic date update in version.inGDB Administrator1-1/+1
2020-02-24Re: vms buffer overflows and large memory allocationAlan Modra2-6/+12
The last patch wasn't quite correct. I'd missed the fact that sbm_off had been updated. * vms-lib.c (_bfd_vms_lib_archive_p): Correct overflow checks.
2020-02-24vms buffer overflows and large memory allocationAlan Modra2-25/+82
* vms-lib.c (struct carsym_mem): Add limit. (vms_add_index): Heed limit. (vms_traverse_index): Catch buffer overflows. Remove outdated fixme. (vms_lib_read_index): Set up limit. Catch 32-bit overflow. Always return actual number read. (_bfd_vms_lib_archive_p): Catch buffer overflows. Replace assertion with error exit.
2020-02-24Automatic date update in version.inGDB Administrator1-1/+1
2020-02-23Automatic date update in version.inGDB Administrator1-1/+1