/************************************************************************ Program to print the addresses corresponding to kernel symbols. These addresses can be used (as in jiffyprint.c) to seek into /dev/kmem and manipulate kernel data structures ************************************************************************/ #include #include /* Ehrm... well, well, well... */ #include #include /* for malloc */ /* * This is here as syscall.h and sys/syscall.h redefine the defines in * unistd.h why doesn't unistd #include them? */ #ifdef __cplusplus extern "C" int syscall(int, ...); #else extern int syscall(int, ...); #endif static int get_kernel_syms(struct kernel_sym *buffer) { return syscall( __NR_get_kernel_syms, buffer); } main() { int num, val, i; struct kernel_sym *ksym, *ptr; val = get_kernel_syms(NULL); printf("There are %d symbols. Error = %d\n", val, errno); ksym = (struct kernel_sym *) malloc(sizeof(struct kernel_sym) * val); if (ksym == NULL) { printf("Could not allocate ksym memory.\n"); exit(-1); } num = val; val = get_kernel_syms(ksym); printf("Read %d symbols. Error = %d\n", val, errno); printf("Address Name\n"); for (i = 0, ptr = ksym; i < num; i++, ptr++) printf("0x%x %s\n", ptr->value, ptr->name); }