From b08f79af78925502ae7aa6b206d3f157ef56f4dc Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 31 Jul 2023 19:34:38 +0000 Subject: [PATCH] riscv64: pass a null argument to ifunc resolvers. glibc maintainer Florian Weimer pointed out that glibc passes a null first argument to riscv64 ifunc resolvers. While not super useful right now, that does make it much easier to switch to providing arguments in future, such as my favorite idea of passing a default set of hwprobe key/value pairs, along with a count of how many pairs. Test: treehugger Change-Id: Ibe2148dc28aa6ad230e6324b6d725fe472b7ef33 --- libc/bionic/bionic_call_ifunc_resolver.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libc/bionic/bionic_call_ifunc_resolver.cpp b/libc/bionic/bionic_call_ifunc_resolver.cpp index 437de78ce..410eb7819 100644 --- a/libc/bionic/bionic_call_ifunc_resolver.cpp +++ b/libc/bionic/bionic_call_ifunc_resolver.cpp @@ -57,6 +57,13 @@ ElfW(Addr) __bionic_call_ifunc_resolver(ElfW(Addr) resolver_addr) { hwcap = getauxval(AT_HWCAP); } return reinterpret_cast(resolver_addr)(hwcap); +#elif defined(__riscv) + // This argument and its value is just a placeholder for now, + // but it means that if we do pass something in future (such as + // getauxval() and/or hwprobe key/value pairs), callees will be able to + // recognize what they're being given. + typedef ElfW(Addr) (*ifunc_resolver_t)(void*); + return reinterpret_cast(resolver_addr)(nullptr); #else typedef ElfW(Addr) (*ifunc_resolver_t)(void); return reinterpret_cast(resolver_addr)();