/* * vdso_test.c: Sample code to test parse_vdso.c * Copyright (c) 2014 Andy Lutomirski * Subject to the GNU General Public License, version 2 * * Compile with: * gcc -std=gnu99 vdso_test.c parse_vdso.c * * Tested on x86, 32-bit and 64-bit. It may work on other architectures, too. */ #include <stdint.h> #include <elf.h> #include <stdio.h> #include <sys/auxv.h> #include <sys/time.h> extern void *vdso_sym(const char *version, const char *name); extern void vdso_init_from_sysinfo_ehdr(uintptr_t base); extern void vdso_init_from_auxv(void *auxv); int main(int argc, char **argv) { unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); if (!sysinfo_ehdr) { printf("AT_SYSINFO_EHDR is not present!\n"); return 0; } vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR)); /* Find gettimeofday. */ typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz); gtod_t gtod = (gtod_t)vdso_sym("LINUX_2.6", "__vdso_gettimeofday"); if (!gtod) { printf("Could not find __vdso_gettimeofday\n"); return 1; } struct timeval tv; long ret = gtod(&tv, 0); if (ret == 0) { printf("The time is %lld.%06lld\n", (long long)tv.tv_sec, (long long)tv.tv_usec); } else { printf("__vdso_gettimeofday failed\n"); } return 0; } mit' value='switch'/></form></td></tr> <tr><td class='sub'>net-next plumbings</td><td class='sub right'>Tobias Klauser</td></tr></table> <table class='tabs'><tr><td> <a href='/cgit.cgi/linux/net-next.git/?h=nds-private-remove'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?h=nds-private-remove'>refs</a><a class='active' href='/cgit.cgi/linux/net-next.git/log/Documentation/devicetree/bindings/usb/fsl-usb.txt?h=nds-private-remove'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/Documentation/devicetree/bindings/usb/fsl-usb.txt?h=nds-private-remove'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/Documentation/devicetree/bindings/usb/fsl-usb.txt?h=nds-private-remove'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/Documentation/devicetree/bindings/usb/fsl-usb.txt?h=nds-private-remove'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/Documentation/devicetree/bindings/usb/fsl-usb.txt'> <input type='hidden' name='h' value='nds-private-remove'/><select name='qt'> <option value='grep'>log msg</option> <option value='author'>author</option> <option value='committer'>committer</option> <option value='range'>range</option> </select> <input class='txt' type='search' size='10' name='q' value=''/> <input type='submit' value='search'/> </form> </td></tr></table> <div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?h=nds-private-remove'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/Documentation?h=nds-private-remove'>Documentation</a>/<a href='/cgit.cgi/linux/net-next.git/log/Documentation/devicetree?h=nds-private-remove'>devicetree</a>/<a href='/cgit.cgi/linux/net-next.git/log/Documentation/devicetree/bindings?h=nds-private-remove'>bindings</a>/<a href='/cgit.cgi/linux/net-next.git/log/Documentation/devicetree/bindings/usb?h=nds-private-remove'>usb</a>/<a href='/cgit.cgi/linux/net-next.git/log/Documentation/devicetree/bindings/usb/fsl-usb.txt?h=nds-private-remove'>fsl-usb.txt</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/Documentation/devicetree/bindings/usb/fsl-usb.txt?h=nds-private-remove&showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>