Ver Fonte

Peter Mazinger writes:
The attached patch is an updated version of an earlier sent patch
It solves the problem that the target utils (ldconfig/ldd/iconv, readelf
is not handled, but can be easily added) are not built w/ the newly
created [S]crt[01].o files.

Joakim Tjernlund há 20 anos atrás
pai
commit
6bc6a6f5d7
3 ficheiros alterados com 62 adições e 11 exclusões
  1. 52 0
      Rules.mak
  2. 4 8
      libpthread/Makefile
  3. 6 3
      utils/Makefile

+ 52 - 0
Rules.mak

@@ -265,6 +265,58 @@ LIBGCC_CFLAGS ?= $(CFLAGS) $(CPU_CFLAGS-y)
 LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)
 LIBGCC_DIR:=$(dir $(LIBGCC))
 
+#
+# common part for libs and binaries
+#
+# normally used start and end files
+N_START_FILE = $(LIBGCC_DIR)crtbegin.o
+N_END_FILE = $(LIBGCC_DIR)crtend.o
+
+# shared/pie start and end files
+S_START_FILE = $(LIBGCC_DIR)crtbeginS.o
+S_END_FILE = $(LIBGCC_DIR)crtendS.o
+
+ifeq ($(DOPIC),y)
+  START_FILE = $(S_START_FILE)
+  END_FILE = $(S_END_FILE)
+else
+  START_FILE = $(N_START_FILE)
+  END_FILE = $(N_END_FILE)
+endif
+
+START_FILES = $(TOPDIR)lib/crti.o $(START_FILE)
+END_FILES = $(END_FILE) $(TOPDIR)lib/crtn.o
+
+#
+# binaries specific part
+#
+ifeq ($(UCLIBC_CTOR_DTOR),y)
+  CRT_FILE=$(TOPDIR)lib/crt1.o
+else
+  CRT_FILE=$(TOPDIR)lib/crt0.o
+endif
+
+# PIE
+S_CRT_FILE=$(TOPDIR)lib/Scrt1.o
+
+# arm and ia64 do not use crtbeginT.o for static linking
+# please add condition for ia64 when it becomes supported
+ifeq ($(TARGET_arm),y)
+  STATIC_BEGIN_FILE=$(LIBGCC_DIR)crtbegin.o
+else
+  STATIC_BEGIN_FILE=$(LIBGCC_DIR)crtbeginT.o
+endif
+
+ifeq ($(UCLIBC_PIE_SUPPORT),y)
+  BIN_START_FILES = $(S_CRT_FILE) $(TOPDIR)lib/crti.o $(S_START_FILE)
+else
+  BIN_START_FILES = $(CRT_FILE) $(TOPDIR)lib/crti.o $(START_FILE)
+endif
+
+# static start and end files
+STATIC_BIN_START_FILES = $(CRT_FILE) $(TOPDIR)lib/crti.o $(STATIC_BEGIN_FILE)
+STATIC_BIN_END_FILES = $(N_END_FILE) $(TOPDIR)lib/crtn.o
+
 ########################################
 #
 # uClinux shared lib support

+ 4 - 8
libpthread/Makefile

@@ -38,14 +38,10 @@ ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
 endif
 endif
 
-ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
-ifeq ($(strip $(DOPIC)),y)
-    START_FILES  = $(TOPDIR)lib/crti.o    $(LIBGCC_DIR)crtbeginS.o
-    END_FILES    = $(LIBGCC_DIR)crtendS.o $(TOPDIR)lib/crtn.o
-else
-    START_FILES  = $(TOPDIR)lib/crti.o    $(LIBGCC_DIR)crtbegin.o
-    END_FILES    = $(LIBGCC_DIR)crtend.o  $(TOPDIR)lib/crtn.o
-endif
+# do we really have to unset these?
+ifneq ($(strip $(UCLIBC_CTOR_DTOR)),y)
+	START_FILES =
+	END_FILES =
 endif
 
 ALL_SUBDIRS = linuxthreads linuxthreads_db

+ 6 - 3
utils/Makefile

@@ -49,19 +49,22 @@ ldconfig:	ldconfig.c readsoname.c
 	$(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s -static \
 		-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
 		-DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
-		$^ -o $@ $(LDADD_LIBFLOAT) -L../lib
+		-nostdlib -o $@ $(STATIC_BIN_START_FILES) $^ $(LDADD_LIBFLOAT) \
+		-L../lib -lc $(LIBGCC) $(STATIC_BIN_END_FILES)
 	$(STRIPTOOL) -x -R .note -R .comment $@
 
 ldd:	ldd.c
 	$(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s \
 		-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
 		-DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
-		$^ -o $@ $(LDADD_LIBFLOAT) -L../lib
+		-nostdlib -o $@ $(BIN_START_FILES) $^ $(LDADD_LIBFLOAT) \
+		-L../lib -lc $(LIBGCC) $(END_FILES)
 	$(STRIPTOOL) -x -R .note -R .comment $@
 
 iconv: ../libc/misc/wchar/wchar.c
 	$(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s -DL_iconv_main \
-		$^ -o $@ $(LDADD_LIBFLOAT) -L../lib
+		-nostdlib -o $@ $(BIN_START_FILES) $^ $(LDADD_LIBFLOAT) \
+		-L../lib -lc $(LIBGCC) $(END_FILES)
 	$(STRIPTOOL) -x -R .note -R .comment $@
 
 hostutils: ldd.host ldconfig.host readelf.host