aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2021-05-17Automatic date update in version.inGDB Administrator1-1/+1
2021-05-16Automatic date update in version.inGDB Administrator1-1/+1
2021-05-15Automatic date update in version.inGDB Administrator1-1/+1
2021-05-14RISC-V: Check the overflow for %pcrel_lo addend more strictly.Nelson Chu2-6/+22
The %pcrel_lo addend may causes the overflow, and need more than one %pcrel_hi values. But there may be only one auipc, shared by those %pcrel_lo with addends. However, the existing check method in the riscv_resolve_pcrel_lo_relocs, may not be able to work for some special/corner cases. Consider the testcases pcrel-lo-addend-2b. Before applying this patch, I can compile it successfully. But in fact the addend cause the value of %pcrel_hi to be different. This patch try to check the value of %pcrel_hi directly, to make sure it won't be changed. Otherwise, linker will report the following errors, (.text+0xa): dangerous relocation: %pcrel_lo overflow with an addend, the value of %pcrel_hi is 0x1000 without any addend, but may be 0x2000 after adding the %pcrel_lo addend The toolchain regressions, rv64gc-linux/rv64gc-elf/rv32gc-linux/rv32i-elf, pass expectedly and looks fine. bfd/ * elfnn-riscv.c (riscv_resolve_pcrel_lo_relocs): Check the values of %pcrel_hi, before and after adding the addend. Make sure the value won't be changed, otherwise, report dangerous error. ld/ * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. * testsuite/ld-riscv-elf/pcrel-lo-addend-2a.d: Renamed from pcrel-lo-addend-2. * testsuite/ld-riscv-elf/pcrel-lo-addend-2a.s: Likewise. * testsuite/ld-riscv-elf/pcrel-lo-addend-2b.d: New testcase. * testsuite/ld-riscv-elf/pcrel-lo-addend-2b.s: Likewise.
2021-05-14Automatic date update in version.inGDB Administrator1-1/+1
2021-05-13RISC-V: Record implicit subsets in a table, to avoid repeated codes.Nelson Chu2-54/+61
Add a new table, riscv_implicit_subsets, to record all implicit information. So that we add all implicit subsets according to the table, to avoid too many repeated codes in the riscv_parse_add_implicit_subsets. Besides, the check_func is used to check whether we should add this implicit subset. For example, check_implicit_for_i checks the version of i, and we only add zicsr and zifencei implicitly only when the version less than 2.1. bfd/ * elfxx-riscv.c (check_implicit_always): The check_func, always add the implicit subset without checking. (check_implicit_for_i): The check_func for i, only add zicsr and zifencei when the version of i less than 2.1. (struct riscv_implicit_subset): Record the subsets and their corresponding implicit subsets. (riscv_implicit_subsets): Table records all implicit informations. (riscv_parse_add_implicit_subsets): Updated and add implicit subsets according to riscv_implicit_subsets. Remove the redundant codes.
2021-05-13PR27858, global-buffer-overflowAlan Modra2-3/+8
PR 27858 * elf32-sh.c (sh_elf_info_to_howto): Correct check for last valid reloc howto.
2021-05-13Automatic date update in version.inGDB Administrator1-1/+1
2021-05-12Add MTE register set support for core filesLuis Machado3-0/+40
* elf-bfd.h (elfcore_write_aarch_mte): New prototype. * elf.c (elfcore_grok_aarch_mte, elfcore_write_aarch_mte): New functions. (elfcore_grok_note): Handle notes of type NT_ARM_TAGGED_ADDR_CTRL. (elfcore_write_register_note): Handle MTE notes.
2021-05-12Automatic date update in version.inGDB Administrator1-1/+1
2021-05-11arm: correctly decode Tag_THUMB_ISA_use=3 for thumb2 featuresRichard Earnshaw1-1/+3
This was detected when a user accidentally tried to build a shared library using armv8-m.main objects. The resulting error was "warning: thumb-1 mode PLT generation not currently supported". Something was clearly wrong because v8-m.main is a thumb-2 variant. It turns out that the code to detect thumb-2 in object files hadn't been updated for the extended definition of Tag_THUMB_ISA_use to support the value 3, meaning 'work it out for yourself from the architecture tag'; something that is now necessary given that the line between thumb-1 and thumb-2 has become blurred over time. Another problem with the function doing this calculation was that the absence of this tag (implying a default value 0) should mean use of thumb code was NOT permitted. However, the code went on to look at the architecture flags and decide that it could ignore this if the architecture flags said that thumb2 features were available, thus completely ignoring the intended meaning. bfd/ * elf32-arm.c (using_thumb2): Correctly handle Tag_THUMB_ISA_use values 0 and 3.
2021-05-11PR27844, Unstable symbol name in objdump outputsAlan Modra3-2/+9
Special care for fuzzers. PR 27844 * pdp11.c (aout_get_external_symbols): Clear first four bytes of strings array, not just the first byte. * aoutx.h (aout_get_external_symbols): Likewise.
2021-05-11Automatic date update in version.inGDB Administrator1-1/+1
2021-05-10Remove strayed fprintf in commit 23182ac0d83H.J. Lu2-1/+6
PR binutils/27839 * simple.c (bfd_simple_get_relocated_section_contents): Remove strayed fprintf.
2021-05-10Fix an indirection via uninitialised memory when parsing a corrupt input file.Nick Clifton2-0/+46
PR 27839 * simple.c (simple_dummy_add_to_set): New function. (simple_dummy_constructor): New function. (simple_dummy_multiple_common): New function. (bfd_simple_get_relocated_section_contents): Zero out the callbacks structure, and then set the add_to_set, constructor and multiple_common fields.
2021-05-10Enable linker garbage collection for the PRU target.Dimitar Dimitrov2-0/+5
bfd * elf32-pru.c (elf_backend_can_gc_sections): Define as 1. ld * testsuite/ld-elf/group8a.d: Remove pru from XFAIL list. * testsuite/ld-elf/group8b.d: Ditto. * testsuite/ld-elf/group9a.d: Ditto. * testsuite/ld-elf/group9b.d: Ditto. * testsuite/ld-elf/pr12851.d: Ditto. * testsuite/ld-elf/pr22677.d: Ditto. * testsuite/lib/ld-lib.exp (check_gc_sections_available): Remove pru from list.
2021-05-10Automatic date update in version.inGDB Administrator1-1/+1
2021-05-09Automatic date update in version.inGDB Administrator1-1/+1
2021-05-08support generating multi-html pages in parallelMike Frysinger3-7/+22
Use the pattern from other projects where we generate the html pages in a dir named the same as the project. So now we have: gas/doc/gas.html - single html page gas/doc/gas/ - multiple html pages This works for projects that have a doc/ subdir already, but gprof & ld require a little tweaking since they generate their docs in their respective toplevels.
2021-05-08generate single html manual page by defaultMike Frysinger3-0/+8
This better matches other GNU projects like autoconf/automake where the html manual is the single page form. We'll support the multi-page form in a follow up change.
2021-05-08Automatic date update in version.inGDB Administrator1-1/+1
2021-05-07Fix .dwsect generation for XCOFF. Handle .function generated with DWARF on ↵Cl?ment Chigot4-2/+21
XCOFF. gas * config/tc-ppc.c (ppc_function): Update comment for fifth argument. (ppc_frob_symbol): Remove ppc_last_function check. Make sure coff_last_function is reset. Correctly set fsize when not provided in .function. * testsuite/gas/ppc/aix.exp: New tests. * testsuite/gas/ppc/xcoff-function-1-32.d: New test. * testsuite/gas/ppc/xcoff-function-1-64.d: New test. * testsuite/gas/ppc/xcoff-function-1.s: New test. bfd * coff-rs6000.c (xcoff_dwsect_names): Add new DWARF sections. * coffgen.c (coff_pointerize_aux): Handle C_DWARF. (coff_print_symbol): Likewise. * libxcoff.h (XCOFF_DWSECT_NBR_NAMES): Update. gas * config/obj-coff.c (coff_frob_symbol): Don't skip C_DWARF. (coff_adjust_section_syms): Use corrext auxent for C_DWARF. (coff_frob_section): Likewise. * config/obj-coff.h (SA_GET_SECT_SCNLEN, SA_GET_SECT_NRELOC, SA_SET_SECT_SCNLEN, SA_SET_SECT_NRELOC) New defines. (SET_SECTION_RELOCS): Adjust for C_DWARF. * config/tc-ppc.c (ppc_frob_symbol): Don't skip C_DWARF. (ppc_adjust_symtab): Reorder C_DWARF symbols. * testsuite/gas/ppc/aix.exp: New tests. * testsuite/gas/ppc/xcoff-dwsect-2-32.d: New test. * testsuite/gas/ppc/xcoff-dwsect-2-64.d: New test. * testsuite/gas/ppc/xcoff-dwsect-2.s: New test. include * coff/internal.h (C_DWARF): New define. * coff/xcoff.h (SSUBTYP_DWLOC, SSUBTYP_DWFRAME, SSUBTYP_DWMAC): New defines.
2021-05-07x86-64/ELF: clear src_mask for all reloc typesJan Beulich2-67/+70
x86-64 uses rela relocations. The comment next to the field's declaration says "Non-zero values for ELF USE_RELA targets should be viewed with suspicion ..." And indeed the fields being non-zero causes section contents to be accumulated into the final relocated values in addition to the relocations' addends, which is contrary to the ELF spec.
2021-05-07Regenerate bfd-in2.h and libbfd.hAlan Modra3-2/+7
Commit 0b3e14c90283 edited these by hand. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate.
2021-05-07Automatic date update in version.inGDB Administrator1-1/+1
2021-05-06or1k: Support large plt_relocs when generating plt entriesStafford Horne2-39/+126
The current PLT generation code will generate invalid code when the PLT relocation offset exceeds 64k. This fixes the issue by detecting large plt_reloc offsets and generare code sequences to create larger plt relocations. The "large" plt code needs 2 extra instructions to create 32-bit offsets. bfd/ChangeLog: PR 27746 * elf32-or1k.c (PLT_ENTRY_SIZE_LARGE, PLT_MAX_INSN_COUNT, OR1K_ADD, OR1K_ORI): New macros to help with plt creation. (elf_or1k_link_hash_table): New field plt_count. (elf_or1k_link_hash_entry): New field plt_index. (elf_or1k_plt_entry_size): New function. (or1k_write_plt_entry): Update to support variable size PLTs. (or1k_elf_finish_dynamic_sections): Use new or1k_write_plt_entry API. (or1k_elf_finish_dynamic_symbol): Update to write large PLTs when needed. (allocate_dynrelocs): Use elf_or1k_plt_entry_size to account for PLT size. ld/ChangeLog: PR 27746 testsuite/ld-or1k/or1k.exp (or1kplttests): Add tests for linking along with gotha() relocations. testsuite/ld-or1k/gotha1.dd: New file. testsuite/ld-or1k/gotha1.s: New file. testsuite/ld-or1k/gotha2.dd: New file. testsuite/ld-or1k/gotha2.s: New file testsuite/ld-or1k/pltlib.s (x): Define size to avoid link failure.
2021-05-06or1k: Avoid R_OR1K_GOT16 overflow failures in presence of R_OR1K_GOT_AHI16Stafford Horne2-0/+18
Now that we support R_OR1K_GOT_AHI16 we can relax the R_OR1K_GOT16 overflow validation check if the section has R_OR1K_GOT_AHI16. We cannot simple disable R_OR1K_GOT16 overflow validation as there will still be binaries that will have only R_OR1K_GOT16. The R_OR1K_GOT_AHI16 relocation will only be added by GCC when building with the option -mcmodel=large. This assumes that R_OR1K_GOT_AHI16 will come before R_OR1K_GOT16, which is the code pattern that will be emitted by GCC. bfd/ChangeLog: PR 21464 * elf32-or1k.c (or1k_elf_relocate_section): Relax R_OR1K_GOT16 overflow check if we have R_OR1K_GOT_AHI16 followed by R_OR1K_GOT16.
2021-05-06or1k: Implement relocation R_OR1K_GOT_AHI16 for gotha()Stafford Horne5-1/+34
The gotha() relocation mnemonic will be outputted by OpenRISC GCC when using the -mcmodel=large option. This relocation is used along with got() to generate 32-bit GOT offsets. This increases the previous GOT offset limit from the previous 16-bit (64K) limit. This is needed on large binaries where the GOT grows larger than 64k. bfd/ChangeLog: PR 21464 * bfd-in2.h: Add BFD_RELOC_OR1K_GOT_AHI16 relocation. * elf32-or1k.c (or1k_elf_howto_table, or1k_reloc_map): Likewise. (or1k_final_link_relocate, or1k_elf_relocate_section, or1k_elf_check_relocs): Likewise. * libbfd.h (bfd_reloc_code_real_names): Likewise. * reloc.c: Likewise. cpu/ChangeLog: PR 21464 * or1k.opc (or1k_imm16_relocs, parse_reloc): Define parse logic for gotha() relocation. include/ChangeLog: PR 21464 * elf/or1k.h (elf_or1k_reloc_type): Define R_OR1K_GOT_AHI16 number. opcodes/ChangeLog: PR 21464 * or1k-asm.c: Regenerate. gas/ChangeLog: PR 21464 * testsuite/gas/or1k/reloc-1.s: Add test for new relocation. * testsuite/gas/or1k/reloc-1.d: Add test result for new relocation. Cc: Giulio Benetti <giulio.benetti@benettiengineering.com> fixup reloc, add tests
2021-05-06or1k: Fix issue with plt link failure for local callsStafford Horne2-5/+11
When building protobuf we were seeing the assert failure: /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld: BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377 /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld: BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377 /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld: BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377 collect2: error: ld returned 1 exit status This failure happens while writing out PLT entries, there is a check "BFD_ASSERT (h->dynindx != -1)" to confirm all plt entries have dynamic symbol attributes. This was failing for symbols that were "forced_local" in previous linking code. The fix adds logic to or1k_elf_adjust_dynamic_symbol to identify "forced_local" symbols and exclude them from the the PLT. bfd/ChangeLog: PR 27624 * elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Change condition used to cleanup plt entries to cleanup forced local entries. Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
2021-05-05elf: Always append ".COUNT" to local symbolsH.J. Lu2-20/+25
Always append ".COUNT" to local symbols to avoid potential conflicts with existing local symbol "XXX.COUNT". bfd/ PR ld/27825 * elflink.c (elf_link_output_symstrtab): Always append ".COUNT" to local symbols. ld/ PR ld/27825 * testsuite/ld-elf/pr27825-1.d: New file. * testsuite/ld-elf/pr27825-1a.s: Likewise. * testsuite/ld-elf/pr27825-1b.s: Likewise. * testsuite/ld-elf/pr27825-2.d: Likewise. * testsuite/ld-elf/pr27825-2a.s: Likewise. * testsuite/ld-elf/pr27825-2b.s: Likewise.
2021-05-06Automatic date update in version.inGDB Administrator1-1/+1
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.