[uClibc-cvs] uClibc/ldso/ldso .cvsignore, 1.6, 1.7 Makefile, 1.40, 1.41 ldso.c, 1.67, 1.68 readelflib1.c, 1.41, 1.42 ld_hash.h, 1.16, NONE ld_string.h, 1.17, NONE ld_syscall.h, 1.17, NONE linuxelf.h, 1.10, NONE
Erik Andersen
andersen at uclibc.org
Tue Aug 19 06:05:35 UTC 2003
- Previous message: [uClibc-cvs] uClibc/ldso/libdl Makefile, 1.27, 1.28 dlib.c, 1.26, 1.27 dlfcn.h, 1.1, NONE
- Next message: [uClibc-cvs] uClibc/ldso/util Makefile, 1.32, 1.33 ldconfig.c, 1.9, 1.10
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/cvs/uClibc/ldso/ldso
In directory winder:/tmp/cvs-serv5232/ldso
Modified Files:
.cvsignore Makefile ldso.c readelflib1.c
Removed Files:
ld_hash.h ld_string.h ld_syscall.h linuxelf.h
Log Message:
Phase one of my evil plan to clean up ld.so...
--- ld_syscall.h DELETED ---
Index: readelflib1.c
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/readelflib1.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- readelflib1.c 18 Jun 2003 22:42:23 -0000 1.41
+++ readelflib1.c 19 Aug 2003 06:05:31 -0000 1.42
@@ -4,7 +4,7 @@
*
* Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
* David Engel, Hongjiu Lu and Mitch D'Souza
- * Copyright (C) 2001-2002, Erik Andersen
+ * Copyright (C) 2001-2003, Erik Andersen
*
* All rights reserved.
*
@@ -316,12 +316,12 @@
struct elf_resolve *_dl_load_elf_shared_library(int secure,
struct dyn_elf **rpnt, char *libname)
{
- elfhdr *epnt;
+ ElfW(Ehdr) *epnt;
unsigned long dynamic_addr = 0;
unsigned long dynamic_size = 0;
Elf32_Dyn *dpnt;
struct elf_resolve *tpnt;
- elf_phdr *ppnt;
+ ElfW(Phdr) *ppnt;
char *status;
char header[4096];
unsigned long dynamic_info[24];
@@ -371,7 +371,7 @@
}
_dl_read(infile, header, sizeof(header));
- epnt = (elfhdr *) (intptr_t) header;
+ epnt = (ElfW(Ehdr) *) (intptr_t) header;
if (epnt->e_ident[0] != 0x7f ||
epnt->e_ident[1] != 'E' ||
epnt->e_ident[2] != 'L' ||
@@ -398,7 +398,7 @@
return NULL;
};
- ppnt = (elf_phdr *)(intptr_t) & header[epnt->e_phoff];
+ ppnt = (ElfW(Phdr) *)(intptr_t) & header[epnt->e_phoff];
piclib = 1;
for (i = 0; i < epnt->e_phnum; i++) {
@@ -446,7 +446,7 @@
flags |= MAP_FIXED;
/* Get the memory to store the library */
- ppnt = (elf_phdr *)(intptr_t) & header[epnt->e_phoff];
+ ppnt = (ElfW(Phdr) *)(intptr_t) & header[epnt->e_phoff];
for (i = 0; i < epnt->e_phnum; i++) {
if (ppnt->p_type == PT_LOAD) {
@@ -577,7 +577,7 @@
if (dynamic_info[DT_TEXTREL]) {
#ifndef FORCE_SHAREABLE_TEXT_SEGMENTS
- ppnt = (elf_phdr *)(intptr_t) & header[epnt->e_phoff];
+ ppnt = (ElfW(Phdr) *)(intptr_t) & header[epnt->e_phoff];
for (i = 0; i < epnt->e_phnum; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
_dl_mprotect((void *) ((piclib ? libaddr : 0) +
@@ -594,7 +594,7 @@
tpnt = _dl_add_elf_hash_table(libname, (char *) libaddr, dynamic_info,
dynamic_addr, dynamic_size);
- tpnt->ppnt = (elf_phdr *)(intptr_t) (tpnt->loadaddr + epnt->e_phoff);
+ tpnt->ppnt = (ElfW(Phdr) *)(intptr_t) (tpnt->loadaddr + epnt->e_phoff);
tpnt->n_phent = epnt->e_phnum;
/*
--- ld_hash.h DELETED ---
Index: .cvsignore
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/.cvsignore,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- .cvsignore 23 Jan 2002 16:04:38 -0000 1.6
+++ .cvsignore 19 Aug 2003 06:05:31 -0000 1.7
@@ -1,2 +1,2 @@
ld-uclibc.so*
-ldso.h
+_dl_progname.h
Index: ldso.c
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/ldso.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- ldso.c 18 Jun 2003 22:42:23 -0000 1.67
+++ ldso.c 19 Aug 2003 06:05:31 -0000 1.68
@@ -105,12 +105,8 @@
* application.
*/
-#include "ld_syscall.h"
-#include "linuxelf.h"
-#include "ld_hash.h"
-#include "ld_string.h"
-#include "dlfcn.h"
-#include "../config.h"
+#include "ldso.h"
+
#define ALLOW_ZERO_PLTGOT
@@ -129,7 +125,7 @@
char *_dl_library_path = 0; /* Where we look for libraries */
char *_dl_preload = 0; /* Things to be loaded before the libs. */
char *_dl_ldsopath = 0;
-static char *_dl_not_lazy = 0;
+static int _dl_be_lazy = 1;
#ifdef __SUPPORT_LD_DEBUG__
static char *_dl_debug = 0;
static char *_dl_debug_symbols = 0;
@@ -150,15 +146,15 @@
struct r_debug *_dl_debug_addr = NULL;
unsigned long *_dl_brkp;
unsigned long *_dl_envp;
-int _dl_fixup(struct elf_resolve *tpnt);
+int _dl_fixup(struct elf_resolve *tpnt, int lazy);
void _dl_debug_state(void);
char *_dl_get_last_path_component(char *path);
static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *app_tpnt,
unsigned long load_addr, unsigned long *hash_addr, Elf32_auxv_t auxvt[AT_EGID + 1],
char **envp, struct r_debug *debug_addr);
-#include "boot1_arch.h"
-#include "ldso.h" /* Pull in the name of ld.so */
+#include "boot1_arch.h"
+#include "_dl_progname.h" /* Pull in the value of _dl_progname */
/* When we enter this piece of code, the program stack looks like this:
argc argument counter (integer)
@@ -202,7 +198,7 @@
unsigned long *got;
unsigned long *aux_dat;
int goof = 0;
- elfhdr *header;
+ ElfW(Ehdr) *header;
struct elf_resolve *tpnt;
struct elf_resolve *app_tpnt;
Elf32_auxv_t auxvt[AT_EGID + 1];
@@ -253,7 +249,7 @@
/* locate the ELF header. We need this done as soon as possible
* (esp since SEND_STDERR() needs this on some platforms... */
load_addr = auxvt[AT_BASE].a_un.a_val;
- header = (elfhdr *) auxvt[AT_BASE].a_un.a_ptr;
+ header = (ElfW(Ehdr) *) auxvt[AT_BASE].a_un.a_ptr;
/* Check the ELF header to make sure everything looks ok. */
if (!header || header->e_ident[EI_CLASS] != ELFCLASS32 ||
@@ -406,10 +402,10 @@
}
{
- elf_phdr *ppnt;
+ ElfW(Phdr) *ppnt;
int i;
- ppnt = (elf_phdr *) auxvt[AT_PHDR].a_un.a_ptr;
+ ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_ptr;
for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++)
if (ppnt->p_type == PT_DYNAMIC) {
dpnt = (Elf32_Dyn *) ppnt->p_vaddr;
@@ -467,7 +463,7 @@
protection back again once we are done */
{
- elf_phdr *ppnt;
+ ElfW(Phdr) *ppnt;
int i;
#ifdef __SUPPORT_LD_DEBUG_EARLY__
@@ -476,8 +472,8 @@
/* First cover the shared library/dynamic linker. */
if (tpnt->dynamic_info[DT_TEXTREL]) {
- header = (elfhdr *) auxvt[AT_BASE].a_un.a_ptr;
- ppnt = (elf_phdr *) ((int)auxvt[AT_BASE].a_un.a_ptr +
+ header = (ElfW(Ehdr) *) auxvt[AT_BASE].a_un.a_ptr;
+ ppnt = (ElfW(Phdr) *) ((int)auxvt[AT_BASE].a_un.a_ptr +
header->e_phoff);
for (i = 0; i < header->e_phnum; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W)) {
@@ -493,7 +489,7 @@
#endif
/* Now cover the application program. */
if (app_tpnt->dynamic_info[DT_TEXTREL]) {
- ppnt = (elf_phdr *) auxvt[AT_PHDR].a_un.a_ptr;
+ ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_ptr;
for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
_dl_mprotect((void *) (ppnt->p_vaddr & PAGE_ALIGN),
@@ -647,7 +643,7 @@
unsigned long load_addr, unsigned long *hash_addr, Elf32_auxv_t auxvt[AT_EGID + 1],
char **envp, struct r_debug *debug_addr)
{
- elf_phdr *ppnt;
+ ElfW(Phdr) *ppnt;
char *lpntstr;
int i, _dl_secure, goof = 0;
struct dyn_elf *rpnt;
@@ -685,13 +681,13 @@
and load them properly. */
{
- elfhdr *epnt;
- elf_phdr *myppnt;
+ ElfW(Ehdr) *epnt;
+ ElfW(Phdr) *myppnt;
int j;
- epnt = (elfhdr *) auxvt[AT_BASE].a_un.a_ptr;
+ epnt = (ElfW(Ehdr) *) auxvt[AT_BASE].a_un.a_ptr;
tpnt->n_phent = epnt->e_phnum;
- tpnt->ppnt = myppnt = (elf_phdr *) (load_addr + epnt->e_phoff);
+ tpnt->ppnt = myppnt = (ElfW(Phdr) *) (load_addr + epnt->e_phoff);
for (j = 0; j < epnt->e_phnum; j++, myppnt++) {
if (myppnt->p_type == PT_DYNAMIC) {
tpnt->dynamic_addr = myppnt->p_vaddr + load_addr;
@@ -720,7 +716,7 @@
and figure out which libraries are supposed to be called. Until
we have this list, we will not be completely ready for dynamic linking */
- ppnt = (elf_phdr *) auxvt[AT_PHDR].a_un.a_ptr;
+ ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_ptr;
for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD) {
if (ppnt->p_vaddr + ppnt->p_memsz > brk_addr)
@@ -751,7 +747,7 @@
app_tpnt->dynamic_info, ppnt->p_vaddr, ppnt->p_filesz);
#endif
_dl_loaded_modules->libtype = elf_executable;
- _dl_loaded_modules->ppnt = (elf_phdr *) auxvt[AT_PHDR].a_un.a_ptr;
+ _dl_loaded_modules->ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_ptr;
_dl_loaded_modules->n_phent = auxvt[AT_PHNUM].a_un.a_val;
_dl_symbol_tables = rpnt = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
_dl_memset(rpnt, 0, sizeof(struct dyn_elf));
@@ -805,7 +801,8 @@
/* Now we need to figure out what kind of options are selected.
Note that for SUID programs we ignore the settings in LD_LIBRARY_PATH */
{
- _dl_not_lazy = _dl_getenv("LD_BIND_NOW", envp);
+ if (_dl_getenv("LD_BIND_NOW", envp))
+ _dl_be_lazy = 0;
if ((auxvt[AT_UID].a_un.a_val == -1 && _dl_suid_ok()) ||
(auxvt[AT_UID].a_un.a_val != -1 &&
@@ -905,9 +902,7 @@
libraries that should be loaded, and insert them on the list in the
correct order. */
-#ifdef USE_CACHE
_dl_map_cache();
-#endif
if (_dl_preload)
@@ -1124,9 +1119,7 @@
}
-#ifdef USE_CACHE
_dl_unmap_cache();
-#endif
/*
* If the program interpreter is not in the module chain, add it. This will
@@ -1187,7 +1180,7 @@
* Now we go through and look for REL and RELA records that indicate fixups
* to the GOT tables. We need to do this in reverse order so that COPY
* directives work correctly */
- goof = _dl_loaded_modules ? _dl_fixup(_dl_loaded_modules) : 0;
+ goof = _dl_loaded_modules ? _dl_fixup(_dl_loaded_modules, _dl_be_lazy) : 0;
/* Some flavors of SVr4 do not generate the R_*_COPY directive,
@@ -1222,7 +1215,7 @@
#ifndef FORCE_SHAREABLE_TEXT_SEGMENTS
{
unsigned int j;
- elf_phdr *myppnt;
+ ElfW(Phdr) *myppnt;
/* We had to set the protections of all pages to R/W for dynamic linking.
Set text pages back to R/O */
@@ -1306,52 +1299,61 @@
{
}
-int _dl_fixup(struct elf_resolve *tpnt)
+int _dl_fixup(struct elf_resolve *tpnt, int flag)
{
int goof = 0;
if (tpnt->next)
- goof += _dl_fixup(tpnt->next);
+ goof += _dl_fixup(tpnt->next, flag);
#if defined (__SUPPORT_LD_DEBUG__)
if(_dl_debug) _dl_dprintf(_dl_debug_file,"\nrelocation processing: %s", tpnt->libname);
#endif
if (tpnt->dynamic_info[DT_REL]) {
#ifdef ELF_USES_RELOCA
- _dl_dprintf(2, "%s: can't handle REL relocation records\n",
- _dl_progname);
- _dl_exit(17);
+#if defined (__SUPPORT_LD_DEBUG__)
+ if(_dl_debug) _dl_dprintf(2, "%s: can't handle REL relocation records\n", _dl_progname);
+#endif
+ goof++;
+ return goof;
#else
if (tpnt->init_flag & RELOCS_DONE)
return goof;
tpnt->init_flag |= RELOCS_DONE;
- goof += _dl_parse_relocation_information(tpnt, tpnt->dynamic_info[DT_REL],
+ goof += _dl_parse_relocation_information(tpnt,
+ tpnt->dynamic_info[DT_REL],
tpnt->dynamic_info[DT_RELSZ], 0);
#endif
}
if (tpnt->dynamic_info[DT_RELA]) {
-#ifdef ELF_USES_RELOCA
+#ifndef ELF_USES_RELOCA
+#if defined (__SUPPORT_LD_DEBUG__)
+ if(_dl_debug) _dl_dprintf(2, "%s: can't handle RELA relocation records\n", _dl_progname);
+#endif
+ goof++;
+ return goof;
+#else
if (tpnt->init_flag & RELOCS_DONE)
return goof;
tpnt->init_flag |= RELOCS_DONE;
- goof += _dl_parse_relocation_information(tpnt, tpnt->dynamic_info[DT_RELA],
+ goof += _dl_parse_relocation_information(tpnt,
+ tpnt->dynamic_info[DT_RELA],
tpnt->dynamic_info[DT_RELASZ], 0);
-#else
- _dl_dprintf(2, "%s: can't handle RELA relocation records\n",
- _dl_progname);
- _dl_exit(18);
#endif
}
if (tpnt->dynamic_info[DT_JMPREL]) {
if (tpnt->init_flag & JMP_RELOCS_DONE)
return goof;
tpnt->init_flag |= JMP_RELOCS_DONE;
- if (!_dl_not_lazy || *_dl_not_lazy == 0)
- _dl_parse_lazy_relocation_information(tpnt, tpnt->dynamic_info[DT_JMPREL],
+ if (flag & RTLD_LAZY) {
+ _dl_parse_lazy_relocation_information(tpnt,
+ tpnt->dynamic_info[DT_JMPREL],
tpnt->dynamic_info [DT_PLTRELSZ], 0);
- else
- goof += _dl_parse_relocation_information(tpnt, tpnt->dynamic_info[DT_JMPREL],
+ } else {
+ goof += _dl_parse_relocation_information(tpnt,
+ tpnt->dynamic_info[DT_JMPREL],
tpnt->dynamic_info[DT_PLTRELSZ], 0);
+ }
}
#if defined (__SUPPORT_LD_DEBUG__)
if(_dl_debug) {
--- ld_string.h DELETED ---
Index: Makefile
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/Makefile,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- Makefile 20 Nov 2002 10:41:04 -0000 1.40
+++ Makefile 19 Aug 2003 06:05:31 -0000 1.41
@@ -27,10 +27,12 @@
LDSO_FULLNAME=ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
-
-XXFLAGS+=-DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
+XXFLAGS=$(XWARNINGS) $(OPTIMIZATION) $(XARCH_CFLAGS) $(CPU_CFLAGS) $(PICFLAG) \
+ -DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
-DUCLIBC_DEVEL_PREFIX=\"$(DEVEL_PREFIX)\" \
- -DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR) && pwd)\"
+ -DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR) && pwd)\" \
+ -fno-builtin -nostdinc -I$(TOPDIR)ldso/include -I. -I$(TOPDIR)include
+XXFLAGS+=$(shell $(CC) -print-search-dirs | sed -ne "s/install: *\(.*\)/-I\1include/gp")
LDFLAGS=$(CPU_LDFLAGS-y) -shared --warn-common --export-dynamic --sort-common \
-z combreloc --discard-locals --discard-all
CSRC= ldso.c #hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c
@@ -61,29 +63,28 @@
all: lib
-lib:: ldso.h $(OBJS) $(DLINK_OBJS)
+lib:: _dl_progname.h $(OBJS) $(DLINK_OBJS)
$(LD) $(LDFLAGS) -e _dl_boot -soname=$(UCLIBC_LDSO) \
-o $(LDSO_FULLNAME) $(OBJS) $(LIBGCC);
install -d $(TOPDIR)lib
install -m 755 $(LDSO_FULLNAME) $(TOPDIR)lib
(cd $(TOPDIR)lib && ln -sf $(LDSO_FULLNAME) $(UCLIBC_LDSO))
-ldso.h: Makefile
- echo "const char *_dl_progname=\""$(UCLIBC_LDSO)"\";" > ldso.h
- echo "#include \"$(TARGET_ARCH)/elfinterp.c\"" >> ldso.h
+_dl_progname.h: Makefile
+ echo "const char *_dl_progname=\""$(UCLIBC_LDSO)"\";" > _dl_progname.h
+ echo "#include \"$(TARGET_ARCH)/elfinterp.c\"" >> _dl_progname.h
$(COBJS): %.o : %.c
- $(CC) $(CFLAGS) $(XXFLAGS) -I. -I./$(TARGET_ARCH) -I../libdl -c $< -o $@
+ $(CC) $(XXFLAGS) -I../libdl -c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
$(AOBJS): %.o : %.S
- $(CC) $(CFLAGS) -I. -I./$(TARGET_ARCH) -I../libdl -c $< -o $@
+ $(CC) $(XXFLAGS) -I../libdl -c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
-ldso.o: ldso.c hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c \
- ld_hash.h ld_string.h ld_syscall.h ldso.h linuxelf.h
+ldso.o: ldso.c hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c _dl_progname.h
clean::
- $(RM) -f $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i ldso.h *~
+ $(RM) -f $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i _dl_progname.h *~
--- linuxelf.h DELETED ---
- Previous message: [uClibc-cvs] uClibc/ldso/libdl Makefile, 1.27, 1.28 dlib.c, 1.26, 1.27 dlfcn.h, 1.1, NONE
- Next message: [uClibc-cvs] uClibc/ldso/util Makefile, 1.32, 1.33 ldconfig.c, 1.9, 1.10
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the uClibc-cvs
mailing list