aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2022-09-22RISC-V: Add T-Head CMO vendor extensionChristoph Müllner1-0/+5
T-Head has a range of vendor-specific instructions. Therefore it makes sense to group them into smaller chunks in form of vendor extensions. This patch adds the XTheadCmo extension, a collection of T-Head specific cache management operations. The 'th' prefix and the "XTheadCmo" extension are documented in a PR for the RISC-V toolchain conventions ([1]). In total XTheadCmo introduces the following 21 instructions: * DCACHE.{C,CI,I}ALL * DCACHE.{C,CI,I}{PA,VA,SW} rs1 * DCACHE.C{PAL1,VAL1} rs1 * ICACHE.I{ALL,ALLS} * ICACHE.I{PA,VA} rs1 * L2CACHE.{C,CI,I}ALL Contrary to Zicbom, the XTheadCmo instructions don't have a constant displacement, therefore we have a different syntax for the arguments. To clarify this is intended behaviour, there is a set of negative test for Zicbom-style arguments in x-thead-cmo-fail.s. [1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19 v2: - Add missing DECLARE_INSN() list - Fix ordering Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2022-09-22RISC-V: Add generic support for vendor extensionsChristoph Müllner1-2/+7
This patch introduces changes that allow the integration of vendor ISA extensions: * Define a list of vendor extensions (riscv_supported_vendor_x_ext) where vendor extensions can be added * Introduce a section with a table in the documentation where vendor extensions can be added To add a vendor extension that consists of instructions only, the following things need to be done: * Add the extension to the riscv_supported_vendor_x_ext list * Add lookup entry in riscv_multi_subset_supports * Documenting the extension in c-riscv.texti * Add test cases for all instructions * Add MATCH*/MASK* constants and DECLARE_INSN() for all instructions * Add new instruction class to enum riscv_insn_class * Define the instructions in riscv_opcodes * Additional changes if necessary (depending on the instructions) Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2022-09-22Automatic date update in version.inGDB Administrator1-1/+1
2022-09-22bfd BLD-POTFILES.in dependenciesAlan Modra2-4/+4
A file that consists of a list of files doesn't depend on those files being built. This patch came from trying to avoid a maintainer-mode make -j bug, where the recipe for targmatch.h was being run twice in parallel. Typical output shown below. make[2]: Entering directory '/build/gas/all/bfd' GEN bfdver.h GEN elf32-target.h GEN elf64-target.h GEN targmatch.h Making info in po make[3]: Entering directory '/build/gas/all/bfd/po' cd .. && make po/SRC-POTFILES.in cd .. && make po/BLD-POTFILES.in make[4]: Entering directory '/build/gas/all/bfd' GEN elf32-aarch64.c GEN elf64-aarch64.c GEN elf32-ia64.c GEN elf64-ia64.c GEN elf32-loongarch.c GEN elf64-loongarch.c GEN elf32-riscv.c GEN elf64-riscv.c GEN peigen.c GEN pepigen.c GEN pex64igen.c GEN pe-aarch64igen.c GEN targmatch.h make[4]: Entering directory '/build/gas/all/bfd' CCLD doc/chew.stamp mv: cannot stat 'targmatch.new': No such file or directory make[4]: *** [Makefile:2325: targmatch.h] Error 1 * Makefile.am (po/BLD-POTFILES.in): Don't depend on $(BLD_POTFILES). (po/SRC-POTFILES.in): Don't depend on $(SRC_POTFILES).
2022-09-21PR29566, objdump -p considers an empty .gnu.version_r invalidAlan Modra1-5/+6
Allow and ignore an empty section. PR 29566 * elf.c (bfd_section_from_shdr): Don't set elf_dynverdef or elf_dynverref for empty sections. (_bfd_elf_slurp_version_tables): Remove now redundant tests.
2022-09-21PR29573, addr2line doesn't display file/line for local symbolsAlan Modra1-18/+16
The DWARF standard is clear that DW_AT_linkage_name is optional. Compilers may not provide the attribute on functions and variables, even though the language mangles names. g++ does not for local variables and functions. Without DW_AT_linkage_name, mangled object file symbols can't be directly matched against the source-level DW_AT_name in DWARF info. One possibility is demangling the object file symbols, but that comes with its own set of problems: 1) A demangler might not be available for the compiler/language. 2) Demangling doesn't give the source function name as stored in DW_AT_name. Class and template parameters must be stripped at least. So this patch takes a simpler approach. A symbol matches DWARF info if the DWARF address matches the symbol address, and if the symbol name contains the DWARF name as a sub-string. Very likely the name matching is entirely superfluous. PR 29573 * dwarf.c (lookup_symbol_in_function_table): Match a symbol containing the DWARF source name as a substring. (lookup_symbol_in_variable_table): Likewise. (_bfd_dwarf2_find_nearest_line_with_alt): If stash_find_line_fast returns false, fall back to comp_unit_find_line.
2022-09-21dwarf2.c: simplify best_fit_len testsAlan Modra1-32/+22
* dwarf2.c (lookup_address_in_function_table): Simplify best_fit_len test. (info_hash_lookup_funcinfo): Likewise. (lookup_symbol_in_function_table): Likewise, also reorder tests and check "file" is set. (lookup_symbol_in_variable_table): Reorder tests.
2022-09-21dwarf2.c: mangle_styleAlan Modra1-11/+33
non_mangled incorrectly returned "true" for Ada. Correct that, and add a few more non-mangled entries. Return a value suitable for passing to cplus_demangle to control demangling. * dwarf2.c: Include demangle.h. (mangle_style): Rename from non_mangled. Return DMGL_* value to suit lang. Adjust all callers.
2022-09-21dwarf2.c remove varinfo and funcinfo sec fieldAlan Modra1-19/+3
The "sec" field in these structures is only set and used in lookup functions. It always starts off as NULL. So the only possible effect of the field is to modify the return of the lookup, which was its purpose back in 2005 when HJ fixed PR990. Since then we solved the problem of relocatable object files with the fix for PR2338, so this field is now redundant. * dwarf.c (struct funcinfo, struct varinfo): Remove "sec" field. (lookup_symbol_in_function_table): Don't set or test "sec". (lookup_symbol_in_variable_table): Likewise. (info_hash_lookup_funcinfo, info_hash_lookup_varinfo): Likewise.
2022-09-21RISC-V: Implement Ztso extensionShihua2-0/+4
This patch support ZTSO extension. It will turn on the tso flag for elf_flags once we have enabled Ztso extension. This is intended to implement v0.1 of the proposed specification which can be found in Chapter 25 of, https://github.com/riscv/riscv-isa-manual/releases/download/draft-20220723-10eea63/riscv-spec.pdf. bfd\ChangeLog: * elfnn-riscv.c (_bfd_riscv_elf_merge_private_bfd_data): Set TSO flag. * elfxx-riscv.c: Add Ztso's arch. binutils\ChangeLog: * readelf.c (get_machine_flags): Set TSO flag. gas\ChangeLog: * config/tc-riscv.c (riscv_set_tso): Ditto. (riscv_set_arch): Ditto. * testsuite/gas/riscv/ztso.d: New test. include\ChangeLog: * elf/riscv.h (EF_RISCV_TSO): Ditto.
2022-09-21Automatic date update in version.inGDB Administrator1-1/+1
2022-09-21looping in alpha_vms_slurp_relocsAlan Modra1-24/+33
The direct cause for the looping was failing to test for error return from _bfd_vms_get_object_record inside a while(1) loop. Fix that. Also record status of first alpha_vms_slurp_relocs call and return that for all subsequent calls. (The object format has one set of relocation records for all sections.) If the first call fails, all others should too. * vms-alpha.c (struct vms_private_data_struct): Make reloc_done a tri-state int. (alpha_vms_slurp_relocs): Set reloc_done to 1 on success, -1 on failure. Return that status on subsequent calls. Check _bfd_vms_get_object_record return status. (alpha_vms_get_reloc_upper_bound): Return status from alpha_vms_slurp_relocs. (alpha_vms_write_exec): Exclude sections with contents NULL due to previous errors from layout, and don't try to write them.
2022-09-20New Serbian translations for various binutils sub-directories.Nick Clifton1-1259/+1404
2022-09-20LoongArch: Fix R_LARCH_IRELATIVE insertion after elf_link_sort_relocsXi Ruoyao1-17/+24
loongarch_elf_finish_dynamic_symbol is called after elf_link_sort_relocs if -z combreloc. elf_link_sort_relocs redistributes the contents of .rela.* sections those would be merged into .rela.dyn, so the slot for R_LARCH_IRELATIVE may be out of relplt->contents now. To make things worse, the boundary check dyn < dyn + relplt->size / sizeof (*dyn) is obviously wrong ("x + 10 < x"? :), causing the issue undetected during the linking process and the resulted executable suddenly crashes at runtime. The issue was found during an attempt to add static-pie support to the toolchain. Fix it by iterating through the inputs of .rela.dyn to find the slot.
2022-09-20LoongArch: Don't write into GOT for local ifuncXi Ruoyao1-2/+3
Local ifuncs are always resolved at runtime via R_LARCH_IRELATIVE, so there is no need to write anything into GOT. And when we write the GOT we actually trigger a heap-buffer-overflow: If a and b are different sections, we cannot access something in b with "a->contents + (offset from a)" because "a->contents" and "b->contents" are heap buffers allocated separately, not slices of a large buffer. So stop writing into GOT for local ifunc now.
2022-09-20Automatic date update in version.inGDB Administrator1-1/+1
2022-09-19Automatic date update in version.inGDB Administrator1-1/+1
2022-09-18Automatic date update in version.inGDB Administrator1-1/+1
2022-09-17Automatic date update in version.inGDB Administrator1-1/+1
2022-09-16pdb sanity check block_sizeAlan Modra1-0/+7
* pdb.c (pdb_get_elt_at_index): Only allow block_size to be 512, 1024, 2048, or 4096.
2022-09-16RISC-V: Make g imply zmmul extension.Nelson Chu1-1/+1
bfd/ * elfxx-riscv.c (riscv_implicit_subset): Moved entry of m after g, so that g can imply zmmul. gas/ * testsuite/gas/riscv/attribute-01.d: Updated. * testsuite/gas/riscv/attribute-02.d: Likewise. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/attribute-04.d: Likewise. * testsuite/gas/riscv/attribute-05.d: Likewise. * testsuite/gas/riscv/attribute-10.d: Likewise. * testsuite/gas/riscv/march-imply-g.d: Likewise. * testsuite/gas/riscv/march-imply-unsupported.d: Likewise.
2022-09-16Automatic date update in version.inGDB Administrator1-1/+1
2022-09-15bfd, binutils, gas: Remove/mark unused variablesTsukasa OI3-5/+2
Clang generates a warning on unused (technically, written but not read thereafter) variables. By the default configuration (with "-Werror"), it causes a build failure (unless "--disable-werror" is specified). This commit adds ATTRIBUTE_UNUSED attribute to some of them, which means they are *possibly* unused (can be used but no warnings occur when unused) and removes others. bfd/ChangeLog: * elf32-lm32.c (lm32_elf_size_dynamic_sections): Mark unused rgot_count variable. * elf32-nds32.c (elf32_nds32_unify_relax_group): Remove unused count variable. * mmo.c (mmo_scan): Mark unused lineno variable. binutils/ChangeLog: * windmc.c (write_rc): Remove unused i variable. gas/ChangeLog: * config/tc-riscv.c (riscv_ip): Remove unused argnum variable. ld/ChangeLog: * pe-dll.c (generate_reloc): Remove unused bi and page_count variables.
2022-09-15Automatic date update in version.inGDB Administrator1-1/+1
2022-09-14looping in bfd_mach_o_fat_openr_next_archived_fileAlan Modra1-4/+23
mach-o.c doesn't sanity check mach-o-fat archives, making it easy for fuzzers to create an archive with mach_o_fat_archentry headers that point to the same offset. bfd_mach_o_fat_openr_next_archived_file uses the previous element offset to find its header, and thus the next element. If two offsets are the same, any tool reading the archive will get stuck. This patch rejects such archives, and any with overlapping elements. * mach-o.c (overlap_previous): New function. (bfd_mach_o_fat_archive_p): Sanity check that elements do not overlap each other or the file and archive headers.
2022-09-14regen pofilesAlan Modra1-0/+1
2022-09-14bfd: Stop using -Wstack-usage=262144 when built with ClangTsukasa OI2-2/+22
Some components of GNU Binutils will pass "-Wstack-usage=262144" when "GCC >= 5.0" is detected. However, Clang does not support "-Wstack-usage", despite that related configuration part in bfd/warning.m4 handles the latest Clang (15.0.0 as of this writing) as "GCC >= 5.0". The option "-Wstack-usage" was ignored when the first version of Clang is released but even this "ignoring" behavior is removed before Clang 4.0.0. So, if we give Clang "-Wstack-usage=262144", it generates a warning, making the build failure. This commit checks "__clang__" macro to prevent adding the option if the compiler is identified as Clang. bfd/ChangeLog: * warning.m4: Stop appending "-Wstack-usage=262144" option when compiled with Clang. * configure: Regenerate. binutils/ChangeLog: * configure: Regenerate. gas/ChangeLog: * configure: Regenerate. gold/ChangeLog: * configure: Regenerate. gprof/ChangeLog: * configure: Regenerate. ld/ChangeLog: * configure: Regenerate. opcodes/ChangeLog: * configure: Regenerate.
2022-09-14asan: som_set_reloc_info heap buffer overflowAlan Modra1-2/+7
Also a bugfix. The first time the section was read, the contents didn't supply an addend. * som.c (som_set_reloc_info): Sanity check offset. Do process contents after reading. Tidy section->contents after freeing.
2022-09-14ubsan: som_is_space null dereferenceAlan Modra1-1/+3
On objcopy of fuzzed file. * som.c (som_write_fixups): Exit loop if space sections all processed.
2022-09-14msan: vms-alpha use-of-uninitialized-value in dst_retrieve_locationAlan Modra1-0/+2
* vms-alpha.c (dst_define_location): Init any unused entries.
2022-09-14PR29540, R_PPC64_NONE in .rela.dyn when linking Linux vdsoAlan Modra2-24/+24
PR 29540 * elf64-ppc.c (allocate_dynrelocs): Don't alloc space for relocs against discarded sections. (ppc64_elf_size_dynamic_sections): Use standard test for discarded sections. * elf32-ppc.c (allocate_dynrelocs): Don't alloc space for relocs against discarded sections. (ppc_elf_size_dynamic_sections): Use standard test for discarded sections.
2022-09-14Automatic date update in version.inGDB Administrator1-1/+1
2022-09-13Add pdb archive formatMark Harmstone7-2/+826
Resubmitted with changes in https://sourceware.org/pipermail/binutils/2022-September/122791.html made.
2022-09-13Automatic date update in version.inGDB Administrator1-1/+1
2022-09-12RISC-V: PR28509, the default visibility symbol cannot be referenced by ↵Nelson Chu1-28/+43
R_RISCV_JAL. When generating the shared object, the default visibility symbols may bind externally, which means they will be exported to the dynamic symbol table, and are preemptible by default. These symbols cannot be referenced by the non-pic R_RISCV_JAL and R_RISCV_RVC_JUMP. However, consider that linker may relax the R_RISCV_CALL relocations to R_RISCV_JAL or R_RISCV_RVC_JUMP, if these relocations are relocated to the plt entries, then we won't report error for them. Perhaps we also need the similar checks for the R_RISCV_BRANCH and R_RISCV_RVC_BRANCH relocations. After applying this patch, and revert the following glibc patch, riscv: Fix incorrect jal with HIDDEN_JUMPTARGET https://sourceware.org/git/?p=glibc.git;a=commit;h=68389203832ab39dd0dbaabbc4059e7fff51c29b I get the expected errors as follows, ld: relocation R_RISCV_RVC_JUMP against `__sigsetjmp' which may bind externally can not be used when making a shared object; recompile with -fPIC ld: relocation R_RISCV_JAL against `exit' which may bind externally can not be used when making a shared object; recompile with -fPIC Besides, we also have similar changes for libgcc, RISC-V: jal cannot refer to a default visibility symbol for shared object https://github.com/gcc-mirror/gcc/commit/45116f342057b7facecd3d05c2091ce3a77eda59 bfd/ pr 28509 * elfnn-riscv.c (riscv_elf_relocate_section): Report errors when makeing a shard object, and the referenced symbols of R_RISCV_JAL relocations are default visibility. Besides, we should handle most of the cases here, so don't need the unresolvable check later for R_RISCV_JAL and R_RISCV_RVC_JUMP. ld/ pr 28509 * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. * testsuite/ld-riscv-elf/lib-nopic-01a.s: Removed. * testsuite/ld-riscv-elf/lib-nopic-01b.d: Likewise. * testsuite/ld-riscv-elf/lib-nopic-01b.s: Likewise. * testsuite/ld-riscv-elf/shared-lib-nopic-01.d: New testcase. * testsuite/ld-riscv-elf/shared-lib-nopic-01.s: Likewise. * testsuite/ld-riscv-elf/shared-lib-nopic-02.d: Likewise. * testsuite/ld-riscv-elf/shared-lib-nopic-02.s: Likewise. * testsuite/ld-riscv-elf/shared-lib-nopic-03.d: Likewise. * testsuite/ld-riscv-elf/shared-lib-nopic-03.s: Likewise. * testsuite/ld-riscv-elf/shared-lib-nopic-04.d: Likewise. * testsuite/ld-riscv-elf/shared-lib-nopic-04.s: Likewise.
2022-09-12Automatic date update in version.inGDB Administrator1-1/+1
2022-09-11Automatic date update in version.inGDB Administrator1-1/+1
2022-09-10Automatic date update in version.inGDB Administrator1-1/+1
2022-09-09Support debuginfo files with empty group sections.Nick Clifton2-1/+11
PR 29532 bfd * elf.c (setup_group): Do not return false if there is no group information available. bionutils* objcopy.c (setup_section): Leave group sections intact when creating separate debuginfo files.
2022-09-09Automatic date update in version.inGDB Administrator1-1/+1
2022-09-08Automatic date update in version.inGDB Administrator1-1/+1
2022-09-07Automatic date update in version.inGDB Administrator1-1/+1
2022-09-06bfd: Add bfd_find_nearest_line_with_altAaron Merey36-17/+237
bfd_find_nearest_line_with_alt functions like bfd_find_nearest_line with the addition of a parameter for specifying the filename of a supplementary debug file such as one referenced by .gnu_debugaltlink or .debug_sup. This patch focuses on implementing bfd_find_nearest_line_with_alt support for ELF/DWARF2 .gnu_debugaltlink. For other targets this function simply sets the invalid_operation bfd_error.
2022-09-06Automatic date update in version.inGDB Administrator1-1/+1
2022-09-05Automatic date update in version.inGDB Administrator1-1/+1
2022-09-04Automatic date update in version.inGDB Administrator1-1/+1
2022-09-03Automatic date update in version.inGDB Administrator1-1/+1
2022-09-02xtensa: bfd: fix TLS relocations generated for PIEMax Filippov1-9/+10
When generating TLS dynamic relocations the existing xtensa BFD code treats linking to a PIE exactly as linking to a shared object, resulting in generation of wrong relocations for TLS entries. Fix that and add tests. bfd/ * elf32-xtensa.c (elf_xtensa_check_relocs): Use bfd_link_dll instead of bfd_link_pic. Add elf_xtensa_dynamic_symbol_p test when generating GOT entries. (elf_xtensa_relocate_section): Use bfd_link_dll instead of bfd_link_pic. ld/ * testsuite/ld-xtensa/tlspie.dd: New file. * testsuite/ld-xtensa/tlspie.rd: New file. * testsuite/ld-xtensa/tlspie.sd: New file. * testsuite/ld-xtensa/tlspie.td: New file. * testsuite/ld-xtensa/xtensa-linux.exp (TLS PIE transitions): New test.
2022-09-02Add OpenBSD ARM Little Endian BFD support.Frederic Cambus2-2/+5
* config.bfd (arm-*-openbsd*): Restore target.
2022-09-02Automatic date update in version.inGDB Administrator1-1/+1