summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Rules.mak52
-rw-r--r--libpthread/Makefile12
-rw-r--r--utils/Makefile9
3 files changed, 62 insertions, 11 deletions
diff --git a/Rules.mak b/Rules.mak
index 20fa6ed03..72dba878f 100644
--- a/Rules.mak
+++ b/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
diff --git a/libpthread/Makefile b/libpthread/Makefile
index 6938b0387..2e3d5a856 100644
--- a/libpthread/Makefile
+++ b/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
diff --git a/utils/Makefile b/utils/Makefile
index a488c32ba..c5c858195 100644
--- a/utils/Makefile
+++ b/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