summaryrefslogtreecommitdiff
path: root/ldso/util
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-06-04 22:13:51 +0000
committerEric Andersen <andersen@codepoet.org>2001-06-04 22:13:51 +0000
commitf68eb8d50b11310628f53a9378bf612e8d4bfa09 (patch)
treee3a4073bbc3ac2349c89ad9b3494b05838f95c0b /ldso/util
parent03f338ab663d8b2fa16c8d1f83be51ecf9c79312 (diff)
Teach the ldso stuff to use the proper elf.h header file, not a local copy.
-Erik
Diffstat (limited to 'ldso/util')
-rw-r--r--ldso/util/.cvsignore1
-rw-r--r--ldso/util/Makefile22
-rw-r--r--ldso/util/ldconfig.c3
-rw-r--r--ldso/util/ldd.c5
-rw-r--r--ldso/util/readsoname.c61
-rw-r--r--ldso/util/readsoname.h (renamed from ldso/util/readelf.h)0
-rw-r--r--ldso/util/readsoname2.c (renamed from ldso/util/readelf2.c)0
7 files changed, 79 insertions, 13 deletions
diff --git a/ldso/util/.cvsignore b/ldso/util/.cvsignore
index 65cb593d4..8d9e73db5 100644
--- a/ldso/util/.cvsignore
+++ b/ldso/util/.cvsignore
@@ -1,2 +1,3 @@
ldd
ldconfig
+readelf
diff --git a/ldso/util/Makefile b/ldso/util/Makefile
index a8f482f20..8fe733eb9 100644
--- a/ldso/util/Makefile
+++ b/ldso/util/Makefile
@@ -2,14 +2,15 @@ TOPDIR=../../
include $(TOPDIR)/ldso/Rules.mak
CFLAGS += -DLDSO_ADDR="0x62f00020" # needed by ldd.o
-CFLAGS += -I./ -I../../include/
-LDFLAGS += -nostdlib $(TOPDIR)lib/libc.a $(TOPDIR)lib/crt0.o $(GCCINCDIR)/../libgcc.a
+#CFLAGS += -I./ -I../../include/
+#LDFLAGS += -nostdlib $(TOPDIR)lib/libc.a $(TOPDIR)lib/crt0.o $(GCCINCDIR)/../libgcc.a
+LDFLAGS += $(TOPDIR)lib/libc.a $(TOPDIR)lib/crt0.o $(GCCINCDIR)/../libgcc.a
-ALL = ldconfig ldd # lddstub
+ALL = ldconfig ldd readelf # lddstub
all: $(ALL)
-CSRC= readelf.c ldconfig.c ldd.c
+CSRC= readelf.c ldconfig.c ldd.c readsoname.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
OBJS=$(COBJS)
@@ -17,13 +18,16 @@ $(COBJS): %.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
-readelf.o: readelf.c readelf2.c
+readsoname.o: readsoname.c readsoname2.c
-ldconfig: ldconfig.o readelf.o
- $(CC) -static $(CFLAGS) $^ $(LDFLAGS) -o $@
+readelf: readelf.o
+ $(CC) $(CFLAGS) $^ -o $@
-ldd: ldd.o readelf.o
- $(CC) -static $(CFLAGS) $^ $(LDFLAGS) -o $@
+ldconfig: ldconfig.o readsoname.o
+ $(CC) $(CFLAGS) $^ -o $@
+
+ldd: ldd.o readsoname.o
+ $(CC) $(CFLAGS) $^ -o $@
#ifeq ($(DEBUG),true)
#STUBFLAGS = -Wl,-dynamic-linker,../d-link/ld-linux.so
diff --git a/ldso/util/ldconfig.c b/ldso/util/ldconfig.c
index 55f79f773..58f9cb10b 100644
--- a/ldso/util/ldconfig.c
+++ b/ldso/util/ldconfig.c
@@ -38,9 +38,8 @@
#include <fcntl.h>
#include <sys/mman.h>
#include <errno.h>
-
#include "../config.h"
-#include "readelf.h"
+#include "readsoname.h"
struct exec
{
diff --git a/ldso/util/ldd.c b/ldso/util/ldd.c
index ea4f1f5ef..dcf895d19 100644
--- a/ldso/util/ldd.c
+++ b/ldso/util/ldd.c
@@ -23,9 +23,10 @@
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
-#include "../d-link/elf.h"
+#include <elf.h>
+#include "../d-link/linuxelf.h"
#include "../config.h"
-#include "readelf.h"
+#include "readsoname.h"
struct exec
{
diff --git a/ldso/util/readsoname.c b/ldso/util/readsoname.c
new file mode 100644
index 000000000..db772f0ae
--- /dev/null
+++ b/ldso/util/readsoname.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 <sys/types.h>
+#include "../config.h"
+#include "readsoname.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 "readsoname2.c"
+
+#undef __ELF_NATIVE_CLASS
+#undef readsonameXX
+#define readsonameXX readsoname64
+#define __ELF_NATIVE_CLASS 64
+#include "readsoname2.c"
diff --git a/ldso/util/readelf.h b/ldso/util/readsoname.h
index 78d2216e0..78d2216e0 100644
--- a/ldso/util/readelf.h
+++ b/ldso/util/readsoname.h
diff --git a/ldso/util/readelf2.c b/ldso/util/readsoname2.c
index 1bf47b7c6..1bf47b7c6 100644
--- a/ldso/util/readelf2.c
+++ b/ldso/util/readsoname2.c