[uClibc] Re: ET_DYN patches made optional
Peter S. Mazinger
ps.m at gmx.net
Fri Nov 21 09:19:36 UTC 2003
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.
Erik please apply this instead of the earlier sent one (if you'd like)
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/Makefile.mps 2003-11-15 11:41:33.000000000 +0100
+++ uClibc-0.9.23/libc/sysdeps/linux/i386/Makefile 2003-11-15 14:07:28.000000000 +0100
@@ -25,6 +25,13 @@
CRT0_DEPS=gmon-start.S
CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
+ifeq ($(strip $(UCLIBC_PAX_LOADER)),y)
+SCRT0_SRC = Scrt0.S
+SCRT0_OBJ = Scrt0.o Scrt1.o
+else
+SCRT0_OBJ =
+endif
+
SSRC=__longjmp.S vfork.S clone.S setjmp.S bsd-setjmp.S \
bsd-_setjmp.S syscall.S mmap64.S
ifeq ($(strip $(UCLIBC_PROFILING)),y)
@@ -49,14 +56,27 @@
$(LIBC): ar-target
-ar-target: $(OBJS) $(CRT0_OBJ) $(CTOR_TARGETS)
+ar-target: $(OBJS) $(CRT0_OBJ) $(CTOR_TARGETS) $(SCRT0_OBJ)
$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
cp $(CRT0_OBJ) $(TOPDIR)lib/
+ifeq ($(strip $(UCLIBC_PAX_LOADER)),y)
+ifneq ($(strip $(UCLIBC_CTOR_DTOR)),y)
+ cp Scrt0.o $(TOPDIR)lib/Scrt1.o
+else
+ cp Scrt1.o $(TOPDIR)lib/
+endif
+endif
$(CRT0_OBJ): $(CRT0_SRC)
$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(STRIPTOOL) -x -R .note -R .comment $*.o
+ifeq ($(strip $(UCLIBC_PAX_LOADER)),y)
+$(SCRT0_OBJ): $(SCRT0_SRC)
+ $(CC) $(CFLAGS) -fPIC -DL_$* $< -c -o $*.o
+ $(STRIPTOOL) -x -R .note -R .comment $*.o
+endif
+
$(SOBJS): %.o : %.S
$(CC) $(CFLAGS) -c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
--- uClibc-0.9.23/libc/sysdeps/linux/i386/Scrt0.S.mps 2003-11-15 11:41:39.000000000 +0100
+++ uClibc-0.9.23/libc/sysdeps/linux/i386/Scrt0.S 2003-11-15 13:45:12.000000000 +0100
@@ -0,0 +1,110 @@
+/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+
+/* Based on the code from GNU libc, but hacked up by John Beppu and Erik Andersen */
+/* crt0.S adapted by Pax Team for ET_DYN binaries */
+
+/*
+ When we enter this piece of code, the program stack looks like this:
+ argc argument counter (integer)
+ argv[0] program name (pointer)
+ argv[1...N] program args (pointers)
+ argv[argc-1] end of args (integer)
+ NULL
+ env[0...N] environment variables (pointers)
+ NULL
+*/
+
+#include <features.h>
+
+.text
+ .align 4
+
+ .global _start
+ .type _start,%function
+#if defined L_Scrt0 || ! defined __UCLIBC_CTOR_DTOR__
+ .type __uClibc_main,%function
+#else
+ .weak _init
+ .weak _fini
+ .type __uClibc_start_main,%function
+#endif
+/* Stick in a dummy reference to main(), so that if an application
+ * is linking when the main() function is in a static library (.a)
+ * we can be sure that main() actually gets linked in */
+ .type main,%function
+
+_start:
+ /* locate the start of the environment variables */
+ popl %ecx /* Store argc into %ecx */
+ movl %esp,%ebx /* Store argv into ebx */
+ movl %esp,%eax /* Store argv into eax as well*/
+ movl %ecx,%edx /* Stick argc into %edx so we can do some math in a sec */
+ leal 4(%eax,%edx,4),%eax
+
+ /* [ register layout ]
+
+ sizeof(char*) == 4
+ %ecx = argc ; 0(esp)
+ %ebx = argv ; 4(esp)
+ %eax = env ; argv + (argc * 4) + 4
+ */
+
+ /* Set up an invalid (NULL return address, NULL frame pointer)
+ callers stack frame so anybody unrolling the stack knows where
+ to stop */
+ xorl %ebp,%ebp /* NULL */
+ pushl %ebp /* callers %cs */
+ pushl %ebp /* callers %eip (return address) */
+ pushl %ebp /* callers %ebp (frame pointer) */
+ movl %esp,%ebp /* mark callers stack frame as invalid */
+
+ call .L0
+.L0:
+ pop %edx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-.L0],%edx
+
+#if (defined L_Scrt1 || defined L_gcrt1 ) && defined __UCLIBC_CTOR_DTOR__
+ /* Push .init and .fini arguments to __uClibc_start_main() on the stack */
+ pushl _fini at GOT(%edx)
+ pushl _init at GOT(%edx)
+
+ /* 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 */
+
+ /* Ok, now run uClibc's main() -- shouldn't return */
+ call *__uClibc_start_main at GOT(%edx)
+#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 */
+
+ call *__uClibc_main at GOT(%edx)
+#endif
+
+ /* Crash if somehow `exit' returns anyways. */
+ hlt
+.size _start,.-_start
+
+#if defined L_gcrt1 && defined __UCLIBC_PROFILING__
+# include "./gmon-start.S"
+#endif
More information about the uClibc
mailing list