@@ -15,6 +15,8 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <sys/auxv.h>
+
#include "defines.h"
#include "../../../../../arch/x86/kernel/cpu/sgx/arch.h"
#include "../../../../../arch/x86/include/uapi/asm/sgx.h"
@@ -30,22 +32,9 @@ struct vdso_symtab {
Elf64_Word *elf_hashtab;
};
-static void *vdso_get_base_addr(char *envp[])
+static void *vdso_get_base_addr(void)
{
- Elf64_auxv_t *auxv;
- int i;
-
- for (i = 0; envp[i]; i++)
- ;
-
- auxv = (Elf64_auxv_t *)&envp[i + 1];
-
- for (i = 0; auxv[i].a_type != AT_NULL; i++) {
- if (auxv[i].a_type == AT_SYSINFO_EHDR)
- return (void *)auxv[i].a_un.a_val;
- }
-
- return NULL;
+ return (void *)getauxval(AT_SYSINFO_EHDR);
}
static Elf64_Dyn *vdso_get_dyntab(void *addr)
@@ -342,7 +331,7 @@ int main(int argc, char *argv[], char *envp[])
memset(&exception, 0, sizeof(exception));
- addr = vdso_get_base_addr(envp);
+ addr = vdso_get_base_addr();
if (!addr)
exit(1);
Replace the open coded ELF fun with a simple getauxval() call. Suggested-by: Cedric Xing <cedric.xing@intel.com> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> --- tools/testing/selftests/x86/sgx/main.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)