readsoname.c 1.3 KB

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