static int dump_file(struct tree_state *t, char *name, char *file) { struct file_state f; int fd; Elf_Scn *scn; GElf_Shdr shdr; if ((dup_mode == HIDE_DUPS) && seen(t, name)) return 0; indent(t); printf("%s", name); if ((dup_mode == PRUNE_DUPS) && seen(t, name)) { printf("...\n"); return 0; } else { printf(":\n"); } see(t, name); f.t = t; fd = open(file, O_RDONLY); if (fd < 0) { unix_err("open(%s) failed", file); return -1; } f.e = elf_begin(fd, ELF_C_READ, NULL); if (!f.e) { elf_err("elf_begin failed on %s", file); return -1; } scn = find_scn(&f, SHT_STRTAB, NULL, &shdr); f.strtab_data = elf_getdata(scn, NULL); if (!f.strtab_data) { app_err("%s has no strtab section", file); return -1; } scn = NULL; while ((scn = find_scn(&f, SHT_DYNAMIC, scn, &shdr))) { dump_dynamic(&f, scn, &shdr); } elf_end(f.e); close(fd); return 0; }
int show_dynamic( char **argv ) { if( *argv ) error_ret("bad args",-1); dump_dynamic( get_elf() ); return( COMMAND_SUCCESS ); }