ldd.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * A small little ldd implementation for uClibc
  4. *
  5. * Copyright (C) 2000 by Lineo, inc and Erik Andersen
  6. * Copyright (C) 2000-2002 Erik Andersen <andersee@debian.org>
  7. *
  8. * Several functions in this file (specifically, elf_find_section_type(),
  9. * elf_find_phdr_type(), and elf_find_dynamic(), were stolen from elflib.c from
  10. * elfvector (http://www.BitWagon.com/elfvector.html) by John F. Reiser
  11. * <jreiser@BitWagon.com>, which is copyright 2000 BitWagon Software LLC
  12. * (GPL2).
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  22. * General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27. *
  28. */
  29. #define _GNU_SOURCE
  30. #include <stdlib.h>
  31. #include <stdio.h>
  32. #include <fcntl.h>
  33. #include <string.h>
  34. #include <unistd.h>
  35. #include <sys/mman.h>
  36. #include <sys/stat.h>
  37. #include <sys/types.h>
  38. #include <sys/types.h>
  39. #include <sys/wait.h>
  40. #include "bswap.h"
  41. #if defined (sun)
  42. #include "link.h"
  43. #else
  44. #include "elf.h"
  45. #endif
  46. #ifdef DMALLOC
  47. #include <dmalloc.h>
  48. #endif
  49. #if defined(__arm__)
  50. #define MATCH_MACHINE(x) (x == EM_ARM)
  51. #define ELFCLASSM ELFCLASS32
  52. #endif
  53. #if defined(__s390__)
  54. #define MATCH_MACHINE(x) (x == EM_S390)
  55. #define ELFCLASSM ELFCLASS32
  56. #endif
  57. #if defined(__i386__)
  58. #ifndef EM_486
  59. #define MATCH_MACHINE(x) (x == EM_386)
  60. #else
  61. #define MATCH_MACHINE(x) (x == EM_386 || x == EM_486)
  62. #endif
  63. #define ELFCLASSM ELFCLASS32
  64. #endif
  65. #if defined(__mc68000__)
  66. #define MATCH_MACHINE(x) (x == EM_68K)
  67. #define ELFCLASSM ELFCLASS32
  68. #endif
  69. #if defined(__mips__)
  70. #define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE)
  71. #define ELFCLASSM ELFCLASS32
  72. #endif
  73. #if defined(__powerpc__)
  74. #define MATCH_MACHINE(x) (x == EM_PPC)
  75. #define ELFCLASSM ELFCLASS32
  76. #endif
  77. #if defined(__sh__)
  78. #define MATCH_MACHINE(x) (x == EM_SH)
  79. #define ELFCLASSM ELFCLASS32
  80. #endif
  81. #if defined (__v850e__)
  82. #define MATCH_MACHINE(x) ((x) == EM_V850 || (x) == EM_CYGNUS_V850)
  83. #define ELFCLASSM ELFCLASS32
  84. #endif
  85. #if defined (__sparc__)
  86. #define MATCH_MACHINE(x) ((x) == EM_SPARC || (x) == EM_SPARC32PLUS)
  87. #define ELFCLASSM ELFCLASS32
  88. #endif
  89. #ifndef MATCH_MACHINE
  90. #warning "You really should add a MATCH_MACHINE() macro for your architecture"
  91. #endif
  92. #if __BYTE_ORDER == __LITTLE_ENDIAN
  93. #define ELFDATAM ELFDATA2LSB
  94. #elif __BYTE_ORDER == __BIG_ENDIAN
  95. #define ELFDATAM ELFDATA2MSB
  96. #endif
  97. struct library {
  98. char *name;
  99. int resolved;
  100. char *path;
  101. struct library *next;
  102. };
  103. struct library *lib_list = NULL;
  104. char not_found[] = "not found";
  105. char *interp = NULL;
  106. char *interp_dir = NULL;
  107. int byteswap;
  108. static int interpreter_already_found=0;
  109. inline uint32_t byteswap32_to_host(uint32_t value)
  110. {
  111. if (byteswap==1) {
  112. return(bswap_32(value));
  113. } else {
  114. return(value);
  115. }
  116. }
  117. Elf32_Shdr * elf_find_section_type( int key, Elf32_Ehdr *ehdr)
  118. {
  119. int j;
  120. Elf32_Shdr *shdr;
  121. shdr = (Elf32_Shdr *)(ehdr->e_shoff + (char *)ehdr);
  122. for (j = ehdr->e_shnum; --j>=0; ++shdr) {
  123. if (key==(int)byteswap32_to_host(shdr->sh_type)) {
  124. return shdr;
  125. }
  126. }
  127. return NULL;
  128. }
  129. Elf32_Phdr * elf_find_phdr_type( int type, Elf32_Ehdr *ehdr)
  130. {
  131. int j;
  132. Elf32_Phdr *phdr = (Elf32_Phdr *)(ehdr->e_phoff + (char *)ehdr);
  133. for (j = ehdr->e_phnum; --j>=0; ++phdr) {
  134. if (type==(int)byteswap32_to_host(phdr->p_type)) {
  135. return phdr;
  136. }
  137. }
  138. return NULL;
  139. }
  140. /* Returns value if return_val==1, ptr otherwise */
  141. void * elf_find_dynamic(int const key, Elf32_Dyn *dynp,
  142. Elf32_Ehdr *ehdr, int return_val)
  143. {
  144. Elf32_Phdr *pt_text = elf_find_phdr_type(PT_LOAD, ehdr);
  145. unsigned tx_reloc = byteswap32_to_host(pt_text->p_vaddr) - byteswap32_to_host(pt_text->p_offset);
  146. for (; DT_NULL!=byteswap32_to_host(dynp->d_tag); ++dynp) {
  147. if (key == (int)byteswap32_to_host(dynp->d_tag)) {
  148. if (return_val == 1)
  149. return (void *)(intptr_t)byteswap32_to_host(dynp->d_un.d_val);
  150. else
  151. return (void *)(byteswap32_to_host(dynp->d_un.d_val) - tx_reloc + (char *)ehdr );
  152. }
  153. }
  154. return NULL;
  155. }
  156. int check_elf_header(Elf32_Ehdr *const ehdr)
  157. {
  158. if (! ehdr || strncmp((void *)ehdr, ELFMAG, SELFMAG) != 0 ||
  159. ehdr->e_ident[EI_CLASS] != ELFCLASS32 ||
  160. ehdr->e_ident[EI_VERSION] != EV_CURRENT)
  161. {
  162. return 1;
  163. }
  164. /* Check if the target endianness matches the host's endianness */
  165. byteswap = 0;
  166. #if __BYTE_ORDER == __LITTLE_ENDIAN
  167. if (ehdr->e_ident[5] == ELFDATA2MSB) {
  168. /* Ick -- we will have to byte-swap everything */
  169. byteswap = 1;
  170. }
  171. #elif __BYTE_ORDER == __BIG_ENDIAN
  172. if (ehdr->e_ident[5] == ELFDATA2LSB) {
  173. /* Ick -- we will have to byte-swap everything */
  174. byteswap = 1;
  175. }
  176. #else
  177. #error Unknown host byte order!
  178. #endif
  179. /* Be vary lazy, and only byteswap the stuff we use */
  180. if (byteswap==1) {
  181. ehdr->e_type=bswap_16(ehdr->e_type);
  182. ehdr->e_phoff=bswap_32(ehdr->e_phoff);
  183. ehdr->e_shoff=bswap_32(ehdr->e_shoff);
  184. ehdr->e_phnum=bswap_16(ehdr->e_phnum);
  185. ehdr->e_shnum=bswap_16(ehdr->e_shnum);
  186. }
  187. return 0;
  188. }
  189. /* This function's behavior must exactly match that
  190. * in uClibc/ldso/ldso/readelflib1.c */
  191. static void search_for_named_library(char *name, char *result, const char *path_list)
  192. {
  193. int i, count = 1;
  194. char *path, *path_n;
  195. struct stat filestat;
  196. /* We need a writable copy of this string */
  197. path = strdup(path_list);
  198. if (!path) {
  199. fprintf(stderr, "Out of memory!\n");
  200. exit(EXIT_FAILURE);
  201. }
  202. /* Eliminate all double //s */
  203. path_n=path;
  204. while((path_n=strstr(path_n, "//"))) {
  205. i = strlen(path_n);
  206. memmove(path_n, path_n+1, i-1);
  207. *(path_n + i - 1)='\0';
  208. }
  209. /* Replace colons with zeros in path_list and count them */
  210. for(i=strlen(path); i > 0; i--) {
  211. if (path[i]==':') {
  212. path[i]=0;
  213. count++;
  214. }
  215. }
  216. path_n = path;
  217. for (i = 0; i < count; i++) {
  218. strcpy(result, path_n);
  219. strcat(result, "/");
  220. strcat(result, name);
  221. if (stat (result, &filestat) == 0 && filestat.st_mode & S_IRUSR) {
  222. free(path);
  223. return;
  224. }
  225. path_n += (strlen(path_n) + 1);
  226. }
  227. free(path);
  228. *result = '\0';
  229. }
  230. void locate_library_file(Elf32_Ehdr* ehdr, Elf32_Dyn* dynamic, int is_suid, struct library *lib)
  231. {
  232. char *buf;
  233. char *path;
  234. struct stat filestat;
  235. /* If this is a fully resolved name, our job is easy */
  236. if (stat (lib->name, &filestat) == 0) {
  237. lib->path = lib->name;
  238. return;
  239. }
  240. /* We need some elbow room here. Make some room...*/
  241. buf = malloc(1024);
  242. if (!buf) {
  243. fprintf(stderr, "Out of memory!\n");
  244. exit(EXIT_FAILURE);
  245. }
  246. /* This function must match the behavior of _dl_load_shared_library
  247. * in readelflib1.c or things won't work out as expected... */
  248. /* The ABI specifies that RPATH is searched first, so do that now. */
  249. path = (char *)elf_find_dynamic(DT_RPATH, dynamic, ehdr, 0);
  250. if (path) {
  251. search_for_named_library(lib->name, buf, path);
  252. if (*buf != '\0') {
  253. lib->path = buf;
  254. return;
  255. }
  256. }
  257. /* Next check LD_{ELF_}LIBRARY_PATH if specified and allowed.
  258. * Since this app doesn't actually run an executable I will skip
  259. * the suid check, and just use LD_{ELF_}LIBRARY_PATH if set */
  260. if (is_suid==1)
  261. path = NULL;
  262. else
  263. path = getenv("LD_LIBRARY_PATH");
  264. if (path) {
  265. search_for_named_library(lib->name, buf, path);
  266. if (*buf != '\0') {
  267. lib->path = buf;
  268. return;
  269. }
  270. }
  271. #ifdef USE_CACHE
  272. /* FIXME -- add code to check the Cache here */
  273. #endif
  274. /* Next look for libraries wherever the shared library
  275. * loader was installed -- this is usually where we
  276. * should find things... */
  277. if (interp_dir) {
  278. search_for_named_library(lib->name, buf, interp_dir);
  279. if (*buf != '\0') {
  280. lib->path = buf;
  281. return;
  282. }
  283. }
  284. /* Lastly, search the standard list of paths for the library.
  285. This list must exactly match the list in uClibc/ldso/ldso/readelflib1.c */
  286. path = UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib:"
  287. UCLIBC_RUNTIME_PREFIX "usr/lib:"
  288. UCLIBC_RUNTIME_PREFIX "lib:"
  289. "/usr/lib:"
  290. "/lib";
  291. search_for_named_library(lib->name, buf, path);
  292. if (*buf != '\0') {
  293. lib->path = buf;
  294. } else {
  295. free(buf);
  296. lib->path = not_found;
  297. }
  298. }
  299. static int add_library(Elf32_Ehdr* ehdr, Elf32_Dyn* dynamic, int is_setuid, char *s)
  300. {
  301. char *tmp, *tmp1, *tmp2;
  302. struct library *cur, *newlib=lib_list;
  303. if (!s || !strlen(s))
  304. return 1;
  305. tmp = s;
  306. while (*tmp) {
  307. if (*tmp == '/')
  308. s = tmp + 1;
  309. tmp++;
  310. }
  311. /* We add libc.so.0 elsewhere */
  312. if (interpreter_already_found && (tmp=strrchr(interp, '/')) != NULL)
  313. {
  314. int len = strlen(interp_dir);
  315. if (strcmp(s, interp+1+len)==0)
  316. return 1;
  317. }
  318. for (cur = lib_list; cur; cur=cur->next) {
  319. /* Check if this library is already in the list */
  320. tmp1 = tmp2 = cur->name;
  321. while (*tmp1) {
  322. if (*tmp1 == '/')
  323. tmp2 = tmp1 + 1;
  324. tmp1++;
  325. }
  326. if(strcmp(tmp2, s)==0) {
  327. //printf("find_elf_interpreter is skipping '%s' (already in list)\n", cur->name);
  328. return 0;
  329. }
  330. }
  331. /* Ok, this lib needs to be added to the list */
  332. newlib = malloc(sizeof(struct library));
  333. if (!newlib)
  334. return 1;
  335. newlib->name = malloc(strlen(s)+1);
  336. strcpy(newlib->name, s);
  337. newlib->resolved = 0;
  338. newlib->path = NULL;
  339. newlib->next = NULL;
  340. /* Now try and locate where this library might be living... */
  341. locate_library_file(ehdr, dynamic, is_setuid, newlib);
  342. //printf("add_library is adding '%s' to '%s'\n", newlib->name, newlib->path);
  343. if (!lib_list) {
  344. lib_list = newlib;
  345. } else {
  346. for (cur = lib_list; cur->next; cur=cur->next); /* nothing */
  347. cur->next = newlib;
  348. }
  349. return 0;
  350. }
  351. static void find_needed_libraries(Elf32_Ehdr* ehdr, Elf32_Dyn* dynamic, char *strtab, int is_setuid)
  352. {
  353. Elf32_Dyn *dyns;
  354. for (dyns=dynamic; byteswap32_to_host(dyns->d_tag)!=DT_NULL; ++dyns) {
  355. if (DT_NEEDED == byteswap32_to_host(dyns->d_tag)) {
  356. add_library(ehdr, dynamic, is_setuid,
  357. (char*)strtab + byteswap32_to_host(dyns->d_un.d_val));
  358. }
  359. }
  360. }
  361. static struct library * find_elf_interpreter(Elf32_Ehdr* ehdr)
  362. {
  363. Elf32_Phdr *phdr;
  364. if (interpreter_already_found==1)
  365. return NULL;
  366. phdr = elf_find_phdr_type(PT_INTERP, ehdr);
  367. if (phdr) {
  368. struct library *cur, *newlib=NULL;
  369. char *s = (char*)ehdr + byteswap32_to_host(phdr->p_offset);
  370. char *tmp, *tmp1;
  371. interp = strdup(s);
  372. interp_dir = strdup(s);
  373. tmp = strrchr(interp_dir, '/');
  374. if (*tmp)
  375. *tmp = '\0';
  376. else {
  377. free(interp_dir);
  378. interp_dir = interp;
  379. }
  380. tmp1 = tmp = s;
  381. while (*tmp) {
  382. if (*tmp == '/')
  383. tmp1 = tmp + 1;
  384. tmp++;
  385. }
  386. for (cur = lib_list; cur; cur=cur->next) {
  387. /* Check if this library is already in the list */
  388. if(strcmp(cur->name, tmp1)==0) {
  389. //printf("find_elf_interpreter is replacing '%s' (already in list)\n", cur->name);
  390. newlib = cur;
  391. free(newlib->name);
  392. free(newlib->path);
  393. return NULL;
  394. }
  395. }
  396. if (newlib == NULL)
  397. newlib = malloc(sizeof(struct library));
  398. if (!newlib)
  399. return NULL;
  400. newlib->name = malloc(strlen(s)+1);
  401. strcpy(newlib->name, s);
  402. newlib->path = newlib->name;
  403. newlib->resolved = 1;
  404. newlib->next = NULL;
  405. #if 0
  406. //printf("find_elf_interpreter is adding '%s' to '%s'\n", newlib->name, newlib->path);
  407. if (!lib_list) {
  408. lib_list = newlib;
  409. } else {
  410. for (cur = lib_list; cur->next; cur=cur->next); /* nothing */
  411. cur->next = newlib;
  412. }
  413. #endif
  414. interpreter_already_found=1;
  415. return newlib;
  416. }
  417. return NULL;
  418. }
  419. /* map the .so, and locate interesting pieces */
  420. int find_dependancies(char* filename)
  421. {
  422. int is_suid = 0;
  423. FILE *thefile;
  424. struct stat statbuf;
  425. char *dynstr=NULL;
  426. Elf32_Ehdr *ehdr = NULL;
  427. Elf32_Shdr *dynsec = NULL;
  428. Elf32_Dyn *dynamic = NULL;
  429. struct library *interp;
  430. if (filename == not_found)
  431. return 0;
  432. if (!filename) {
  433. fprintf(stderr, "No filename specified.\n");
  434. return -1;
  435. }
  436. if (!(thefile = fopen(filename, "r"))) {
  437. perror(filename);
  438. return -1;
  439. }
  440. if (fstat(fileno(thefile), &statbuf) < 0) {
  441. perror(filename);
  442. return -1;
  443. }
  444. if ((size_t)statbuf.st_size < sizeof(Elf32_Ehdr))
  445. goto foo;
  446. if (!S_ISREG(statbuf.st_mode))
  447. goto foo;
  448. /* mmap the file to make reading stuff from it effortless */
  449. ehdr = (Elf32_Ehdr *)mmap(0, statbuf.st_size,
  450. PROT_READ|PROT_WRITE, MAP_PRIVATE, fileno(thefile), 0);
  451. foo:
  452. /* Check if this looks like a legit ELF file */
  453. if (check_elf_header(ehdr)) {
  454. fprintf(stderr, "%s: not an ELF file.\n", filename);
  455. return -1;
  456. }
  457. /* Check if this is the right kind of ELF file */
  458. if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN) {
  459. fprintf(stderr, "%s: not a dynamic executable\n", filename);
  460. return -1;
  461. }
  462. if (ehdr->e_type == ET_EXEC) {
  463. if (statbuf.st_mode & S_ISUID)
  464. is_suid = 1;
  465. if ((statbuf.st_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
  466. is_suid = 1;
  467. /* FIXME */
  468. if (is_suid)
  469. fprintf(stderr, "%s: is setuid\n", filename);
  470. }
  471. interpreter_already_found=0;
  472. interp = find_elf_interpreter(ehdr);
  473. #ifdef __LDSO_LDD_SUPPORT
  474. if (interp && ehdr->e_type == ET_EXEC && ehdr->e_ident[EI_CLASS] == ELFCLASSM &&
  475. ehdr->e_ident[EI_DATA] == ELFDATAM
  476. && ehdr->e_ident[EI_VERSION] == EV_CURRENT && MATCH_MACHINE(ehdr->e_machine))
  477. {
  478. struct stat statbuf;
  479. if (stat(interp->path, &statbuf) == 0 && S_ISREG(statbuf.st_mode)) {
  480. pid_t pid;
  481. int status;
  482. static const char * const environment[] = {
  483. "PATH=/usr/bin:/bin:/usr/sbin:/sbin",
  484. "SHELL=/bin/sh",
  485. "LD_TRACE_LOADED_OBJECTS=1",
  486. NULL
  487. };
  488. if ((pid = fork()) == 0) {
  489. /* Cool, it looks like we should be able to actually
  490. * run this puppy. Do so now... */
  491. execle(filename, filename, NULL, environment);
  492. _exit(0xdead);
  493. }
  494. /* Wait till it returns */
  495. waitpid(pid, &status, 0);
  496. if (WIFEXITED(status) && WEXITSTATUS(status)==0) {
  497. return 1;
  498. }
  499. /* If the exec failed, we fall through to trying to find
  500. * all the needed libraries ourselves by rummaging about
  501. * in the ELF headers... */
  502. }
  503. }
  504. #endif
  505. dynsec = elf_find_section_type(SHT_DYNAMIC, ehdr);
  506. if (dynsec) {
  507. dynamic = (Elf32_Dyn*)(byteswap32_to_host(dynsec->sh_offset) + (intptr_t)ehdr);
  508. dynstr = (char *)elf_find_dynamic(DT_STRTAB, dynamic, ehdr, 0);
  509. find_needed_libraries(ehdr, dynamic, dynstr, is_suid);
  510. }
  511. return 0;
  512. }
  513. int main( int argc, char** argv)
  514. {
  515. int multi=0;
  516. int got_em_all=1;
  517. char *filename = NULL;
  518. struct library *cur;
  519. if (argc < 2) {
  520. fprintf(stderr, "ldd: missing file arguments\n");
  521. fprintf(stderr, "Try `ldd --help' for more information.\n");
  522. exit(EXIT_FAILURE);
  523. }
  524. if (argc > 2) {
  525. multi++;
  526. }
  527. while (--argc > 0) {
  528. ++argv;
  529. if(strcmp(*argv, "--")==0) {
  530. /* Ignore "--" */
  531. continue;
  532. }
  533. if(strcmp(*argv, "--help")==0) {
  534. fprintf(stderr, "Usage: ldd [OPTION]... FILE...\n");
  535. fprintf(stderr, "\t--help\t\tprint this help and exit\n");
  536. exit(EXIT_FAILURE);
  537. }
  538. filename=*argv;
  539. if (!filename) {
  540. fprintf(stderr, "No filename specified.\n");
  541. exit(EXIT_FAILURE);
  542. }
  543. if (multi) {
  544. printf("%s:\n", *argv);
  545. }
  546. if (find_dependancies(filename)!=0)
  547. continue;
  548. while(got_em_all) {
  549. got_em_all=0;
  550. /* Keep walking the list till everybody is resolved */
  551. for (cur = lib_list; cur; cur=cur->next) {
  552. if (cur->resolved == 0 && cur->path) {
  553. got_em_all=1;
  554. //printf("checking sub-depends for '%s\n", cur->path);
  555. find_dependancies(cur->path);
  556. cur->resolved = 1;
  557. }
  558. }
  559. }
  560. /* Print the list */
  561. got_em_all=0;
  562. for (cur = lib_list; cur; cur=cur->next) {
  563. got_em_all=1;
  564. printf("\t%s => %s (0x00000000)\n", cur->name, cur->path);
  565. }
  566. if (interp_dir && got_em_all==1)
  567. printf("\t%s => %s (0x00000000)\n", interp, interp);
  568. if (got_em_all==0)
  569. printf("\tnot a dynamic executable\n");
  570. for (cur = lib_list; cur; cur=cur->next) {
  571. free(cur->name);
  572. cur->name=NULL;
  573. free(cur->path);
  574. cur->path=NULL;
  575. }
  576. lib_list=NULL;
  577. }
  578. return 0;
  579. }