aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/riscv/dl-irel.h
diff options
context:
space:
mode:
authorEvan Green <evan@rivosinc.com>2024-02-27 14:56:40 -0800
committerPalmer Dabbelt <palmer@rivosinc.com>2024-03-01 07:14:58 -0800
commit78308ce77ad55191d2e578bbcd19bb55c68926cb (patch)
treeb3d1d142e10539967b6cc545e4f3c76763a76015 /sysdeps/riscv/dl-irel.h
parente7919e0db28837ae5e4315933a061a7c2eda442e (diff)
downloadglibc-78308ce77ad55191d2e578bbcd19bb55c68926cb.zip
glibc-78308ce77ad55191d2e578bbcd19bb55c68926cb.tar.gz
glibc-78308ce77ad55191d2e578bbcd19bb55c68926cb.tar.bz2
riscv: Add __riscv_hwprobe pointer to ifunc calls
The new __riscv_hwprobe() function is designed to be used by ifunc selector functions. This presents a challenge for applications and libraries, as ifunc selectors are invoked before all relocations have been performed, so an external call to __riscv_hwprobe() from an ifunc selector won't work. To address this, pass a pointer to the __riscv_hwprobe() function into ifunc selectors as the second argument (alongside dl_hwcap, which was already being passed). Include a typedef as well for convenience, so that ifunc users don't have to go through contortions to call this routine. Users will need to remember to check the second argument for NULL, to account for older glibcs that don't pass the function. Signed-off-by: Evan Green <evan@rivosinc.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'sysdeps/riscv/dl-irel.h')
-rw-r--r--sysdeps/riscv/dl-irel.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/sysdeps/riscv/dl-irel.h b/sysdeps/riscv/dl-irel.h
index e6ab51c..61b3511 100644
--- a/sysdeps/riscv/dl-irel.h
+++ b/sysdeps/riscv/dl-irel.h
@@ -24,6 +24,7 @@
#include <unistd.h>
#include <ldsodefs.h>
#include <sysdep.h>
+#include <sys/hwprobe.h>
#define ELF_MACHINE_IRELA 1
@@ -31,10 +32,10 @@ static inline ElfW(Addr)
__attribute ((always_inline))
elf_ifunc_invoke (ElfW(Addr) addr)
{
- /* The second argument is a void pointer to preserve the extension
- fexibility. */
- return ((ElfW(Addr) (*) (uint64_t, void *)) (addr))
- (GLRO(dl_hwcap), NULL);
+ /* The third argument is a void pointer to preserve the extension
+ flexibility. */
+ return ((ElfW(Addr) (*) (uint64_t, void *, void *)) (addr))
+ (GLRO(dl_hwcap), __riscv_hwprobe, NULL);
}
static inline void