aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2020-09-16Tidy elf_symbol_fromAlan Modra3-5/+11
bfd/ * elf-bfd.h (elf_symbol_from): Remove unused ABFD parameter. * elf.c (ignore_section_sym, _bfd_elf_copy_private_symbol_data), (swap_out_syms): Adjust elf_symbol_from invocation. binutils/ * nm.c (print_symbol): Adjust elf_symbol_from invocation. * objcopy.c (is_hidden_symbol): Likewise. gas/ * config/obj-elf.c (obj_elf_visibility, elf_frob_symbol): Adjust elf_symbol_from invocation. * config/tc-aarch64.c (s_variant_pcs): Likewise. * config/tc-m68hc11.c (s_m68hc11_mark_symbol): Likewise. * config/tc-ppc.c (ppc_elf_localentry, ppc_force_relocation), (ppc_fix_adjustable): Likewise. * config/tc-xgate.c (xgate_frob_symbol): Likewise. ld/ * plugin.c (asymbol_from_plugin_symbol): Adjust elf_symbol_from invocation. opcodes/ * ppc-dis.c (ppc_symbol_is_valid): Adjust elf_symbol_from invocation.
2020-09-16PR26623, buffer overflow in ppc_symbol_is_validAlan Modra2-1/+7
PR 26623 * elf-bfd.h (elf_symbol_from): Exclude synthetic symbols.
2020-09-16Automatic date update in version.inGDB Administrator1-1/+1
2020-09-15PE/x86-64: Display PE relocation namesH.J. Lu2-11/+15
For PE/x86-64, display PE relocation names: R_X86_64_64 -> IMAGE_REL_AMD64_ADDR64 R_X86_64_32 -> IMAGE_REL_AMD64_ADDR32. rva32 -> IMAGE_REL_AMD64_ADDR32NB R_X86_64_PC32 -> IMAGE_REL_AMD64_REL32 DISP32+1 -> IMAGE_REL_AMD64_REL32_1 DISP32+2 -> IMAGE_REL_AMD64_REL32_2 DISP32+3 -> IMAGE_REL_AMD64_REL32_3 DISP32+4 -> IMAGE_REL_AMD64_REL32_4 DISP32+5 -> IMAGE_REL_AMD64_REL32_5 secrel32 -> IMAGE_REL_AMD64_SECREL bfd/ * coff-x86_64.c (howto_table): Display PE relocation names. gas/ * testsuite/gas/cfi/reloc-pe-i386.d: Updated. * testsuite/gas/i386/x86-64-w64-pcrel.d: Likewise.
2020-09-15CRIS: fix PR ld/26589, a missing NULL check in fix for PR ld/22269Hans-Peter Nilsson2-1/+7
Not sure why there wasn't a NULL check in the ld/22269 patch (e01c16a8) at the time, as there was one for the corresponding patch to elf32-m68k.c (5056ba1d). Incidentally, I had missed that in 2017, as a prerequisite for the ld/22269 series, the check_relocs function finally were made "safe"! (I.e. the number of references and symbol types are final, garbage collection done, so port-specific accounting can be made sanely.) Committed. bfd: PR ld/26589 * elf32-cris.c (cris_elf_check_relocs): Add missing NULL check on argument before calling UNDEFWEAK_NO_DYNAMIC_RELOC. ld: PR ld/26589 * testsuite/ld-elf/pr26589.d, testsuite/ld-elf/locref3.s: New test.
2020-09-15Automatic date update in version.inGDB Administrator1-1/+1
2020-09-14Automatic date update in version.inGDB Administrator1-1/+1
2020-09-13Automatic date update in version.inGDB Administrator1-1/+1
2020-09-12elf: Add -z unique-symbol to avoid duplicated local symbol namesH.J. Lu2-41/+177
The symbol string table in the .symtab section is optional and cosmetic. The contents of the .symtab section have no impact on run-time execution. The symbol names in the symbol string table help distinguish addresses at different locations. Add a linker option, -z unique-symbol, to avoid duplicated local symbol names in the symbol string table. This feature was well received by the livepatch maintainers. It not only solves the duplicated local symbol name problem, but also would allow livepatch to more precisely locate duplicate symbols in general for patching. bfd/ PR ld/26391 * elflink.c (elf_final_link_info): Add local_hash_table. (local_hash_entry): New. (local_hash_newfunc): Likewise. (elf_link_output_symstrtab): Append ".COUNT" to duplicated local symbols. (bfd_elf_final_link): Initialize and free local_hash_table for "-z unique-symbol". include/ PR ld/26391 * bfdlink.h (bfd_link_info): Add unique_symbol. ld/ PR ld/26391 * NEWS: Mention "-z unique-symbol". * emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Handle "-z unique-symbol" and "-z nounique-symbol". * ld.texi: Document "-z unique-symbol" and "-z nounique-symbol". * lexsup.c (elf_static_list_options): Add "-z unique-symbol" and "-z nounique-symbol". * testsuite/ld-elf/elf.exp: Add PR ld/26391 tests. * testsuite/ld-elf/pr26391.nd: New file. * testsuite/ld-elf/pr26391.out: Likewise. * testsuite/ld-elf/pr26391a.c: Likewise. * testsuite/ld-elf/pr26391b.c: Likewise. * testsuite/ld-elf/pr26391c.c: Likewise. * testsuite/ld-elf/pr26391d.c: Likewise.
2020-09-12Automatic date update in version.inGDB Administrator1-1/+1
2020-09-11Automatic date update in version.inGDB Administrator1-1/+1
2020-09-10aarch64: Return an error on conditional branch to an undefined symbolSiddhesh Poyarekar2-18/+26
The fix in 7e05773767820b441b23a16628b55c98cb1aef46 introduced a PLT for conditional jumps when the target symbol is undefined. This is incorrect because conditional branch relocations are not allowed to clobber IP0/IP1 and hence, should not result in a dynamic relocation. Revert that change and in its place, issue an error when the target symbol is undefined. bfd/ 2020-09-10 Siddhesh Poyarekar <siddesh.poyarekar@arm.com> * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Revert changes in 7e05773767820b441b23a16628b55c98cb1aef46. Set error for undefined symbol in BFD_RELOC_AARCH64_BRANCH19 and BFD_RELOC_AARCH64_TSTBR14 relocations. ld/ 2020-09-10 Siddhesh Poyarekar <siddesh.poyarekar@arm.com> * testsuite/ld-aarch64/emit-relocs-560.d: Expect error instead of valid output.
2020-09-10Automatic date update in version.inGDB Administrator1-1/+1
2020-09-09Fix thinko in the code to check coff archive elements.Nick Clifton2-4/+9
* cofflink.c (coff_link_check_archive_element): Move the check for coff type input to the start of the function.
2020-09-09Automatic date update in version.inGDB Administrator1-1/+1
2020-09-09Re: MSP430: Support relocations for subtract expressions in .uleb128 directivesAlan Modra3-2/+9
Put the prototype where it won't disappear on the next regen of libbfd.h. * libbfd-in.h (_bfd_write_unsigned_leb128): Declare. * libbfd.h: Regenerate.
2020-09-08MSP430: Support relocations for subtract expressions in .uleb128 directivesJozef Lawrynowicz6-7/+197
Link-time relaxations of branches are common for MSP430, given that GCC can generate pessimal branch instructions, and the -mcode-region=either/-mdata-region=either options to shuffle sections can further change the type of branch instruction required. These relaxations can result in invalid code when .uleb128 directives, used in the .gcc_except_table section, are used to calculate the distance between two labels. A value for the .uleb128 directive is calculated at assembly-time, and can't be updated at link-time, even if relaxation causes the distance between the labels to change. This patch adds relocations for subtract expressions in .uleb128 directives, to allow the linker to re-calculate the value of these expressions after relaxation has been performed. bfd/ChangeLog: * bfd-in2.h (bfd_reloc_code_real): Add BFD_RELOC_MSP430_{SET,SUB}_ULEB128. * elf32-msp430.c (msp430_elf_ignore_reloc): New. (elf_msp430_howto_table): Add R_MSP430{,X}_GNU_{SET,SUB}_ULEB128. (msp430_reloc_map): Add R_MSP430_GNU_{SET,SUB}_ULEB128. (msp430x_reloc_map): Add R_MSP430X_GNU_{SET,SUB}_ULEB128. (write_uleb128): New. (msp430_final_link_relocate): Handle R_MSP430{,X}_GNU_{SET,SUB}_ULEB128. * libbfd.c (_bfd_write_unsigned_leb128): New. * libbfd.h (_bfd_write_unsigned_leb128): New prototype. Add BFD_RELOC_MSP430_{SET,SUB}_ULEB128. * reloc.c: Document BFD_RELOC_MSP430_{SET,SUB}_ULEB128. binutils/ChangeLog: * readelf.c (target_specific_reloc_handling): Handle R_MSP430{,X}_GNU_{SET,SUB}_ULEB128. gas/ChangeLog: * config/tc-msp430.c (msp430_insert_uleb128_fixes): New. (msp430_md_end): Call msp430_insert_uleb128_fixes. include/ChangeLog: * elf/msp430.h (elf_msp430_reloc_type): Add R_MSP430_GNU_{SET,SUB}_ULEB128. (elf_msp430x_reloc_type): Add R_MSP430X_GNU_{SET,SUB}_ULEB128. ld/ChangeLog: * testsuite/ld-msp430-elf/msp430-elf.exp: Run new tests. * testsuite/ld-msp430-elf/uleb128.s: New test. * testsuite/ld-msp430-elf/uleb128_430.d: New test. * testsuite/ld-msp430-elf/uleb128_430x.d: New test.
2020-09-08aarch64: Add base support for Armv8-RAlex Coplan4-1/+14
This patch adds the basic infrastructure needed to support Armv8-R in AArch64 binutils: new command-line flags, new feature bits, a new BFD architecture, and support for differentiating between architecture variants in the disassembler. The new command-line options added by this patch are -march=armv8-r in GAS and -m aarch64:armv8-r in objdump. The disassembler support is necessary since Armv8-R AArch64 introduces a system register (VSCTLR_EL2) which shares an encoding with a different system register (TTBR0_EL2) in Armv8-A. This also allows us to use the correct preferred disassembly for the new DFB alias introduced in Armv8-R. bfd/ChangeLog: 2020-09-08 Alex Coplan <alex.coplan@arm.com> * archures.c (bfd_mach_aarch64_8R): New. * bfd-in2.h: Regenerate. * cpu-aarch64.c (bfd_aarch64_arch_v8_r): New. (bfd_aarch64_arch_ilp32): Update tail pointer. gas/ChangeLog: 2020-09-08 Alex Coplan <alex.coplan@arm.com> * config/tc-aarch64.c (aarch64_archs): Add armv8-r. * doc/c-aarch64.texi: Document -march=armv8-r. include/ChangeLog: 2020-09-08 Alex Coplan <alex.coplan@arm.com> * opcode/aarch64.h (AARCH64_FEATURE_V8_A): New. (AARCH64_FEATURE_V8_R): New. (AARCH64_ARCH_V8): Include new A-profile feature bit. (AARCH64_ARCH_V8_R): New. opcodes/ChangeLog: 2020-09-08 Alex Coplan <alex.coplan@arm.com> * aarch64-dis.c (arch_variant): New. (determine_disassembling_preference): Disassemble according to arch variant. (select_aarch64_variant): New. (print_insn_aarch64): Set feature set.
2020-09-08PR26580, Size and alignment of commons vs as-needed shared libAlan Modra2-40/+46
Two pieces to this puzzle: 1) Revert HJ's fix for PR13250 so that size and alignment isn't sticky, instead attack the real underlying problem that _bfd_generic_link_add_one_symbol does the wrong thing in making a common section in a shared library bfd. 2) Save and restore common u.c.p fields, which hold the section and alignment. A better fix for (2) would be to throw away all of that horrible code saving and restoring the hash table when loading as-needed library symbols, and instead do a scan over as-needed library symbols before adding anything. bfd/ PR 13250 PR 26580 * elflink.c (_bfd_elf_merge_symbol): Make "override" a bfd**. Return oldbfd in override when old common should override new common. (_bfd_elf_add_default_symbol): Adjust to suit. (elf_link_add_object_symbols): Likewise. Pass "override" to _bfd_generic_link_add_one_symbol. Save and restore common u.c.p field for --as-needed shared libraries. Revert pr13250 changes. ld/ * testsuite/ld-elf/pr26580-a.s, * testsuite/ld-elf/pr26580-b.s, * testsuite/ld-elf/pr26580-1.sd, * testsuite/ld-elf/pr26580-2.sd: New tests * testsuite/ld-elf/comm-data.exp: Run new tests. * testsuite/ld-elf/pr26580-a.c, * testsuite/ld-elf/pr26580-b.c, * testsuite/ld-elf/pr26580-3.out, * testsuite/ld-elf/pr26580-4.out: New tests. * testsuite/ld-elf/shared.exp: Run new tests.
2020-09-08Stop the plugin handler from ignoring unknown symbol types when ↵Nick Clifton2-0/+7
conanicalizing weak definitions. * plugin.c (bfd_plugin_canonicalize_symtab): Handle the case of an unrecognized symbol type in a weak definition.
2020-09-08Automatic date update in version.inGDB Administrator1-1/+1
2020-09-07Automatic date update in version.inGDB Administrator1-1/+1
2020-09-06Automatic date update in version.inGDB Administrator1-1/+1
2020-09-05Automatic date update in version.inGDB Administrator1-1/+1
2020-09-04PR26574, heap buffer overflow in _bfd_elf_slurp_secondary_reloc_sectionAlan Modra3-5/+14
A horribly fuzzed object with section headers inside the ELF header. Disallow that, and crazy reloc sizes. PR 26574 * elfcode.h (elf_object_p): Sanity check section header offset. * elf.c (_bfd_elf_slurp_secondary_reloc_section): Sanity check sh_entsize.
2020-09-04Allow plugin syms to mark as-needed shared libs neededAlan Modra2-10/+12
We must tell LTO about symbols in all shared libraries loaded. That means we can't load extra shared libraries after LTO recompilation, at least, not those that affect the set of symbols that LTO cares about, the IR symbols. This change will likely result in complaints about --as-needed libraries being loaded unnecessarily, but being correct is more important than being optimal. One of the PR15146 tests regresses, and while that could be hidden by disabling the missing dso message by making it conditional on h->root.non_ir_ref_regular, that would just be sweeping a problem under the rug. bfd/ PR 15146 PR 26314 PR 26530 * elflink.c (elf_link_add_object_symbols): Do set def_regular and ref_regular for IR symbols. Don't clear dynsym, allowing IR symbols to load --as-needed shared libraries, but prevent IR symbols from becoming dynamic. ld/ * testsuite/ld-plugin/lto.exp: Don't run pr15146 tests. * testsuite/ld-plugin/pr15146.d: Delete. * testsuite/ld-plugin/pr15146a.c: Delete. * testsuite/ld-plugin/pr15146b.c: Delete. * testsuite/ld-plugin/pr15146c.c: Delete. * testsuite/ld-plugin/pr15146d.c: Delete.
2020-09-04Automatic date update in version.inGDB Administrator1-1/+1
2020-09-03Fix a division by zero error when processing secondary relocs in a fuzzed ↵Nick Clifton2-0/+17
input file. PR 26521 * elf.c (_bfd_elf_write_secondary_reloc_section): Check for secondary reloc sections with a zero sh_entsize field.
2020-09-03RISC-V: Minor cleanup and typos when merging elf attributes.Nelson Chu2-12/+19
bfd/ * elfnn-riscv.c (riscv_i_or_e_p): Minor cleanup for warnings/errors. (riscv_merge_std_ext): Likewise. (riscv_merge_arch_attr_info): Likewise. (riscv_merge_attributes): Likewise and fix comment typos. ld/ * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Remove the useless `warnings` keywords. * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Likewise.
2020-09-03RISC-V: Report warnings rather than errors for the mis-matched ISA versions.Nelson Chu2-32/+51
Same as the privileged spec attributes check - different ISA versions should be compatible, unless there are some known conflicts. Therefore, we should allow to link objects with different ISA versions, and update the output ISA versions once the corresponding input ones are newer. But it's better to also warn people that the conflicts may happen when the ISA versions are mis-matched. bfd/ * elfnn-riscv.c (riscv_version_mismatch): Change the return type from void to bfd_boolean. Report warnings rather than errors when the ISA versions are mis-matched. Afterwards, remember to update the output ISA versions to the newest ones. (riscv_merge_std_ext): Allow to link objects with different standard ISA versions. Try to add output ISA versions to merged_subsets first. (riscv_merge_multi_letter_ext): Likewise. But for standard additional ISA and non-standard ISA versions. ld/ * testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Update the message from error to warning. * testsuite/ld-riscv-elf/attr-merge-arch-failed-02.d: New testcases. * testsuite/ld-riscv-elf/attr-merge-arch-failed-02a.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-failed-02b.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-failed-02c.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-failed-02d.s: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
2020-09-03RISC-V: Improve the error message for the mis-matched ISA versions.Kito Cheng3-4/+17
Consider the updated attr-merge-arch-failed-01.d testcase. Extension A's version are mis-matched between attr-merge-arch-failed-01a.s and attr-merge-arch-failed-01b.s. But the old binutils reports that the mis-matched extension is M rather than A. This commit is used to fix the wrong mis-matched error message. Besides, when parsing the arch string in the riscv_parse_subset, it shouldn't be NULL or empty. However, it might be empty when we failed to merge the arch string in the riscv_merge_attributes. Since we should already issue the correct error message in another side, and the message - ISA string must begin with rv32 or rv64 - is meaninglesss when the arch string is empty, so do not issue it. bfd/ * elfnn-riscv.c (riscv_merge_std_ext): Fix to report the correct error message when the versions of extension are mis-matched. * elfxx-riscv.c (riscv_parse_subset): Don't issue the error when the string is empty. ld/ * testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Updated. * testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s: Likewise.
2020-09-03heap use after free in xcoff_archive_info_eqAlan Modra2-1/+6
Using an input file objalloc memory for anything that isn't created when opening the bfd is not a good idea. The problem is that this memory can disappear if bfd_free_cached_info is called or when bfd closes files in order to keep the number of open files reasonable. bfd/ * xcofflink.c (xcoff_get_archive_info): Allocate xcoff_archive_info on the output bfd objalloc memory. ld/ * testsuite/ld-scripts/sysroot-prefix.exp (single_sysroot_prefix_test): Log $scriptname.
2020-09-03Automatic date update in version.inGDB Administrator1-1/+1
2020-09-02ubsan elfnn-aarch64.c:7142 shift exponent 32 is too largeAlan Modra2-1/+6
* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Correct type of constant shifted left.
2020-09-02ubasn: elf32-pru.c:570 left shift of negative valueAlan Modra2-1/+6
* elf32-pru.c (pru_elf32_do_ldi32_relocate): Use an unsigned type for "relocation".
2020-09-02Automatic date update in version.inGDB Administrator1-1/+1
2020-09-01arm: ubsan: shift exponent 4GAlan Modra3-4/+11
* reloc.c (N_ONES): Handle N=0. * elf32-arm.c (elf32_arm_howto_table_1): Set complain_overflow_dont for R_ARM_TLS_DESCSEQ and R_ARM_THM_TLS_DESCSEQ.
2020-09-01PR26429 UBSAN: elf32-arm.c load /store misaligned addressAlan Modra2-8/+27
PR 26429 * elf32-arm.c (elf32_arm_allocate_local_sym_info): Allocate arrays in descending order of alignment.
2020-09-01PR26423 UBSAN: elf32-arm.c:10237 left shift cannot be representedAlan Modra2-1/+6
PR 26423 * elf32-arm.c (calculate_group_reloc_mask): Use 3u in shift.
2020-09-01Automatic date update in version.inGDB Administrator1-1/+1
2020-08-31PR26493 UBSAN: elfnn-riscv.c left shift of negative valueAlan Modra2-3/+10
include/ PR 26493 * opcode/riscv.h (OP_MASK_CSR, OP_MASK_CUSTOM_IMM) (OP_MASK_FUNCT7, OP_MASK_RS3): Make unsigned. bfd/ PR 26493 * elfnn-riscv.c (riscv_make_plt_header): Cast PLT_HEADER_SIZE to unsigned when using with RISCV_ITYPE. (_bfd_riscv_relax_call): Use an unsigned foff.
2020-08-31PR26476, PR26477 UBSAN: elfxx-mips.c:2695,5370 cannot be representedAlan Modra2-5/+14
PR 26476 PR 26477 * elfxx-mips.c (CRINFO_CTYPE, CRINFO_RTYPE, CRINFO_DIST2TO), (CRINFO_RELVADDR): Make unsigned. (mips_elf_nullify_got_load): Use unsigned constant when shifting into sign bit.
2020-08-31PR26466 UBSAN: elf32-mep.c:300 left shift of negative valueAlan Modra3-50/+57
PR 26466 * mep-relocs.pl (emit_apply): Handle HI16S adjustment. Use "u" variable and rewrite signed overflow check. * elf32-mep.c: Regenerate. (mep_final_link_relocate): Delete "s".
2020-08-31PR26461 UBSAN: elfxx-ia64.c:747 cannot be representedAlan Modra2-3/+9
PR 26461 * elfxx-ia64.c (ia64_elf_install_value): Make expressions unsigned that might shift values into sign bit.
2020-08-31PR26445 UBSAN: elf32-csky.c:4115 left shift of negative valueAlan Modra2-12/+18
PR 26445 * elf32-csky.c (csky_relocate_contents): Make relocation a bfd_vma, and similarly for variables dealing with overflow.
2020-08-31PR26442 UBSAN: elf32-crx.c:512 cannot be represented in intAlan Modra2-14/+13
PR 26442 * elf32-crx.c (crx_elf_final_link_relocate): Calculate reloc_bits without undefined behaviour. Tidy excess casts.
2020-08-31mn10300: ubsan: shift exponent too largeAlan Modra2-8/+16
* elf-m10300.c (mn10300_elf_relax_delete_bytes): Calculate alignment from reloc addend after reloc type R_MN10300_ALIGN is found.
2020-08-31Automatic date update in version.inGDB Administrator1-1/+1
2020-08-30PR26435, PR26436 UBSAN: elf32-cr16.c:928 left shiftAlan Modra2-4/+8
PR 26435 PR 26436 * elf32-cr16.c (cr16_elf_final_link_relocate): Calculate reloc_bits without undefined behaviour.
2020-08-30Automatic date update in version.inGDB Administrator1-1/+1