-
-
Save prattmic/a9816731294715426d7b85eb091d0102 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdio.h> | |
#include <sys/auxv.h> | |
int main(int argc, char** argv, char** envv) { | |
uintptr_t vdso_base = getauxval(AT_SYSINFO_EHDR); | |
vdso_base &= ~0xfff; // round down; | |
printf("VDSO base: %#llx\n", vdso_base); | |
// Linux 5.6+ have 4 pages of VVAR. | |
uintptr_t vvar_offset = 4 * 4096; | |
// Linux 4.12+ have 3 pages of VVAR. | |
//vvar_offset = 3 * 4096; | |
// Linux 4.7+ have 2 pages of VVAR. | |
//vvar_offset = 2 * 4096; | |
// Earlier has 1 page. | |
//vvar_offset = 1 * 4096; | |
uintptr_t vvar_base = vdso_base - vvar_offset; | |
// Dump first 512 bytes. | |
for (int i = 0; i < 512; i += 4) { | |
uintptr_t addr = vvar_base + i; | |
if (i % 16 == 0) { | |
printf("\n%#llx:", addr); | |
} | |
printf(" 0x%08x", *(uint32_t*)addr); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment