[RFC] RISC-V: Support STO_RISCV_VARIANT_CC and DT_RISCV_VARIANT_CC.
Fangrui Song
i@maskray.me
Fri Aug 13 03:13:07 GMT 2021
On 2021-08-11, Nelson Chu wrote:
>This is the original discussion,
>https://github.com/riscv/riscv-elf-psabi-doc/pull/190
>
>And here is the glibc part,
>https://sourceware.org/pipermail/libc-alpha/2021-August/129931.html
>
>For binutils part, we need to support a new direcitve: .variant_cc.
>The function symbol marked by .variant_cc means it need to be resolved
>directly without resolver for dynamic linker. We also add a new dynamic
>entry, STO_RISCV_VARIANT_CC, to indicate there are symbols with the
>special attribute in the dynamic symbol table of the object.
>
>This patch just passed the toolchain regressions. I have not integrated
>the llvm and glibc parts, and tested them together. Maybe someone can help
>to put them together for testing, that would be very great.
>
>bfd/
> * elfnn-riscv.c (riscv_elf_link_hash_table): Added variant_cc
> flag. It is used to check if relocations for variant CC symbols
> may be present.
> (allocate_dynrelocs): If the symbol has STO_RISCV_VARIANT_CC
> flag, then raise the variant_cc flag of riscv_elf_link_hash_table.
> (riscv_elf_size_dynamic_sections): Added dynamic entry for
> variant_cc.
> (riscv_elf_merge_symbol_attribute): New function, used to merge
> non-visibility st_other attributes, including STO_RISCV_VARIANT_CC.
>binutils/
> * readelf.c (get_riscv_dynamic_type): New function.
> (get_dynamic_type): Called get_riscv_dynamic_type for riscv targets.
> (get_riscv_symbol_other): New function.
> (get_symbol_other): Called get_riscv_symbol_other for riscv targets.
>gas/
> * config/tc-riscv.c (s_variant_cc): Marked symbol that it follows a
> variant CC convention.
> (riscv_elf_copy_symbol_attributes): Same as elf_copy_symbol_attributes,
> but without copying st_other. If a function symbol has special st_other
> value set via directives, then attaching an IFUNC resolver to that symbol
> should not override the st_other setting.
> (riscv_pseudo_table): Support variant_cc diretive.
> * config/tc-riscv.h (OBJ_COPY_SYMBOL_ATTRIBUTES): Defined.
> * testsuite/gas/riscv/variant_cc-set.d: New testcase.
> * testsuite/gas/riscv/variant_cc-set.s: Likewise.
> * testsuite/gas/riscv/variant_cc.d: Likewise.
> * testsuite/gas/riscv/variant_cc.s: Likewise.
Quick comment:
For LLD's STO_RISCV_VARIANT_CC patch, I asked what to do with
STT_GNU_IFUNC. The reply was that nothing is needed.
Does RISC-V do special things with IFUNC? I haven't looked at the patch.
https://reviews.llvm.org/D93045
More information about the Binutils
mailing list