Linux-2.6.12-rc2
[linux-2.6/kvm.git] / arch / ppc / kernel / find_name.c
blob3c0fa8e0c07751760644bcdcb3530593ee0c082f
1 #include <stdio.h>
2 #include <asm/page.h>
3 #include <sys/mman.h>
4 #include <strings.h>
5 /*
6 * Finds a given address in the System.map and prints it out
7 * with its neighbors. -- Cort
8 */
10 int main(int argc, char **argv)
12 unsigned long addr, cmp, i;
13 FILE *f;
14 char s[256], last[256];
16 if ( argc < 2 )
18 fprintf(stderr, "Usage: %s <address>\n", argv[0]);
19 return -1;
22 for ( i = 1 ; argv[i] ; i++ )
24 sscanf( argv[i], "%0lx", &addr );
25 /* adjust if addr is relative to kernelbase */
26 if ( addr < PAGE_OFFSET )
27 addr += PAGE_OFFSET;
29 if ( (f = fopen( "System.map", "r" )) == NULL )
31 perror("fopen()\n");
32 exit(-1);
35 while ( !feof(f) )
37 fgets(s, 255 , f);
38 sscanf( s, "%0lx", &cmp );
39 if ( addr < cmp )
40 break;
41 strcpy( last, s);
44 printf( "%s%s", last, s );
46 fclose(f);
47 return 0;