summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2005-10-27 22:58:52 +0000
committerPeter S. Mazinger <ps.m@gmx.net>2005-10-27 22:58:52 +0000
commit237277e9a8133c64026b736b1427141e71655330 (patch)
tree43d2f15804d486c56d7fba35c97b6d38ccc9fc6d /ldso
parent6e3a0044cc3b4d6f3f13f2d9d1d0a83d60ca800f (diff)
Moved guard_setup to dl-osinfo.h (used commonly by ldso and libc). Renamed to _dl_setup_stack_chk_guard, as in glibc. SSP requires now binutils-2.16.1 and newer. Add NOT_IN_libc/IS_IN_libc. Began using -DSHARED in uClibc_main.c, there are more candidates in there. Move back dl_protect_relro to it's earlier place.
Diffstat (limited to 'ldso')
-rw-r--r--ldso/include/dl-syscall.h6
-rw-r--r--ldso/ldso/Makefile2
-rw-r--r--ldso/ldso/Makefile.in4
-rw-r--r--ldso/ldso/ldso.c31
-rw-r--r--ldso/libdl/Makefile.in16
-rw-r--r--ldso/libdl/libdl.c19
6 files changed, 49 insertions, 29 deletions
diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
index d4348afc0..70b79f6cf 100644
--- a/ldso/include/dl-syscall.h
+++ b/ldso/include/dl-syscall.h
@@ -105,6 +105,12 @@ static inline _syscall0(gid_t, _dl_getpid);
#define __NR__dl_readlink __NR_readlink
static inline _syscall3(int, _dl_readlink, const char *, path, char *, buf, size_t, bufsiz);
+#ifdef __UCLIBC_HAS_SSP__
+#include <sys/time.h>
+#define __NR__dl_gettimeofday __NR_gettimeofday
+static inline _syscall2(int, _dl_gettimeofday, struct timeval *, tv, struct timezone *, tz);
+#endif
+
#ifdef __NR_mmap
#ifdef MMAP_HAS_6_ARGS
#define __NR__dl_mmap __NR_mmap
diff --git a/ldso/ldso/Makefile b/ldso/ldso/Makefile
index fe356ea50..bdc4904f1 100644
--- a/ldso/ldso/Makefile
+++ b/ldso/ldso/Makefile
@@ -19,7 +19,7 @@
TOPDIR=../../
include $(TOPDIR)Rules.mak
-XXFLAGS=$(XWARNINGS) $(SSP_DISABLE_FLAGS)
+XXFLAGS=$(XWARNINGS) $(SSP_DISABLE_FLAGS) -DNOT_IN_libc
ifeq ($(DODEBUG),y)
# Not really much point in including debugging info, since gdb
diff --git a/ldso/ldso/Makefile.in b/ldso/ldso/Makefile.in
index 30a6c4ec2..47ab64bca 100644
--- a/ldso/ldso/Makefile.in
+++ b/ldso/ldso/Makefile.in
@@ -19,6 +19,8 @@ ifeq ($(SUPPORT_LD_DEBUG_EARLY),y)
CFLAGS+=-D__SUPPORT_LD_DEBUG_EARLY__
endif
+CFLAGS+=-DNOT_IN_libc
+
ifeq ($(DODEBUG),y)
# Not really much point in including debugging info, since gdb
# can't really debug ldso, since gdb requires help from ldso to
@@ -60,8 +62,6 @@ EXTRA_LINK_LIBS:=$(LIBGCC) # $(LDADD_LIBFLOAT)
ld-uClibc-so-$(HAVE_SHARED):=$(ld-uClibc_OBJS:.o=.os)
-ld-uClibc-multi-$(HAVE_SHARED):=$(ld-uClibc_SRC) $(ld-uClibc_SSRC)
-
objclean-y+=ld-uClibc_clean ld-uClibc_arch_clean
ld-uClibc_arch_clean:
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 3b678588f..3d6884c0c 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -85,6 +85,16 @@ static struct elf_resolve **init_fini_list;
static int nlist; /* # items in init_fini_list */
extern void _start(void);
+#ifdef __UCLIBC_HAS_SSP__
+#include <dl-osinfo.h>
+#ifndef THREAD_SET_STACK_GUARD
+/* Only exported for architectures that don't store the stack guard canary
+ * in local thread area. */
+uintptr_t __stack_chk_guard attribute_relro;
+strong_alias(__stack_chk_guard,__guard)
+#endif
+#endif
+
static void __attribute__ ((destructor)) __attribute_used__ _dl_fini(void)
{
int i;
@@ -196,6 +206,17 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
unlazy = RTLD_NOW;
}
+ /* sjhill: your TLS init should go before this */
+#ifdef __UCLIBC_HAS_SSP__
+ /* Set up the stack checker's canary. */
+ uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard ();
+# ifdef THREAD_SET_STACK_GUARD
+ THREAD_SET_STACK_GUARD (stack_chk_guard);
+# else
+ __stack_chk_guard = stack_chk_guard;
+# endif
+#endif
+
/* At this point we are now free to examine the user application,
* and figure out which libraries are supposed to be called. Until
* we have this list, we will not be completely ready for dynamic
@@ -705,6 +726,11 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
if (_dl_symbol_tables)
goof += _dl_fixup(_dl_symbol_tables, unlazy);
+ for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
+ if (tpnt->relro_size)
+ _dl_protect_relro (tpnt);
+ }
+
/* OK, at this point things are pretty much ready to run. Now we need
* to touch up a few items that are required, and then we can let the
* user application have at it. Note that the dynamic linker itself
@@ -756,11 +782,6 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
}
}
- for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
- if (tpnt->relro_size)
- _dl_protect_relro (tpnt);
- }
-
/* Find the real malloc function and make ldso functions use that from now on */
_dl_malloc_function = (void* (*)(size_t)) (intptr_t) _dl_find_hash("malloc",
_dl_symbol_tables, NULL, ELF_RTYPE_CLASS_PLT);
diff --git a/ldso/libdl/Makefile.in b/ldso/libdl/Makefile.in
index 1e758e148..be1242f60 100644
--- a/ldso/libdl/Makefile.in
+++ b/ldso/libdl/Makefile.in
@@ -21,7 +21,7 @@ ifeq ($(TARGET_ARCH),mips)
CFLAGS:=$(CFLAGS:-O0=-O1)
endif
-# we need special .oS file created, do not enable this
+# can't combine .c w/ .S
DOMULTI=n
LIB_NAME:=libdl
@@ -36,18 +36,11 @@ libdl_OUT:=$(top_builddir)ldso/libdl
libdl_SRC:=$(libdl_DIR)/libdl.c
libdl_OBJ:=$(patsubst $(libdl_DIR)/%.c,$(libdl_OUT)/%.o,$(libdl_SRC))
-# use other suffixes, so that it does not pick up the multi rule from Makerules
-$(libdl_OUT)/libdl.oS: $(libdl_DIR)/libdl.c
- $(compile.c) -DSHARED
-
resolve:=$(top_builddir)ldso/ldso/$(TARGET_ARCH)/resolve.o
-libdl-a-$(HAVE_SHARED):=$(libdl_OBJ) $(resolve)
-libdl-a-pic-$(HAVE_SHARED):=$(libdl_OBJ:.o=.os) $(resolve:.o=.os)
-libdl-so-$(HAVE_SHARED):=$(libdl_OBJ:.o=.oS)
-
-# do not disable this
-libdl-multi-$(HAVE_SHARED):=$(libdl_SRC)
+libdl-a-$(HAVE_SHARED):=$(libdl_OBJ)
+libdl-static-$(HAVE_SHARED):=$(resolve)
+libdl-shared-$(HAVE_SHARED):=$(libdl_OUT)/libdl.oS
objclean-y+=libdl_clean libdl_extra_clean
@@ -55,5 +48,4 @@ libdl_extra_clean:
$(RM) $(libdl_OUT)/*.oS
lib-a-$(HAVE_SHARED)+=$(top_builddir)lib/libdl.a
-lib-a-pic-$(HAVE_SHARED)+=$(top_builddir)lib/libdl.a
lib-so-$(HAVE_SHARED)+=$(top_builddir)lib/libdl.so
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 12de25fd0..5efe36155 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -346,6 +346,15 @@ void *dlopen(const char *libname, int flag)
if (_dl_fixup(dyn_chain, now_flag))
goto oops;
+ if (relro_ptr) {
+ for (rpnt = relro_ptr->next; rpnt; rpnt = rpnt->next) {
+ if (rpnt->dyn->relro_size)
+ _dl_protect_relro(rpnt->dyn);
+ }
+ }
+ /* TODO: Should we set the protections of all pages back to R/O now ? */
+
+
/* Notify the debugger we have added some objects. */
if (_dl_debug_addr) {
dl_brk = (void (*)(void)) _dl_debug_addr->r_brk;
@@ -376,15 +385,7 @@ void *dlopen(const char *libname, int flag)
}
}
}
-#endif
-
- if (relro_ptr) {
- for (rpnt = relro_ptr->next; rpnt; rpnt = rpnt->next) {
- if (rpnt->dyn->relro_size)
- _dl_protect_relro(rpnt->dyn);
- }
- }
- /* TODO: Should we set the protections of all pages back to R/O now ? */
+#endif /* SHARED */
_dl_unmap_cache();
return (void *) dyn_chain;