[uClibc] Re: ET_DYN patches made optional
Peter S. Mazinger
ps.m at gmx.net
Fri Nov 21 11:35:32 UTC 2003
On Fri, 21 Nov 2003, Peter S. Mazinger wrote:
> On Fri, 21 Nov 2003, Peter S. Mazinger wrote:
>
> > On Wed, 19 Nov 2003, Peter S. Mazinger wrote:
> >
> > > Hello!
> > >
> > > I have changes the pax and crt0S.S to be an option
> > > (UCLIBC_PAX_LOADER, defaults to no). This also requires the
> > > FORCE_SHAREABLE_TEXT_SEGMENTS set to yes (so both have to be set, to get
> > > it active). I had to remove COMPLETELY_PIC option (it's unused).
> > >
> > > Added also preliminary patch for propolice support in uClibc, I have
> > > stolen the ssp.c file from glibc-2.3.2 (gentoo). It is implemented also
> > > as an option, defaulting to no (UCLIBC_PROPOLICE). Please check the
> > > location for __guard_setup() in __uClibc_main.c if it ok.
> > >
> > > Erik, the PaX and crt0S.S patches (if ok from PaX and solar) can
> > > be applied (if you would like to) to cvs, they won't disturb normal
> > > functionality.
> > After some hints from pappy I have modified the patch sent earlier to
> > behave like glibc-2.3.2 (file installed is Scrt1.o, interp.o not needed
> > anymore), so the pie option from binutils >= 2.14.90.0.6 works without
> > changes to the gcc's specs file.
> I have removed the crt0S.S file completely and integrated it into the
> main crt0.S.
> It would ease porting to other archs.
Sorry for missing patch, here it comes.
Peter
--
Peter S. Mazinger <ps.m at gmx.net> ID: 0xA5F059F2 NIC: IXUYHSKQLI
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08 BB6E C389 975E A5F0 59F2
____________________________________________________________________
Miert fizetsz az internetert? Korlatlan, ingyenes internet hozzaferes a FreeStarttol.
Probald ki most! http://www.freestart.hu
-------------- next part --------------
--- uClibc-0.9.23/libc/sysdeps/linux/i386/crt0.S.mps 2003-11-21 10:51:56.000000000 +0100
+++ uClibc-0.9.23/libc/sysdeps/linux/i386/crt0.S 2003-11-21 11:13:02.000000000 +0100
@@ -18,6 +18,7 @@
/* Based on the code from GNU libc, but hacked up by John Beppu and Erik Andersen */
+/* adapted by Pax Team for ET_DYN binaries */
/*
When we enter this piece of code, the program stack looks like this:
@@ -37,7 +38,7 @@
.global _start
.type _start,%function
-#if defined L_crt0 || ! defined __UCLIBC_CTOR_DTOR__
+#if (defined L_crt0 || defined L_Scrt0 ) || ! defined __UCLIBC_CTOR_DTOR__
.type __uClibc_main,%function
#else
.weak _init
@@ -74,10 +75,22 @@
pushl %ebp /* callers %ebp (frame pointer) */
movl %esp,%ebp /* mark callers stack frame as invalid */
-#if (defined L_crt1 || defined L_gcrt1 ) && defined __UCLIBC_CTOR_DTOR__
+#if defined L_Scrt0 || defined L_Scrt1
+ call .L0
+.L0:
+ pop %edx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-.L0],%edx
+#endif
+
+#if ((defined L_crt1 || defined L_Scrt1 ) || defined L_gcrt1 ) && defined __UCLIBC_CTOR_DTOR__
/* Push .init and .fini arguments to __uClibc_start_main() on the stack */
+#ifdef L_Scrt1
+ pushl _fini at GOT(%edx)
+ pushl _init at GOT(%edx)
+#else
pushl $_fini
pushl $_init
+#endif
/* Push envp, argc, and argc arguments to __uClibc_start_main() on the stack */
pushl %eax /* Environment pointer */
@@ -85,15 +98,23 @@
pushl %ecx /* And the argument count */
/* Ok, now run uClibc's main() -- shouldn't return */
+#ifdef L_Scrt1
+ call *__uClibc_start_main at GOT(%edx)
+#else
call __uClibc_start_main
+#endif
#else
/* Push envp, argc, and argc arguments to __uClibc_start_main() on the stack */
pushl %eax /* Environment pointer */
pushl %ebx /* Argument pointer */
pushl %ecx /* And the argument count */
+#ifdef L_Scrt0
+ call *__uClibc_main at GOT(%edx)
+#else
call __uClibc_main
#endif
+#endif
/* Crash if somehow `exit' returns anyways. */
hlt
--- uClibc-0.9.23/libc/sysdeps/linux/i386/Makefile.mps 2003-11-21 11:21:04.000000000 +0100
+++ uClibc-0.9.23/libc/sysdeps/linux/i386/Makefile 2003-11-21 11:26:56.000000000 +0100
@@ -22,6 +22,10 @@
CRT0_SRC = crt0.S
CRT0_OBJ = crt0.o crt1.o gcrt1.o
+ifeq ($(strip $(UCLIBC_PAX_LOADER)),y)
+CRT0_OBJ += Scrt0.o Scrt1.o
+SCRT_FLAGS = -fPIC
+endif
CRT0_DEPS=gmon-start.S
CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
@@ -52,9 +56,16 @@
ar-target: $(OBJS) $(CRT0_OBJ) $(CTOR_TARGETS)
$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
cp $(CRT0_OBJ) $(TOPDIR)lib/
+ifeq ($(strip $(UCLIBC_PAX_LOADER)),y)
+ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
+ $(RM) $(TOPDIR)lib/Scrt0.o
+else
+ mv $(TOPDIR)lib/Scrt0.o $(TOPDIR)lib/Scrt1.o
+endif
+endif
$(CRT0_OBJ): $(CRT0_SRC)
- $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+ $(CC) $(CFLAGS) $(SCRT_FLAGS) -DL_$* $< -c -o $*.o
$(STRIPTOOL) -x -R .note -R .comment $*.o
$(SOBJS): %.o : %.S
More information about the uClibc
mailing list