diff options
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | include/elf.h | 2 | ||||
-rw-r--r-- | ldso/Makefile | 24 | ||||
-rw-r--r-- | ldso/include/dl-string.h | 1 | ||||
-rw-r--r-- | ldso/ldso/dl-startup.c | 2 | ||||
-rw-r--r-- | ldso/ldso/sh/elfinterp.c | 77 | ||||
-rw-r--r-- | utils/Makefile | 14 |
7 files changed, 60 insertions, 63 deletions
@@ -102,6 +102,9 @@ Arch specific TODO: ldso needs to have lazy bindings checked pthread isn't working really at all (pthreads tests) + cris rfv nios nios2 sh64: + need to be updated to new ldso changes and unification of the + two uClibc_main funcs (__uClibc_start_main doesnt exist anymore) diff --git a/include/elf.h b/include/elf.h index e00969266..2b2aafde9 100644 --- a/include/elf.h +++ b/include/elf.h @@ -1910,7 +1910,7 @@ typedef Elf32_Addr Elf32_Conflict; #define LITUSE_ALPHA_TLS_LDM 5 /* Legal values for d_tag of Elf64_Dyn. */ -#define DT_ALPHA_PLTRO 0x70000000 +#define DT_ALPHA_PLTRO (DT_LOPROC + 0) #define DT_ALPHA_NUM 1 /* PowerPC specific declarations */ diff --git a/ldso/Makefile b/ldso/Makefile index f0d1ca56d..b7ce3625a 100644 --- a/ldso/Makefile +++ b/ldso/Makefile @@ -1,6 +1,6 @@ # Makefile for uClibc # -# Copyright (C) 2000-2004 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> # # This program 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 @@ -35,21 +35,21 @@ ldso libdl shared: echo "Skipping $@ target" endif -HEADERS = $(patsubst %, include/%, elf.h dl-startup.h dl-syscalls.h dl-sysdep.h dl-debug.h) -headers: $(HEADERS) include/dl-progname.h +LN_HEADERS := $(patsubst %, include/%, elf.h) +LN_ARCH_HEADERS := $(patsubst %, include/%, dl-startup.h dl-syscalls.h dl-sysdep.h dl-debug.h) +HEADERS := $(LN_HEADERS) $(LN_ARCH_HEADERS) include/dl-progname.h +headers: $(HEADERS) +$(LN_HEADERS): + $(LN) -fs $(TOPDIR)../$@ $@ +$(LN_ARCH_HEADERS): + $(LN) -fs ../ldso/$(TARGET_ARCH)/$(patsubst include/%,%,$@) $@ include/dl-progname.h: - echo "const char *_dl_progname=\""$(UCLIBC_LDSO)"\";" \ + echo 'const char *_dl_progname="$(UCLIBC_LDSO)";' \ > include/dl-progname.h - echo "#include \"$(TARGET_ARCH)/elfinterp.c\"" \ + echo '#include "$(TARGET_ARCH)/elfinterp.c"' \ >> include/dl-progname.h -$(HEADERS): - $(LN) -fs $(TOPDIR)../include/elf.h include/ - $(LN) -fs ../ldso/$(TARGET_ARCH)/dl-startup.h include/ - $(LN) -fs ../ldso/$(TARGET_ARCH)/dl-syscalls.h include/ - $(LN) -fs ../ldso/$(TARGET_ARCH)/dl-sysdep.h include/ - $(LN) -fs ../ldso/$(TARGET_ARCH)/dl-debug.h include/ clean: set -e ; for d in $(DIRS) ; do $(MAKE) -C $$d $@ ; done -find . -name '*~' | xargs $(RM) - $(RM) $(HEADERS) include/dl-progname.h + $(RM) $(HEADERS) diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h index 2e21a3dff..eea406435 100644 --- a/ldso/include/dl-string.h +++ b/ldso/include/dl-string.h @@ -281,6 +281,7 @@ static __always_inline char * _dl_simple_ltoahex(char * local, unsigned long i) || defined(__sh__) || defined(__powerpc__) # define CONSTANT_STRING_GOT_FIXUP(X) \ if ((X) < (const char *) load_addr) (X) += load_addr +# define NO_EARLY_SEND_STDERR #else # define CONSTANT_STRING_GOT_FIXUP(X) #endif diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c index 3c6ce48f5..c2686c733 100644 --- a/ldso/ldso/dl-startup.c +++ b/ldso/ldso/dl-startup.c @@ -136,12 +136,14 @@ static void * __attribute_used__ _dl_start(unsigned long args) aux_dat += argc; /* Skip over the argv pointers */ aux_dat++; /* Skip over NULL at end of argv */ envp = (char **) aux_dat; +#ifndef NO_EARLY_SEND_STDERR SEND_STDERR_DEBUG("argc="); SEND_NUMBER_STDERR_DEBUG(argc, 0); SEND_STDERR_DEBUG(" argv="); SEND_ADDRESS_STDERR_DEBUG(argv, 0); SEND_STDERR_DEBUG(" envp="); SEND_ADDRESS_STDERR_DEBUG(envp, 1); +#endif while (*aux_dat) aux_dat++; /* Skip over the envp pointers */ aux_dat++; /* Skip over NULL at end of envp */ diff --git a/ldso/ldso/sh/elfinterp.c b/ldso/ldso/sh/elfinterp.c index 393435bbb..3027a27f8 100644 --- a/ldso/ldso/sh/elfinterp.c +++ b/ldso/ldso/sh/elfinterp.c @@ -61,21 +61,19 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) symtab_index = ELF32_R_SYM(this_reloc->r_info); symtab = (Elf32_Sym *)(intptr_t) tpnt->dynamic_info[DT_SYMTAB]; - strtab = (char *) tpnt->dynamic_info[DT_STRTAB]; + strtab = (char *)tpnt->dynamic_info[DT_STRTAB]; symname = strtab + symtab[symtab_index].st_name; if (unlikely(reloc_type != R_SH_JMP_SLOT)) { - _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n", - _dl_progname); - _dl_exit(1); + _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n", + _dl_progname); + _dl_exit(1); } /* Address of jump instruction to fix up */ - instr_addr = ((unsigned long) this_reloc->r_offset + - (unsigned long) tpnt->loadaddr); + instr_addr = (unsigned long) (this_reloc->r_offset + tpnt->loadaddr); got_addr = (char **) instr_addr; - /* Get the address of the GOT entry */ new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT); if (unlikely(!new_addr)) { @@ -84,18 +82,15 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) } #if defined (__SUPPORT_LD_DEBUG__) - if ((unsigned long) got_addr < 0x20000000) - { - if (_dl_debug_bindings) - { + if ((unsigned long) got_addr < 0x20000000) { + if (_dl_debug_bindings) { _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname); if(_dl_debug_detail) _dl_dprintf(_dl_debug_file, "\n\tpatched %x ==> %x @ %x\n", *got_addr, new_addr, got_addr); } } - if (!_dl_debug_nofixups) { + if (!_dl_debug_nofixups) *got_addr = new_addr; - } #else *got_addr = new_addr; #endif @@ -123,25 +118,24 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, symtab = (Elf32_Sym *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB]; strtab = (char *)tpnt->dynamic_info[DT_STRTAB]; - for (i = 0; i < rel_size; i++, rpnt++) { - int res; + for (i = 0; i < rel_size; i++, rpnt++) { + int res; symtab_index = ELF32_R_SYM(rpnt->r_info); debug_sym(symtab,strtab,symtab_index); debug_reloc(symtab,strtab,rpnt); - res = reloc_fnc (tpnt, scope, rpnt, symtab, strtab); + res = reloc_fnc(tpnt, scope, rpnt, symtab, strtab); - if (res==0) continue; + if (res == 0) continue; _dl_dprintf(2, "\n%s: ",_dl_progname); if (symtab_index) - _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name); + _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name); - if (unlikely(res <0)) - { - int reloc_type = ELF32_R_TYPE(rpnt->r_info); + if (unlikely(res < 0)) { + int reloc_type = ELF32_R_TYPE(rpnt->r_info); #if defined (__SUPPORT_LD_DEBUG__) _dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type)); #else @@ -149,13 +143,12 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, #endif _dl_exit(-res); } - if (unlikely(res >0)) - { + if (unlikely(res > 0)) { _dl_dprintf(2, "can't resolve symbol\n"); return res; } - } - return 0; + } + return 0; } @@ -163,7 +156,7 @@ static int _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab) { - int reloc_type; + int reloc_type; int symtab_index; char *symname; unsigned long *reloc_addr; @@ -176,7 +169,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, reloc_type = ELF32_R_TYPE(rpnt->r_info); symtab_index = ELF32_R_SYM(rpnt->r_info); symbol_addr = 0; - symname = strtab + symtab[symtab_index].st_name; + symname = strtab + symtab[symtab_index].st_name; if (symtab_index) { symbol_addr = (unsigned long) _dl_find_hash(symname, scope, tpnt, @@ -188,17 +181,16 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, * here, so all bases should be covered. */ if (!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) { - _dl_dprintf (2, "%s: can't resolve symbol '%s'\n", - _dl_progname, strtab + symtab[symtab_index].st_name); + _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", + _dl_progname, strtab + symtab[symtab_index].st_name); _dl_exit (1); } } - #if defined (__SUPPORT_LD_DEBUG__) old_val = *reloc_addr; #endif - switch (reloc_type) { + switch (reloc_type) { case R_SH_NONE: break; case R_SH_COPY: @@ -226,7 +218,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, break; default: return -1; /*call _dl_exit(1) */ - } + } #if defined (__SUPPORT_LD_DEBUG__) if(_dl_debug_reloc && _dl_debug_detail) _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, *reloc_addr, reloc_addr); @@ -255,17 +247,17 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope, #if defined (__SUPPORT_LD_DEBUG__) old_val = *reloc_addr; #endif - switch (reloc_type) { - case R_SH_NONE: - break; - case R_SH_JMP_SLOT: - *reloc_addr += (unsigned long) tpnt->loadaddr; - break; - default: - return -1; /*call _dl_exit(1) */ - } + switch (reloc_type) { + case R_SH_NONE: + break; + case R_SH_JMP_SLOT: + *reloc_addr += (unsigned long) tpnt->loadaddr; + break; + default: + return -1; /*call _dl_exit(1) */ + } #if defined (__SUPPORT_LD_DEBUG__) - if(_dl_debug_reloc && _dl_debug_detail) + if(_dl_debug_reloc && _dl_debug_detail) _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, *reloc_addr, reloc_addr); #endif return 0; @@ -283,4 +275,3 @@ int _dl_parse_relocation_information(struct dyn_elf *rpnt, { return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc); } - diff --git a/utils/Makefile b/utils/Makefile index dec011780..fcd38fea4 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -43,28 +43,28 @@ headers: readelf.c ldconfig.c ldd.c: headers readelf: readelf.c - $(CC) $(CFLAGS) -Wl,-s $^ -o $@ - $(STRIPTOOL) -x -R .note -R .comment $@ + $(CC) $(CFLAGS) $^ -o $@ + $(STRIPTOOL) -s -x -R .note -R .comment $@ ldconfig: ldconfig.c - $(CC) $(CFLAGS) -Wl,-s $(if $(filter $(UCLIBC_STATIC_LDCONFIG),y),-static) \ + $(CC) $(CFLAGS) $(if $(filter $(UCLIBC_STATIC_LDCONFIG),y),-static) \ -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \ -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \ $^ -o $@ - $(STRIPTOOL) -x -R .note -R .comment $@ + $(STRIPTOOL) -s -x -R .note -R .comment $@ ldd: ldd.c - $(CC) $(CFLAGS) $(PIEFLAG) -Wl,-s \ + $(CC) $(CFLAGS) $(PIEFLAG) \ -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \ -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \ $^ -o $@ - $(STRIPTOOL) -x -R .note -R .comment $@ + $(STRIPTOOL) -s -x -R .note -R .comment $@ iconv: ../libc/misc/wchar/wchar.c $(CC) $(CFLAGS) $(PIEFLAG) -Wl,-s \ -DL_iconv_main \ $^ -o $@ - $(STRIPTOOL) -x -R .note -R .comment $@ + $(STRIPTOOL) -s -x -R .note -R .comment $@ ifeq ($(strip $(HAVE_SHARED)),y) hostutils: ldd.host ldconfig.host readelf.host |