summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-12-11 12:23:37 +0000
committerEric Andersen <andersen@codepoet.org>2004-12-11 12:23:37 +0000
commita56073a28beba540347846a193d25fd61584c2af (patch)
tree5c22cb4bc0d147e50df51730aa27adf172c15ae7 /ldso
parentfb6f30cabdaa0ed74d0f7ec9d1feb137260e37aa (diff)
Partial commit of a patch from Alexandre Oliva:
Here's an updated version of the patch I posted about a month ago. It leaves -nostdinc alone, and uses -print-file-name=include instead of -print-search-dirs to figure out where GCC's internal headers are. Please let me know whether there are any portions of this patch you'd like me to break into smaller pieces, to rework, or to give up trying to get into uClibc :-) Thanks,
Diffstat (limited to 'ldso')
-rw-r--r--ldso/include/dl-string.h8
-rw-r--r--ldso/ldso/Makefile8
-rw-r--r--ldso/ldso/frv/dl-inlines.h12
-rw-r--r--ldso/ldso/frv/dl-startup.h4
-rw-r--r--ldso/ldso/frv/dl-sysdep.h26
-rw-r--r--ldso/ldso/frv/elfinterp.c7
-rw-r--r--ldso/libdl/Makefile2
7 files changed, 52 insertions, 15 deletions
diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h
index c428634d2..9426860cc 100644
--- a/ldso/include/dl-string.h
+++ b/ldso/include/dl-string.h
@@ -262,6 +262,14 @@ static inline char *_dl_simple_ltoahex(char * local, unsigned long i)
#define SEND_STDERR(X) _dl_write(2, X, _dl_strlen(X));
#endif
+/* Some targets may have to override this to something that doesn't
+ reference constant strings through the GOT. This macro should be
+ preferred over SEND_STDERR for constant strings before we complete
+ bootstrap. */
+#ifndef SEND_EARLY_STDERR
+# define SEND_EARLY_STDERR(S) SEND_STDERR(S)
+#endif
+
#define SEND_ADDRESS_STDERR(X, add_a_newline) { \
char tmp[22], *tmp1; \
_dl_memset(tmp, 0, sizeof(tmp)); \
diff --git a/ldso/ldso/Makefile b/ldso/ldso/Makefile
index f58c3e857..2d2abeeb6 100644
--- a/ldso/ldso/Makefile
+++ b/ldso/ldso/Makefile
@@ -39,7 +39,13 @@ XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) $(PICFLAG) \
# BEWARE!!! At least mips* will die if -O0 is used!!!
XXFLAGS :=$(XXFLAGS:-O0=-O1)
-XXFLAGS+=$(shell $(CC) -print-search-dirs | sed -ne "s/install: *\(.*\)/-I\1include/gp")
+ifeq ($(PIEFLAG),)
+PIEFLAG=-fPIC
+endif
+
+XXFLAGS+=$(PIEFLAG)
+
+XXFLAGS+=-isystem $(shell $(CC) -print-file-name=include)
LDFLAGS=$(CPU_LDFLAGS-y) -z now -Bsymbolic -shared --warn-common --export-dynamic --sort-common \
-z combreloc --discard-locals --discard-all --no-undefined
diff --git a/ldso/ldso/frv/dl-inlines.h b/ldso/ldso/frv/dl-inlines.h
index f09c8b93a..855362e10 100644
--- a/ldso/ldso/frv/dl-inlines.h
+++ b/ldso/ldso/frv/dl-inlines.h
@@ -414,11 +414,11 @@ _dl_funcdesc_for (void *entry_point, void *got_value)
return _dl_stabilize_funcdesc (*entry);
}
-inline static void *
-_dl_lookup_address (void *address)
+inline static void const *
+_dl_lookup_address (void const *address)
{
struct elf_resolve *rpnt;
- struct funcdesc_value *fd;
+ struct funcdesc_value const *fd;
/* Make sure we don't make assumptions about its alignment. */
asm ("" : "+r" (address));
@@ -427,7 +427,7 @@ _dl_lookup_address (void *address)
/* It's not a function descriptor. */
return address;
- fd = (struct funcdesc_value *)address;
+ fd = (struct funcdesc_value const *)address;
for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next)
{
@@ -439,9 +439,9 @@ _dl_lookup_address (void *address)
address = htab_find_slot (rpnt->funcdesc_ht, (void*)fd->entry_point, 0);
- if (address && *(struct funcdesc_value **)address == fd)
+ if (address && *(struct funcdesc_value *const*)address == fd)
{
- address = (*(struct funcdesc_value **)address)->entry_point;
+ address = (*(struct funcdesc_value *const*)address)->entry_point;
break;
}
else
diff --git a/ldso/ldso/frv/dl-startup.h b/ldso/ldso/frv/dl-startup.h
index 98c5677f6..46875c95e 100644
--- a/ldso/ldso/frv/dl-startup.h
+++ b/ldso/ldso/frv/dl-startup.h
@@ -145,7 +145,3 @@ struct elf32_fdpic_loadmap;
/* _dl_dprintf(2, "entry point is (%x,%x)\n", dl_main_funcdesc->entry_point, dl_main_funcdesc->got_value); */ \
return; \
} while (0)
-
-
-
-
diff --git a/ldso/ldso/frv/dl-sysdep.h b/ldso/ldso/frv/dl-sysdep.h
index 32d540caf..158f6af04 100644
--- a/ldso/ldso/frv/dl-sysdep.h
+++ b/ldso/ldso/frv/dl-sysdep.h
@@ -129,6 +129,16 @@ struct funcdesc_ht;
#define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \
(! (TFROM) && __dl_addr_in_loadaddr ((void*)(ADDR), (TPNT)->loadaddr))
+/* Make sure we only load libraries that use the same number of
+ general-purpose and floating-point registers the dynamic loader was
+ compiled for. */
+#define DL_CHECK_REG_COUNT(flags) \
+ (((flags & EF_FRV_GPR_MASK) == EF_FRV_GPR_32 ? __FRV_GPR__ == 32 : 1) \
+ && ((flags & EF_FRV_GPR_MASK) == EF_FRV_GPR_64 ? __FRV_GPR__ == 64 : 1) \
+ && ((flags & EF_FRV_FPR_MASK) == EF_FRV_FPR_32 ? __FRV_FPR__ == 32 : 1) \
+ && ((flags & EF_FRV_FPR_MASK) == EF_FRV_FPR_64 ? __FRV_FPR__ == 64 : 1) \
+ && ((flags & EF_FRV_FPR_MASK) == EF_FRV_FPR_NONE ? __FRV_FPR__ == 0 : 1))
+
/* We only support loading FDPIC independently-relocatable shared
libraries. It probably wouldn't be too hard to support loading
shared libraries that require relocation by the same amount, but we
@@ -149,6 +159,14 @@ do \
_dl_close(infile); \
return NULL; \
} \
+\
+ if (! DL_CHECK_REG_COUNT ((epnt)->e_flags)) \
+ { \
+ _dl_internal_error_number = LD_ERROR_NOTDYN; \
+ _dl_dprintf(2, "%s: '%s' assumes different register counts" \
+ "\n", (_dl_progname), (libname)); \
+ _dl_close(infile); \
+ } \
} \
while (0)
@@ -172,6 +190,14 @@ while (0)
(TPNT)->loadaddr.got_value) \
: DL_RELOC_ADDR ((SYM)->st_value, (TPNT)->loadaddr))
+#define DL_GET_READY_TO_RUN_EXTRA_PARMS \
+ , struct elf32_fdpic_loadmap *dl_boot_progmap
+#define DL_GET_READY_TO_RUN_EXTRA_ARGS \
+ , dl_boot_progmap
+
+
+
+
#ifdef __USE_GNU
# include <link.h>
#else
diff --git a/ldso/ldso/frv/elfinterp.c b/ldso/ldso/frv/elfinterp.c
index 2b2891880..9ab1a9777 100644
--- a/ldso/ldso/frv/elfinterp.c
+++ b/ldso/ldso/frv/elfinterp.c
@@ -153,10 +153,11 @@ _dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
DL_RELOC_ADDR (this_reloc->r_offset, tpnt->loadaddr);
/* Get the address to be used to fill in the GOT entry. */
- new_addr = _dl_find_hash_mod(symname, tpnt->symbol_scope, 0,
+ new_addr = _dl_find_hash_mod(symname, tpnt->symbol_scope, NULL, 0,
&new_tpnt);
if (!new_addr) {
- new_addr = _dl_find_hash_mod(symname, NULL, 0, &new_tpnt);
+ new_addr = _dl_find_hash_mod(symname, NULL, NULL, 0,
+ &new_tpnt);
if (!new_addr) {
_dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, symname);
@@ -278,7 +279,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
} else {
symbol_addr = (unsigned long)
- _dl_find_hash_mod(symname, scope, 0, &symbol_tpnt);
+ _dl_find_hash_mod(symname, scope, NULL, 0, &symbol_tpnt);
/*
* We want to allow undefined references to weak symbols - this might
diff --git a/ldso/libdl/Makefile b/ldso/libdl/Makefile
index 2da54e0a7..7f65128c4 100644
--- a/ldso/libdl/Makefile
+++ b/ldso/libdl/Makefile
@@ -31,7 +31,7 @@ XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) \
-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
-fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso -I. -I$(TOPDIR)include
-XXFLAGS+=$(shell $(CC) -print-search-dirs | sed -ne "s/install: *\(.*\)/-I\1include/gp")
+XXFLAGS+=-isystem $(shell $(CC) -print-file-name=include)
XXFLAGS_NOPIC:=$(XXFLAGS)
ifeq ($(DOPIC),y)
XXFLAGS += $(PICFLAG) -D__LIBDL_SHARED__