summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-07-03 06:22:20 +0000
committerEric Andersen <andersen@codepoet.org>2001-07-03 06:22:20 +0000
commit4836768df76d3919451aa9f847182c8f5f4068e7 (patch)
tree54feed2e3b0b50e8933bf74486060caa9a134502
parent094983cd14c21fe112a5ef09bbd347b938349e86 (diff)
Allow the shared lib loader to fallback on the builddir if everything
else fails. Let <arch>-uclibc-gcc --uclibc-use-build-dir set the shared lib loader to the one in the builddir's path. -Erik
-rw-r--r--Rules.mak1
-rw-r--r--extra/gcc-uClibc/Makefile1
-rw-r--r--extra/gcc-uClibc/gcc-uClibc.c6
-rw-r--r--ldso/ldso/Makefile2
-rw-r--r--ldso/ldso/dl-elf.c13
-rw-r--r--ldso/ldso/readelflib1.c13
6 files changed, 34 insertions, 2 deletions
diff --git a/Rules.mak b/Rules.mak
index 7b8223950..03334679c 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -91,6 +91,7 @@ endif
ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
LDSO=$(TOPDIR)lib/$(UCLIBC_LDSO)
DYNAMIC_LINKER=$(ROOT_DIR)/lib/$(UCLIBC_LDSO)
+ BUILD_DYNAMIC_LINKER=$(shell cd $(TOPDIR)lib; pwd)/$(UCLIBC_LDSO)
else
LDSO=$(SYSTEM_LDSO)
DYNAMIC_LINKER=$(SYSTEM_LDSO)
diff --git a/extra/gcc-uClibc/Makefile b/extra/gcc-uClibc/Makefile
index 59b71790b..11e2d19e1 100644
--- a/extra/gcc-uClibc/Makefile
+++ b/extra/gcc-uClibc/Makefile
@@ -19,6 +19,7 @@ gcc-uClibc.h: $(TOPDIR)/Config
@echo "#define GCC_INCDIR " \"-I$(GCCINCDIR)/\" >> gcc-uClibc.h
@echo "#define TARGET_ARCH " \"$(TARGET_ARCH)\" >> gcc-uClibc.h
@echo "#define DYNAMIC_LINKER " \"$(DYNAMIC_LINKER)\" >> gcc-uClibc.h
+ @echo "#define BUILD_DYNAMIC_LINKER " \"$(BUILD_DYNAMIC_LINKER)\" >> gcc-uClibc.h
gcc-uClibc: gcc-uClibc.h gcc-uClibc.c
gcc -Wall -O2 -s gcc-uClibc.c -o $(TARGET_ARCH)-uclibc-gcc
diff --git a/extra/gcc-uClibc/gcc-uClibc.c b/extra/gcc-uClibc/gcc-uClibc.c
index b5a392086..a114160d5 100644
--- a/extra/gcc-uClibc/gcc-uClibc.c
+++ b/extra/gcc-uClibc/gcc-uClibc.c
@@ -118,8 +118,10 @@ int main(int argc, char **argv)
int i, j;
char ** gcc_argv;
char *dlstr;
+ char *build_dlstr;
char *ep;
+ build_dlstr = "-Wl,--dynamic-linker," BUILD_DYNAMIC_LINKER;
dlstr = getenv("UCLIBC_GCC_DLOPT");
if (!dlstr) {
dlstr = "-Wl,--dynamic-linker," DYNAMIC_LINKER;
@@ -216,7 +218,9 @@ int main(int argc, char **argv)
}
if (linking && source_count) {
if (!use_static_linking) {
- if (dlstr) {
+ if (dlstr && use_build_dir) {
+ gcc_argv[i++] = build_dlstr;
+ } else if (dlstr) {
gcc_argv[i++] = dlstr;
}
if (use_rpath) {
diff --git a/ldso/ldso/Makefile b/ldso/ldso/Makefile
index 35f383881..7128b0185 100644
--- a/ldso/ldso/Makefile
+++ b/ldso/ldso/Makefile
@@ -29,7 +29,7 @@ TARGET_CFLAGS += #-DDL_DEBUG #-funroll-loops
LDSO_FULLNAME=ld-uclibc-$(MAJOR_VERSION).$(MINOR_VERSION).so
-TARGET_CFLAGS+=-fPIC -D__PIC__ -DUCLIBC_ROOT_DIR=\"$(ROOT_DIR)\"
+TARGET_CFLAGS+=-fPIC -D__PIC__ -DUCLIBC_ROOT_DIR=\"$(ROOT_DIR)\" -DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR); pwd)\"
CSRC= boot1.c hash.c readelflib1.c vsprintf.c $(TARGET_ARCH)/elfinterp.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
ASRC=$(shell ls $(TARGET_ARCH)/*.S)
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index c1a4a41ee..4e1de140e 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -274,6 +274,19 @@ struct elf_resolve *_dl_load_shared_library(int secure,
if (tpnt1)
return tpnt1;
+ /* Bummer. Nothing so far. Check in <builddir>/lib */
+ pnt1 = UCLIBC_BUILD_DIR "/lib/";
+ pnt = mylibname;
+ while (*pnt1)
+ *pnt++ = *pnt1++;
+ pnt1 = libname;
+ while (*pnt1)
+ *pnt++ = *pnt1++;
+ *pnt++ = 0;
+ tpnt1 = _dl_load_elf_shared_library(secure, mylibname, 0);
+ if (tpnt1)
+ return tpnt1;
+
goof:
/* Well, we shot our wad on that one. All we can do now is punt */
if (_dl_internal_error_number)
diff --git a/ldso/ldso/readelflib1.c b/ldso/ldso/readelflib1.c
index c1a4a41ee..4e1de140e 100644
--- a/ldso/ldso/readelflib1.c
+++ b/ldso/ldso/readelflib1.c
@@ -274,6 +274,19 @@ struct elf_resolve *_dl_load_shared_library(int secure,
if (tpnt1)
return tpnt1;
+ /* Bummer. Nothing so far. Check in <builddir>/lib */
+ pnt1 = UCLIBC_BUILD_DIR "/lib/";
+ pnt = mylibname;
+ while (*pnt1)
+ *pnt++ = *pnt1++;
+ pnt1 = libname;
+ while (*pnt1)
+ *pnt++ = *pnt1++;
+ *pnt++ = 0;
+ tpnt1 = _dl_load_elf_shared_library(secure, mylibname, 0);
+ if (tpnt1)
+ return tpnt1;
+
goof:
/* Well, we shot our wad on that one. All we can do now is punt */
if (_dl_internal_error_number)