aboutsummaryrefslogtreecommitdiff
path: root/tools/auxv-dump.c
blob: a15e5c10827b1a6defbd6b831482c849e094e5f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdlib.h>
#include <stdio.h>

#include <sys/auxv.h>
#include <errno.h>
#include <dlfcn.h>

#include <cpuinfo.h>


typedef unsigned long (*getauxval_function_t)(unsigned long);

int main(int argc, char** argv) {
	void* libc = dlopen("libc.so", RTLD_NOW);
	if (libc == NULL) {
		fprintf(stderr, "Error: failed to load libc.so: %s\n", dlerror());
		exit(EXIT_FAILURE);
	}

	getauxval_function_t getauxval = (getauxval_function_t) dlsym(libc, "getauxval");
	if (getauxval == NULL) {
		fprintf(stderr, "Error: failed to locate getauxval in libc.so: %s", dlerror());
		exit(EXIT_FAILURE);
	}

	printf("AT_HWCAP = 0x%08lX\n", getauxval(AT_HWCAP));
	#if CPUINFO_ARCH_ARM
		printf("AT_HWCAP2 = 0x%08lX\n", getauxval(AT_HWCAP2));
	#endif

	return 0;
}