aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2019-12-20ubsan: xtensa: left shift cannot be represented in type 'int'Alan Modra2-1/+5
* xtensa-isa.c (xtensa_insnbuf_from_chars): Avoid signed overflow.
2019-12-20ubsan: hppa: left shift of negative valueAlan Modra2-52/+43
bfd/ * libhppa.h (hppa_field_adjust, bfd_hppa_insn2fmt): Delete forward declaration. Move ATTRIBUTE_UNUSED to definition. (sign_extend, low_sign_extend, sign_unext, low_sign_unext), (re_assemble_3, re_assemble_12, re_assemble_14, re_assemble_16), (re_assemble_17, re_assemble_21, re_assemble_22): Likewise. Make args and return value unsigned. Use unsigned variables. (hppa_rebuild_insn): Similarly. opcodes/ * hppa-dis.c (extract_16, extract_21, print_insn_hppa): Use unsigned variables.
2019-12-20bfd_check_format memory leakAlan Modra2-0/+7
* format.c (bfd_check_format_matches): Free matching_vector when not returning matching target strings.
2019-12-20coff-alpha memory leakAlan Modra2-1/+8
* coff-alpha.c (alpha_ecoff_read_ar_hdr): Free ar_hdr on error return.
2019-12-20Automatic date update in version.inGDB Administrator1-1/+1
2019-12-19xcoff slurp_armap bounds checkingAlan Modra3-6/+40
"count * 8 >= size" might overflow, "count >= size / 8" doesn't. * coff-rs6000.c (_bfd_xcoff_slurp_armap): Don't overflow when checking symbol count against section size. Guard against strlen running off end of buffer by allocating one more byte and zeroing. * coff64-rs6000.c (xcoff64_slurp_armap): Likewise.
2019-12-19PowerPC, use size_t rather than long for indicesAlan Modra3-3/+9
This is fussing about nothing really but since I was looking at signed vs. unsigned issues, I decided to use the correct types here. * elf32-ppc.c (ppc_elf_get_synthetic_symtab): Use size_t for vars. * elf64-ppc.c (sym_exists_at): Use size_t for lo, hi and mid.
2019-12-19Automatic date update in version.inGDB Administrator1-1/+1
2019-12-18Yet more signed overflow fixesAlan Modra7-110/+122
* elf-bfd.h (ELF_LOCAL_SYMBOL_HASH): Avoid signed overflow. * elf32-hppa.c (final_link_relocate): Likewise. * elf32-ppc.c (_bfd_elf_ppc_at_tls_transform): Likewise. (_bfd_elf_ppc_at_tprel_transform, is_insn_ds_form): Likewise. (is_insn_dq_form, ppc_elf_relocate_section): Likewise. * elf64-ppc.c (ok_lo_toc_insn, ppc64_elf_edit_toc): Likewise. (ppc64_elf_relocate_section): Likewise. * elfxx-mips.c (mips_elf_perform_relocation): Likewise. * netbsd.h (N_SET_FLAGS): Likewise.
2019-12-18Automatic date update in version.inGDB Administrator1-1/+1
2019-12-17Remove tic80 supportAlan Modra14-805/+18
This is one way of fixing ubsan bug reports, just delete the code. The assembler support was removed back in 2005 along with other non-BFD assemblers, but somehow the remainder of the port stayed in. bfd/ * coff-tic80.c: Delete file. * cpu-tic80.c: Delete file. * archures.c: Remove tic80 support. * coffcode.h: Likewise. * coffswap.h: Likewise. * targets.c: Likewise. * config.bfd: Likewise. * configure.ac: Likewise. * Makefile.am: Likewise. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * configure: Regenerate. * po/SRC-POTFILES.in: Regenerate. binutils/ * testsuite/binutils-all/objcopy.exp: Remove tic80 support. * testsuite/binutils-all/objdump.exp: Likewise. gas/ * doc/as.texi: Remove mention of tic80. include/ * coff/tic80.h: Delete file. * opcode/tic80.h: Delete file. ld/ * emulparams/tic80coff.sh: Delete file. * scripttempl/tic80coff.sc: Delete file. * configure.tgt: Remove tic80 support. * Makefile.am: Likewise. * Makefile.in: Regenerate. * po/BLD-POTFILES.in: Regenerate. opcodes/ * tic80-dis.c: Delete file. * tic80-opc.c: Delete file. * disassemble.c: Remove tic80 support. * disassemble.h: Likewise. * Makefile.am: Likewise. * configure.ac: Likewise. * Makefile.in: Regenerate. * configure: Regenerate. * po/POTFILES.in: Regenerate.
2019-12-17Automatic date update in version.inGDB Administrator1-1/+1
2019-12-16Automatic date update in version.inGDB Administrator1-1/+1
2019-12-15Automatic date update in version.inGDB Administrator1-1/+1
2019-12-14Automatic date update in version.inGDB Administrator1-1/+1
2019-12-13Set no file contents PT_LOAD p_offset to first pageAlan Modra2-1/+16
PR 25237 * elf.c (assign_file_positions_for_load_sections): Attempt to keep meaningless p_offset for PT_LOAD segments without file contents within file size.
2019-12-13Automatic date update in version.inGDB Administrator1-1/+1
2019-12-12Remove duplicate castAlan Modra3-2/+7
* libbfd.c (bfd_get): Don't cast result of bfd_get_8. * bfd-in2.h: Regenerate.
2019-12-12Automatic date update in version.inGDB Administrator1-1/+1
2019-12-11bfd signed overflow fixesAlan Modra8-28/+41
Aimed at quietening ubsan. include/ * opcode/mmix.h (PUSHGO_INSN_BYTE): Make unsigned. (GO_INSN_BYTE, SETL_INSN_BYTE, INCML_INSN_BYTE, INCMH_INSN_BYTE), (INCH_INSN_BYTE, SWYM_INSN_BYTE, JMP_INSN_BYTE): Likewise. bfd/ * elf32-rx.c (elf32_rx_relax_section): Avoid signed overflow. * libaout.h (N_SET_INFO, N_SET_FLAGS): Likewise. * netbsd.h (write_object_contents): Likewise. * elf32-arm.c (bfd_elf32_arm_vfp11_erratum_scan): Likewise. * libhppa.h (HPPA_R_CONSTANT): Don't signed extend with shifts. (stm32l4xx_create_replacing_stub_vldm): Don't truncate high bits with shifts. * elf32-nds32.h (R_NDS32_RELAX_ENTRY_DISABLE_RELAX_FLAG): Define using 1u shifted left. Ditto for other macros. * mmo.c (LOP): Make unsigned.
2019-12-11Make bfd_get_8 return a bfd_vma like other bfd_get_* functionsAlan Modra3-4/+10
And similarly for bfd_get_signed_8. bfd/ * libbfd.c (bfd_get_8): Return a bfd_vma. (bfd_get_signed_8): Return a bfd_signed_vma. * bfd-in2.h: Regenerate. binutils/ * od-xcoff.c (dump_dumpx_core): Adjust for bfd_h_get_8 change.
2019-12-11ubsan: xtensa: left shift cannot be represented in type 'int'Alan Modra2-962/+578
In Operand_soffsetx4_decode: soffsetx4_0 = 0x4 + ((((int) offset_0 << 14) >> 14) << 2); and other places. Don't sign extend with shifts! This file also has many occurrences of truncation via shifts, which aren't a problem due to using uint32, but I dislike on principle enough to fix. * xtensa-modules.c (Field_* functions): Don't mask using shifts. (Operand_soffsetx4_decode, Operand_simm4_decode), (Operand_simm8_decode, Operand_simm8x256_decode), (Operand_simm12b_decode, Operand_label8_decode), (Operand_label12_decode, Operand_soffset_decode), (Operand_xt_wbr15_label_decode, Operand_xt_wbr18_label_decode): Don't sign extend using shifts. (Operand_immrx4_decode, Operand_uimm16x4_decode): Avoid UB in constant.
2019-12-11ubsan: ia64: left shift of negative valueAlan Modra2-3/+8
Here, since val is signed: *valuep = (val << scale); * cpu-ia64-opc.c (ext_imms_scaled): Avoid undefined left shift of negative values by using unsigned vars.
2019-12-11Automatic date update in version.inGDB Administrator1-1/+1
2019-12-10Automatic date update in version.inGDB Administrator1-1/+1
2019-12-09Automatic date update in version.inGDB Administrator1-1/+1
2019-12-08Automatic date update in version.inGDB Administrator1-1/+1
2019-12-07PR25236, common sym versioningAlan Modra2-3/+11
In cases where a relocatable object file has a common symbol, no other file has a definition, and there is a matching common symbol found in a shared library then ld will output a definition using the largest of size and alignment for the commons. This patch fixes a bug in ld that ignored common symbols when assigning versions, resulting in such symbols being given VER_NDX_LOCAL versions. PR 25236 * elflink.c (_bfd_elf_link_assign_sym_version): Assign versions for ELF_COMMON_DEF_P symbols. (elf_link_output_extsym, _bfd_elf_add_default_symbol): Adjust to suit.
2019-12-07Automatic date update in version.inGDB Administrator1-1/+1
2019-12-06Automatic date update in version.inGDB Administrator1-1/+1
2019-12-05Only give FDE encoding warnings if --eh-frame-hdr was specified.Sandra Loosemore2-12/+23
This bug was observed on nios2-linux-gnu with some C++ programs linked with -pie or -shared. The nios2 ABI doesn't include appropriate relocations in this instance and GCC is also being patched not to pass --eh-frame-hdr to the linker in those cases. 2019-12-05 Sandra Loosemore <sandra@codesourcery.com> bfd/ * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Make FDE encoding warning conditional.
2019-12-05Fix a problem computing the size fields in the PE format header.Nick Clifton2-0/+9
PR 25029 * peXXigen.c (_bfd_XXi_swap_aouthdr_out): Ignore empty sections when computing the sizes stored in the headers.
2019-12-05Automatic date update in version.inGDB Administrator1-1/+1
2019-12-04Automatic date update in version.inGDB Administrator1-1/+1
2019-12-03PR25230, addr2line fails on dwz outputAlan Modra2-60/+172
This patch remedies the following DW_FORM_GNU_ref_alt related problem: /* FIXME: Do we need to locate the correct CU, in a similar fashion to the code in the DW_FORM_ref_addr case above ? */ Without the correct CU the wrong abbrevs are used, resulting in errors and/or wrong file names. There is scope for further work here. Parsing of CUs should be a two step process, with the first stage just finding the bounds of the CU. This would allow find_abstract_instance to quickly find the CU referenced by DW_FORM_ref_addr or DW_FORM_GNU_ref_alt, then take the second stage of CU parsing where abbrevs, ranges and suchlike consume time and memory. As it is, we just process CUs from the start of .debug_info until we find the one of interest. The testcase in the PR takes 98G of virtual memory. PR 25230 * dwarf2.c (struct dwarf2_debug_file): Add line_table and abbrev_offsets. (struct abbrev_offset_entry): New. (hash_abbrev, eq_abbrev, del_abbrev): New functions. (read_abbrevs): Check whether we have already read abbrevs at given offset, and add new offset/abbrev to hash table. (decode_line_info): Keep line table at offset zero in file struct. Return this for a cu reusing the same dir/file list. (find_abstract_instance): Find cu for DW_FORM_GNU_ref_alt. (_bfd_dwarf2_slurp_debug_info): Create offset/abbrev hash tables. (_bfd_dwarf2_cleanup_debug_info): Adjust deletion of lines and abbrevs.
2019-12-03PR25230, dwarf2.c per file stashAlan Modra2-246/+261
This is just moving things around, in preparation for parsing alt file debug_info. PR 25230 * dwarf2.c (struct dwarf2_debug_file): New struct. (struct dwarf2_debug): Delete fields now in dwarf2_debug_file. Add f, alt fields. (struct comp_unit): Add file field. (read_indirect_string, read_indirect_line_string): Adjust to suit. (read_alt_indirect_string, read_alt_indirect_ref): Likewise. (read_debug_ranges, find_abstract_instance, read_rangelist): Likewise. (_bfd_dwarf2_stash_syms, place_sections): Likewise. (stash_maybe_update_info_hash_tablse): Likewise. (stash_verify_info_hash_table): Likewise. (_bfd_dwarf2_slurp_debug_info): Likewise. (_bfd_dwarf2_find_symbol_bias): Likewise. (_bfd_dwarf2_find_nearest_line): Likewise. (_bfd_dwarf2_cleanup_debug_info): Likewise. (read_abbrevs): Add file param and adjust. Update calls. (stash_comp_unit): Likewise. (decode_line_info): Delete stash param and adjust. Update calls. (comp_unit_find_nearest_line): Likewise. (comp_unit_maybe_decode_line_info): Likewise. (comp_unit_find_line): Likewise. (parse_comp_unit): Add file and info_ptr param and adjust. Update calls.
2019-12-03dwarf2.c: read_abbrevs fail cleanup, and offset checkingAlan Modra2-29/+32
read_section does offset checking, reporting an error on out of bounds. There's no need to duplicate the check in functions calling read_section. Also, I spotted a place where a pointer difference expression was being cast to unsigned int, possibly truncating relevant bits on a 64-bit host. * dwarf2.c (read_indirect_string): Don't duplicate offset check done in read_section. (read_indirect_line_string): Likewise. (read_alt_indirect_string): Likewise. (read_alt_indirect_ref): Likewise. (read_abbrevs): Likewise. Free memory on all failure paths. Use correct unsigned type for pointer difference comparison.
2019-12-03dwarf2.c stash->sec_info_ptr and stash->secAlan Modra2-20/+12
These are unused. Remove them. Also fix the wrong sort of 0 being returned from read_alt_indirect_ref. * dwarf2.c (struct dwarf2_debug): Update comments. Remove sec and sec_info_ptr. (_bfd_dwarf2_slurp_debug_info): Don't set sec or sec_info_ptr. (stash_comp_unit): Likewise. (read_alt_indirect_ref): Return NULL not FALSE.
2019-12-03_bfd_dwarf2_find_nearest_line comment fixAlan Modra2-3/+5
These lines should have been removed along with the addr_size parameter. * dwarf2.c (_bfd_dwarf2_find_nearest_line): Correct function comment.
2019-12-03Automatic date update in version.inGDB Administrator1-1/+1
2019-12-02Automatic date update in version.inGDB Administrator1-1/+1
2019-12-01Automatic date update in version.inGDB Administrator1-1/+1
2019-11-30Automatic date update in version.inGDB Administrator1-1/+1
2019-11-29Automatic date update in version.inGDB Administrator1-1/+1
2019-11-28Automatic date update in version.inGDB Administrator1-1/+1
2019-11-27PR23652, Use symbols from debug bfd for _bfd_elf_find_function properlyAlan Modra6-10/+34
There were a number of problems with the previous patch. Firstly, _bfd_dwarf2_stash_syms didn't do anything when the original file had dynamic symbols, and secondly, info found by the symbol search didn't make it out of _bfd_elf_find_nearest_line except in the case of DWARF functions without external linkage. PR 23652 * dwarf2.c (_bfd_dwarf2_stash_syms): Break out of loop on finding matching section. (_bfd_dwarf2_find_nearest_line): Return an int, with value 2 when returning info from the symbol table. Do the _bfd_elf_find_function search also when !found. Call _bfd_dwarf2_stash_syms regardless of symbols. * elf64-alpha.c (elf64_alpha_find_nearest_line): Accept dwarf2 result of 1 only. * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Likewise. * libbfd-in.h (_bfd_dwarf2_find_nearest_line): Update prototype. * libbfd.h: Regenerate.
2019-11-27PR23652, Use symbols from debug bfd for _bfd_elf_find_functionAlan Modra6-253/+147
Sometimes DWARF info for a function is incomplete, and the function can be retrieved by examining symbols. However, when separate debug files are used it may be that the original file is completely stripped of symbols. This patch teaches BFD to look at symbols from the debug file in that case. The patch also removes arm_elf_find_function, instead implementing elf_backend_maybe_function_sym. arm_elf_find_function was written before the generic _bfd_elf_find_function called maybe_function_sym. aarch64 copied arm, so that file gets the same treatment. There is some chance this will speed up arm and aarch64 lookup of function/line. PR 23652 * dwarf2.c (_bfd_dwarf2_stash_syms): New function. (_bfd_dwarf2_find_nearest_line): Use it here, passing syms to _bfd_elf_find_function. Call _bfd_elf_find_function in cases where _bfd_elf_find_nearest_line would do so. * elf.c (_bfd_elf_find_nearest_line): Omit _bfd_elf_find_function for dwarf2. * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Similarly. Tidy. * elf32-arm.c (elf32_arm_maybe_function_sym): New function. (elf_backend_maybe_function_sym): Define. (arm_elf_find_function, elf32_arm_find_nearest_line): Delete. (bfd_elf32_find_nearest_line): Don't define. * elfnn-aarch64.c (elfNN_aarch64_maybe_function_sym): New function. (elf_backend_maybe_function_sym): Define. (aarch64_elf_find_function, elfNN_aarch64_find_nearest_line): Delete. (bfd_elfNN_find_nearest_line): Don't define.
2019-11-27Correct R_SH_IND12W handlingAlan Modra3-17/+20
Using bfd_vma for insn is to avoid having to worry about sign propagation in expressions involving insn and sym_value when bfd_vma is not the same as unsigned long. * elf32-sh.c (sh_reloc): Use a bfd_vma insn. (sh_reloc <R_SH_IND12W>): Divide calculated relocation value by two before applying to insn. Correct overflow test. * coff-sh.c (sh_reloc): Likewise.
2019-11-27Automatic date update in version.inGDB Administrator1-1/+1
2019-11-26Fix comparison operations in SH code that trigger warning in clang.Nick Clifton3-2/+8
* elf32-sh.c (sh_elf_reloc): Use a signed_vma when checking for a negative relocated value. * coff-sh.c (sh_reloc): Likewise.