Browse Source

Fix the bug where binaries built with older toolchains would
segfault. Turns out that 'ld -nostdlib' was the culprit.
Who wouldof thought...
-Erik

Eric Andersen 23 years ago
parent
commit
75d013b16a
9 changed files with 36 additions and 31 deletions
  1. 2 2
      Rules.mak
  2. 3 3
      ldso/libdl/Makefile
  3. 14 8
      ldso/util/Makefile
  4. 2 3
      libc/Makefile
  5. 3 3
      libcrypt/Makefile
  6. 3 3
      libm/Makefile
  7. 3 3
      libpthread/Makefile
  8. 3 3
      libresolv/Makefile
  9. 3 3
      libutil/Makefile

+ 2 - 2
Rules.mak

@@ -88,11 +88,11 @@ NATIVE_CFLAGS=-O2 -Wall
 
 ifeq ($(strip $(DODEBUG)),true)
     CFLAGS += -g
-    LDFLAGS = -shared -nostdlib --warn-common --warn-once -z combreloc
+    LDFLAGS = -shared --warn-common --warn-once -z combreloc
     STRIPTOOL = /bin/true -Since_we_are_debugging
 else
     CFLAGS  += -DNDEBUG #-fomit-frame-pointer
-    LDFLAGS  = -s -shared -nostdlib --warn-common --warn-once -z combreloc
+    LDFLAGS  = -s -shared --warn-common --warn-once -z combreloc
 endif
 
 ifeq ($(strip $(HAVE_SHARED)),true)

+ 3 - 3
ldso/libdl/Makefile

@@ -50,9 +50,9 @@ $(OBJS): %.o : %.c
 $(OBJ): Makefile
 
 shared: all
-	$(LD) $(LDFLAGS) -o $(LIBDL_SHARED_FULLNAME) \
-	    -soname=$(LIBDL_SHARED).$(MAJOR_VERSION) \
-	    --whole-archive $(LIBDL) -Bdynamic -L$(TOPDIR)/lib -lc;
+	$(LD) $(LDFLAGS) -soname=$(LIBDL_SHARED).$(MAJOR_VERSION) \
+		-o $(LIBDL_SHARED_FULLNAME) --whole-archive $(LIBDL) \
+		--no-whole-archive -L$(TOPDIR)/lib -lc;
 	install -d $(TOPDIR)lib
 	rm -f $(TOPDIR)lib/$(LIBDL_SHARED_FULLNAME) $(TOPDIR)lib/$(LIBDL_SHARED).$(MAJOR_VERSION)
 	install -m 644 $(LIBDL_SHARED_FULLNAME) $(TOPDIR)lib;

+ 14 - 8
ldso/util/Makefile

@@ -22,8 +22,9 @@
 
 TOPDIR=../../
 include $(TOPDIR)Rules.mak
+TARGET_CC = $(TOPDIR)extra/gcc-uClibc/$(NATIVE_ARCH)-uclibc-gcc
 
-TARGETS=ldd.uclibc ldd readelf ldconfig
+TARGETS=ldconfig ldd ldd.target readelf readelf.target
 all: $(TARGETS)
 
 readsoname.o: readsoname.c readsoname2.c
@@ -36,7 +37,11 @@ ldconfig.o: ldconfig.c
 	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 readelf: readelf.c
-	$(CC) $(CFLAGS) -static readelf.c -o $@
+	$(NATIVE_CC) $(NATIVE_CFLAGS) readelf.c -o $@
+	$(STRIPTOOL) -x -R .note -R .comment $@
+
+readelf.target: readelf.c
+	$(TARGET_CC) $(CFLAGS) -static -s readelf.c -o $@
 	$(STRIPTOOL) -x -R .note -R .comment $@
 
 ifeq ($(strip $(LIBRARY_CACHE)),)
@@ -44,24 +49,25 @@ ldconfig:
 	echo "LIBRARY_CACHE disabled -- not building ldconfig"
 else
 ldconfig: ldconfig.o readsoname.o
-	$(CC) $(CFLAGS) -static $^ -o $@
+	$(CC) $(CFLAGS) $^ -o $@
 	$(STRIPTOOL) -x -R .note -R .comment $@
 endif
 
 ldd: ldd.c
-	$(CC) $(CFLAGS) -DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
+	$(NATIVE_CC) $(NATIVE_CFLAGS) -DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
 		-DUCLIBC_DEVEL_PREFIX=\"$(DEVEL_PREFIX)\" \
 		-DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR) && pwd)\" \
 		-DUCLIBC_LDSO=\"$(UCLIBC_LDSO)\" \
-		-static ldd.c -o $@
+		ldd.c -o $@ 
 	$(STRIPTOOL) -x -R .note -R .comment $@
 
-ldd.uclibc: ldd.c
-	$(NATIVE_CC) $(NATIVE_CFLAGS) -s -DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
+ldd.target: ldd.c
+	$(TARGET_CC) $(CFLAGS) -static -s -DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
 		-DUCLIBC_DEVEL_PREFIX=\"$(DEVEL_PREFIX)\" \
 		-DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR) && pwd)\" \
 		-DUCLIBC_LDSO=\"$(UCLIBC_LDSO)\" \
-		ldd.c -o $@ 
+		ldd.c -o $@
+	$(STRIPTOOL) -x -R .note -R .comment $@
 
 clean:
 	rm -f $(TARGETS) *.o *~ core

+ 2 - 3
libc/Makefile

@@ -46,9 +46,8 @@ shared: $(TOPDIR)lib/$(LIBNAME)
 	$(AR) rv ./tmp/libgcc-need.a
 	@(cd tmp && CC=$(CC) LD=$(LD) NM=$(NM) AR=$(AR) \
 		/bin/sh ../../extra/scripts/get-needed-libgcc-objects.sh)
-	$(LD) $(LDFLAGS) -o $(SHARED_FULLNAME) -soname=$(SHARED_MAJORNAME) \
-		--dynamic-linker $(DYNAMIC_LINKER) --whole-archive $(LIBNAME) \
-		./tmp/libgcc-need.a -Bdynamic $(LDSO)
+	$(LD) $(LDFLAGS) -soname=$(SHARED_MAJORNAME) -o $(SHARED_FULLNAME) \
+		--whole-archive ./tmp/libgcc-need.a $(LIBNAME) --no-whole-archive $(LDSO)
 	@/bin/true #rm -rf tmp
 	install -d $(TOPDIR)lib
 	rm -f $(TOPDIR)lib/$(SHARED_FULLNAME)

+ 3 - 3
libcrypt/Makefile

@@ -48,9 +48,9 @@ $(OBJS): %.o : %.c
 $(OBJ): Makefile
 
 shared: all
-	$(LD) $(LDFLAGS) -o $(LIBCRYPT_SHARED_FULLNAME) \
-		-soname=$(LIBCRYPT_SHARED).$(MAJOR_VERSION) \
-		--whole-archive $(LIBCRYPT) -Bdynamic -L$(TOPDIR)/lib -lc;
+	$(LD) $(LDFLAGS) -soname=$(LIBCRYPT_SHARED).$(MAJOR_VERSION) \
+		-o $(LIBCRYPT_SHARED_FULLNAME) --whole-archive $(LIBCRYPT) \
+		--no-whole-archive -L$(TOPDIR)/lib -lc;
 	install -d $(TOPDIR)lib
 	rm -f $(TOPDIR)lib/$(LIBCRYPT_SHARED_FULLNAME) $(TOPDIR)lib/$(LIBCRYPT_SHARED).$(MAJOR_VERSION)
 	install -m 644 $(LIBCRYPT_SHARED_FULLNAME) $(TOPDIR)lib;

+ 3 - 3
libm/Makefile

@@ -93,9 +93,9 @@ $(LIBM): ar-target
 shared: all
 	@if [ -f $(LIBM) ] ; then \
 	    set -x -e; \
-	    $(LD) $(LDFLAGS) -o $(LIBM_SHARED_FULLNAME) \
-		-soname=$(LIBM_SHARED).$(MAJOR_VERSION) \
-		--whole-archive $(LIBM) -Bdynamic -L$(TOPDIR)/lib -lc; \
+	    $(LD) $(LDFLAGS) -soname=$(LIBM_SHARED).$(MAJOR_VERSION) \
+		    -o $(LIBM_SHARED_FULLNAME) --whole-archive $(LIBM) \
+		    --no-whole-archive -L$(TOPDIR)/lib -lc; \
 	    install -d $(TOPDIR)lib; \
 	    rm -f $(TOPDIR)lib/$(LIBM_SHARED_FULLNAME) $(TOPDIR)lib/$(LIBM_SHARED).$(MAJOR_VERSION); \
 	    install -m 644 $(LIBM_SHARED_FULLNAME) $(TOPDIR)lib; \

+ 3 - 3
libpthread/Makefile

@@ -48,9 +48,9 @@ $(OBJS): %.o : %.c
 $(OBJ): Makefile
 
 shared: all
-	$(LD) $(LDFLAGS) -o $(LIBPTHREAD_SHARED_FULLNAME) \
-	    -soname=$(LIBPTHREAD_SHARED).$(MAJOR_VERSION) \
-	    --whole-archive $(LIBPTHREAD) -Bdynamic -L$(TOPDIR)/lib -lc;
+	$(LD) $(LDFLAGS) -soname=$(LIBPTHREAD_SHARED).$(MAJOR_VERSION) \
+		-o $(LIBPTHREAD_SHARED_FULLNAME) --whole-archive $(LIBPTHREAD) \
+		--no-whole-archive -L$(TOPDIR)/lib -lc;
 	install -d $(TOPDIR)lib
 	rm -f $(TOPDIR)lib/$(LIBPTHREAD_SHARED_FULLNAME) $(TOPDIR)lib/$(LIBPTHREAD_SHARED).$(MAJOR_VERSION)
 	install -m 644 $(LIBPTHREAD_SHARED_FULLNAME) $(TOPDIR)lib;

+ 3 - 3
libresolv/Makefile

@@ -49,9 +49,9 @@ $(OBJS): %.o : %.c
 $(OBJ): Makefile
 
 shared: all
-	$(LD) $(LDFLAGS) -o $(LIBRESOLV_SHARED_FULLNAME) \
-	    -soname=$(LIBRESOLV_SHARED).$(MAJOR_VERSION) \
-	    --whole-archive $(LIBRESOLV) -Bdynamic -L$(TOPDIR)/lib -lc;
+	$(LD) $(LDFLAGS) -soname=$(LIBRESOLV_SHARED).$(MAJOR_VERSION) \
+		-o $(LIBRESOLV_SHARED_FULLNAME) --whole-archive $(LIBRESOLV) \
+		--no-whole-archive -L$(TOPDIR)/lib -lc;
 	install -d $(TOPDIR)lib
 	rm -f $(TOPDIR)lib/$(LIBRESOLV_SHARED_FULLNAME) $(TOPDIR)lib/$(LIBRESOLV_SHARED).$(MAJOR_VERSION)
 	install -m 644 $(LIBRESOLV_SHARED_FULLNAME) $(TOPDIR)lib;

+ 3 - 3
libutil/Makefile

@@ -50,9 +50,9 @@ $(OBJS): %.o : %.c
 	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 shared: all
-	$(LD) $(LDFLAGS) -o $(LIBUTIL_SHARED_FULLNAME) \
-	    -soname=$(LIBUTIL_SHARED).$(MAJOR_VERSION) \
-	    --whole-archive $(LIBUTIL) -Bdynamic -L$(TOPDIR)/lib -lc;
+	$(LD) $(LDFLAGS) -soname=$(LIBUTIL_SHARED).$(MAJOR_VERSION) \
+		-o $(LIBUTIL_SHARED_FULLNAME) --whole-archive $(LIBUTIL) \
+		--no-whole-archive -L$(TOPDIR)/lib -lc;
 	install -d $(TOPDIR)lib
 	rm -f $(TOPDIR)lib/$(LIBUTIL_SHARED_FULLNAME) $(TOPDIR)lib/$(LIBUTIL_SHARED).$(MAJOR_VERSION)
 	install -m 644 $(LIBUTIL_SHARED_FULLNAME) $(TOPDIR)lib/;