summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-08-11 00:18:07 +0000
committerEric Andersen <andersen@codepoet.org>2001-08-11 00:18:07 +0000
commit29be1bc88c81f4068a75084ed48f18cb6b0bdbde (patch)
treee3926a73dc5f20b97e1f52071b8ebfccbd668168 /ldso
parent8f127c4f0a825156c28887733f31a7012e398655 (diff)
Begin removing some unnecessary inlining, and fix naming
of _dl_fprintf which should really be _dl_dprintf -Erik
Diffstat (limited to 'ldso')
-rw-r--r--ldso/ldso/arm/elfinterp.c32
-rw-r--r--ldso/ldso/boot1.c192
-rw-r--r--ldso/ldso/dl-elf.c24
-rw-r--r--ldso/ldso/i386/elfinterp.c30
-rw-r--r--ldso/ldso/ld-uClibc.c1309
-rw-r--r--ldso/ldso/ld_string.h66
-rw-r--r--ldso/ldso/ldso.c192
-rw-r--r--ldso/ldso/m68k/elfinterp.c34
-rw-r--r--ldso/ldso/powerpc/elfinterp.c54
-rw-r--r--ldso/ldso/readelflib1.c24
-rw-r--r--ldso/ldso/sparc/elfinterp.c42
-rw-r--r--ldso/ldso/string.h66
-rw-r--r--ldso/libdl/dlib.c24
-rw-r--r--ldso/libdl/libdl.c24
14 files changed, 270 insertions, 1843 deletions
diff --git a/ldso/ldso/arm/elfinterp.c b/ldso/ldso/arm/elfinterp.c
index 09b934a1a..f0c83a166 100644
--- a/ldso/ldso/arm/elfinterp.c
+++ b/ldso/ldso/arm/elfinterp.c
@@ -81,7 +81,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
if (reloc_type != R_ARM_JUMP_SLOT) {
- _dl_fprintf(2, "%s: Incorrect relocation type in jump relocations\n",
+ _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
_dl_progname);
_dl_exit(1);
};
@@ -92,7 +92,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
got_addr = (char **) instr_addr;
#ifdef DL_DEBUG
- _dl_fprintf(2, "Resolving symbol %s\n",
+ _dl_dprintf(2, "Resolving symbol %s\n",
strtab + symtab[symtab_index].st_name);
#endif
@@ -100,13 +100,13 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
new_addr = _dl_find_hash(strtab + symtab[symtab_index].st_name,
tpnt->symbol_scope, (unsigned long) got_addr, tpnt, 0);
if (!new_addr) {
- _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
#ifdef DL_DEBUG
if ((unsigned long) got_addr < 0x40000000) {
- _dl_fprintf(2, "Calling library function: %s\n",
+ _dl_dprintf(2, "Calling library function: %s\n",
strtab + symtab[symtab_index].st_name);
} else {
*got_addr = new_addr;
@@ -156,13 +156,13 @@ void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt,
*reloc_addr += (unsigned long) tpnt->loadaddr;
break;
default:
- _dl_fprintf(2, "%s: (LAZY) can't handle reloc type ",
+ _dl_dprintf(2, "%s: (LAZY) can't handle reloc type ",
_dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fprintf(2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_dprintf(2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
+ _dl_dprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
};
@@ -239,7 +239,7 @@ int _dl_parse_relocation_information(struct elf_resolve *tpnt,
* here, so all bases should be covered.
*/
if (!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) == STB_GLOBAL) {
- _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
}
@@ -267,7 +267,7 @@ int _dl_parse_relocation_information(struct elf_resolve *tpnt,
topbits = newvalue & 0xfe000000;
if (topbits != 0xfe000000 && topbits != 0x00000000)
{
- _dl_fprintf(2, "R_ARM_PC24 relocation out of range ");
+ _dl_dprintf(2, "R_ARM_PC24 relocation out of range ");
_dl_exit(1);
}
}
@@ -286,20 +286,20 @@ int _dl_parse_relocation_information(struct elf_resolve *tpnt,
case R_ARM_COPY:
#if 0
/* Do this later */
- _dl_fprintf(2, "Doing copy for symbol ");
- if (symtab_index) _dl_fprintf(2, strtab + symtab[symtab_index].st_name);
- _dl_fprintf(2, "\n");
+ _dl_dprintf(2, "Doing copy for symbol ");
+ if (symtab_index) _dl_dprintf(2, strtab + symtab[symtab_index].st_name);
+ _dl_dprintf(2, "\n");
_dl_memcpy((void *) symtab[symtab_index].st_value,
(void *) symbol_addr, symtab[symtab_index].st_size);
#endif
break;
default:
- _dl_fprintf(2, "%s: can't handle reloc type ", _dl_progname);
+ _dl_dprintf(2, "%s: can't handle reloc type ", _dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fprintf(2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_dprintf(2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
+ _dl_dprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
@@ -360,7 +360,7 @@ int _dl_parse_copy_information(struct dyn_elf *xpnt, unsigned long rel_addr,
symtab[symtab_index].st_name, xpnt->next,
(unsigned long) reloc_addr, NULL, 1);
if (!symbol_addr) {
- _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
};
diff --git a/ldso/ldso/boot1.c b/ldso/ldso/boot1.c
index 038a68dbb..43c89adbc 100644
--- a/ldso/ldso/boot1.c
+++ b/ldso/ldso/boot1.c
@@ -207,7 +207,7 @@ DL_BOOT(unsigned long args)
Elf32_auxv_t *auxv_entry = (Elf32_auxv_t*) aux_dat;
if (auxv_entry->a_type <= AT_EGID) {
- _dl_memcpy_inline(&(auxv_t[auxv_entry->a_type]),
+ _dl_memcpy(&(auxv_t[auxv_entry->a_type]),
auxv_entry, sizeof(Elf32_auxv_t));
}
aux_dat += 2;
@@ -221,7 +221,7 @@ DL_BOOT(unsigned long args)
/* Check the ELF header to make sure everything looks ok. */
if (! header || header->e_ident[EI_CLASS] != ELFCLASS32 ||
header->e_ident[EI_VERSION] != EV_CURRENT ||
- _dl_strncmp_inline((void *)header, ELFMAGIC, SELFMAG) != 0)
+ _dl_strncmp((void *)header, ELFMAGIC, SELFMAG) != 0)
{
SEND_STDERR("Invalid ELF header\n");
_dl_exit(0);
@@ -314,15 +314,15 @@ found_got:
}
tpnt = DL_MALLOC(sizeof(struct elf_resolve));
- _dl_memset_inline(tpnt, 0, sizeof(*tpnt));
+ _dl_memset(tpnt, 0, sizeof(*tpnt));
app_tpnt = DL_MALLOC(sizeof(struct elf_resolve));
- _dl_memset_inline(app_tpnt, 0, sizeof(*app_tpnt));
+ _dl_memset(app_tpnt, 0, sizeof(*app_tpnt));
/*
* This is used by gdb to locate the chain of shared libraries that are currently loaded.
*/
debug_addr = DL_MALLOC(sizeof(struct r_debug));
- _dl_memset_inline(debug_addr, 0, sizeof(*debug_addr));
+ _dl_memset(debug_addr, 0, sizeof(*debug_addr));
/* OK, that was easy. Next scan the DYNAMIC section of the image.
We are only doing ourself right now - we will have to do the rest later */
@@ -630,10 +630,10 @@ found_got:
if (!tpnt1) {
#ifdef DL_TRACE
if (_dl_trace_loaded_objects)
- _dl_fprintf(1, "\t%s => not found\n", str);
+ _dl_dprintf(1, "\t%s => not found\n", str);
else {
#endif
- _dl_fprintf(2, "%s: can't load "
+ _dl_dprintf(2, "%s: can't load "
"library '%s'\n", _dl_progname, str);
_dl_exit(15);
#ifdef DL_TRACE
@@ -646,7 +646,7 @@ found_got:
/* this is a real hack to make ldd not print
* the library itself when run on a library. */
if (_dl_strcmp(_dl_progname, str) != 0)
- _dl_fprintf(1, "\t%s => %s (0x%x)\n", str, tpnt1->libname,
+ _dl_dprintf(1, "\t%s => %s (0x%x)\n", str, tpnt1->libname,
(unsigned) tpnt1->loadaddr);
}
#endif
@@ -674,14 +674,14 @@ found_got:
if (!_dl_stat(LDSO_PRELOAD, &st) && st.st_size > 0) {
if ((fd = _dl_open(LDSO_PRELOAD, O_RDONLY)) < 0) {
- _dl_fprintf(2, "%s: can't open file '%s'\n",
+ _dl_dprintf(2, "%s: can't open file '%s'\n",
_dl_progname, LDSO_PRELOAD);
} else {
preload = (caddr_t) _dl_mmap(0, st.st_size + 1,
PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
_dl_close(fd);
if (preload == (caddr_t) - 1) {
- _dl_fprintf(2, "%s: can't map file '%s'\n",
+ _dl_dprintf(2, "%s: can't map file '%s'\n",
_dl_progname, LDSO_PRELOAD);
} else {
char c, *cp, *cp2;
@@ -714,10 +714,10 @@ found_got:
if (!tpnt1) {
#ifdef DL_TRACE
if (_dl_trace_loaded_objects)
- _dl_fprintf(1, "\t%s => not found\n", cp2);
+ _dl_dprintf(1, "\t%s => not found\n", cp2);
else {
#endif
- _dl_fprintf(2, "%s: can't load library '%s'\n",
+ _dl_dprintf(2, "%s: can't load library '%s'\n",
_dl_progname, cp2);
_dl_exit(15);
#ifdef DL_TRACE
@@ -727,7 +727,7 @@ found_got:
#ifdef DL_TRACE
if (_dl_trace_loaded_objects
&& !tpnt1->usage_count) {
- _dl_fprintf(1, "\t%s => %s (0x%x)\n", cp2,
+ _dl_dprintf(1, "\t%s => %s (0x%x)\n", cp2,
tpnt1->libname, (unsigned) tpnt1->loadaddr);
}
#endif
@@ -766,7 +766,7 @@ found_got:
#ifdef DL_TRACE
if (_dl_trace_loaded_objects && !tpnt->usage_count) {
- _dl_fprintf(1, "\t%s => %s (0x%x)\n",
+ _dl_dprintf(1, "\t%s => %s (0x%x)\n",
lpnt, tpnt->libname, (unsigned) tpnt->loadaddr);
}
#endif
@@ -789,10 +789,10 @@ found_got:
if (!(tpnt1 = _dl_load_shared_library(0, tcurr, lpnt))) {
#ifdef DL_TRACE
if (_dl_trace_loaded_objects)
- _dl_fprintf(1, "\t%s => not found\n", lpnt);
+ _dl_dprintf(1, "\t%s => not found\n", lpnt);
else {
#endif
- _dl_fprintf(2, "%s: can't load library '%s'\n",
+ _dl_dprintf(2, "%s: can't load library '%s'\n",
_dl_progname, lpnt);
_dl_exit(16);
#ifdef DL_TRACE
@@ -801,7 +801,7 @@ found_got:
} else {
#ifdef DL_TRACE
if (_dl_trace_loaded_objects && !tpnt1->usage_count)
- _dl_fprintf(1, "\t%s => %s (0x%x)\n", lpnt, tpnt1->libname,
+ _dl_dprintf(1, "\t%s => %s (0x%x)\n", lpnt, tpnt1->libname,
(unsigned) tpnt1->loadaddr);
#endif
rpnt->next = (struct dyn_elf *)
@@ -955,13 +955,13 @@ found_got:
#undef DL_DEBUG
#ifdef DL_DEBUG
else {
- _dl_fprintf(2, tpnt->libname);
- _dl_fprintf(2, ": ");
+ _dl_dprintf(2, tpnt->libname);
+ _dl_dprintf(2, ": ");
if (!_dl_atexit)
- _dl_fprintf(2, "The address is atexit () is 0x0.");
+ _dl_dprintf(2, "The address is atexit () is 0x0.");
if (!tpnt->dynamic_info[DT_FINI])
- _dl_fprintf(2, "Invalid .fini section.");
- _dl_fprintf(2, "\n");
+ _dl_dprintf(2, "Invalid .fini section.");
+ _dl_dprintf(2, "\n");
}
#endif
#undef DL_DEBUG
@@ -996,7 +996,7 @@ int _dl_fixup(struct elf_resolve *tpnt)
goof += _dl_fixup(tpnt->next);
if (tpnt->dynamic_info[DT_REL]) {
#ifdef ELF_USES_RELOCA
- _dl_fprintf(2, "%s: can't handle REL relocation records\n",
+ _dl_dprintf(2, "%s: can't handle REL relocation records\n",
_dl_progname);
_dl_exit(17);
#else
@@ -1015,7 +1015,7 @@ int _dl_fixup(struct elf_resolve *tpnt)
goof += _dl_parse_relocation_information(tpnt,
tpnt->dynamic_info[DT_RELA], tpnt->dynamic_info[DT_RELASZ], 0);
#else
- _dl_fprintf(2, "%s: can't handle RELA relocation records\n",
+ _dl_dprintf(2, "%s: can't handle RELA relocation records\n",
_dl_progname);
_dl_exit(18);
#endif
@@ -1054,7 +1054,7 @@ void *_dl_malloc(int size)
_dl_mmap_zero = _dl_malloc_addr = _dl_mmap((void *) 0, size,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
if (_dl_mmap_check_error(_dl_mmap_zero)) {
- _dl_fprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
+ _dl_dprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
_dl_exit(20);
}
}
@@ -1113,144 +1113,8 @@ char *_dl_strdup(const char *string)
return retval;
}
-char *_dl_get_last_path_component(char *path)
-{
- char *s;
-
- s=path+_dl_strlen(path)-1;
-
- /* strip trailing slashes */
- while (s != path && *s == '/') {
- *s-- = '\0';
- }
-
- /* find last component */
- s = _dl_strrchr(path, '/');
- if (s == NULL || s[1] == '\0')
- return path;
- else
- return s+1;
-}
-
-size_t _dl_strlen(const char * str)
-{
- register char *ptr = (char *) str;
-
- while (*ptr)
- ptr++;
- return (ptr - str);
-}
-
-char * _dl_strcpy(char * dst,const char *src)
-{
- register char *ptr = dst;
-
- while (*src)
- *dst++ = *src++;
- *dst = '\0';
-
- return ptr;
-}
-
-int _dl_strcmp(const char * s1,const char * s2)
-{
- unsigned register char c1, c2;
-
- do {
- c1 = (unsigned char) *s1++;
- c2 = (unsigned char) *s2++;
- if (c1 == '\0')
- return c1 - c2;
- }
- while (c1 == c2);
-
- return c1 - c2;
-}
-
-int _dl_strncmp(const char * s1,const char * s2,size_t len)
-{
- unsigned register char c1 = '\0';
- unsigned register char c2 = '\0';
-
- while (len > 0) {
- c1 = (unsigned char) *s1++;
- c2 = (unsigned char) *s2++;
- if (c1 == '\0' || c1 != c2)
- return c1 - c2;
- len--;
- }
-
- return c1 - c2;
-}
-
-char * _dl_strchr(const char * str,int c)
-{
- register char ch;
-
- do {
- if ((ch = *str) == c)
- return (char *) str;
- str++;
- }
- while (ch);
-
- return 0;
-}
-
-char *_dl_strrchr(const char *str, int c)
-{
- register char *prev = 0;
- register char *ptr = (char *) str;
-
- while (*ptr != '\0') {
- if (*ptr == c)
- prev = ptr;
- ptr++;
- }
- if (c == '\0')
- return(ptr);
- return(prev);
-}
-
-void * _dl_memcpy(void * dst, const void * src, size_t len)
-{
- register char *a = dst;
- register const char *b = src;
-
- while (len--)
- *a++ = *b++;
-
- return dst;
-}
-
-#ifdef USE_CACHE
-int _dl_memcmp(const void * s1,const void * s2,size_t len)
-{
- unsigned char *c1 = (unsigned char *)s1;
- unsigned char *c2 = (unsigned char *)s2;
-
- while (len--) {
- if (*c1 != *c2)
- return *c1 - *c2;
- c1++;
- c2++;
- }
- return 0;
-}
-#endif
-
-void * _dl_memset(void * str,int c,size_t len)
-{
- register char *a = str;
-
- while (len--)
- *a++ = c;
-
- return str;
-}
-
/* Minimum printf which handles only characters, %d's and %s's */
-void _dl_fprintf(int fd, const char *fmt, ...)
+void _dl_dprintf(int fd, const char *fmt, ...)
{
int num;
va_list args;
@@ -1294,7 +1158,7 @@ void _dl_fprintf(int fd, const char *fmt, ...)
{
char tmp[13];
num = va_arg(args, int);
- string = _dl_simple_ltoa_inline(tmp, num);
+ string = _dl_simple_ltoa(tmp, num);
_dl_write(fd, string, _dl_strlen(string));
break;
}
@@ -1303,7 +1167,7 @@ void _dl_fprintf(int fd, const char *fmt, ...)
{
char tmp[13];
num = va_arg(args, int);
- string = _dl_simple_ltoahex_inline(tmp, num);
+ string = _dl_simple_ltoahex(tmp, num);
_dl_write(fd, string, _dl_strlen(string));
break;
}
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index ebc9bc8dc..75acde927 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -54,7 +54,7 @@ int _dl_map_cache(void)
if (_dl_stat(LDSO_CACHE, &st)
|| (fd = _dl_open(LDSO_CACHE, O_RDONLY)) < 0) {
- _dl_fprintf(2, "%s: can't open cache '%s'\n", _dl_progname, LDSO_CACHE);
+ _dl_dprintf(2, "%s: can't open cache '%s'\n", _dl_progname, LDSO_CACHE);
_dl_cache_addr = (caddr_t) - 1; /* so we won't try again */
return -1;
}
@@ -63,7 +63,7 @@ int _dl_map_cache(void)
_dl_cache_addr = (caddr_t) _dl_mmap(0, _dl_cache_size, PROT_READ, MAP_SHARED, fd, 0);
_dl_close(fd);
if (_dl_cache_addr == (caddr_t) - 1) {
- _dl_fprintf(2, "%s: can't map cache '%s'\n",
+ _dl_dprintf(2, "%s: can't map cache '%s'\n",
_dl_progname, LDSO_CACHE);
return -1;
}
@@ -77,7 +77,7 @@ int _dl_map_cache(void)
(sizeof(header_t) + header->nlibs * sizeof(libentry_t))
|| _dl_cache_addr[_dl_cache_size - 1] != '\0')
{
- _dl_fprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname,
+ _dl_dprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname,
LDSO_CACHE);
goto fail;
}
@@ -90,7 +90,7 @@ int _dl_map_cache(void)
if (libent[i].sooffset >= strtabsize ||
libent[i].liboffset >= strtabsize)
{
- _dl_fprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname, LDSO_CACHE);
+ _dl_dprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname, LDSO_CACHE);
goto fail;
}
}
@@ -387,7 +387,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
* NO! When we open shared libraries we may search several paths.
* it is inappropriate to generate an error here.
*/
- _dl_fprintf(2, "%s: can't open '%s'\n", _dl_progname, libname);
+ _dl_dprintf(2, "%s: can't open '%s'\n", _dl_progname, libname);
#endif
_dl_internal_error_number = DL_ERROR_NOFILE;
return NULL;
@@ -400,7 +400,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
epnt->e_ident[2] != 'L' ||
epnt->e_ident[3] != 'F')
{
- _dl_fprintf(2, "%s: '%s' is not an ELF file\n", _dl_progname,
+ _dl_dprintf(2, "%s: '%s' is not an ELF file\n", _dl_progname,
libname);
_dl_internal_error_number = DL_ERROR_NOTELF;
_dl_close(infile);
@@ -415,7 +415,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
{
_dl_internal_error_number =
(epnt->e_type != ET_DYN ? DL_ERROR_NOTDYN : DL_ERROR_NOTMAGIC);
- _dl_fprintf(2, "%s: '%s' is not an ELF executable for " ELF_TARGET
+ _dl_dprintf(2, "%s: '%s' is not an ELF executable for " ELF_TARGET
"\n", _dl_progname, libname);
_dl_close(infile);
return NULL;
@@ -428,7 +428,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
if (ppnt->p_type == PT_DYNAMIC) {
if (dynamic_addr)
- _dl_fprintf(2, "%s: '%s' has more than one dynamic section\n",
+ _dl_dprintf(2, "%s: '%s' has more than one dynamic section\n",
_dl_progname, libname);
dynamic_addr = ppnt->p_vaddr;
dynamic_size = ppnt->p_filesz;
@@ -460,7 +460,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
status = (char *) _dl_mmap((char *) (piclib ? 0 : minvma),
maxvma - minvma, PROT_NONE, flags | MAP_ANONYMOUS, -1, 0);
if (_dl_mmap_check_error(status)) {
- _dl_fprintf(2, "%s: can't map '/dev/zero'\n", _dl_progname);
+ _dl_dprintf(2, "%s: can't map '/dev/zero'\n", _dl_progname);
_dl_internal_error_number = DL_ERROR_MMAP_FAILED;
_dl_close(infile);
return NULL;
@@ -492,7 +492,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
ppnt->p_offset & 0x7ffff000);
if (_dl_mmap_check_error(status)) {
- _dl_fprintf(2, "%s: can't map '%s'\n",
+ _dl_dprintf(2, "%s: can't map '%s'\n",
_dl_progname, libname);
_dl_internal_error_number = DL_ERROR_MMAP_FAILED;
_dl_munmap((char *) libaddr, maxvma - minvma);
@@ -524,7 +524,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
ppnt->p_filesz, LXFLAGS(ppnt->p_flags), flags,
infile, ppnt->p_offset & 0x7ffff000);
if (_dl_mmap_check_error(status)) {
- _dl_fprintf(2, "%s: can't map '%s'\n", _dl_progname, libname);
+ _dl_dprintf(2, "%s: can't map '%s'\n", _dl_progname, libname);
_dl_internal_error_number = DL_ERROR_MMAP_FAILED;
_dl_munmap((char *) libaddr, maxvma - minvma);
_dl_close(infile);
@@ -554,7 +554,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
if (!dynamic_addr) {
_dl_internal_error_number = DL_ERROR_NODYNAMIC;
- _dl_fprintf(2, "%s: '%s' is missing a dynamic section\n",
+ _dl_dprintf(2, "%s: '%s' is missing a dynamic section\n",
_dl_progname, libname);
return NULL;
}
diff --git a/ldso/ldso/i386/elfinterp.c b/ldso/ldso/i386/elfinterp.c
index 56b18ceb8..621272bee 100644
--- a/ldso/ldso/i386/elfinterp.c
+++ b/ldso/ldso/i386/elfinterp.c
@@ -74,7 +74,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
if (reloc_type != R_386_JMP_SLOT) {
- _dl_fprintf(2, "%s: Incorrect relocation type in jump relocations\n",
+ _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
_dl_progname);
_dl_exit(1);
};
@@ -85,7 +85,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
got_addr = (char **) instr_addr;
#ifdef DEBUG
- _dl_fprintf(2, "Resolving symbol %s\n",
+ _dl_dprintf(2, "Resolving symbol %s\n",
strtab + symtab[symtab_index].st_name);
#endif
@@ -93,14 +93,14 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
new_addr = _dl_find_hash(strtab + symtab[symtab_index].st_name,
tpnt->symbol_scope, (unsigned long) got_addr, tpnt, 0);
if (!new_addr) {
- _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
/* #define DEBUG_LIBRARY */
#ifdef DEBUG_LIBRARY
if ((unsigned long) got_addr < 0x40000000) {
- _dl_fprintf(2, "Calling library function: %s\n",
+ _dl_dprintf(2, "Calling library function: %s\n",
strtab + symtab[symtab_index].st_name);
} else {
*got_addr = new_addr;
@@ -150,13 +150,13 @@ void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt,
*reloc_addr += (unsigned long) tpnt->loadaddr;
break;
default:
- _dl_fprintf(2, "%s: (LAZY) can't handle reloc type ",
+ _dl_dprintf(2, "%s: (LAZY) can't handle reloc type ",
_dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fprintf(2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_dprintf(2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
+ _dl_dprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
};
@@ -209,7 +209,7 @@ int _dl_parse_relocation_information(struct elf_resolve *tpnt,
*/
if (!symbol_addr &&
ELF32_ST_BIND(symtab[symtab_index].st_info) == STB_GLOBAL) {
- _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
}
@@ -233,20 +233,20 @@ int _dl_parse_relocation_information(struct elf_resolve *tpnt,
case R_386_COPY:
#if 0
/* Do this later */
- _dl_fprintf(2, "Doing copy for symbol ");
- if (symtab_index) _dl_fprintf(2, strtab + symtab[symtab_index].st_name);
- _dl_fprintf(2, "\n");
+ _dl_dprintf(2, "Doing copy for symbol ");
+ if (symtab_index) _dl_dprintf(2, strtab + symtab[symtab_index].st_name);
+ _dl_dprintf(2, "\n");
_dl_memcpy((void *) symtab[symtab_index].st_value,
(void *) symbol_addr, symtab[symtab_index].st_size);
#endif
break;
default:
- _dl_fprintf(2, "%s: can't handle reloc type ", _dl_progname);
+ _dl_dprintf(2, "%s: can't handle reloc type ", _dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fprintf(2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_dprintf(2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
+ _dl_dprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
@@ -307,7 +307,7 @@ int _dl_parse_copy_information(struct dyn_elf *xpnt, unsigned long rel_addr,
symtab[symtab_index].st_name, xpnt->next,
(unsigned long) reloc_addr, NULL, 1);
if (!symbol_addr) {
- _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
};
diff --git a/ldso/ldso/ld-uClibc.c b/ldso/ldso/ld-uClibc.c
deleted file mode 100644
index cbf6b1aae..000000000
--- a/ldso/ldso/ld-uClibc.c
+++ /dev/null
@@ -1,1309 +0,0 @@
-/* Run an ELF binary on a linux system.
-
- Copyright (C) 1993-1996, Eric Youngdale.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
-
-/* Program to load an ELF binary on a linux system, and run it.
- * References to symbols in sharable libraries can be resolved by
- * an ELF sharable library. */
-
-/* Disclaimer: I have never seen any AT&T source code for SVr4, nor have
- I ever taken any courses on internals. This program was developed using
- information available through the book "UNIX SYSTEM V RELEASE 4,
- Programmers guide: Ansi C and Programming Support Tools", which did
- a more than adequate job of explaining everything required to get this
- working. */
-
-/*
- * The main trick with this program is that initially, we ourselves are not
- * dynamicly linked. This means that we cannot access any global variables
- * since the GOT is initialized by the linker assuming a virtual address of 0,
- * and we cannot call any functions since the PLT is not initialized at all
- * (it will tend to want to call the dynamic linker
- *
- * There are further restrictions - we cannot use large switch statements,
- * since the compiler generates tables of addresses and jumps through them.
- * We can use inline functions, because these do not transfer control to
- * a new address, but they must be static so that they are not exported
- * from the modules. We cannot use normal syscall stubs, because these
- * all reference the errno global variable which is not yet initialized.
- * We can use all of the local stack variables that we want, since these
- * are all referenced to %ebp or %esp.
- *
- * Life is further complicated by the fact that initially we do not want
- * to do a complete dynamic linking. We want to allow the user to supply
- * new functions replacing some of the library versions, and until we have
- * the list of modules that we should search set up, we do not want to do
- * any of this. Thus I have chosen to only perform the relocations for
- * variables that start with "_dl_" since ANSI specifies that the user is
- * not supposed to redefine any of these variables.
- *
- * Fortunately, the linker itself leaves a few clues lying around, and
- * when the kernel starts the image, there are a few further clues.
- * First of all, there is information buried on the stack that the kernel
- * leaves, which includes information about the load address that the
- * program interpreter was loaded at, the number of sections, the address
- * the application was loaded at and so forth. Here this information
- * is stored in the array dl_info, and the indicies are taken from the
- * file /usr/include/sys/auxv.h on any SVr4 system.
- *
- * The linker itself leaves a pointer to the .dynamic section in the first
- * slot of the GOT, and as it turns out, %ebx points to ghe GOT when
- * you are using PIC code, so we just dereference this to get the address
- * of the dynamic sections.
- *
- * Typically you must load all text pages as writable so that dynamic linking
- * can succeed. The kernel under SVr4 loads these as R/O, so we must call
- * mprotect to change the protections. Once we are done, we should set these
- * back again, so the desired behavior is achieved. Under linux there is
- * currently no mprotect function in the distribution kernel (although
- * someone has alpha patches), so for now everything is loaded writable.
- *
- * We do not have access to malloc and friends at the initial stages of dynamic
- * linking, and it would be handy to have some scratchpad memory available for
- * use as we set things up. We mmap one page of scratch space, and have a
- * simple _dl_malloc that uses this memory. This is a good thing, since we do
- * not want to use the same memory pool as malloc anyway - esp if the user
- * redefines malloc to do something funky.
- *
- * Our first task is to perform a minimal linking so that we can call other
- * portions of the dynamic linker. Once we have done this, we then build
- * the list of modules that the application requires, using LD_LIBRARY_PATH
- * if this is not a suid program (/usr/lib otherwise). Once this is done,
- * we can do the dynamic linking as required (and we must omit the things
- * we did to get the dynamic linker up and running in the first place.
- * After we have done this, we just have a few housekeeping chores and we
- * can transfer control to the user's application.
- */
-
-#include <stdarg.h>
-#include "sysdep.h" /* before elf.h to get ELF_USES_RELOCA right */
-#include <elf.h>
-#include "linuxelf.h"
-#include "hash.h"
-#include "syscall.h"
-#include "string.h"
-#include "../config.h"
-
-#define ALLOW_ZERO_PLTGOT
-
-/* Some arches may need to override this in boot1_arch.h */
-#define ELFMAGIC ELFMAG
-
-/* This is a poor man's malloc, used prior to resolving our internal poor man's malloc */
-#define DL_MALLOC(SIZE) ((void *) (malloc_buffer += SIZE, malloc_buffer - SIZE)) ; REALIGN();
-/*
- * Make sure that the malloc buffer is aligned on 4 byte boundary. For 64 bit
- * platforms we may need to increase this to 8, but this is good enough for
- * now. This is typically called after DL_MALLOC.
- */
-#define REALIGN() malloc_buffer = (char *) (((unsigned long) malloc_buffer + 3) & ~(3))
-
-static char *_dl_malloc_addr, *_dl_mmap_zero;
-char *_dl_library_path = 0; /* Where we look for libraries */
-char *_dl_preload = 0; /* Things to be loaded before the libs. */
-#include "ld.so.h" /* Pull in the name of ld.so */
-const char *_dl_progname=_dl_static_progname;
-static char *_dl_not_lazy = 0;
-#ifdef DL_TRACE
-static char *_dl_trace_loaded_objects = 0;
-#endif
-static int (*_dl_elf_main) (int, char **, char **);
-static int (*_dl_elf_init) (void);
-void *(*_dl_malloc_function) (int size) = NULL;
-struct r_debug *_dl_debug_addr = NULL;
-unsigned long *_dl_brkp;
-unsigned long *_dl_envp;
-char *_dl_getenv(char *symbol, char **envp);
-void _dl_unsetenv(char *symbol, char **envp);
-int _dl_fixup(struct elf_resolve *tpnt);
-void _dl_debug_state(void);
-char *_dl_get_last_path_component(char *path);
-
-#include "boot1_arch.h"
-
-
-/* When we enter this piece of code, the program stack looks like this:
- argc argument counter (integer)
- argv[0] program name (pointer)
- argv[1...N] program args (pointers)
- argv[argc-1] end of args (integer)
- NULL
- env[0...N] environment variables (pointers)
- NULL
- auxv_t[0...N] Auxiliary Vector Table elements (mixed types)
-*/
-
-DL_BOOT(unsigned long args)
-{
- unsigned int argc;
- char **argv, **envp;
- unsigned long load_addr;
- unsigned long *got;
- unsigned long *aux_dat;
- int goof = 0;
- elfhdr *header;
- struct elf_resolve *tpnt;
- struct dyn_elf *rpnt;
- struct elf_resolve *app_tpnt;
- unsigned long brk_addr;
- Elf32_auxv_t auxv_t[AT_EGID + 1];
- unsigned char *malloc_buffer, *mmap_zero;
- int (*_dl_atexit) (void *);
- unsigned long *lpnt;
- Elf32_Dyn *dpnt;
- unsigned long *hash_addr;
- struct r_debug *debug_addr;
- unsigned long *chains;
- int indx;
- int _dl_secure;
- int status;
-
-
- /* WARNING! -- we cannot make _any_ funtion calls until we have
- * taken care of fixing up our own relocations. Making static
- * lnline calls is ok, but _no_ function calls. Not yet
- * anyways. */
-
- /* First obtain the information on the stack that tells us more about
- what binary is loaded, where it is loaded, etc, etc */
- GET_ARGV(aux_dat,args);
-#if defined(__arm__)
- aux_dat+=1;
-#endif
- argc = *(aux_dat - 1);
- argv = (char **) aux_dat;
- aux_dat += argc; /* Skip over the argv pointers */
- aux_dat++; /* Skip over NULL at end of argv */
- envp = (char **) aux_dat;
- while (*aux_dat)
- aux_dat++; /* Skip over the envp pointers */
- aux_dat++; /* Skip over NULL at end of envp */
-
- /* Place -1 here as a checkpoint. We later check if it was changed
- * when we read in the auxv_t */
- auxv_t[AT_UID].a_type = -1;
-
- /* The junk on the stack immediately following the environment is
- * the Auxiliary Vector Table. Read out the elements of the auxv_t,
- * sort and store them in auxv_t for later use. */
- while (*aux_dat)
- {
- Elf32_auxv_t *auxv_entry = (Elf32_auxv_t*) aux_dat;
-
- if (auxv_entry->a_type <= AT_EGID) {
- _dl_memcpy_inline(&(auxv_t[auxv_entry->a_type]),
- auxv_entry, sizeof(Elf32_auxv_t));
- }
- aux_dat += 2;
- }
-
- /* locate the ELF header. We need this done as soon as possible
- * (esp since SEND_STDERR() needs this on some platforms... */
- load_addr = auxv_t[AT_BASE].a_un.a_val;
- header = (elfhdr *) auxv_t[AT_BASE].a_un.a_ptr;
-
- /* Check the ELF header to make sure everything looks ok. */
- if (! header || header->e_ident[EI_CLASS] != ELFCLASS32 ||
- header->e_ident[EI_VERSION] != EV_CURRENT ||
- _dl_strncmp_inline((void *)header, ELFMAGIC, SELFMAG) != 0)
- {
- SEND_STDERR("Invalid ELF header\n");
- _dl_exit(0);
- }
-#ifdef DL_DEBUG
- SEND_STDERR("ELF header =");
- SEND_ADDRESS_STDERR(load_addr, 1);