summaryrefslogtreecommitdiff
path: root/ldso/util/readelf.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-04-23 17:43:54 +0000
committerEric Andersen <andersen@codepoet.org>2001-04-23 17:43:54 +0000
commit66f269d2a51dae6a2cb10f1a9ae4aaeba815219b (patch)
treee2094832990caf6d849ba90e4b1a82a6264f86b3 /ldso/util/readelf.c
parentc4a3f3f81ea90e3df93c352ac0e2161a4bfd3327 (diff)
Initial checkin for ld.so. This is a combination of effort from Manuel Novoa
III and me. I've been working on stripping out arch dependant stuff and replacing it with generic stuff whenever possible. -Erik
Diffstat (limited to 'ldso/util/readelf.c')
-rw-r--r--ldso/util/readelf.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/ldso/util/readelf.c b/ldso/util/readelf.c
new file mode 100644
index 000000000..ba93d2d31
--- /dev/null
+++ b/ldso/util/readelf.c
@@ -0,0 +1,61 @@
+/* adapted from Eric Youngdale's readelf program */
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <link.h>
+#include <elf.h>
+#include <unistd.h>
+#include "../config.h"
+#include "readelf.h"
+#include <sys/types.h>
+
+void warn(char *fmt, ...);
+char *xstrdup(char *);
+
+struct needed_tab
+{
+ char *soname;
+ int type;
+};
+
+struct needed_tab needed_tab[] = {
+ { "libc.so.5", LIB_ELF_LIBC5 },
+ { "libm.so.5", LIB_ELF_LIBC5 },
+ { "libdl.so.1", LIB_ELF_LIBC5 },
+ { "libc.so.6", LIB_ELF_LIBC6 },
+ { "libm.so.6", LIB_ELF_LIBC6 },
+ { "libdl.so.2", LIB_ELF_LIBC6 },
+ { NULL, LIB_ELF }
+};
+
+char *readsoname(char *name, FILE *infile, int expected_type,
+ int *type, int elfclass)
+{
+ char *res;
+
+ if (elfclass == ELFCLASS32)
+ res = readsoname32(name, infile, expected_type, type);
+ else
+ {
+ res = readsoname64(name, infile, expected_type, type);
+#if 0
+ *type |= LIB_ELF64;
+#endif
+ }
+
+ return res;
+}
+
+#undef __ELF_NATIVE_CLASS
+#undef readsonameXX
+#define readsonameXX readsoname32
+#define __ELF_NATIVE_CLASS 32
+#include "readelf2.c"
+
+#undef __ELF_NATIVE_CLASS
+#undef readsonameXX
+#define readsonameXX readsoname64
+#define __ELF_NATIVE_CLASS 64
+#include "readelf2.c"