aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2021-05-05asan: stack-buffer-overflow vms-lib.c:367Alan Modra2-1/+6
* vms-lib.c (vms_traverse_index): Account for vms_kbn size when sanity checking keylen.
2021-05-05Automatic date update in version.inGDB Administrator1-1/+1
2021-05-04Define bfd_realloc(ptr,0) to return allocated memory, whilst ↵Nick Clifton4-23/+117
bfd_realloc_or_free(ptr,0) frees ptr. * libbfd.c (bfd_malloc): Provide some documenation. Treat a size of 0 as 1. (bfd_realloc): Likewise. (bfd_zmalloc): Likewise. (bfd_realloc_or_free): Provide some documentation. Treat a size of 0 as a request to free. * libbfd-in.h (bfd_realloc): Remove prototype. (bfd_realloc_or_free): Remove prototype. (bfd_zmalloc): Remove prototype. * libbfd.h: Regenerate.
2021-05-04Automatic date update in version.inGDB Administrator1-1/+1
2021-05-03x86: don't request useless overflow checkingJan Beulich3-40/+47
Relocations with a bitsize matching the architecture's address width can't usefully use an overflow checking approach other than "dont" or "signed": All others involve perhaps complex calculations in _bfd_relocate_contents() (or, not as severe, in bfd_check_overflow()) without ever finding anything to complain about - because of the address width masking applied. Avoid this unnecessary overhead and switch all such reloc types to "dont". Note that "signed" checking with rela relocations (i.e. x86-64 here) is only going to be useful if the addend actually got passed to _bfd_relocate_contents() (and maybe others) instead of bogusly adding in prior section contents (which apparently is assumed to be zero, and hence again no overflow would ever be detected). See https://sourceware.org/pipermail/binutils/2021-April/116164.html.
2021-05-03PPC: undefweak dynamic relocsAlan Modra3-2/+18
This makes the default for ppc to keep dynamic relocs on undefweak symbols when the code won't cause DT_TEXTREL (for instance when -fPIE or -fPIC). If ld is given -z dynamic-undefined-weak then dynamic relocations will be created for non-PIC at the expense of possibly causing DT_TEXTREL to be set on ppc32. Note that DT_TEXTREL and GNU indirect functions are incompatible. * elf32-ppc.c (allocate_dynrelocs): Keep dyn_relocs for undefweak symbols when -z dynamic-undefined-weak or when there are no dynamic relocs in read-only sections and -z nodynamic-undefined-weak is not given. * elf64-ppc.c (allocate_dynrelocs): Likewise.
2021-05-03PPC: ensure_undef_dynamic on weak undef only in pltAlan Modra3-2/+16
It's slightly weird to have a call to a weak function not protected by a test of that function being non-NULL, but the non-NULL test might be covered by a test of another function. For example: if (func1) { func1 (); func2 (); } where func2 is known to exist if func1 exists. * elf32-ppc.c (allocate_dynrelocs): Call ensure_undef_dynamic for weak undefined symols that only appear on PLT relocs. * elf64-ppc.c (allocate_dynrelocs): Likewise.
2021-05-03PR27755, powerpc-ld infinite loopAlan Modra2-1/+6
PR 27755 * elf32-ppc.c (ppc_elf_inline_plt): Do increment rel in loop.
2021-05-03csky: fix annobin test failsAlan Modra2-0/+42
* elf32-csky.c (is_mapping_symbol_name): New function. (csky_elf_is_target_special_symbol): Likewise. (csky_elf_maybe_function_sym): Likewise. (bfd_elf32_bfd_is_target_special_symbol): Define. (elf_backend_maybe_function_sym): Define.
2021-05-03Automatic date update in version.inGDB Administrator1-1/+1
2021-05-02Automatic date update in version.inGDB Administrator1-1/+1
2021-05-01Automatic date update in version.inGDB Administrator1-1/+1
2021-04-30Fix illegal memory access parsing a corrupt MACH-O format file.Nick Clifton2-1/+8
PR 27801 * mach-o.c (bfd_mach_o_core_fetch_environment): Use bfd_get_32 to read 32-bit value.
2021-04-30Fix an illegal memory access when parsing a corrupt core note.Nick Clifton2-1/+12
PR 27799 * elf32-xtensa.c (elf_xtensa_grok_prstatus): Check for core notes that are too small.
2021-04-30Fix a double free when re-allocating a buffer to size 0.Nick Clifton2-1/+7
PR 27797 * libbfd.c (bfd_realloc_or_free): Do not free a pointer than has been realloc'ed to size 0.
2021-04-30Fix illegal memory access when parsing a corrupt PE format file.Nick Clifton2-0/+10
PR 27795 * coff-rs6000.c (_bfd_xcoff_read_ar_hdr): Check for invalid name lengths.
2021-04-30Automatic date update in version.inGDB Administrator1-1/+1
2021-04-29Fix an access through a null pointer when parsing a corrupt SOM format fle.Nick Clifton3-1/+22
PR 27793 * som.c (som_slurp_symbol_table): Assign symbols without any scope to the undefined section. (som_decode_symclass): Check for a missing symbol section. * syms.c (bfd_decode_symclass): Likewise.
2021-04-29Fix illegal memory accesses when parsing a corrupt SOM format file.Nick Clifton2-4/+20
PR 27792 * som.c (som_slurp_string_table): Place a terminating NUL byte at the end of the table. (som_slurp_symbol_table): Check for an over-large offset into the string string table.
2021-04-29Automatic date update in version.inGDB Administrator1-1/+1
2021-04-28Stop the BFD library from treating annobin symbols as potential function ↵Nick Clifton5-30/+77
symbols. bfd * elf.c (_bfd_elf_maybe_function_sym): Do not accept annobin symbols as potential function symbols. * elfnn-aarch64.c (elfNN_aarch64_maybe_function_sym): Likewise. * elf64-ppc.c (ppc64_elf_maybe_function_sym): Likewise. * elf32-arm.c (elf32_arm_maybe_function_sym): Likewise. ld * testsuite/ld-elf/anno-sym.s: New test source file. * testsuite/ld-elf/anno-sym.d: New test driver. * testsuite/ld-elf/anno-sym.l: New test error output.
2021-04-28Automatic date update in version.inGDB Administrator1-1/+1
2021-04-26bfd: add stdlib.h when using abortMike Frysinger2-0/+6
Since this file calls abort() now, we need to include stdlib.h for its prototype.
2021-04-27Automatic date update in version.inGDB Administrator1-1/+1
2021-04-26x86: correct overflow checking for 16-bit PC-relative relocsJan Beulich3-2/+9
The only insn requiring a truly 16-bit PC-relative relocation outside of 16-bit mode is XBEGIN (with an operand size override). For it, the relocation generated should behave similar to 8- and (for 64-bit) 32-bit PC-relatives ones, i.e. be checked for a signed value to fit the field. This same mode is also correct for 16-bit code. Outside of 16-bit code, branches with operand size overrides act in a truly PC-relative way only when living in the low 32k of address space, as they truncate rIP to 16 bits. This can't be expressed by a PC-relative relocation. Putting in place a new testcase, I'd like to note that the two existing ones (pcrel16 and pcrel16abs) appear to be pretty pointless: They don't expect any error despite supposedly checking for overflow, and in fact there can't possibly be any error for the - former since gas doesn't emit any relocation in the first place there, - latter because the way the relocation gets expressed by gas doesn't allow the linker to notice the overflow; it should be detected by gas if at all, but see above (an error would be reported here for x86-64 afaict, but this test doesn't get re-used there).
2021-04-26Automatic date update in version.inGDB Administrator1-1/+1
2021-04-25Automatic date update in version.inGDB Administrator1-1/+1
2021-04-24Automatic date update in version.inGDB Administrator1-1/+1
2021-04-23Fix type of .persistent.bss sectionEric Botcazou2-0/+5
The change implementing the .persistent family of sections broke the existing support for the .persistent.bss section in the compiler: int a __attribute__ ((section (".persistent.bss"))); t.s: Assembler messages: t.s:4: Warning: setting incorrect section type for .persistent.bss The compiler encodes it as @nobits but the assembler expects @progbits. The assembler is incorrect and should treat the section like the compiler. bfd/ * elf.c (special_sections_p): Add .persistent.bss. gas/ * testsuite/gas/elf/section25.d: Run it everywhere. * testsuite/gas/elf/section26.d: Likewise. * testsuite/gas/elf/section26.s: Add test for .persistent.bss.
2021-04-23x86: TLS desc call relocs target zero-size fieldsJan Beulich3-2/+9
These are marker relocations, so together with their bit size being zero their byte size should be zero as well. This is expressed by a value of 3, not 0.
2021-04-23Automatic date update in version.inGDB Administrator1-1/+1
2021-04-22fix string table generation for XCOFF64 .debug sectionCl?ment Chigot5-18/+40
bfd * hash.c (struct bfd_strtab_hash): Remove xcoff field. Add length_field_size field. (_bfd_stringtab_init): Change prototype. Adapt to new length_field_size. (_bfd_xcoff_stringtab_init): Likewise. (_bfd_stringtab_add): Likewise. (_bfd_stringtab_emit): Likewise. * libbfd-in.h (_bfd_xcoff_stringtab_init): Change prototype. * libbfd.h: Regenerate. * xcofflink.c (_bfd_xcoff_bfd_link_hash_table_create): Call _bfd_xcoff_stringtab_init with isxcoff64 value.
2021-04-22Harmonize and improve auxiliary entries support for XCOFFCl?ment Chigot3-200/+203
bfd/ChangeLog: * coff-rs6000.c (_bfd_xcoff_swap_aux_in): Add errors for unsupported storage class or auxialiry entries. Improve and adapt to new aux structures. Add C_DWARF support. (_bfd_xcoff_swap_aux_out): Likewise. * coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Likewise. (_bfd_xcoff64_swap_aux_out): Likewise. binutils/ChangeLog: * od-xcoff.c (dump_xcoff32_symbols): Adapt to new aux structures. include/ChangeLog: * coff/internal.h (union internal_auxent): Add x_sect structure. * coff/rs6000.h (union external_auxent): Rework to match official documentation. * coff/rs6k64.h (union external_auxent): Likewise. (_AUX_SECT): New define.
2021-04-22Automatic date update in version.inGDB Administrator1-1/+1
2021-04-21Extend the description of PE header flags.Eli Zaretskii2-0/+39
PR 27760 include * coff/pe.h (IMAGE_DLLCHARACTERISTICS_APPCONTAINER): Define. (IMAGE_DLLCHARACTERISTICS_GUARD_CF): Define. bfd * peXXigen.c (_bfd_XX_print_private_bfd_data_common): Add display of IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP, IMAGE_FILE_NET_RUN_FROM_SWAP and IMAGE_FILE_UP_SYSTEM_ONLY flags. Decode the contents of the DllCharacteristics field.
2021-04-21Fix an assertion failure in the BFD library when parsing a corrupt SREC ↵Nick Clifton2-4/+14
format file. PR 27759 * srec.c (srec_read_section): Replace assertions with error returns.
2021-04-21Automatic date update in version.inGDB Administrator1-1/+1
2021-04-20Rework the R_NEG support on both gas and ld for the PowerPC AIX targets, in ↵Cl?ment Chigot7-5/+56
order to manage C++ exceptions built with GCC. bfd PR binutils/21700 * reloc.c (BFD_RELOC_PPC_NEG): New relocation. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * coff-rs6000.c (_bfd_xcoff_reloc_type_lookup): Add BFD_RELOC_PPC_NEG handler. (xcoff_reloc_type_neg): Correctly substract addend. * coff64-rs6000.c (xcoff64_howto_table): Add R_NEG_32 howto. (xcoff64_rtype2howto): Add handler for R_NEG_32. (xcoff64_reloc_type_lookup): Add BFD_RELOC_PPC_NEG handler. * xcofflink.c (xcoff_need_ldrel_p): Check output section for R_POS-like relocations. New argument added. (xcoff_mark): Adapt to new xcoff_need_ldrel_p argument. (xcoff_link_input_bfd): Likewise. gas * config/tc-ppc.c (ppc_get_csect_to_adjust): New function. (ppc_fix_adjustable): Manage fx_subsy part. (tc_gen_reloc): Create second relocation when both fx_addsy and fx_subsy are provided. * config/tc-ppc.h (RELOC_EXPANSION_POSSIBLE): New define. (MAX_RELOC_EXPANSION): Likewise. (TC_FORCE_RELOCATION_SUB_SAME): Likewise (UNDEFINED_DIFFERENCE_OK): Likewise * testsuite/gas/all/gas.exp: Skip difference between two undefined symbols test. ld * testsuite/ld-powerpc/aix52.exp: Add new test. * testsuite/ld-powerpc/aix-neg-reloc-32.d: New test. * testsuite/ld-powerpc/aix-neg-reloc-64.d: New test. * testsuite/ld-powerpc/aix-neg-reloc.ex: New test. * testsuite/ld-powerpc/aix-neg-reloc.s: New test.
2021-04-20Automatic date update in version.inGDB Administrator1-1/+1
2021-04-19Automatic date update in version.inGDB Administrator1-1/+1
2021-04-18Automatic date update in version.inGDB Administrator1-1/+1
2021-04-17Automatic date update in version.inGDB Administrator1-1/+1
2021-04-16PR27567, Linking PE files adds alignment section flags to executablesAlan Modra2-8/+15
So don't set those flags for an executable. In the patch I also test DYNAMIC even though the PE bfd code doesn't appear to set it for dlls. I figure it doesn't hurt to include that flag too. PR 27567 bfd/ * coffcode.h (styp_to_sec_flags): Use an unsigned long styp_flags. (coff_write_object_contents): Pass bfd to COFF_ENCODE_ALIGNMENT, ignore alignment checks when return is false. Formatting. include/ * coff/internal.h (struct internal_scnhdr): Make s_flags unsigned long. * coff/pe.h (COFF_ENCODE_ALIGNMENT): Don't set align flags for an executable and return false. Do so for a relocatable object and evaluate to true. * coff/ti.h (COFF_ENCODE_ALIGNMENT): Add bfd arg and evaluate to true. (COFF_DECODE_ALIGNMENT): Formatting. * coff/z80.h (COFF_ENCODE_ALIGNMENT): Similarly. (COFF_DECODE_ALIGNMENT): Similarly.
2021-04-16Automatic date update in version.inGDB Administrator1-1/+1
2021-04-15RISC-V: PR27584, surpress local and empty name symbols for nm.Nelson Chu2-0/+18
The local ".L0" symbol are usually generated to mark where the auipc instruction is, and clang also uses ".LBB" to do the same thing. Besides, clang also uses the empty name symbols for label differences. Arm surpress their mapping symbols by regarding them as special symbols, and MIPS surpress all local symbols. Therefore, RISC-V probably need to surpress the local and empty name symbols for nm and related tools. User can use "--special-syms" to show these surpressed symbols. bfd/ PR27584 * elfnn-riscv.c (riscv_elf_is_target_special_symbol): Added to omit local and empty symbols since they usually generated to mark the auipc instructions.
2021-04-15CSKY: Fix special_function in howto tableLifang Xia2-60/+70
The special_function for reloc should be 'bfd_elf_generic_reloc', reloc list: R_CKCORE_PCREL_IMM16BY2, R_CKCORE_PCREL_IMM16BY4, R_CKCORE_PCREL_IMM10BY4, R_CKCORE_PCREL_IMM18BY2, R_CKCORE_PCREL_FLRW_IMM8BY4 bfd/ * elf32-csky.c (csky_elf_howto_table) <R_CKCORE_PCREL_IMM16BY2>: Set special_function to bfd_elf_generic_reloc. <R_CKCORE_PCREL_IMM16BY4>: Likewise. <R_CKCORE_PCREL_IMM10BY4>: Likewise. <R_CKCORE_PCREL_IMM18BY2>: Likewise. <R_CKCORE_PCREL_FLRW_IMM8BY4>: Likewise.
2021-04-15Automatic date update in version.inGDB Administrator1-1/+1
2021-04-14elf: Set p_memsz to p_filesz for loadable PT_NOTE segmentH.J. Lu2-0/+11
Since p_memsz of the loadable PT_NOTE segment should be the same as p_filesz, set p_memsz on the loadable PT_NOTE segment when updating p_filesz. bfd/ PR binutils/27708 * elf.c (assign_file_positions_for_non_load_sections): Set p_memsz to p_filesz for the loadable PT_NOTE segment. binutils/ PR binutils/27708 * testsuite/binutils-all/x86-64/pr27708.dump: New file. * testsuite/binutils-all/x86-64/pr27708.exe.bz2: Likewise. * testsuite/binutils-all/x86-64/x86-64.exp: Run binutils/27708 test.
2021-04-14Remove unneeded tests for definitions of NT_BSDNETCORE values.Frederic Cambus2-4/+5
binutils* readelf.c (get_netbsd_elfcore_note_type): Remove unneeded #ifdef checks for NT_NETBSDCORE_AUXV and NT_NETBSDCORE_LWPSTATUS. bfd * elf.c (elfcore_grok_netbsd_note): Remove unneeded #ifdef checks for NT_NETBSDCORE_AUXV and NT_NETBSDCORE_LWPSTATUS.
2021-04-14PR27631, ubsan: elf32-metag.c:1550:10Alan Modra2-2/+8
PR 27631 * elf32-metag.c (elf_metag_relocate_section): Don't use &hh->elf when hh might be NULL, test for NULL first.