summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/internals/__uClibc_main.c28
-rw-r--r--libc/sysdeps/linux/common/getpagesize.c24
2 files changed, 39 insertions, 13 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 73abcfa77..79b71cb3c 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -1,6 +1,6 @@
/*
* Manuel Novoa III Feb 2001
- * Erik Andersen Mar 2002
+ * Erik Andersen 2002-2004
*
* __uClibc_main is the routine to be called by all the arch-specific
* versions of crt0.S in uClibc.
@@ -15,6 +15,8 @@
#include <features.h>
#include <unistd.h>
#include <stdlib.h>
+#include <string.h>
+#include <elf.h>
#ifdef __UCLIBC_PROPOLICE__
extern void __guard_setup(void);
#endif
@@ -44,6 +46,9 @@ extern void weak_function __pthread_initialize_minimal(void);
* environ symbol is also included.
*/
+extern int _dl_secure;
+extern size_t _dl_pagesize;
+
char **__environ = 0;
const char *__progname = 0;
weak_alias(__environ, environ);
@@ -116,6 +121,23 @@ void __attribute__ ((__noreturn__))
__uClibc_start_main(int argc, char **argv, char **envp,
void (*app_init)(void), void (*app_fini)(void))
{
+ unsigned long *aux_dat;
+ Elf32_auxv_t auxvt[AT_EGID + 1];
+
+ /* Pull stuff from the ELF header when possible */
+ aux_dat = (unsigned long*)envp;
+ while (*aux_dat) {
+ aux_dat++;
+ }
+ aux_dat++;
+ while (*aux_dat) {
+ Elf32_auxv_t *auxv_entry = (Elf32_auxv_t *) aux_dat;
+ if (auxv_entry->a_type <= AT_EGID) {
+ memcpy(&(auxvt[auxv_entry->a_type]), auxv_entry, sizeof(Elf32_auxv_t));
+ }
+ aux_dat += 2;
+ }
+ _dl_pagesize = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : 4096;
/* If we are dynamically linked the shared lib loader already
* did this for us. But if we are statically linked, we need
@@ -134,7 +156,7 @@ __uClibc_start_main(int argc, char **argv, char **envp,
#ifdef __UCLIBC_CTOR_DTOR__
/* Arrange for the application's dtors to run before we exit. */
- __app_fini = app_fini;
+ __app_fini = app_fini;
/* Run all the application's ctors now. */
if (app_init!=NULL) {
@@ -143,7 +165,7 @@ __uClibc_start_main(int argc, char **argv, char **envp,
#endif
#ifdef __UCLIBC_PROPOLICE__
- __guard_setup ();
+ __guard_setup ();
#endif
/* Note: It is possible that any initialization done above could
diff --git a/libc/sysdeps/linux/common/getpagesize.c b/libc/sysdeps/linux/common/getpagesize.c
index 859338003..72da95bbc 100644
--- a/libc/sysdeps/linux/common/getpagesize.c
+++ b/libc/sysdeps/linux/common/getpagesize.c
@@ -1,28 +1,32 @@
-/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1992,1995-1997,2000,2002 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.
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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.
+ Lesser 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., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <unistd.h>
#include <features.h>
#include <sys/param.h>
+extern size_t _dl_pagesize;
/* Return the system page size. */
int __getpagesize(void)
{
+ if (_dl_pagesize != 0)
+ return _dl_pagesize;
+
#ifdef EXEC_PAGESIZE
return EXEC_PAGESIZE;
#else /* No EXEC_PAGESIZE. */
@@ -36,5 +40,5 @@ int __getpagesize(void)
#endif /* NBPG. */
#endif /* EXEC_PAGESIZE. */
}
-
weak_alias(__getpagesize, getpagesize);
+