1 /* nm.c - a feeble shared-lib library parser
2 * Copyright 1997, 1998 Tom Spindler
3 * This software is covered under perl's Artistic license.
6 /* $Id: nm.c,v 1.1 1998/02/16 03:51:26 dogcow Exp $ */
8 #include <be/kernel/image.h>
15 main(int argc, char **argv) {
19 volatile int32 symnamelen, symtype;
22 if (argc != 2) { printf("more args, bozo\n"); exit(1); }
24 path = (void *) malloc((size_t) 2048);
25 symname = (void *) malloc((size_t) 2048);
27 if (!getcwd(path, 2048)) { printf("aiee!\n"); exit(1); }
28 if (!strcat(path, "/")) {printf("naah.\n"); exit (1); }
29 /*printf("%s\n",path);*/
31 if ('/' != argv[1][0]) {
32 if (!strcat(path, argv[1])) { printf("feh1\n"); exit(1); }
34 if (!strcpy(path, argv[1])) { printf("gah!\n"); exit(1); }
36 /*printf("%s\n",path);*/
38 img = load_add_on(path);
39 if (B_ERROR == img) {printf("Couldn't load_add_on() %s.\n", path); exit(2); }
43 while (B_BAD_INDEX != get_nth_image_symbol(img, n++, symname, &symnamelen,
45 printf("%s |%s |GLOB %Lx | \n", symname,
46 ((B_SYMBOL_TYPE_ANY == symtype) || (B_SYMBOL_TYPE_TEXT == symtype)) ? "FUNC" : "VAR ", symloc);
49 printf("number of symbols: %d\n", n);
50 if (B_ERROR == unload_add_on(img)) {printf("err while closing.\n"); exit(3); }