[uClibc] Proposal adding -z defs by default

Peter S. Mazinger ps.m at gmx.net
Wed Nov 3 17:35:47 UTC 2004


On Wed, 3 Nov 2004, Erik Andersen wrote:

> On Wed Nov 03, 2004 at 09:38:43AM +0100, Joakim Tjernlund wrote:
> > > > Yes, unless I am mistaken, ld complain that main is undefined in __uClibc_main.c. Making it weak
> > > > will shut up ld and resolve to NULL iff no main function is found elsewere. That would also mean that
> > > > if you try ty build an exec and forget to define main, you will probably NOT get a compliant from ld
> > > > about missing main function.
> > > 
> > > Then I wouldn't add that ;-(, it would introduce probably more trouble.
> > > 
> > > Would you accept a patch that ignores libc, but adds -z defs to LDFLAGS to 
> > > all other libs?
> > > 
> > > Peter
> > 
> > This is a system wide change and I don't know if there are other side effects, you
> > better ask Erik.
> 
> I have no problem with using 'ld -z defs' on libm and whatnot
> other than libc.  Would be nice for libc (we used to have a
> script that performed a similar function) but sadly it does
> indeed whine about missing main, and we can't add even a weak
> main to libc or badness will ensue.  Might be possible to link
> libuClibc twice, with a script wrapping up ld and filtering
> stdout for 'main' and only emitting an error for additional
> output....

Attached.

A maybe better solution would be to define some var before including 
Rules.mak in the patched Makefiles, that let's say define NOT_in_libc 
(glibc uses something like this), and then all the non-libc related stuff 
can be done in Rules.mak (ssp could benefit of this approach too, I know, not 
many are using it ;-), it would allow easily to add full protected build 
because only libc.so itself is not allowed to be built fully propolice 
protected).

Peter

-- 
Peter S. Mazinger <ps dot m at gmx dot net>           ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08  BB6E C389 975E A5F0 59F2
-------------- next part --------------
diff -urN uClibc-0.9.26.orig/ldso/ldso/Makefile uClibc-0.9.26/ldso/ldso/Makefile
--- uClibc-0.9.26.orig/ldso/ldso/Makefile	2004-11-03 17:33:08.000000000 +0100
+++ uClibc-0.9.26/ldso/ldso/Makefile	2004-11-03 17:38:02.000000000 +0100
@@ -41,7 +41,7 @@
 
 XXFLAGS+=$(shell $(CC) -print-search-dirs | sed -ne "s/install: *\(.*\)/-I\1include/gp")
 LDFLAGS=$(CPU_LDFLAGS-y) -z now -Bsymbolic -shared --warn-common --export-dynamic --sort-common \
-	-z combreloc --discard-locals --discard-all --no-undefined
+	-z combreloc --discard-locals --discard-all --no-undefined -z defs
 
 CSRC= ldso.c
 COBJS=$(patsubst %.c,%.o, $(CSRC))
diff -urN uClibc-0.9.26.orig/ldso/libdl/Makefile uClibc-0.9.26/ldso/libdl/Makefile
--- uClibc-0.9.26.orig/ldso/libdl/Makefile	2004-11-03 17:33:08.000000000 +0100
+++ uClibc-0.9.26/ldso/libdl/Makefile	2004-11-03 17:38:30.000000000 +0100
@@ -21,6 +21,8 @@
 TOPDIR=../../
 include $(TOPDIR)Rules.mak
 
+LDFLAGS+=-z defs
+
 XXFLAGS=$(XWARNINGS)
 ifeq ($(DODEBUG),y)
 XXFLAGS+=-O0 -g3
diff -urN uClibc-0.9.26.orig/libcrypt/Makefile uClibc-0.9.26/libcrypt/Makefile
--- uClibc-0.9.26.orig/libcrypt/Makefile	2004-11-03 17:33:11.000000000 +0100
+++ uClibc-0.9.26/libcrypt/Makefile	2004-11-03 17:37:14.000000000 +0100
@@ -24,6 +24,8 @@
 TOPDIR=../
 include $(TOPDIR)Rules.mak
 
+LDFLAGS+=-z defs
+
 LIBCRYPT=libcrypt.a
 LIBCRYPT_SHARED=libcrypt.so
 LIBCRYPT_SHARED_FULLNAME=libcrypt-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
diff -urN uClibc-0.9.26.orig/libintl/Makefile uClibc-0.9.26/libintl/Makefile
--- uClibc-0.9.26.orig/libintl/Makefile	2004-11-03 17:33:11.000000000 +0100
+++ uClibc-0.9.26/libintl/Makefile	2004-11-03 17:39:53.000000000 +0100
@@ -23,6 +23,9 @@
 
 TOPDIR=../
 include $(TOPDIR)Rules.mak
+
+LDFLAGS+=-z defs
+
 LIBC=$(TOPDIR)libc.a
 
 LIBINTL=libintl.a
diff -urN uClibc-0.9.26.orig/libm/Makefile uClibc-0.9.26/libm/Makefile
--- uClibc-0.9.26.orig/libm/Makefile	2004-11-03 17:33:11.000000000 +0100
+++ uClibc-0.9.26/libm/Makefile	2004-11-03 17:40:23.000000000 +0100
@@ -34,6 +34,8 @@
 TOPDIR=../
 include $(TOPDIR)Rules.mak
 
+LDFLAGS+=-z defs
+
 DIRS = 
 ifeq ($(strip $(HAS_FPU)),y)
 ifeq ($(TARGET_ARCH),$(wildcard $(TARGET_ARCH)))
diff -urN uClibc-0.9.26.orig/libnsl/Makefile uClibc-0.9.26/libnsl/Makefile
--- uClibc-0.9.26.orig/libnsl/Makefile	2004-11-03 17:33:11.000000000 +0100
+++ uClibc-0.9.26/libnsl/Makefile	2004-11-03 17:40:40.000000000 +0100
@@ -19,6 +19,8 @@
 TOPDIR=../
 include $(TOPDIR)Rules.mak
 
+LDFLAGS+=-z defs
+
 LIBNSL=libnsl.a
 LIBNSL_SHARED=libnsl.so
 LIBNSL_SHARED_FULLNAME=libnsl-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
diff -urN uClibc-0.9.26.orig/libpthread/Makefile uClibc-0.9.26/libpthread/Makefile
--- uClibc-0.9.26.orig/libpthread/Makefile	2004-11-03 17:33:11.000000000 +0100
+++ uClibc-0.9.26/libpthread/Makefile	2004-11-03 17:44:39.000000000 +0100
@@ -19,6 +19,8 @@
 TOPDIR=../
 include $(TOPDIR)Rules.mak
 
+LDFLAGS+=-z defs
+
 #Adjust the soname version to avoid namespace collisions with glibc's libpthread
 LIBPTHREAD=libpthread.a
 LIBPTHREAD_SHARED=libpthread.so
@@ -34,7 +36,7 @@
 	LDFLAGS_PTHREADS:= $(LDFLAGS)
 ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
 	DIRS+=linuxthreads_db
-	LDFLAGS_PTHREADS:= $(CPU_LDFLAGS-y) -shared --warn-common --warn-once -z combreloc
+	LDFLAGS_PTHREADS:= $(CPU_LDFLAGS-y) -shared --warn-common --warn-once -z combreloc -z defs
 endif
 endif
 
diff -urN uClibc-0.9.26.orig/libresolv/Makefile uClibc-0.9.26/libresolv/Makefile
--- uClibc-0.9.26.orig/libresolv/Makefile	2004-11-03 17:33:11.000000000 +0100
+++ uClibc-0.9.26/libresolv/Makefile	2004-11-03 17:44:58.000000000 +0100
@@ -25,6 +25,8 @@
 TOPDIR=../
 include $(TOPDIR)Rules.mak
 
+LDFLAGS+=-z defs
+
 LIBRESOLV=libresolv.a
 LIBRESOLV_SHARED=libresolv.so
 LIBRESOLV_SHARED_FULLNAME=libresolv-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
diff -urN uClibc-0.9.26.orig/libutil/Makefile uClibc-0.9.26/libutil/Makefile
--- uClibc-0.9.26.orig/libutil/Makefile	2004-11-03 17:33:11.000000000 +0100
+++ uClibc-0.9.26/libutil/Makefile	2004-11-03 17:45:25.000000000 +0100
@@ -23,6 +23,9 @@
 
 TOPDIR=../
 include $(TOPDIR)Rules.mak
+
+LDFLAGS+=-z defs
+
 LIBC=$(TOPDIR)libc.a
 
 LIBUTIL=libutil.a


More information about the uClibc mailing list