diff options
author | caiyinyu <caiyinyu@loongson.cn> | 2023-09-15 17:35:19 +0800 |
---|---|---|
committer | caiyinyu <caiyinyu@loongson.cn> | 2024-04-24 18:22:38 +0800 |
commit | 095067efdf68c8061d6f99a21a0300841bede999 (patch) | |
tree | 6632c0cb08991fbd2c08809f24320493687c81a6 /sysdeps/loongarch/dl-machine.h | |
parent | f4724843ada64a51d66f65d3199fe431f9d4c254 (diff) | |
download | glibc-095067efdf68c8061d6f99a21a0300841bede999.tar.gz glibc-095067efdf68c8061d6f99a21a0300841bede999.tar.xz glibc-095067efdf68c8061d6f99a21a0300841bede999.zip |
LoongArch: Add glibc.cpu.hwcap support.
The current IFUNC selection is always using the most recent features which are available via AT_HWCAP. But in some scenarios it is useful to adjust this selection. The environment variable: GLIBC_TUNABLES=glibc.cpu.hwcaps=-xxx,yyy,zzz,.... can be used to enable HWCAP feature yyy, disable HWCAP feature xxx, where the feature name is case-sensitive and has to match the ones used in sysdeps/loongarch/cpu-tunables.c. Signed-off-by: caiyinyu <caiyinyu@loongson.cn>
Diffstat (limited to 'sysdeps/loongarch/dl-machine.h')
-rw-r--r-- | sysdeps/loongarch/dl-machine.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/sysdeps/loongarch/dl-machine.h b/sysdeps/loongarch/dl-machine.h index ab81b82d95..6baf0e600a 100644 --- a/sysdeps/loongarch/dl-machine.h +++ b/sysdeps/loongarch/dl-machine.h @@ -29,6 +29,8 @@ #include <dl-static-tls.h> #include <dl-machine-rel.h> +#include <cpu-features.c> + #ifndef _RTLD_PROLOGUE # define _RTLD_PROLOGUE(entry) \ ".globl\t" __STRING (entry) "\n\t" \ @@ -53,6 +55,23 @@ #define ELF_MACHINE_NO_REL 1 #define ELF_MACHINE_NO_RELA 0 +#define DL_PLATFORM_INIT dl_platform_init () + +static inline void __attribute__ ((unused)) +dl_platform_init (void) +{ + if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0') + /* Avoid an empty string which would disturb us. */ + GLRO(dl_platform) = NULL; + +#ifdef SHARED + /* init_cpu_features has been called early from __libc_start_main in + static executable. */ + init_cpu_features (&GLRO(dl_larch_cpu_features)); +#endif +} + + /* Return nonzero iff ELF header is compatible with the running host. */ static inline int elf_machine_matches_host (const ElfW (Ehdr) *ehdr) @@ -290,10 +309,10 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], #ifdef SHARED if (profile != 0) { -# if !defined __loongarch_soft_float - if (SUPPORT_LASX) +#if !defined __loongarch_soft_float + if (RTLD_SUPPORT_LASX) gotplt[0] = (ElfW(Addr)) &_dl_runtime_profile_lasx; - else if (SUPPORT_LSX) + else if (RTLD_SUPPORT_LSX) gotplt[0] = (ElfW(Addr)) &_dl_runtime_profile_lsx; else # endif @@ -312,9 +331,9 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], indicated by the offset on the stack, and then jump to the resolved address. */ #if !defined __loongarch_soft_float - if (SUPPORT_LASX) + if (RTLD_SUPPORT_LASX) gotplt[0] = (ElfW(Addr)) &_dl_runtime_resolve_lasx; - else if (SUPPORT_LSX) + else if (RTLD_SUPPORT_LSX) gotplt[0] = (ElfW(Addr)) &_dl_runtime_resolve_lsx; else #endif |