From 04c9cf0a8c5f03e5a1bb91a954cc42eb83a3e493 Mon Sep 17 00:00:00 2001 From: Nelson Chu Date: Wed, 31 Jul 2024 13:00:11 +0800 Subject: RISC-V: PR32014, .option directives shuoldn't affect elf attribute. The .option arch/rvc/norvc/push/pop directives can only take effect for a small/large specific code region, so they are not file-level architecture setting. They should only affect the mapping symbols only rather than the file-level elf architecture attribute. Otherwise, the elf architecture attribute will appear to missing some extensions when -flto merges files with different .option architecture settings. gas/ PR 32014 * config/tc-riscv.c (file_arch_str): New const char *, rather than the arch_str in the riscv_rps_as.subset_list, it's file-level so only be affected by .attribute arch directive. (riscv_reset_subsets_list_arch_str): Renamed to riscv_set_arch_str, and also can handle both file_arch_str and arch_str in subset_list, just give the pointer address as the input. (riscv_set_arch): Called by -march and .attribute arch, so set both file_arch_str and arch_str in subset_list. (s_riscv_option): Updated .option arch/rvc/norvc/push/pop that only set the arch_str in subset_list. (riscv_write_out_attrs): Output elf architecture attribute according to file_arch_str. Freed file_arch_str. * doc/c-riscv.texi: Added destrbution that .option directives shouldn't affect the elf attribute settings. * testsuite/gas/riscv/option-arch.s: From option-arch-01/02/03 merged. * testsuite/gas/riscv/option-arch-dis.d: Likewise, for dis-assembler. * testsuite/gas/riscv/option-arch-attr.d: Likewise, to check readelf -A. --- gas/doc/c-riscv.texi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gas/doc') diff --git a/gas/doc/c-riscv.texi b/gas/doc/c-riscv.texi index cec7457..9a2349f 100644 --- a/gas/doc/c-riscv.texi +++ b/gas/doc/c-riscv.texi @@ -178,7 +178,12 @@ instead of just It's not expected that options are changed in this manner during regular use, but there are a handful of esoteric cases like the one above where users need to disable particular features of the assembler for particular code sequences. -The complete list of option arguments is shown below: +However, it's also useful to enable/disable the extensions for some specific +code regions by @samp{.option arch, +-}. This is very common in the ifunc +libraries. We can support functions which are implemented by different +extensions in the same library, but these should not affect any file-level +settings, like the elf architecture attribute. The complete list of option +arguments is shown below: @table @code @item push -- cgit v1.1