readelf.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* adapted from Eric Youngdale's readelf program */
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <sys/stat.h>
  5. #include <sys/mman.h>
  6. #include <link.h>
  7. #include <elf.h>
  8. #include <unistd.h>
  9. #include "../config.h"
  10. #include "readelf.h"
  11. #include <sys/types.h>
  12. void warn(char *fmt, ...);
  13. char *xstrdup(char *);
  14. struct needed_tab
  15. {
  16. char *soname;
  17. int type;
  18. };
  19. struct needed_tab needed_tab[] = {
  20. { "libc.so.5", LIB_ELF_LIBC5 },
  21. { "libm.so.5", LIB_ELF_LIBC5 },
  22. { "libdl.so.1", LIB_ELF_LIBC5 },
  23. { "libc.so.6", LIB_ELF_LIBC6 },
  24. { "libm.so.6", LIB_ELF_LIBC6 },
  25. { "libdl.so.2", LIB_ELF_LIBC6 },
  26. { NULL, LIB_ELF }
  27. };
  28. char *readsoname(char *name, FILE *infile, int expected_type,
  29. int *type, int elfclass)
  30. {
  31. char *res;
  32. if (elfclass == ELFCLASS32)
  33. res = readsoname32(name, infile, expected_type, type);
  34. else
  35. {
  36. res = readsoname64(name, infile, expected_type, type);
  37. #if 0
  38. *type |= LIB_ELF64;
  39. #endif
  40. }
  41. return res;
  42. }
  43. #undef __ELF_NATIVE_CLASS
  44. #undef readsonameXX
  45. #define readsonameXX readsoname32
  46. #define __ELF_NATIVE_CLASS 32
  47. #include "readelf2.c"
  48. #undef __ELF_NATIVE_CLASS
  49. #undef readsonameXX
  50. #define readsonameXX readsoname64
  51. #define __ELF_NATIVE_CLASS 64
  52. #include "readelf2.c"