#include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { long storage_needed; long number_of_symbols; long i; symbol_info syminfo; bfd *ibfd; asymbol **symbol_table; if (argc != 2) { printf("Usage: %s kernel-image\n", argv[0]); exit(1); } if ((ibfd = (bfd_openr(argv[1], NULL))) == NULL) { perror("bfd_openr"); exit(1); } if (!bfd_check_format(ibfd, bfd_object)) { perror("bfd_check_format"); exit(1); } if ((storage_needed = bfd_get_symtab_upper_bound(ibfd)) < 1) { if (storage_needed < 0) perror("bfd_get_symtab_upper_bound"); else perror("no symbols"); exit(1); } if ((symbol_table = (asymbol **)xmalloc(storage_needed)) == NULL) { perror("xmalloc"); exit(1); } if ((number_of_symbols = bfd_canonicalize_symtab(ibfd, symbol_table)) < 0) { perror("bfd_canonicalize_symtab"); exit(1); } for (i = 0; i < number_of_symbols; i++) { bfd_get_symbol_info(ibfd, symbol_table[i], &syminfo); if (syminfo.name) printf("%s\n", syminfo.name); } }