aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2020-12-24Automatic date update in version.inGDB Administrator1-1/+1
2020-12-23x86-64: Add Intel LAM property supportH.J. Lu3-27/+110
Add Intel Linear Address Masking (LAM) property support. LAM modifies the checking that is applied to 64-bit linear addresses, allowing software to use of the untranslated address bits for metadata. bfd/ * elf-linker-x86.h (elf_x86_cet_report): Renamed to ... (elf_x86_prop_report): This. (elf_linker_x86_params): Add lam_u48, lam_u57, lam_u48_report and lam_u57_report. * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Support GNU_PROPERTY_X86_FEATURE_1_LAM_U48 and GNU_PROPERTY_X86_FEATURE_1_LAM_U57. (_bfd_x86_elf_link_fixup_gnu_properties): Keep LAM features only for 64-bit output. binutils/ * NEWS: Mention LAM_U48 and LAM_U57 support. * elfedit.c (elf_x86_feature): Support lam_u48 and lam_u57. (usage): Add lam_u48 and lam_u57. * readelf.c (decode_x86_feature_1): Support LAM_U48 and LAM_U57. * doc/binutils.texi: Update elfedit with lam_u48 and lam_u57 support. * testsuite/binutils-all/x86-64/lam-u48.d: New file. * testsuite/binutils-all/x86-64/lam-u48.s: Likewise. * testsuite/binutils-all/x86-64/lam-u57.d: Likewise. * testsuite/binutils-all/x86-64/lam-u57.s: Likewise. include/ * elf/common.h (GNU_PROPERTY_X86_FEATURE_1_LAM_U48): New. (GNU_PROPERTY_X86_FEATURE_1_LAM_U57): Likewise. ld/ * NEWS: Mention LAM_U48 and LAM_U57 support. * ld.texi: Document LAM_U48 and LAM_U57 support. * emulparams/cet.sh: Updated. * emulparams/elf_x86_64.sh: Source x86-64-lam.sh. * emulparams/x86-64-lam.sh: New file. * testsuite/ld-x86-64/property-x86-lam-u48-1a.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u48-1b.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u48-2.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u48-3a.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u48-3b.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u48-4.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u48-5.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u48.s: Likewise. * testsuite/ld-x86-64/property-x86-lam-u57-1a.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u57-1b.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u57-2.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u57-3a.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u57-3b.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u57-4.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u57-5.d: Likewise. * testsuite/ld-x86-64/property-x86-lam-u57.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run LAM tests.
2020-12-23Automatic date update in version.inGDB Administrator1-1/+1
2020-12-22Automatic date update in version.inGDB Administrator1-1/+1
2020-12-21Automatic date update in version.inGDB Administrator1-1/+1
2020-12-20Automatic date update in version.inGDB Administrator1-1/+1
2020-12-19Automatic date update in version.inGDB Administrator1-1/+1
2020-12-18elf: Copy elf_gnu_osabi_retain only for relocatable linkH.J. Lu2-1/+9
Copy elf_gnu_osabi_retain from input only for relocatable link since SHF_GNU_RETAIN has no impact on non-relocatable outputs. bfd/ PR ld/27091 * elflink.c (elf_link_input_bfd): Copy elf_gnu_osabi_retain from input only for relocatable link. ld/ PR ld/27091 * testsuite/ld-elf/retain7.s: New file. * testsuite/ld-elf/retain7a.d: Likewise. * testsuite/ld-elf/retain7b.d: Likewise.
2020-12-18Assorted tidiesAlan Modra5-6/+11
bfd/ * elf32-microblaze.c (dbg): Delete unused variable. * elf32-nds32.c (relax_group_section_id_list): Make static. * som.c (reloc_queue): Make static. * xtensa-isa.c (xtisa_errno, xtisa_error_msg): Make static. include/ * xtensa-isa-internal.h (xtisa_errno, xtisa_error_msg): Delete.
2020-12-18Remove some static buffersAlan Modra14-51/+94
Fixes possible overflow of a static buffer for powerpc with translated messages, and on v850 when symbol names are large. * archive.c (_bfd_ar_spacepad, _bfd_ar_sizepad): Use auto buf. * coff-mcore.c (coff_mcore_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_unhandled_reloc): Use asprintf in place of fixed size and possibly too small buf for translated message. * elf64-ppc.c (ppc64_elf_unhandled_reloc): Likewise. * elf32-v850.c (v850_elf_check_relocs): Likewise. * ecoff.c (ecoff_type_to_string): Pass in return string buff rather than using static buffer2. Delete dead code. Remove unnecessary parentheses. (_bfd_ecoff_print_symbol): Pass auto buff to ecoff_type_to_string. * elf32-rx.c (describe_flags): Pass in return string buf rather than using static buf. (rx_elf_merge_private_bfd_data): Pass buf to describe_flags. (rx_elf_print_private_bfd_data): Likewise. * mach-o.c (cpusubtype): Pass in return string buffer rather than using static buffer. (bfd_mach_o_bfd_print_private_bfd_data): Pass buff to cpusubtype. * opncls.c (separate_debug_file_exists): Make buffer an auto var. (bfd_fill_in_gnu_debuglink_section): Likewise. * peXXigen.c (rsrc_resource_name): Pass in return string buffer rather than using static buffer. (rsrc_sort_entries): Pass buff to rsrc_resource_name. * vms-alpha.c (_bfd_vms_write_emh): Pass tbuf to get_vms_time_string. * vms-misc.c (get_vms_time_string): Pass in return string tbuf rather than using static tbuf. * vms.h (get_vms_time_string): Update prototype.
2020-12-18Constify more arraysAlan Modra11-17/+33
bfd/ * coff-z80.c (bfd_howto_type): Make typedef const. * elf32-z80.c (bfd_howto_type): Likewise. * elf32-m32c.c (EncodingTable): Likewise. * elf32-csky.c (csky_arch_for_merge): Likewise. (csky_archs): Use typedef. * elf32-m68hc11.c (m68hc11_direct_relax_table): Make const. (find_relaxable_insn, m68hc11_elf_relax_section): Adjust to suit. * elf32-ppc.c (ppc_alt_plt): Make const. * elf32-rl78.c (relax_addr16): Likewise. * targets.c (_bfd_associated_vector): Likewise. (bfd_target_vector, bfd_associated_vector): Likewise. * libbfd-in.h (bfd_target_vector, bfd_associated_vector): Likewise. * libbfd.h: Regenerate. include/ * opcode/arc-attrs.h (CONFLICT_LIST): Make const.
2020-12-18Statically initialise target common sectionsAlan Modra9-215/+80
This tidies initialisation of target common sections, doing so using a static initialiser rather than via code and deleting unnecessary symbol_ptr_ptr variables (the one in asection is used instead). The patch also initialises ecoff.c:bfd_debug_section using BFD_FAKE_SECTION. That does change bfd_debug_section slightly, output_section was NULL now bfd_debug_section, and symbol_ptr_ptr was NULL now &bfd_debug_section.symbol, but I believe those changes are safe. bfd/ * ecoff.c (bfd_debug_section): Init using BFD_FAKE_SECTION. (ecoff_scom_section, ecoff_scom_symbol): Statically init using BFD_FAKE_SECTION and GLOBAL_SYM_INIT. Delete initialisation code. (ecoff_scom_symbol_ptr): Delete. * elf32-m32r.c (m32r_elf_scom_section, m32r_elf_scom_symbol), (m32r_elf_scom_symbol_ptr), * elf32-score.c (score_elf_scom_section, score_elf_scom_symbol), (score_elf_scom_symbol_ptr), * elf32-score7.c (score_elf_scom_section, score_elf_scom_symbol), (score_elf_scom_symbol_ptr), * elf32-tic6x.c (tic6x_elf_scom_section, tic6x_elf_scom_symbol), (tic6x_elf_scom_symbol_ptr), * elf32-v850.c (v850_elf_scom_section, v850_elf_scom_symbol), (v850_elf_scom_symbol_ptr), (v850_elf_tcom_section, v850_elf_tcom_symbol), (v850_elf_tcom_symbol_ptr), (v850_elf_zcom_section, v850_elf_zcom_symbol), (v850_elf_zcom_symbol_ptr), * elf64-mmix.c (mmix_elf_reg_section, mmix_elf_reg_section_symbol), (mmix_elf_reg_section_symbol_ptr), * elfxx-mips.c (mips_elf_scom_section, mips_elf_scom_symbol), (mips_elf_scom_symbol_ptr): Likewise. gas/ * ecoff.c (ecoff_frob_symbol): Rename scom_section to ecoff_scom_section and statically initialise.
2020-12-18Automatic date update in version.inGDB Administrator1-1/+1
2020-12-17Automatic date update in version.inGDB Administrator1-1/+1
2020-12-16constify elfNN_bedAlan Modra6-88/+67
elfNN_bed was made writable as an expedient means of communicating ld -z max-page-size and ld -z common-page-size values to BFD linker code, and even for objcopy to communicate segment alignment between copy_private_bfd_data, rewrite_elf_program_header and assign_file_positions_for_load_sections. Some time later elfNN_bed elf_osabi was written by gas. It turns out none of these modifications to elfNN_bed was necessary, so make it const again. include/ * bfdlink.h (struct bfd_link_info): Add maxpagesize and commonpagesize. bfd/ * elfxx-target.h (elfNN_bed): Constify. * bfd.c (bfd_elf_set_pagesize): Delete. (bfd_emul_set_maxpagesize, bfd_emul_set_commonpagesize): Delete. * elf.c (get_program_header_size): Get commonpagesize from link info. (_bfd_elf_map_sections_to_segments): Get maxpagesize from link info. (assign_file_positions_for_load_sections): Likewise. (assign_file_positions_for_non_load_sections): Likewise. (rewrite_elf_program_header): Add maxpagesize param. Set map_p_align. (copy_private_bfd_data): Don't call bfd_elf_set_maxpagesize. Instead pass maxpagesize to rewrite_elf_program_header. * elf32-nds32.c (relax_range_measurement): Add link_info param. Get maxpagesize from link_info. Adjust caller. * bfd-in2.h: Regenerate. gas/ * config/obj-elf.c (obj_elf_section): Don't set elf_osabi here. (obj_elf_type): Likewise. ld/ * ld.h (ld_config_type): Delete maxpagesize and commonpagesize. * emultempl/elf.em: Use link_info rather than config for maxpagesize and commonpagesize. * emultempl/ppc32elf.em: Likewise. * ldexp.c (fold_binary, fold_name): Likewise. * ldemul.c (after_parse_default): Likewise. (set_output_arch_default): Don't call bfd_emul_set_maxpagesize or bfd_emul_set_commonpagesize.
2020-12-16elflink.c constifyAlan Modra2-1/+5
* elflink.c (elf_flags_to_names): Constify.
2020-12-16XCOFF constifyAlan Modra4-40/+56
There are occasions where it is reasonable to use a macro defining function parameters, but this isn't one of them. Use typedefs instead, which also simplifies declaring a const array of function pointers. * libxcoff.h (struct xcoff_backend_data_rec): Constify _xcoff_glink_code. (XCOFF_RELOC_FUNCTION_ARGS, XCOFF_COMPLAIN_FUNCTION_ARGS): Delete. (xcoff_reloc_function, xcoff_complain_function): New typedef. (xcoff_calculate_relocation, xcoff_complain_overflow), (xcoff_reloc_type_noop, xcoff_reloc_type_fail), (xcoff_reloc_type_pos, xcoff_reloc_type_neg), (xcoff_reloc_type_rel, xcoff_reloc_type_toc), (xcoff_reloc_type_ba, xcoff_reloc_type_crel): Update declaration. * coff-rs6000.c (xcoff_reloc_type_br): Declare using typedef. (xcoff_complain_overflow_dont_func): Likewise. (xcoff_complain_overflow_bitfield_func): Likewise. (xcoff_complain_overflow_signed_func): Likewise. (xcoff_complain_overflow_unsigned_func): Likewise. (xcoff_calculate_relocation, xcoff_complain_overflow): Constify. (xcoff_glink_code): Constify. * coff64-rs6000.c (xcoff64_reloc_type_br): Declare using typedef. (xcoff64_calculate_relocation, xcoff64_glink_code): Constify.
2020-12-16xtensa constifyAlan Modra3-552/+557
Move lots of read-only arrays to .rodata. include/ * xtensa-isa-internal.h (xtensa_format_internal), (xtensa_slot_internal, xtensa_operand_internal), (xtensa_arg_internal, xtensa_iclass_internal), (xtensa_opcode_internal, xtensa_regfile_internal), (xtensa_interface_internal, xtensa_funcUnit_internal), (xtensa_state_internal, xtensa_sysreg_internal): Constify. bfd/ * elf32-xtensa.c (narrowable, widenable): Constify. * xtensa-modules.c: Constify many arrays.
2020-12-16ppc64 constifyAlan Modra2-1/+5
Nothing to see here. * elf64-ppc.c (synthetic_opd): Constify.
2020-12-16arc constifyAlan Modra3-5/+11
Move a read-only array to .rodata. * arc-plt.h (plt_versions): Constify. * elf32-arc.c (arc_get_plt_version): Constify return pointer, adjust uses throughout.
2020-12-16Lose some COFF/PE static vars, and peicode.h constifyAlan Modra4-27/+37
This patch tidies some COFF and PE code that unnecessarily used static variables to communicate between functions. * coffcode.h (pelength, peheader): Delete static variables. (coff_apply_checksum): Instead, define them as auto vars, and pass.. (coff_read_word, coff_compute_checksum): ..to here. Delete unnecessary forward declarations. * pei-x86_64.c (pdata_count): Delete static variable. (struct pex64_paps): New. (pex64_print_all_pdata_sections, pex64_bfd_print_pdata): Pass a pex64_paps for counting. * peicode.h (jtab): Constify.
2020-12-16Automatic date update in version.inGDB Administrator1-1/+1
2020-12-15Handle -z unique/-z nounique in ldVivek Das Mohapatra2-1/+9
Add (or suppress) a DT_GNU_FLAGS_1 dynamic section with a bit flag value of DF_GNU_1_UNIQUE. bfd/ * elflink.c (bfd_elf_size_dynamic_sections): Call _bfd_elf_add_dynamic_entry to add a DT_GNU_FLAGS_1 section. include/ * bfdlink.h (struct bfd_link_info): New field gnu_flags_1. ld/ * emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Parse -z unique / -z nounique options.
2020-12-15Automatic date update in version.inGDB Administrator1-1/+1
2020-12-14Put bfd_section_from_shdr loop detection array in elf_tdataAlan Modra4-45/+20
The static variables used by bfd_section_from_shdr to detect loops in ELF sections have a problem: Comparing a BFD pointer doesn't guarantee that the current bfd is the same as the one previously used to allocate the sections_being_created array. For example, doing size bad_elf_1 bad_elf_2 with two corrupted ELF files containing section loops will leave the section_being_created array allocated for the first file and since bfd_close is called for bad_elf_1 before bfd_elf_2 is opened, it is possible that the BFD for the second file is allocated in the same memory as the first file. If bad_elf_2 has more sections than bad_elf_1 then we might write beyond the end of the array. So this patch implements the FIXME Nick put in a comment about attaching the array to the BFD. * elf-bfd.h (struct elf_obj_tdata): Add being_created. * elf.c (bfd_section_from_shdr): Delete static vars for loop detection. Use new tdata variable instead. * elfcode.h (elf_object_p): Allocate being_created.
2020-12-14Automatic date update in version.inGDB Administrator1-1/+1
2020-12-13Automatic date update in version.inGDB Administrator1-1/+1
2020-12-12Automatic date update in version.inGDB Administrator1-1/+1
2020-12-11Automatic date update in version.inGDB Administrator1-1/+1
2020-12-10RISC-V: Control fence.i and csr instructions by zifencei and zicsr.Nelson Chu2-20/+51
bfd/ * elfxx-riscv.c (riscv_ext_dont_care_version): New function. Return TRUE if we don't care the versions of the extensions. These extensions are added to the subset list for special purposes, with the explicit versions or the RISCV_UNKNOWN_VERSION versions. (riscv_parse_add_subset): If we do care the versions of the extension, and the versions are unknown, then report errors for the non-implicit extensions, and return directly for the implicit one. (riscv_arch_str1): Do not output i extension after e, and the extensions which versions are unknown. gas/ * config/tc-riscv.c (riscv_multi_subset_supports): Handle INSN_CLASS_ZICSR and INSN_CLASS_ZIFENCEI. * testsuite/gas/riscv/march-imply-i.s: New testcase. * testsuite/gas/riscv/march-imply-i2p0-01.d: New testcase. The version of i is less than 2.1, and zi* are supported in the chosen spec, so enable the fence.i and csr instructions, also output the implicit zi* to the arch string. * testsuite/gas/riscv/march-imply-i2p0-02.d: Likewise, but the zi* are not supported in the spec 2.2. Enable the related instructions since i's version is less than 2.1, but do not output them. * testsuite/gas/riscv/march-imply-i2p1-01.d: New testcase. The version of i is 2.1, so don't add it's implicit zi*, and disable the related instructions. * testsuite/gas/riscv/march-imply-i2p1-01.l: Likewise. * testsuite/gas/riscv/march-imply-i2p1-02.d: Likewise, and set the zi* explicitly, so enable the related instructions. * testsuite/gas/riscv/march-imply-i2p0.d: Removed. * testsuite/gas/riscv/march-imply-i2p1.d: Removed. include/ * opcode/riscv.h: Add INSN_CLASS_ZICSR and INSN_CLASS_ZIFENCEI. opcodes/ * riscv-opc.c (riscv_opcodes): Control fence.i and csr instructions by zifencei and zicsr.
2020-12-10Automatic date update in version.inGDB Administrator1-1/+1
2020-12-09Automatic date update in version.inGDB Administrator1-1/+1
2020-12-08Automatic date update in version.inGDB Administrator1-1/+1
2020-12-07binutils: Use file descriptors from make_tempnameSiddhesh Poyarekar3-0/+41
The purpose of creating a temporary file securely using mkstemp is defeated if it is closed in make_tempname and reopened later for use; it is as good as using mktemp. Get the file descriptor instead and then use it to create the BFD object. bfd/ * opncls.c (bfd_fdopenw): New function. * bfd-in2.h: Regenerate. binutils/ * bucomm.c (make_tempname): Add argument to return file descriptor. * bucomm.h (make_tempname): Likewise. * ar.c: Include libbfd.h. (write_archive): Adjust for change in make_tempname. Call bfd_fdopenw instead of bfd_openw. * objcopy.c: Include libbfd.h. (copy_file): New argument OFD. Use bfd_fdopenw instead of bfd_openw. (strip_main): Adjust for change in make_tempname and copy_file. (copy_main): Likewise.
2020-12-07elf32-csky.c:3932:19: error: comparison is always falseAlan Modra4-9/+9
It looks like csky missed out on an edit for 706704c8834. Not that it matters very much. There doesn't appear to be any csky reloc howto that sets the negate bit. Similarly for ns32k and nds32. * elf32-csky.c (csky_relocate_contents): Correct negate test. * cpu-ns32k.c (_bfd_do_ns32k_reloc_contents): Likewise. * elf32-nds32.c (nds32_relocate_contents): Likewise.
2020-12-07Automatic date update in version.inGDB Administrator1-1/+1
2020-12-06Automatic date update in version.inGDB Administrator1-1/+1
2020-12-05VAX/BFD: Do not warn about GOT addend mismatches if no GOT entry is madeMaciej W. Rozycki2-1/+7
Match the condition used in `elf_vax_instantiate_got_entries' for the creation of GOT entries in the processing of R_VAX_GOT32 relocations in `elf_vax_check_relocs', removing incorrect warnings about a GOT addend mismatch like: ./ld-new: tmpdir/got-local-ref-off-r.o: warning: GOT addend of 1 to `bar_hidden' does not match previous GOT addend of 0 ./ld-new: tmpdir/got-local-ref-off-r.o: warning: GOT addend of 2 to `bar_hidden' does not match previous GOT addend of 0 and corresponding failures with the test cases newly added here: FAIL: GOT test (executable hidden reference with offset) FAIL: GOT test (executable visible reference with offset) for symbols that are considered local for reasons other than having been forced local with a version script, which is usually the ELF visibility. Correct code is produced regardless, but the warning breaks `-Werror' compilation and may upset people regardless. Interestingly this shows with executable links only, because in shared library links code from `elf_link_add_object_symbols' triggers: /* If the symbol already has a dynamic index, but visibility says it should not be visible, turn it into a local symbol. */ switch (ELF_ST_VISIBILITY (h->other)) { case STV_INTERNAL: case STV_HIDDEN: (*bed->elf_backend_hide_symbol) (info, h, TRUE); dynsym = FALSE; break; } that sets `h->forced_local' like with a version script. Add suitable test cases including disassembly to verify correct code has been produced where no warnings have been issued, and that warnings do get issued where necessary. Do not verify (broken) code produced in the latter case; we should probably make the warning an error, or preferably actually start supporting GOT references with different addends as they appear feasible with explicitly relocated GOT that we use. bfd/ * elf32-vax.c (elf_vax_check_relocs) <R_VAX_GOT32>: Use SYMBOL_REFERENCES_LOCAL rather than `h->forced_local' to check whether the symbol referred is local or not. ld/ * testsuite/ld-vax-elf/got-local-exe-off-hidden.dd: New test dump. * testsuite/ld-vax-elf/got-local-exe-off-visible.dd: New test dump. * testsuite/ld-vax-elf/got-local-lib-off-hidden.dd: New test dump. * testsuite/ld-vax-elf/got-local-lib-off-visible.ed: New test dump. * testsuite/ld-vax-elf/got-local-off-external.ed: New test dump. * testsuite/ld-vax-elf/got-local-exe-off.xd: New test dump. * testsuite/ld-vax-elf/got-local-lib-off.xd: New test dump. * testsuite/ld-vax-elf/got-local.ld: New test linker script. * testsuite/ld-vax-elf/got-local-aux-off.s: New test source. * testsuite/ld-vax-elf/got-local-def-off.s: New test source. * testsuite/ld-vax-elf/got-local-ref-off-external.s: New test source. * testsuite/ld-vax-elf/got-local-ref-off-hidden.s: New test source. * testsuite/ld-vax-elf/got-local-ref-off-visible.s: New test source. * testsuite/ld-vax-elf/vax-elf.exp: Run the new tests.
2020-12-04x86-64: Convert load to mov only for GOTPCRELX relocationsH.J. Lu2-1/+7
Since converting load to mov needs to rewrite the REX byte and we don't know if there is a REX byte with GOTPCREL relocation, do it only for GOTPCRELX relocations. bfd/ PR ld/27016 * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Convert load to mov only for GOTPCRELX relocations. ld/ PR ld/27016 * testsuite/ld-x86-64/x86-64.exp: Run pr27016a and pr27016b. * testsuite/ld-x86-64/pr27016a.d: New file. * testsuite/ld-x86-64/pr27016a.s: Likewise. * testsuite/ld-x86-64/pr27016b.d: Likewise. * testsuite/ld-x86-64/pr27016b.s: Likewise.
2020-12-05Automatic date update in version.inGDB Administrator1-1/+1
2020-12-04PR26978, Inconsistency for strong foo@v1 and weak foo@@v1Alan Modra3-33/+75
Prior to this patch ld -shared --version-script=pr26979.ver pr26978a.o pr26978b.o results in ld: pr26978b.o: in function `foo_v1': (.text+0x0): multiple definition of `foo@v1' ld: pr26978b.o:(*IND*+0x0): multiple definition of `foo' while ld -shared --version-script=pr26979.ver pr26978b.o pr26978a.o results in no error, but some odd dynamic symbols. ... 0 NOTYPE GLOBAL DEFAULT 7 foo@v1 ... 0 NOTYPE WEAK DEFAULT 7 foo@@v1 When linking an undecorated reference to foo against such a shared library, ld complains about multiple definitions of foo@v1 while gold creates a dynamic reference to foo@v1. That results in foo@v1 being used at runtime. While we could error in both cases, it is reasonable to say foo@v1 and foo@@v1 are in fact the same symbol. (Same name, same version. The only real difference is that foo@@v1 satisfies a reference to plain foo, while foo@v1 does not.) Just as merging a weak undecorated sym with a strong sym results in the strong sym prevailing, so should the strong foo@v1 prevail. And since there is a definition that satisfies plain foo, the foo@@v1 variety of dynamic symbol should be emitted at the foo@v1 value. That makes the testcase that currently links continue to produce a shared library, and that shared library can now be used by both ld and gold with the same runtime behaviour as when using gold with the odd dynamic symbol library. bfd/ PR 26978 * elflink.c (_bfd_elf_add_default_symbol): Handle the case where a new weak sym@@ver should be overridden by an existing sym@ver. (elf_link_add_object_symbols): Don't _bfd_elf_add_default_symbol for a new weak sym@ver when sym@@ver already exists. * linker.c (link_action): Choose MIND for previous indirect, current def, rather than MDEF. (_bfd_generic_link_add_one_symbol <MIND>): Handle redefinition of weak indirect symbol. ld/ * testsuite/ld-elf/pr26978a.d, * testsuite/ld-elf/pr26978a.s, * testsuite/ld-elf/pr26978b.d, * testsuite/ld-elf/pr26978b.s: New tests.
2020-12-04Automatic date update in version.inGDB Administrator1-1/+1
2020-12-03Automatic date update in version.inGDB Administrator1-1/+1
2020-12-02Automatic date update in version.inGDB Administrator1-1/+1
2020-12-01RISC-V: Fix the order checking for Z* extension.Nelson Chu2-2/+6
We have to check the first char of the Z* extensions, to make sure that they follow the order of the standard extensions. But we can not have the testcases for this patch, since we only support the zicsr and zifencei so far, both of them are the sub extensions of i. bfd/ * elfxx-riscv.c (riscv_parse_prefixed_ext): Use riscv_compare_subsets to check the Z* extensions' order.
2020-12-01RISC-V: Support to add implicit extensions for G.Nelson Chu3-8/+32
G is a special case, consider the ISA spec github issue as follows, https://github.com/riscv/riscv-isa-manual/issues/575 My understand is that - i, m, a, f and d extensions are not g's implicit extensions, they are g's expansions. The zifencei is the implicit extension of g, and so is zicsr, since it is implicited by f (or i2p1). However, we add the g with the RISCV_UNKNOWN_VERSION to the subset list, and it will not output to the arch string, it is only used to check what implicit extensions are need to be added. bfd/ * elfxx-riscv.c (riscv_parse_add_subset): Allow to add g with RISCV_UNKNOWN_VERSION versions. (riscv_parse_std_ext): Add g to the subset list, we only use it to add the implicit extensions, but won't output it to arch string. (riscv_parse_add_implicit_subsets): Add implicit zicsr and zifencei for g extension. (riscv_arch_str1): Do not output g to the arch string. * elfxx-riscv.h (RISCV_UNKNOWN_VERSION): Moved to include/opcode/riscv.h. gas/ * testsuite/gas/riscv/attribute-10.d: Updated. * testsuite/gas/riscv/march-imply-g.d: New testcase for g. * testsuite/gas/riscv/march-imply-unsupported.d: The zicsr and zifencei are not supported in the ISA spec v2.2, so don't add and output them. include/ * opcode/riscv.h (RISCV_UNKNOWN_VERSION): added.
2020-12-01RISC-V: Support to add implicit extensions.Nelson Chu4-57/+267
We have to parse and add all arch string extensions at first, and then start to add their implicit extensions. That means we can always add arch string extensions at the end of the subset list, but we need to search the right place to add their implicit extensions. For now we follow the following rules to add the implicit extensions, * Add zicsr and zifencei only when the i's version less than 2.1. * Add d, f and zicsr when q is found. * Add f and zicsr when d is found. * Add zicsr when f is found. Besides, we do not add the implicit extensions if they are already added in the subset list, or we cannot find their default versions according to the chosen ISA spec. bfd/ * elfnn-riscv.c (riscv_merge_std_ext): Updated since riscv_lookup_subset is changed. * elfxx-riscv.c (riscv_ext_order): New Array used to compare the extensions' order quickly. (riscv_init_ext_order): New function. Init the riscv_ext_order according to the riscv_supported_std_ext and parse_config[i].class automatically. (riscv_compare_subsets): New function. Similar to the strcmp, but compare the subsets with the specific order. (riscv_lookup_subset): Return TRUE and set `current` to the subset if it is found. Otherwise, return FALSE and set `current` to the place where we should insert the subset. (riscv_add_implicit_subset): New function. Search the list first, and then find the right place to add the implicit_subset. (riscv_parse_add_subset): Since We have to add all arch string extensions first, and then start to add their implicit extensions. We can add arch string extensions in order by the original riscv_add_subset, and then add the implicit subsets by the riscv_add_implicit_subset. Besides, do not add the implicit extensions if we failed to find their default versions. (riscv_parse_std_ext): Updated. (riscv_parse_add_implicit_subsets): New function. Add all implicit extensions according to the arch string extensions. (riscv_parse_subset): Call riscv_init_ext_order and riscv_parse_add_implicit_subsets, before and after parsing the arch string. Remove parts of the ISA conflict checking since the implicit extensions are added. * elfxx-riscv.h (riscv_lookup_subset): Updated. gas/ * config/tc-riscv.c (riscv_subset_supports): Updated. * testsuite/gas/riscv/march-imply-i2p0.d: New testcase. Need to add the implicit zicsr and zifencei when i's version less than 2.1. * testsuite/gas/riscv/march-imply-i2p1.d: New testcase. * testsuite/gas/riscv/march-imply-d.d: Likewise. * testsuite/gas/riscv/march-imply-f.d: Likewise. * testsuite/gas/riscv/march-imply-q.d: Likewise. * testsuite/gas/riscv/march-fail-rv32iq.l: Updated. * testsuite/gas/riscv/march-fail-rv32id.d: Removed. * testsuite/gas/riscv/march-fail-rv32id.l: Likewise. * testsuite/gas/riscv/march-fail-rv64iq.d: Likewise. * testsuite/gas/riscv/march-fail-rv64iq.l: Likewise.
2020-12-01RISC-V: Improve the version parsing for arch string.Nelson Chu3-186/+171
Keep the riscv_add_subset to do the same thing, and use a new function, riscv_parse_add_subset, to cover most of the things when parsing, including find the default versions for extensions, and check whether the versions are valid. The version 0p0 should be an invalid version, that is the mistake I made before. This patch clarify the version rules as follows, * We accept any version of extensions set by users, except 0p0. * The non-standard x extensions must be set with versions in arch string. * If user don't set the versions, or set 0p0 for the extensions, then try to find the supported versions according to the chosen ISA spec. Otherwise, report errors rather than output 0p0 for them. Besides, we use as_bad rather than as_fatal to report more errors for assembler. bfd/ * elfxx-riscv.c (riscv_lookup_subset): Moved to front. (riscv_add_subset): Likewise. (riscv_release_subset_list): Likewise. (riscv_parse_add_subset): New function. Find and check the versions before adding them by riscv_add_subset. (riscv_parsing_subset_version): Remove use_default_version and change the version type from unsigned to int. Set the versions to RISCV_UNKNOWN_VERSION if we can not find them in the arch string. (riscv_parse_std_ext): Updated. (riscv_parse_prefixed_ext): Updated. Since we use as_bad rather than as_fatal to report more errors, return NULL string if the parsed end_of_version is NULL, too. (riscv_parse_subset): Use a new boolean, no_conflict, to report more errors when we have more than one ISA conflicts. * elfxx-riscv.h (RISCV_DONT_CARE_VERSION): Changed to RISCV_UNKNOWN_VERSION. (riscv_lookup_subset_version): Removed. (riscv_parse_subset_t): Updated. gas/ * config/tc-riscv.c (riscv_get_default_ext_version): Change the version type from unsigned to int. (riscv_set_arch): Use as_bad rather than as_fatal to report more errors. * testsuite/gas/riscv/attribute-02.d: Updated since x must be set with versions. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/march-ok-two-nse.d: Likewise. * testsuite/gas/riscv/attribute-09.d: zicsr wasn't supported in the spec 2.2, so choose the newer spec. * testsuite/gas/riscv/march-fail-base-01.l: Updated since as_bad. * testsuite/gas/riscv/march-fail-base-02.l: Likewise. * testsuite/gas/riscv/march-fail-order-std.l: Likewise. * testsuite/gas/riscv/march-fail-order-x.l: Likewise. * testsuite/gas/riscv/march-fail-order-z.l: Likewise. * testsuite/gas/riscv/march-fail-porder.l: Likewise. * testsuite/gas/riscv/march-fail-rv32ef.l: Likewise. * testsuite/gas/riscv/march-fail-rv32id.l: Likewise. * testsuite/gas/riscv/march-fail-rv32iq.l: Likewise. * testsuite/gas/riscv/march-fail-rv64iq.l: Likewise. * testsuite/gas/riscv/march-fail-single-char.l: Likewise. * testsuite/gas/riscv/march-fail-unknown-std.l: Likewise. * testsuite/gas/riscv/march-fail-unknown.l: Likewise. * testsuite/gas/riscv/march-fail-uppercase.l: Likewise. * testsuite/gas/riscv/march-fail-version.l: Likewise. * testsuite/gas/riscv/march-fail-isa-spec.d: Likewise. * testsuite/gas/riscv/march-fail-isa-spec.l: Likewise. include/ * opcode/riscv.h (riscv_ext_version): Change the version type from unsigned to int.
2020-12-01RISC-V: Add zifencei and prefixed h class extensions.Nelson Chu3-2/+31
bfd/ * elfxx-riscv.c (riscv_parse_std_ext): Stop parsing standard extensions when parsed h keyword. (riscv_get_prefix_class): Support prefixed h class. (riscv_std_h_ext_strtab): Likewise. (riscv_ext_h_valid_p): Likewise. (parse_config): Likewise. (riscv_std_z_ext_strtab): Add zifencei. * elfxx-riscv.h (riscv_isa_ext_class): Add RV_ISA_CLASS_H. gas/ * testsuite/gas/riscv/march-fail-order-z.d: New testcase, check orders of prefixed z extensions. * testsuite/gas/riscv/march-fail-order-z.l: Likewise. * testsuite/gas/riscv/march-fail-single-char-h.d: New testcase. * testsuite/gas/riscv/march-fail-single-char.l: Updated. * testsuite/gas/riscv/march-fail-unknown-h.d: New testcase. * testsuite/gas/riscv/march-fail-unknown.l: Updated. opcodes/ * riscv-opc.c (riscv_ext_version_table): Add zifencei.
2020-12-01RISC-V: Don't allow any uppercase letter in the arch string.Nelson Chu2-1/+18
Although I cannot find any RISC-V specs said that uppercases are not allowed in the arhc string, but seems like it is an established fact both for GNU and LLVM. Therefore, we shouldn't allow the uppercases for the non-standard x extensions, too. bfd/ * elfxx-riscv.c (riscv_parse_subset): ISA string cannot contain any uppercase letter. gas/ * testsuite/gas/riscv/march-fail-uppercase-base.d: Updated. * testsuite/gas/riscv/march-fail-uppercase.l: Updated. * testsuite/gas/riscv/march-fail-uppercase-x.d: New testcase.