diff options
author | Marat Dukhan <marat@fb.com> | 2017-11-29 15:15:36 -0800 |
---|---|---|
committer | Marat Dukhan <marat@fb.com> | 2017-11-29 15:15:36 -0800 |
commit | f3a71e68abc065478780cf4f36bede13cad9e3cf (patch) | |
tree | bda99037028d84af71edf64676200670dfb1eda8 /tools/auxv-dump.c | |
parent | 63a7a6b48f72e7eef62522240a39d3bd0eb7fb02 (diff) | |
download | cpuinfo-f3a71e68abc065478780cf4f36bede13cad9e3cf.tar.gz |
Add tool to extract ELF Auxiliary vectors for HWCAPs
Diffstat (limited to 'tools/auxv-dump.c')
-rw-r--r-- | tools/auxv-dump.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/auxv-dump.c b/tools/auxv-dump.c new file mode 100644 index 0000000..a15e5c1 --- /dev/null +++ b/tools/auxv-dump.c @@ -0,0 +1,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; +} |