LDSO_FULLNAME=ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so
TARGET_CFLAGS+=-fPIC -D__PIC__ -DUCLIBC_ROOT_DIR=\"$(DEVEL_PREFIX)\" -DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR); pwd)\"
-CSRC= boot1.c hash.c readelflib1.c vsprintf.c $(TARGET_ARCH)/elfinterp.c
+CSRC= boot1.c hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
ASRC=$(shell ls $(TARGET_ARCH)/*.S)
AOBJS=$(patsubst %.S,%.o, $(ASRC))
strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
if (reloc_type != R_ARM_JUMP_SLOT) {
- _dl_fdprintf(2, "%s: Incorrect relocation type in jump relocations\n",
+ _dl_fprintf(2, "%s: Incorrect relocation type in jump relocations\n",
_dl_progname);
_dl_exit(1);
};
got_addr = (char **) instr_addr;
#ifdef DL_DEBUG
- _dl_fdprintf(2, "Resolving symbol %s\n",
+ _dl_fprintf(2, "Resolving symbol %s\n",
strtab + symtab[symtab_index].st_name);
#endif
new_addr = _dl_find_hash(strtab + symtab[symtab_index].st_name,
tpnt->symbol_scope, (unsigned long) got_addr, tpnt, 0);
if (!new_addr) {
- _dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf(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_fdprintf(2, "Calling library function: %s\n",
+ _dl_fprintf(2, "Calling library function: %s\n",
strtab + symtab[symtab_index].st_name);
} else {
*got_addr = new_addr;
*reloc_addr += (unsigned long) tpnt->loadaddr;
break;
default:
- _dl_fdprintf(2, "%s: (LAZY) can't handle reloc type ",
+ _dl_fprintf(2, "%s: (LAZY) can't handle reloc type ",
_dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fdprintf(2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_fprintf(2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fdprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
+ _dl_fprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
};
* here, so all bases should be covered.
*/
if (!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) == STB_GLOBAL) {
- _dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
}
topbits = newvalue & 0xfe000000;
if (topbits != 0xfe000000 && topbits != 0x00000000)
{
- _dl_fdprintf(2, "R_ARM_PC24 relocation out of range ");
+ _dl_fprintf(2, "R_ARM_PC24 relocation out of range ");
_dl_exit(1);
}
}
case R_ARM_COPY:
#if 0
/* Do this later */
- _dl_fdprintf(2, "Doing copy for symbol ");
- if (symtab_index) _dl_fdprintf(2, strtab + symtab[symtab_index].st_name);
- _dl_fdprintf(2, "\n");
+ _dl_fprintf(2, "Doing copy for symbol ");
+ if (symtab_index) _dl_fprintf(2, strtab + symtab[symtab_index].st_name);
+ _dl_fprintf(2, "\n");
_dl_memcpy((void *) symtab[symtab_index].st_value,
(void *) symbol_addr, symtab[symtab_index].st_size);
#endif
break;
default:
- _dl_fdprintf(2, "%s: can't handle reloc type ", _dl_progname);
+ _dl_fprintf(2, "%s: can't handle reloc type ", _dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fdprintf(2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_fprintf(2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fdprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
+ _dl_fprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
symtab[symtab_index].st_name, xpnt->next,
(unsigned long) reloc_addr, NULL, 1);
if (!symbol_addr) {
- _dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
};
#include "ld.so.h" /* Pull in the name of ld.so */
const char *_dl_progname=_dl_static_progname;
static char *_dl_not_lazy = 0;
-static char *_dl_warn = 0; /* Used by ldd */
+#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;
aux_dat += 2;
}
- /* locate the ELF header. We need this done as easly as possible
+ /* 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;
}
}
+#ifdef DL_TRACE
_dl_trace_loaded_objects = _dl_getenv("LD_TRACE_LOADED_OBJECTS", envp);
-
+#endif
/* OK, we now have the application in the list, and we have some
basic stuff in place. Now search through the list for other shared
libraries that should be loaded, and insert them on the list in the
{
tpnt1 = _dl_load_shared_library(_dl_secure, NULL, str);
if (!tpnt1) {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects)
- _dl_fdprintf(1, "\t%s => not found\n", str);
+ _dl_fprintf(1, "\t%s => not found\n", str);
else {
- _dl_fdprintf(2, "%s: can't load "
+#endif
+ _dl_fprintf(2, "%s: can't load "
"library '%s'\n", _dl_progname, str);
_dl_exit(15);
+#ifdef DL_TRACE
}
+#endif
} else {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects
&& !tpnt1->usage_count) {
/* 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_fdprintf(1, "\t%s => %s (0x%x)\n", str, tpnt1->libname,
+ _dl_fprintf(1, "\t%s => %s (0x%x)\n", str, tpnt1->libname,
(unsigned) tpnt1->loadaddr);
}
+#endif
rpnt->next = (struct dyn_elf *)
_dl_malloc(sizeof(struct dyn_elf));
_dl_memset(rpnt->next, 0, sizeof(*(rpnt->next)));
if (!_dl_stat(LDSO_PRELOAD, &st)) {
if ((fd = _dl_open(LDSO_PRELOAD, O_RDONLY)) < 0) {
- _dl_fdprintf(2, "%s: can't open file '%s'\n",
+ _dl_fprintf(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_fdprintf(2, "%s: can't map file '%s'\n",
+ _dl_fprintf(2, "%s: can't map file '%s'\n",
_dl_progname, LDSO_PRELOAD);
} else {
char c, *cp, *cp2;
tpnt1 = _dl_load_shared_library(0, NULL, cp2);
if (!tpnt1) {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects)
- _dl_fdprintf(1, "\t%s => not found\n", cp2);
+ _dl_fprintf(1, "\t%s => not found\n", cp2);
else {
- _dl_fdprintf(2, "%s: can't load library '%s'\n",
+#endif
+ _dl_fprintf(2, "%s: can't load library '%s'\n",
_dl_progname, cp2);
_dl_exit(15);
- }
+#ifdef DL_TRACE
+ }
+#endif
} else {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects
&& !tpnt1->usage_count) {
- _dl_fdprintf(1, "\t%s => %s (0x%x)\n", cp2,
+ _dl_fprintf(1, "\t%s => %s (0x%x)\n", cp2,
tpnt1->libname, (unsigned) tpnt1->loadaddr);
}
+#endif
rpnt->next = (struct dyn_elf *)
_dl_malloc(sizeof(struct dyn_elf));
_dl_memset(rpnt->next, 0,
_dl_get_last_path_component(tpnt->libname)) == 0) {
struct elf_resolve *ttmp;
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects && !tpnt->usage_count) {
- _dl_fdprintf(1, "\t%s => %s (0x%x)\n",
+ _dl_fprintf(1, "\t%s => %s (0x%x)\n",
lpnt, tpnt->libname, (unsigned) tpnt->loadaddr);
}
+#endif
ttmp = _dl_loaded_modules;
while (ttmp->next)
ttmp = ttmp->next;
continue;
}
if (!(tpnt1 = _dl_load_shared_library(0, tcurr, lpnt))) {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects)
- _dl_fdprintf(1, "\t%s => not found\n", lpnt);
+ _dl_fprintf(1, "\t%s => not found\n", lpnt);
else {
- _dl_fdprintf(2, "%s: can't load library '%s'\n",
+#endif
+ _dl_fprintf(2, "%s: can't load library '%s'\n",
_dl_progname, lpnt);
_dl_exit(16);
+#ifdef DL_TRACE
}
+#endif
} else {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects && !tpnt1->usage_count)
- _dl_fdprintf(1, "\t%s => %s (0x%x)\n", lpnt, tpnt1->libname,
+ _dl_fprintf(1, "\t%s => %s (0x%x)\n", lpnt, tpnt1->libname,
(unsigned) tpnt1->loadaddr);
+#endif
rpnt->next = (struct dyn_elf *)
_dl_malloc(sizeof(struct dyn_elf));
_dl_memset(rpnt->next, 0, sizeof(*(rpnt->next)));
_dl_unmap_cache();
#endif
/* ldd uses uses this. I am not sure how you pick up the other flags */
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects) {
+ char *_dl_warn = 0;
_dl_warn = _dl_getenv("LD_WARN", envp);
if (!_dl_warn)
_dl_exit(0);
}
+#endif
/*
* If the program interpreter is not in the module chain, add it. This will
if (_dl_symbol_tables)
goof += _dl_copy_fixups(_dl_symbol_tables);
+#ifdef DL_TRACE
if (goof || _dl_trace_loaded_objects)
_dl_exit(0);
+#endif
/* 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
#undef DL_DEBUG
#ifdef DL_DEBUG
else {
- _dl_fdprintf(2, tpnt->libname);
- _dl_fdprintf(2, ": ");
+ _dl_fprintf(2, tpnt->libname);
+ _dl_fprintf(2, ": ");
if (!_dl_atexit)
- _dl_fdprintf(2, "The address is atexit () is 0x0.");
+ _dl_fprintf(2, "The address is atexit () is 0x0.");
if (!tpnt->dynamic_info[DT_FINI])
- _dl_fdprintf(2, "Invalid .fini section.");
- _dl_fdprintf(2, "\n");
+ _dl_fprintf(2, "Invalid .fini section.");
+ _dl_fprintf(2, "\n");
}
#endif
#undef DL_DEBUG
goof += _dl_fixup(tpnt->next);
if (tpnt->dynamic_info[DT_REL]) {
#ifdef ELF_USES_RELOCA
- _dl_fdprintf(2, "%s: can't handle REL relocation records\n",
+ _dl_fprintf(2, "%s: can't handle REL relocation records\n",
_dl_progname);
_dl_exit(17);
#else
goof += _dl_parse_relocation_information(tpnt,
tpnt->dynamic_info[DT_RELA], tpnt->dynamic_info[DT_RELASZ], 0);
#else
- _dl_fdprintf(2, "%s: can't handle RELA relocation records\n",
+ _dl_fprintf(2, "%s: can't handle RELA relocation records\n",
_dl_progname);
_dl_exit(18);
#endif
_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_fdprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
+ _dl_fprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
_dl_exit(20);
}
}
return str;
}
+/* Minimum printf which handles only characters, %d's and %s's */
+void _dl_fprintf(int fd, const char *fmt, ...)
+{
+ int num;
+ va_list args;
+ char *start, *ptr, *string;
+ char buf[2048];
+
+ start = ptr = buf;
+
+ if (!fmt)
+ return;
+
+ if (_dl_strlen(fmt) >= (sizeof(buf)-1))
+ _dl_write(fd, "(overflow)\n", 10);
+
+ _dl_strcpy(buf, fmt);
+ va_start(args, fmt);
+
+ while(start)
+ {
+ while(*ptr != '%' && *ptr) {
+ ptr++;
+ }
+
+ if(*ptr == '%')
+ {
+ *ptr++ = '\0';
+ _dl_write(fd, start, _dl_strlen(start));
+
+ switch(*ptr++)
+ {
+ case 's':
+ string = va_arg(args, char *);
+ if (!string)
+ _dl_write(fd, "(null)", 6);
+ else
+ _dl_write(fd, string, _dl_strlen(string));
+ break;
+
+ case 'i':
+ case 'd':
+ {
+ char tmp[13];
+ num = va_arg(args, int);
+ string = _dl_simple_ltoa_inline(tmp, num);
+ _dl_write(fd, string, _dl_strlen(string));
+ break;
+ }
+ case 'x':
+ case 'X':
+ {
+ char tmp[13];
+ num = va_arg(args, int);
+ string = _dl_simple_ltoahex_inline(tmp, num);
+ _dl_write(fd, string, _dl_strlen(string));
+ break;
+ }
+ default:
+ _dl_write(fd, "(null)", 6);
+ break;
+ }
+
+ start = ptr;
+ }
+ else
+ {
+ _dl_write(fd, start, _dl_strlen(start));
+ start = NULL;
+ }
+ }
+ return;
+}
+
if (_dl_stat(LDSO_CACHE, &st)
|| (fd = _dl_open(LDSO_CACHE, O_RDONLY)) < 0) {
- _dl_fdprintf(2, "%s: can't open cache '%s'\n", _dl_progname, LDSO_CACHE);
+ _dl_fprintf(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;
}
_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_fdprintf(2, "%s: can't map cache '%s'\n",
+ _dl_fprintf(2, "%s: can't map cache '%s'\n",
_dl_progname, LDSO_CACHE);
return -1;
}
(sizeof(header_t) + header->nlibs * sizeof(libentry_t))
|| _dl_cache_addr[_dl_cache_size - 1] != '\0')
{
- _dl_fdprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname,
+ _dl_fprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname,
LDSO_CACHE);
goto fail;
}
if (libent[i].sooffset >= strtabsize ||
libent[i].liboffset >= strtabsize)
{
- _dl_fdprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname, LDSO_CACHE);
+ _dl_fprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname, LDSO_CACHE);
goto fail;
}
}
* NO! When we open shared libraries we may search several paths.
* it is inappropriate to generate an error here.
*/
- _dl_fdprintf(2, "%s: can't open '%s'\n", _dl_progname, libname);
+ _dl_fprintf(2, "%s: can't open '%s'\n", _dl_progname, libname);
#endif
_dl_internal_error_number = DL_ERROR_NOFILE;
return NULL;
epnt->e_ident[2] != 'L' ||
epnt->e_ident[3] != 'F')
{
- _dl_fdprintf(2, "%s: '%s' is not an ELF file\n", _dl_progname,
+ _dl_fprintf(2, "%s: '%s' is not an ELF file\n", _dl_progname,
libname);
_dl_internal_error_number = DL_ERROR_NOTELF;
_dl_close(infile);
{
_dl_internal_error_number =
(epnt->e_type != ET_DYN ? DL_ERROR_NOTDYN : DL_ERROR_NOTMAGIC);
- _dl_fdprintf(2, "%s: '%s' is not an ELF executable for " ELF_TARGET
+ _dl_fprintf(2, "%s: '%s' is not an ELF executable for " ELF_TARGET
"\n", _dl_progname, libname);
_dl_close(infile);
return NULL;
if (ppnt->p_type == PT_DYNAMIC) {
if (dynamic_addr)
- _dl_fdprintf(2, "%s: '%s' has more than one dynamic section\n",
+ _dl_fprintf(2, "%s: '%s' has more than one dynamic section\n",
_dl_progname, libname);
dynamic_addr = ppnt->p_vaddr;
dynamic_size = ppnt->p_filesz;
status = (char *) _dl_mmap((char *) (piclib ? 0 : minvma),
maxvma - minvma, PROT_NONE, flags | MAP_ANONYMOUS, -1, 0);
if (_dl_mmap_check_error(status)) {
- _dl_fdprintf(2, "%s: can't map '/dev/zero'\n", _dl_progname);
+ _dl_fprintf(2, "%s: can't map '/dev/zero'\n", _dl_progname);
_dl_internal_error_number = DL_ERROR_MMAP_FAILED;
_dl_close(infile);
return NULL;
ppnt->p_offset & 0x7ffff000);
if (_dl_mmap_check_error(status)) {
- _dl_fdprintf(2, "%s: can't map '%s'\n",
+ _dl_fprintf(2, "%s: can't map '%s'\n",
_dl_progname, libname);
_dl_internal_error_number = DL_ERROR_MMAP_FAILED;
_dl_munmap((char *) libaddr, maxvma - minvma);
ppnt->p_filesz, LXFLAGS(ppnt->p_flags), flags,
infile, ppnt->p_offset & 0x7ffff000);
if (_dl_mmap_check_error(status)) {
- _dl_fdprintf(2, "%s: can't map '%s'\n", _dl_progname, libname);
+ _dl_fprintf(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);
if (!dynamic_addr) {
_dl_internal_error_number = DL_ERROR_NODYNAMIC;
- _dl_fdprintf(2, "%s: '%s' is missing a dynamic section\n",
+ _dl_fprintf(2, "%s: '%s' is missing a dynamic section\n",
_dl_progname, libname);
return NULL;
}
int copyrel);
extern int _dl_linux_dynamic_link(void);
-#if defined mc68000 || defined __arm__
-/* On some arches constant strings are referenced through the GOT. */
-/* XXX Requires load_addr to be defined. */
-#define SEND_STDERR(X) \
- { const char *__s = (X); \
- if (__s < (const char *) load_addr) __s += load_addr; \
- _dl_write (2, __s, _dl_strlen_inline (__s)); \
- }
-#else
-#define SEND_STDERR(X) _dl_write(2, X, _dl_strlen_inline(X));
-#endif
-
-#define SEND_ADDRESS_STDERR(X, add_a_newline) { \
- char tmp[13], *tmp1; \
- _dl_memset_inline(tmp, 0, sizeof(tmp)); \
- tmp1=_dl_simple_ltoahex_inline( tmp, (unsigned long)(X)); \
- _dl_write(2, tmp1, _dl_strlen_inline(tmp1)); \
- if (add_a_newline) { \
- tmp[0]='\n'; \
- _dl_write(2, tmp, 1); \
- } \
-};
-
-#define SEND_NUMBER_STDERR(X, add_a_newline) { \
- char tmp[13], *tmp1; \
- _dl_memset_inline(tmp, 0, sizeof(tmp)); \
- tmp1=_dl_simple_ltoahex_inline( tmp, (unsigned long)(X)); \
- _dl_write(2, tmp1, _dl_strlen_inline(tmp1)); \
- if (add_a_newline) { \
- tmp[0]='\n'; \
- _dl_write(2, tmp, 1); \
- } \
-};
-
-extern int _dl_fdprintf(int, const char *, ...);
extern char * _dl_library_path;
extern char * _dl_not_lazy;
-extern char * _dl_strdup(const char *);
extern unsigned long _dl_elf_hash(const char * name);
static inline int _dl_symbol(char * name)
if (reloc_type != R_386_JMP_SLOT) {
- _dl_fdprintf(2, "%s: Incorrect relocation type in jump relocations\n",
+ _dl_fprintf(2, "%s: Incorrect relocation type in jump relocations\n",
_dl_progname);
_dl_exit(1);
};
got_addr = (char **) instr_addr;
#ifdef DEBUG
- _dl_fdprintf(2, "Resolving symbol %s\n",
+ _dl_fprintf(2, "Resolving symbol %s\n",
strtab + symtab[symtab_index].st_name);
#endif
new_addr = _dl_find_hash(strtab + symtab[symtab_index].st_name,
tpnt->symbol_scope, (unsigned long) got_addr, tpnt, 0);
if (!new_addr) {
- _dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf(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_fdprintf(2, "Calling library function: %s\n",
+ _dl_fprintf(2, "Calling library function: %s\n",
strtab + symtab[symtab_index].st_name);
} else {
*got_addr = new_addr;
*reloc_addr += (unsigned long) tpnt->loadaddr;
break;
default:
- _dl_fdprintf(2, "%s: (LAZY) can't handle reloc type ",
+ _dl_fprintf(2, "%s: (LAZY) can't handle reloc type ",
_dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fdprintf(2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_fprintf(2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fdprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
+ _dl_fprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
};
*/
if (!symbol_addr &&
ELF32_ST_BIND(symtab[symtab_index].st_info) == STB_GLOBAL) {
- _dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
}
case R_386_COPY:
#if 0
/* Do this later */
- _dl_fdprintf(2, "Doing copy for symbol ");
- if (symtab_index) _dl_fdprintf(2, strtab + symtab[symtab_index].st_name);
- _dl_fdprintf(2, "\n");
+ _dl_fprintf(2, "Doing copy for symbol ");
+ if (symtab_index) _dl_fprintf(2, strtab + symtab[symtab_index].st_name);
+ _dl_fprintf(2, "\n");
_dl_memcpy((void *) symtab[symtab_index].st_value,
(void *) symbol_addr, symtab[symtab_index].st_size);
#endif
break;
default:
- _dl_fdprintf(2, "%s: can't handle reloc type ", _dl_progname);
+ _dl_fprintf(2, "%s: can't handle reloc type ", _dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fdprintf(2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_fprintf(2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fdprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
+ _dl_fprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
symtab[symtab_index].st_name, xpnt->next,
(unsigned long) reloc_addr, NULL, 1);
if (!symbol_addr) {
- _dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
};
#include "ld.so.h" /* Pull in the name of ld.so */
const char *_dl_progname=_dl_static_progname;
static char *_dl_not_lazy = 0;
-static char *_dl_warn = 0; /* Used by ldd */
+#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;
aux_dat += 2;
}
- /* locate the ELF header. We need this done as easly as possible
+ /* 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;
}
}
+#ifdef DL_TRACE
_dl_trace_loaded_objects = _dl_getenv("LD_TRACE_LOADED_OBJECTS", envp);
-
+#endif
/* OK, we now have the application in the list, and we have some
basic stuff in place. Now search through the list for other shared
libraries that should be loaded, and insert them on the list in the
{
tpnt1 = _dl_load_shared_library(_dl_secure, NULL, str);
if (!tpnt1) {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects)
- _dl_fdprintf(1, "\t%s => not found\n", str);
+ _dl_fprintf(1, "\t%s => not found\n", str);
else {
- _dl_fdprintf(2, "%s: can't load "
+#endif
+ _dl_fprintf(2, "%s: can't load "
"library '%s'\n", _dl_progname, str);
_dl_exit(15);
+#ifdef DL_TRACE
}
+#endif
} else {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects
&& !tpnt1->usage_count) {
/* 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_fdprintf(1, "\t%s => %s (0x%x)\n", str, tpnt1->libname,
+ _dl_fprintf(1, "\t%s => %s (0x%x)\n", str, tpnt1->libname,
(unsigned) tpnt1->loadaddr);
}
+#endif
rpnt->next = (struct dyn_elf *)
_dl_malloc(sizeof(struct dyn_elf));
_dl_memset(rpnt->next, 0, sizeof(*(rpnt->next)));
if (!_dl_stat(LDSO_PRELOAD, &st)) {
if ((fd = _dl_open(LDSO_PRELOAD, O_RDONLY)) < 0) {
- _dl_fdprintf(2, "%s: can't open file '%s'\n",
+ _dl_fprintf(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_fdprintf(2, "%s: can't map file '%s'\n",
+ _dl_fprintf(2, "%s: can't map file '%s'\n",
_dl_progname, LDSO_PRELOAD);
} else {
char c, *cp, *cp2;
tpnt1 = _dl_load_shared_library(0, NULL, cp2);
if (!tpnt1) {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects)
- _dl_fdprintf(1, "\t%s => not found\n", cp2);
+ _dl_fprintf(1, "\t%s => not found\n", cp2);
else {
- _dl_fdprintf(2, "%s: can't load library '%s'\n",
+#endif
+ _dl_fprintf(2, "%s: can't load library '%s'\n",
_dl_progname, cp2);
_dl_exit(15);
- }
+#ifdef DL_TRACE
+ }
+#endif
} else {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects
&& !tpnt1->usage_count) {
- _dl_fdprintf(1, "\t%s => %s (0x%x)\n", cp2,
+ _dl_fprintf(1, "\t%s => %s (0x%x)\n", cp2,
tpnt1->libname, (unsigned) tpnt1->loadaddr);
}
+#endif
rpnt->next = (struct dyn_elf *)
_dl_malloc(sizeof(struct dyn_elf));
_dl_memset(rpnt->next, 0,
_dl_get_last_path_component(tpnt->libname)) == 0) {
struct elf_resolve *ttmp;
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects && !tpnt->usage_count) {
- _dl_fdprintf(1, "\t%s => %s (0x%x)\n",
+ _dl_fprintf(1, "\t%s => %s (0x%x)\n",
lpnt, tpnt->libname, (unsigned) tpnt->loadaddr);
}
+#endif
ttmp = _dl_loaded_modules;
while (ttmp->next)
ttmp = ttmp->next;
continue;
}
if (!(tpnt1 = _dl_load_shared_library(0, tcurr, lpnt))) {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects)
- _dl_fdprintf(1, "\t%s => not found\n", lpnt);
+ _dl_fprintf(1, "\t%s => not found\n", lpnt);
else {
- _dl_fdprintf(2, "%s: can't load library '%s'\n",
+#endif
+ _dl_fprintf(2, "%s: can't load library '%s'\n",
_dl_progname, lpnt);
_dl_exit(16);
+#ifdef DL_TRACE
}
+#endif
} else {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects && !tpnt1->usage_count)
- _dl_fdprintf(1, "\t%s => %s (0x%x)\n", lpnt, tpnt1->libname,
+ _dl_fprintf(1, "\t%s => %s (0x%x)\n", lpnt, tpnt1->libname,
(unsigned) tpnt1->loadaddr);
+#endif
rpnt->next = (struct dyn_elf *)
_dl_malloc(sizeof(struct dyn_elf));
_dl_memset(rpnt->next, 0, sizeof(*(rpnt->next)));
_dl_unmap_cache();
#endif
/* ldd uses uses this. I am not sure how you pick up the other flags */
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects) {
+ char *_dl_warn = 0;
_dl_warn = _dl_getenv("LD_WARN", envp);
if (!_dl_warn)
_dl_exit(0);
}
+#endif
/*
* If the program interpreter is not in the module chain, add it. This will
if (_dl_symbol_tables)
goof += _dl_copy_fixups(_dl_symbol_tables);
+#ifdef DL_TRACE
if (goof || _dl_trace_loaded_objects)
_dl_exit(0);
+#endif
/* 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
#undef DL_DEBUG
#ifdef DL_DEBUG
else {
- _dl_fdprintf(2, tpnt->libname);
- _dl_fdprintf(2, ": ");
+ _dl_fprintf(2, tpnt->libname);
+ _dl_fprintf(2, ": ");
if (!_dl_atexit)
- _dl_fdprintf(2, "The address is atexit () is 0x0.");
+ _dl_fprintf(2, "The address is atexit () is 0x0.");
if (!tpnt->dynamic_info[DT_FINI])
- _dl_fdprintf(2, "Invalid .fini section.");
- _dl_fdprintf(2, "\n");
+ _dl_fprintf(2, "Invalid .fini section.");
+ _dl_fprintf(2, "\n");
}
#endif
#undef DL_DEBUG
goof += _dl_fixup(tpnt->next);
if (tpnt->dynamic_info[DT_REL]) {
#ifdef ELF_USES_RELOCA
- _dl_fdprintf(2, "%s: can't handle REL relocation records\n",
+ _dl_fprintf(2, "%s: can't handle REL relocation records\n",
_dl_progname);
_dl_exit(17);
#else
goof += _dl_parse_relocation_information(tpnt,
tpnt->dynamic_info[DT_RELA], tpnt->dynamic_info[DT_RELASZ], 0);
#else
- _dl_fdprintf(2, "%s: can't handle RELA relocation records\n",
+ _dl_fprintf(2, "%s: can't handle RELA relocation records\n",
_dl_progname);
_dl_exit(18);
#endif
_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_fdprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
+ _dl_fprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
_dl_exit(20);
}
}
return str;
}
+/* Minimum printf which handles only characters, %d's and %s's */
+void _dl_fprintf(int fd, const char *fmt, ...)
+{
+ int num;
+ va_list args;
+ char *start, *ptr, *string;
+ char buf[2048];
+
+ start = ptr = buf;
+
+ if (!fmt)
+ return;
+
+ if (_dl_strlen(fmt) >= (sizeof(buf)-1))
+ _dl_write(fd, "(overflow)\n", 10);
+
+ _dl_strcpy(buf, fmt);
+ va_start(args, fmt);
+
+ while(start)
+ {
+ while(*ptr != '%' && *ptr) {
+ ptr++;
+ }
+
+ if(*ptr == '%')
+ {
+ *ptr++ = '\0';
+ _dl_write(fd, start, _dl_strlen(start));
+
+ switch(*ptr++)
+ {
+ case 's':
+ string = va_arg(args, char *);
+ if (!string)
+ _dl_write(fd, "(null)", 6);
+ else
+ _dl_write(fd, string, _dl_strlen(string));
+ break;
+
+ case 'i':
+ case 'd':
+ {
+ char tmp[13];
+ num = va_arg(args, int);
+ string = _dl_simple_ltoa_inline(tmp, num);
+ _dl_write(fd, string, _dl_strlen(string));
+ break;
+ }
+ case 'x':
+ case 'X':
+ {
+ char tmp[13];
+ num = va_arg(args, int);
+ string = _dl_simple_ltoahex_inline(tmp, num);
+ _dl_write(fd, string, _dl_strlen(string));
+ break;
+ }
+ default:
+ _dl_write(fd, "(null)", 6);
+ break;
+ }
+
+ start = ptr;
+ }
+ else
+ {
+ _dl_write(fd, start, _dl_strlen(start));
+ start = NULL;
+ }
+ }
+ return;
+}
+
int copyrel);
extern int _dl_linux_dynamic_link(void);
-#if defined mc68000 || defined __arm__
-/* On some arches constant strings are referenced through the GOT. */
-/* XXX Requires load_addr to be defined. */
-#define SEND_STDERR(X) \
- { const char *__s = (X); \
- if (__s < (const char *) load_addr) __s += load_addr; \
- _dl_write (2, __s, _dl_strlen_inline (__s)); \
- }
-#else
-#define SEND_STDERR(X) _dl_write(2, X, _dl_strlen_inline(X));
-#endif
-
-#define SEND_ADDRESS_STDERR(X, add_a_newline) { \
- char tmp[13], *tmp1; \
- _dl_memset_inline(tmp, 0, sizeof(tmp)); \
- tmp1=_dl_simple_ltoahex_inline( tmp, (unsigned long)(X)); \
- _dl_write(2, tmp1, _dl_strlen_inline(tmp1)); \
- if (add_a_newline) { \
- tmp[0]='\n'; \
- _dl_write(2, tmp, 1); \
- } \
-};
-
-#define SEND_NUMBER_STDERR(X, add_a_newline) { \
- char tmp[13], *tmp1; \
- _dl_memset_inline(tmp, 0, sizeof(tmp)); \
- tmp1=_dl_simple_ltoahex_inline( tmp, (unsigned long)(X)); \
- _dl_write(2, tmp1, _dl_strlen_inline(tmp1)); \
- if (add_a_newline) { \
- tmp[0]='\n'; \
- _dl_write(2, tmp, 1); \
- } \
-};
-
-extern int _dl_fdprintf(int, const char *, ...);
extern char * _dl_library_path;
extern char * _dl_not_lazy;
-extern char * _dl_strdup(const char *);
extern unsigned long _dl_elf_hash(const char * name);
static inline int _dl_symbol(char * name)
extern void * _dl_memcpy(void * dst, const void * src, size_t len);
extern int _dl_memcmp(const void * s1,const void * s2,size_t len);
extern void * _dl_memset(void * str,int c,size_t len);
+extern void _dl_fprintf(int, const char *, ...);
#ifndef NULL
#define NULL ((void *) 0)
return p + 1;
}
+
+#if defined mc68000 || defined __arm__
+/* On some arches constant strings are referenced through the GOT. */
+/* XXX Requires load_addr to be defined. */
+#define SEND_STDERR(X) \
+ { const char *__s = (X); \
+ if (__s < (const char *) load_addr) __s += load_addr; \
+ _dl_write (2, __s, _dl_strlen_inline (__s)); \
+ }
+#else
+#define SEND_STDERR(X) _dl_write(2, X, _dl_strlen_inline(X));
+#endif
+
+#define SEND_ADDRESS_STDERR(X, add_a_newline) { \
+ char tmp[13], *tmp1; \
+ _dl_memset_inline(tmp, 0, sizeof(tmp)); \
+ tmp1=_dl_simple_ltoahex_inline( tmp, (unsigned long)(X)); \
+ _dl_write(2, tmp1, _dl_strlen_inline(tmp1)); \
+ if (add_a_newline) { \
+ tmp[0]='\n'; \
+ _dl_write(2, tmp, 1); \
+ } \
+};
+
+#define SEND_NUMBER_STDERR(X, add_a_newline) { \
+ char tmp[13], *tmp1; \
+ _dl_memset_inline(tmp, 0, sizeof(tmp)); \
+ tmp1=_dl_simple_ltoahex_inline( tmp, (unsigned long)(X)); \
+ _dl_write(2, tmp1, _dl_strlen_inline(tmp1)); \
+ if (add_a_newline) { \
+ tmp[0]='\n'; \
+ _dl_write(2, tmp, 1); \
+ } \
+};
+
+
#endif
#include "ld.so.h" /* Pull in the name of ld.so */
const char *_dl_progname=_dl_static_progname;
static char *_dl_not_lazy = 0;
-static char *_dl_warn = 0; /* Used by ldd */
+#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;
aux_dat += 2;
}
- /* locate the ELF header. We need this done as easly as possible
+ /* 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;
}
}
+#ifdef DL_TRACE
_dl_trace_loaded_objects = _dl_getenv("LD_TRACE_LOADED_OBJECTS", envp);
-
+#endif
/* OK, we now have the application in the list, and we have some
basic stuff in place. Now search through the list for other shared
libraries that should be loaded, and insert them on the list in the
{
tpnt1 = _dl_load_shared_library(_dl_secure, NULL, str);
if (!tpnt1) {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects)
- _dl_fdprintf(1, "\t%s => not found\n", str);
+ _dl_fprintf(1, "\t%s => not found\n", str);
else {
- _dl_fdprintf(2, "%s: can't load "
+#endif
+ _dl_fprintf(2, "%s: can't load "
"library '%s'\n", _dl_progname, str);
_dl_exit(15);
+#ifdef DL_TRACE
}
+#endif
} else {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects
&& !tpnt1->usage_count) {
/* 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_fdprintf(1, "\t%s => %s (0x%x)\n", str, tpnt1->libname,
+ _dl_fprintf(1, "\t%s => %s (0x%x)\n", str, tpnt1->libname,
(unsigned) tpnt1->loadaddr);
}
+#endif
rpnt->next = (struct dyn_elf *)
_dl_malloc(sizeof(struct dyn_elf));
_dl_memset(rpnt->next, 0, sizeof(*(rpnt->next)));
if (!_dl_stat(LDSO_PRELOAD, &st)) {
if ((fd = _dl_open(LDSO_PRELOAD, O_RDONLY)) < 0) {
- _dl_fdprintf(2, "%s: can't open file '%s'\n",
+ _dl_fprintf(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_fdprintf(2, "%s: can't map file '%s'\n",
+ _dl_fprintf(2, "%s: can't map file '%s'\n",
_dl_progname, LDSO_PRELOAD);
} else {
char c, *cp, *cp2;
tpnt1 = _dl_load_shared_library(0, NULL, cp2);
if (!tpnt1) {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects)
- _dl_fdprintf(1, "\t%s => not found\n", cp2);
+ _dl_fprintf(1, "\t%s => not found\n", cp2);
else {
- _dl_fdprintf(2, "%s: can't load library '%s'\n",
+#endif
+ _dl_fprintf(2, "%s: can't load library '%s'\n",
_dl_progname, cp2);
_dl_exit(15);
- }
+#ifdef DL_TRACE
+ }
+#endif
} else {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects
&& !tpnt1->usage_count) {
- _dl_fdprintf(1, "\t%s => %s (0x%x)\n", cp2,
+ _dl_fprintf(1, "\t%s => %s (0x%x)\n", cp2,
tpnt1->libname, (unsigned) tpnt1->loadaddr);
}
+#endif
rpnt->next = (struct dyn_elf *)
_dl_malloc(sizeof(struct dyn_elf));
_dl_memset(rpnt->next, 0,
_dl_get_last_path_component(tpnt->libname)) == 0) {
struct elf_resolve *ttmp;
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects && !tpnt->usage_count) {
- _dl_fdprintf(1, "\t%s => %s (0x%x)\n",
+ _dl_fprintf(1, "\t%s => %s (0x%x)\n",
lpnt, tpnt->libname, (unsigned) tpnt->loadaddr);
}
+#endif
ttmp = _dl_loaded_modules;
while (ttmp->next)
ttmp = ttmp->next;
continue;
}
if (!(tpnt1 = _dl_load_shared_library(0, tcurr, lpnt))) {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects)
- _dl_fdprintf(1, "\t%s => not found\n", lpnt);
+ _dl_fprintf(1, "\t%s => not found\n", lpnt);
else {
- _dl_fdprintf(2, "%s: can't load library '%s'\n",
+#endif
+ _dl_fprintf(2, "%s: can't load library '%s'\n",
_dl_progname, lpnt);
_dl_exit(16);
+#ifdef DL_TRACE
}
+#endif
} else {
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects && !tpnt1->usage_count)
- _dl_fdprintf(1, "\t%s => %s (0x%x)\n", lpnt, tpnt1->libname,
+ _dl_fprintf(1, "\t%s => %s (0x%x)\n", lpnt, tpnt1->libname,
(unsigned) tpnt1->loadaddr);
+#endif
rpnt->next = (struct dyn_elf *)
_dl_malloc(sizeof(struct dyn_elf));
_dl_memset(rpnt->next, 0, sizeof(*(rpnt->next)));
_dl_unmap_cache();
#endif
/* ldd uses uses this. I am not sure how you pick up the other flags */
+#ifdef DL_TRACE
if (_dl_trace_loaded_objects) {
+ char *_dl_warn = 0;
_dl_warn = _dl_getenv("LD_WARN", envp);
if (!_dl_warn)
_dl_exit(0);
}
+#endif
/*
* If the program interpreter is not in the module chain, add it. This will
if (_dl_symbol_tables)
goof += _dl_copy_fixups(_dl_symbol_tables);
+#ifdef DL_TRACE
if (goof || _dl_trace_loaded_objects)
_dl_exit(0);
+#endif
/* 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
#undef DL_DEBUG
#ifdef DL_DEBUG
else {
- _dl_fdprintf(2, tpnt->libname);
- _dl_fdprintf(2, ": ");
+ _dl_fprintf(2, tpnt->libname);
+ _dl_fprintf(2, ": ");
if (!_dl_atexit)
- _dl_fdprintf(2, "The address is atexit () is 0x0.");
+ _dl_fprintf(2, "The address is atexit () is 0x0.");
if (!tpnt->dynamic_info[DT_FINI])
- _dl_fdprintf(2, "Invalid .fini section.");
- _dl_fdprintf(2, "\n");
+ _dl_fprintf(2, "Invalid .fini section.");
+ _dl_fprintf(2, "\n");
}
#endif
#undef DL_DEBUG
goof += _dl_fixup(tpnt->next);
if (tpnt->dynamic_info[DT_REL]) {
#ifdef ELF_USES_RELOCA
- _dl_fdprintf(2, "%s: can't handle REL relocation records\n",
+ _dl_fprintf(2, "%s: can't handle REL relocation records\n",
_dl_progname);
_dl_exit(17);
#else
goof += _dl_parse_relocation_information(tpnt,
tpnt->dynamic_info[DT_RELA], tpnt->dynamic_info[DT_RELASZ], 0);
#else
- _dl_fdprintf(2, "%s: can't handle RELA relocation records\n",
+ _dl_fprintf(2, "%s: can't handle RELA relocation records\n",
_dl_progname);
_dl_exit(18);
#endif
_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_fdprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
+ _dl_fprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
_dl_exit(20);
}
}
return str;
}
+/* Minimum printf which handles only characters, %d's and %s's */
+void _dl_fprintf(int fd, const char *fmt, ...)
+{
+ int num;
+ va_list args;
+ char *start, *ptr, *string;
+ char buf[2048];
+
+ start = ptr = buf;
+
+ if (!fmt)
+ return;
+
+ if (_dl_strlen(fmt) >= (sizeof(buf)-1))
+ _dl_write(fd, "(overflow)\n", 10);
+
+ _dl_strcpy(buf, fmt);
+ va_start(args, fmt);
+
+ while(start)
+ {
+ while(*ptr != '%' && *ptr) {
+ ptr++;
+ }
+
+ if(*ptr == '%')
+ {
+ *ptr++ = '\0';
+ _dl_write(fd, start, _dl_strlen(start));
+
+ switch(*ptr++)
+ {
+ case 's':
+ string = va_arg(args, char *);
+ if (!string)
+ _dl_write(fd, "(null)", 6);
+ else
+ _dl_write(fd, string, _dl_strlen(string));
+ break;
+
+ case 'i':
+ case 'd':
+ {
+ char tmp[13];
+ num = va_arg(args, int);
+ string = _dl_simple_ltoa_inline(tmp, num);
+ _dl_write(fd, string, _dl_strlen(string));
+ break;
+ }
+ case 'x':
+ case 'X':
+ {
+ char tmp[13];
+ num = va_arg(args, int);
+ string = _dl_simple_ltoahex_inline(tmp, num);
+ _dl_write(fd, string, _dl_strlen(string));
+ break;
+ }
+ default:
+ _dl_write(fd, "(null)", 6);
+ break;
+ }
+
+ start = ptr;
+ }
+ else
+ {
+ _dl_write(fd, start, _dl_strlen(start));
+ start = NULL;
+ }
+ }
+ return;
+}
+
if (reloc_type != R_68K_JMP_SLOT)
{
- _dl_fdprintf (2, "%s: incorrect relocation type in jump relocations\n",
+ _dl_fprintf (2, "%s: incorrect relocation type in jump relocations\n",
_dl_progname);
_dl_exit (1);
}
got_addr = (char **) instr_addr;
#ifdef DEBUG
- _dl_fdprintf (2, "Resolving symbol %s\n",
+ _dl_fprintf (2, "Resolving symbol %s\n",
strtab + symtab[symtab_index].st_name);
#endif
tpnt->symbol_scope, (int) got_addr, tpnt, 0);
if (!new_addr)
{
- _dl_fdprintf (2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf (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 int) got_addr < 0x40000000)
- _dl_fdprintf (2, "Calling library function: %s\n",
+ _dl_fprintf (2, "Calling library function: %s\n",
strtab + symtab[symtab_index].st_name);
else
#endif
*reloc_addr += (unsigned int) tpnt->loadaddr;
break;
default:
- _dl_fdprintf (2, "%s: (LAZY) can't handle reloc type ", _dl_progname);
+ _dl_fprintf (2, "%s: (LAZY) can't handle reloc type ", _dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fdprintf (2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_fprintf (2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fdprintf (2, "'%s'", strtab + symtab[symtab_index].st_name);
- _dl_fdprintf (2, "\n");
+ _dl_fprintf (2, "'%s'", strtab + symtab[symtab_index].st_name);
+ _dl_fprintf (2, "\n");
_dl_exit (1);
}
}
if (!symbol_addr
&& ELF32_ST_BIND (symtab[symtab_index].st_info) == STB_GLOBAL)
{
- _dl_fdprintf (2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf (2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
}
break;
case R_68K_COPY:
#if 0 /* Do this later. */
- _dl_fdprintf (2, "Doing copy");
+ _dl_fprintf (2, "Doing copy");
if (symtab_index)
- _dl_fdprintf (2, " for symbol %s",
+ _dl_fprintf (2, " for symbol %s",
strtab + symtab[symtab_index].st_name);
- _dl_fdprintf (2, "\n");
+ _dl_fprintf (2, "\n");
_dl_memcpy ((void *) symtab[symtab_index].st_value,
(void *) symbol_addr,
symtab[symtab_index].st_size);
#endif
break;
default:
- _dl_fdprintf (2, "%s: can't handle reloc type ", _dl_progname);
+ _dl_fprintf (2, "%s: can't handle reloc type ", _dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fdprintf (2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_fprintf (2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fdprintf (2, "'%s'", strtab + symtab[symtab_index].st_name);
- _dl_fdprintf (2, "\n");
+ _dl_fprintf (2, "'%s'", strtab + symtab[symtab_index].st_name);
+ _dl_fprintf (2, "\n");
_dl_exit (1);
}
xpnt->next, (int) reloc_addr, NULL, 1);
if (!symbol_addr)
{
- _dl_fdprintf (2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf (2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
}
unsigned int rel_offset_words;
unsigned int offset;
- _dl_fdprintf(2,"init_got plt=%08lx, tpnt=%08lx\n",
+ _dl_fprintf(2,"init_got plt=%x, tpnt=%x\n",
(unsigned long)plt,(unsigned long)tpnt);
n_plt_entries = tpnt->dynamic_info[DT_PLTRELSZ] / sizeof(ELF_RELOC);
-_dl_fdprintf(2,"n_plt_entries %d\n",n_plt_entries);
+_dl_fprintf(2,"n_plt_entries %d\n",n_plt_entries);
rel_offset_words = PLT_DATA_START_WORDS(n_plt_entries);
-_dl_fdprintf(2,"rel_offset_words %08x\n",rel_offset_words);
+_dl_fprintf(2,"rel_offset_words %x\n",rel_offset_words);
data_words = (unsigned long)(plt + rel_offset_words);
-_dl_fdprintf(2,"data_words %08x\n",data_words);
+_dl_fprintf(2,"data_words %x\n",data_words);
//lpnt += PLT_INITIAL_ENTRY_WORDS;
char **got_addr;
unsigned long instr_addr;
-_dl_fdprintf(2,"linux_resolver tpnt=%08x reloc_entry=%08x\n",tpnt,reloc_entry);
+_dl_fprintf(2,"linux_resolver tpnt=%x reloc_entry=%x\n",tpnt,reloc_entry);
rel_addr = (ELF_RELOC *) (tpnt->dynamic_info[DT_JMPREL] + tpnt->loadaddr);
this_reloc = (void *)rel_addr + reloc_entry;
if (reloc_type != R_PPC_JMP_SLOT) {
- _dl_fdprintf(2, "%s: Incorrect relocation type [%s] in jump relocations\n",
+ _dl_fprintf(2, "%s: Incorrect relocation type [%s] in jump relocations\n",
_dl_progname,
(reloc_type<N_RELTYPES)?_dl_reltypes[reloc_type]:"unknown");
_dl_exit(1);
got_addr = (char **) instr_addr;
#ifdef DEBUG
- _dl_fdprintf(2, "Resolving symbol %s %08x --> ",
+ _dl_fprintf(2, "Resolving symbol %s %x --> ",
strtab + symtab[symtab_index].st_name,
instr_addr);
#endif
new_addr = _dl_find_hash(strtab + symtab[symtab_index].st_name,
tpnt->symbol_scope, (unsigned long) got_addr, tpnt, 0);
if (!new_addr) {
- _dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
#ifdef DEBUG
- _dl_fdprintf(2, "%08x\n", new_addr);
+ _dl_fprintf(2, "%x\n", new_addr);
#endif
/* #define DEBUG_LIBRARY */
#ifdef DEBUG_LIBRARY
if ((unsigned long) got_addr < 0x40000000) {
- _dl_fdprintf(2, "Calling library function: %s\n",
+ _dl_fprintf(2, "Calling library function: %s\n",
strtab + symtab[symtab_index].st_name);
} else {
*got_addr = new_addr;
int index;
#ifdef DEBUG
-_dl_fdprintf(2,"_dl_parse_lazy_relocation_information(tpnt=%08x, rel_addr=%08x, rel_size=%08x, type=%d)\n",
+_dl_fprintf(2,"_dl_parse_lazy_relocation_information(tpnt=%x, rel_addr=%x, rel_size=%x, type=%d)\n",
tpnt,rel_addr,rel_size,type);
#endif
/* Now parse the relocation information */
continue;
#ifdef DEBUG
-_dl_fdprintf(2, "L %08x %-16s %-20s %08x %08x\n",
+_dl_fprintf(2, "L %x %s %s %x %x\n",
reloc_addr, _dl_reltypes[reloc_type],
symtab_index?strtab + symtab[symtab_index].st_name:"",0,0);
#endif
/sizeof(unsigned long);
index /= 2;
#ifdef DEBUG
-_dl_fdprintf(2, " index %08x delta %08x\n",index,delta);
+_dl_fprintf(2, " index %x delta %x\n",index,delta);
#endif
reloc_addr[0] = OPCODE_LI(11,index*4);
reloc_addr[1] = OPCODE_B(delta);
break;
}
default:
- _dl_fdprintf(2, "%s: (LAZY) can't handle reloc type ",
+ _dl_fprintf(2, "%s: (LAZY) can't handle reloc type ",
_dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fdprintf(2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_fprintf(2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fdprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
+ _dl_fprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
unsigned long *plt;
#ifdef DEBUG
-_dl_fdprintf(2,"_dl_parse_relocation_information(tpnt=%08x, rel_addr=%08x, rel_size=%08x, type=%d)\n",
+_dl_fprintf(2,"_dl_parse_relocation_information(tpnt=%x, rel_addr=%x, rel_size=%x, type=%d)\n",
tpnt,rel_addr,rel_size,type);
#endif
/* Now parse the relocation information */
*/
if (!symbol_addr &&
ELF32_ST_BIND(symtab[symtab_index].st_info) == STB_GLOBAL) {
- _dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
}
}
#ifdef DEBUG
-_dl_fdprintf(2, " %08x %-16s %-20s %08x %08x\n",
+_dl_fprintf(2, " %x %s %s %x %x\n",
reloc_addr, _dl_reltypes[reloc_type],
symtab_index?strtab + symtab[symtab_index].st_name:"",
symbol_addr, addend);
{
int delta = symbol_addr - (unsigned long)reloc_addr;
if(delta<<6>>6 != delta){
- _dl_fdprintf(2,"R_PPC_REL24: Reloc out of range\n");
+ _dl_fprintf(2,"R_PPC_REL24: Reloc out of range\n");
_dl_exit(1);
}
*reloc_addr &= 0xfc000003;
/sizeof(unsigned long);
index /= 2;
#ifdef DEBUG
-_dl_fdprintf(2, " index %08x delta %08x\n",index,delta);
+_dl_fprintf(2, " index %x delta %x\n",index,delta);
#endif
reloc_addr[0] = OPCODE_LI(11,index*4);
reloc_addr[1] = OPCODE_B(delta);
break;
}
default:
- _dl_fdprintf(2, "%s: can't handle reloc type ", _dl_progname);
+ _dl_fprintf(2, "%s: can't handle reloc type ", _dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fdprintf(2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_fprintf(2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fdprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
+ _dl_fprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
_dl_exit(1);
};
PPC_SYNC;
PPC_ICBI(reloc_addr);
-//_dl_fdprintf(2,"reloc_addr %08x: %08x\n",reloc_addr,*reloc_addr);
+//_dl_fprintf(2,"reloc_addr %x: %x\n",reloc_addr,*reloc_addr);
};
return goof;
}
struct elf_resolve *tpnt;
int symtab_index;
-_dl_fdprintf(2,"parse_copy xpnt=%08x rel_addr=%08x rel_size=%08x type=%d\n",
+_dl_fprintf(2,"parse_copy xpnt=%x rel_addr=%x rel_size=%x type=%d\n",
(int)xpnt,rel_addr,rel_size,type);
/* Now parse the relocation information */
symtab[symtab_index].st_name, xpnt->next,
(unsigned long) reloc_addr, NULL, 1);
if (!symbol_addr) {
- _dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
};
if (_dl_stat(LDSO_CACHE, &st)
|| (fd = _dl_open(LDSO_CACHE, O_RDONLY)) < 0) {
- _dl_fdprintf(2, "%s: can't open cache '%s'\n", _dl_progname, LDSO_CACHE);
+ _dl_fprintf(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;
}
_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_fdprintf(2, "%s: can't map cache '%s'\n",
+ _dl_fprintf(2, "%s: can't map cache '%s'\n",
_dl_progname, LDSO_CACHE);
return -1;
}
(sizeof(header_t) + header->nlibs * sizeof(libentry_t))
|| _dl_cache_addr[_dl_cache_size - 1] != '\0')
{
- _dl_fdprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname,
+ _dl_fprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname,
LDSO_CACHE);
goto fail;
}
if (libent[i].sooffset >= strtabsize ||
libent[i].liboffset >= strtabsize)
{
- _dl_fdprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname, LDSO_CACHE);
+ _dl_fprintf(2, "%s: cache '%s' is corrupt\n", _dl_progname, LDSO_CACHE);
goto fail;
}
}
* NO! When we open shared libraries we may search several paths.
* it is inappropriate to generate an error here.
*/
- _dl_fdprintf(2, "%s: can't open '%s'\n", _dl_progname, libname);
+ _dl_fprintf(2, "%s: can't open '%s'\n", _dl_progname, libname);
#endif
_dl_internal_error_number = DL_ERROR_NOFILE;
return NULL;
epnt->e_ident[2] != 'L' ||
epnt->e_ident[3] != 'F')
{
- _dl_fdprintf(2, "%s: '%s' is not an ELF file\n", _dl_progname,
+ _dl_fprintf(2, "%s: '%s' is not an ELF file\n", _dl_progname,
libname);
_dl_internal_error_number = DL_ERROR_NOTELF;
_dl_close(infile);
{
_dl_internal_error_number =
(epnt->e_type != ET_DYN ? DL_ERROR_NOTDYN : DL_ERROR_NOTMAGIC);
- _dl_fdprintf(2, "%s: '%s' is not an ELF executable for " ELF_TARGET
+ _dl_fprintf(2, "%s: '%s' is not an ELF executable for " ELF_TARGET
"\n", _dl_progname, libname);
_dl_close(infile);
return NULL;
if (ppnt->p_type == PT_DYNAMIC) {
if (dynamic_addr)
- _dl_fdprintf(2, "%s: '%s' has more than one dynamic section\n",
+ _dl_fprintf(2, "%s: '%s' has more than one dynamic section\n",
_dl_progname, libname);
dynamic_addr = ppnt->p_vaddr;
dynamic_size = ppnt->p_filesz;
status = (char *) _dl_mmap((char *) (piclib ? 0 : minvma),
maxvma - minvma, PROT_NONE, flags | MAP_ANONYMOUS, -1, 0);
if (_dl_mmap_check_error(status)) {
- _dl_fdprintf(2, "%s: can't map '/dev/zero'\n", _dl_progname);
+ _dl_fprintf(2, "%s: can't map '/dev/zero'\n", _dl_progname);
_dl_internal_error_number = DL_ERROR_MMAP_FAILED;
_dl_close(infile);
return NULL;
ppnt->p_offset & 0x7ffff000);
if (_dl_mmap_check_error(status)) {
- _dl_fdprintf(2, "%s: can't map '%s'\n",
+ _dl_fprintf(2, "%s: can't map '%s'\n",
_dl_progname, libname);
_dl_internal_error_number = DL_ERROR_MMAP_FAILED;
_dl_munmap((char *) libaddr, maxvma - minvma);
ppnt->p_filesz, LXFLAGS(ppnt->p_flags), flags,
infile, ppnt->p_offset & 0x7ffff000);
if (_dl_mmap_check_error(status)) {
- _dl_fdprintf(2, "%s: can't map '%s'\n", _dl_progname, libname);
+ _dl_fprintf(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);
if (!dynamic_addr) {
_dl_internal_error_number = DL_ERROR_NODYNAMIC;
- _dl_fdprintf(2, "%s: '%s' is missing a dynamic section\n",
+ _dl_fprintf(2, "%s: '%s' is missing a dynamic section\n",
_dl_progname, libname);
return NULL;
}
symtab = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr);
strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
- _dl_fdprintf(2, "tpnt = %x\n", tpnt);
- _dl_fdprintf(2, "reloc = %x\n", this_reloc);
- _dl_fdprintf(2, "symtab = %x\n", symtab);
- _dl_fdprintf(2, "strtab = %x\n", strtab);
+ _dl_fprintf(2, "tpnt = %x\n", tpnt);
+ _dl_fprintf(2, "reloc = %x\n", this_reloc);
+ _dl_fprintf(2, "symtab = %x\n", symtab);
+ _dl_fprintf(2, "strtab = %x\n", strtab);
if (reloc_type != R_SPARC_JMP_SLOT) {
- _dl_fdprintf(2, "%s: incorrect relocation type in jump relocations (%d)\n",
+ _dl_fprintf(2, "%s: incorrect relocation type in jump relocations (%d)\n",
_dl_progname, reloc_type);
_dl_exit(30);
};
instr_addr = ((int)this_reloc->r_offset + (int)tpnt->loadaddr);
got_addr = (char **) instr_addr;
- _dl_fdprintf(2, "symtab_index %d\n", symtab_index);
+ _dl_fprintf(2, "symtab_index %d\n", symtab_index);
#ifdef DEBUG
- _dl_fdprintf(2, "Resolving symbol %s\n",
+ _dl_fprintf(2, "Resolving symbol %s\n",
strtab + symtab[symtab_index].st_name);
#endif
new_addr = _dl_find_hash(strtab + symtab[symtab_index].st_name,
tpnt->symbol_scope, (int) got_addr, tpnt, 0);
if(!new_addr) {
- _dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
_dl_exit(31);
};
/* #define DEBUG_LIBRARY */
#ifdef DEBUG_LIBRARY
if((unsigned int) got_addr < 0x40000000) {
- _dl_fdprintf(2, "Calling library function: %s\n",
+ _dl_fprintf(2, "Calling library function: %s\n",
strtab + symtab[symtab_index].st_name);
} else {
got_addr[1] = (char *) (0x03000000 | (((unsigned int) new_addr >> 10) & 0x3fffff));
got_addr[1] = (char *) (0x03000000 | (((unsigned int) new_addr >> 10) & 0x3fffff));
got_addr[2] = (char *) (0x81c06000 | ((unsigned int) new_addr & 0x3ff));
#endif
- _dl_fdprintf(2, "Address = %x\n",new_addr);
+ _dl_fprintf(2, "Address = %x\n",new_addr);
_dl_exit(32);
return (unsigned int) new_addr;
case R_SPARC_JMP_SLOT:
break;
default:
- _dl_fdprintf(2, "%s: (LAZY) can't handle reloc type ", _dl_progname);
+ _dl_fprintf(2, "%s: (LAZY) can't handle reloc type ", _dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fdprintf(2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_fprintf(2, "%s ", _dl_reltypes[reloc_type]);
#endif
- if(symtab_index) _dl_fdprintf(2, "'%s'\n",
+ if(symtab_index) _dl_fprintf(2, "'%s'\n",
strtab + symtab[symtab_index].st_name);
_dl_exit(33);
};
if(!symbol_addr &&
ELF32_ST_BIND(symtab [symtab_index].st_info) == STB_GLOBAL) {
- _dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
};
break;
case R_SPARC_COPY:
#if 0 /* This one is done later */
- _dl_fdprintf(2, "Doing copy for symbol ");
- if(symtab_index) _dl_fdprintf(2, strtab + symtab[symtab_index].st_name);
- _dl_fdprintf(2, "\n");
+ _dl_fprintf(2, "Doing copy for symbol ");
+ if(symtab_index) _dl_fprintf(2, strtab + symtab[symtab_index].st_name);
+ _dl_fprintf(2, "\n");
_dl_memcpy((void *) symtab[symtab_index].st_value,
(void *) symbol_addr,
symtab[symtab_index].st_size);
#endif
break;
default:
- _dl_fdprintf(2, "%s: can't handle reloc type ", _dl_progname);
+ _dl_fprintf(2, "%s: can't handle reloc type ", _dl_progname);
#ifdef VERBOSE_DLINKER
- _dl_fdprintf(2, "%s ", _dl_reltypes[reloc_type]);
+ _dl_fprintf(2, "%s ", _dl_reltypes[reloc_type]);
#endif
if (symtab_index)
- _dl_fdprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
+ _dl_fprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
_dl_exit(34);
};
_dl_find_hash(strtab + symtab[symtab_index].st_name,
xpnt->next, (int) reloc_addr, NULL, 1);
if(!symbol_addr) {
- _dl_fdprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_fprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
goof++;
};
extern void * _dl_memcpy(void * dst, const void * src, size_t len);
extern int _dl_memcmp(const void * s1,const void * s2,size_t len);
extern void * _dl_memset(void * str,int c,size_t len);
+extern void _dl_fprintf(int, const char *, ...);
#ifndef NULL
#define NULL ((void *) 0)
return p + 1;
}
+
+#if defined mc68000 || defined __arm__
+/* On some arches constant strings are referenced through the GOT. */
+/* XXX Requires load_addr to be defined. */
+#define SEND_STDERR(X) \
+ { const char *__s = (X); \
+ if (__s < (const char *) load_addr) __s += load_addr; \
+ _dl_write (2, __s, _dl_strlen_inline (__s)); \
+ }
+#else
+#define SEND_STDERR(X) _dl_write(2, X, _dl_strlen_inline(X));
+#endif
+
+#define SEND_ADDRESS_STDERR(X, add_a_newline) { \
+ char tmp[13], *tmp1; \
+ _dl_memset_inline(tmp, 0, sizeof(tmp)); \
+ tmp1=_dl_simple_ltoahex_inline( tmp, (unsigned long)(X)); \
+ _dl_write(2, tmp1, _dl_strlen_inline(tmp1)); \
+ if (add_a_newline) { \
+ tmp[0]='\n'; \
+ _dl_write(2, tmp, 1); \
+ } \
+};
+
+#define SEND_NUMBER_STDERR(X, add_a_newline) { \
+ char tmp[13], *tmp1; \
+ _dl_memset_inline(tmp, 0, sizeof(tmp)); \
+ tmp1=_dl_simple_ltoahex_inline( tmp, (unsigned long)(X)); \
+ _dl_write(2, tmp1, _dl_strlen_inline(tmp1)); \
+ if (add_a_newline) { \
+ tmp[0]='\n'; \
+ _dl_write(2, tmp, 1); \
+ } \
+};
+
+
#endif
+++ /dev/null
-/*
- * vsprintf.c
- *
- * Copyright (C) 1991-1996 Linus Torvalds
- */
-
-/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
-/*
- * Wirzenius wrote this portably, Torvalds fucked it up :-)
- */
-
-#include <stdarg.h>
-#include "string.h"
-#include "hash.h"
-#include "syscall.h"
-
-/* we use this so that we can do without the ctype library */
-#define is_digit(c) ((c) >= '0' && (c) <= '9')
-
-static int skip_atoi(const char **s)
-{
- int i=0;
-
- while (is_digit(**s))
- i = i*10 + *((*s)++) - '0';
- return i;
-}
-
-#define ZEROPAD 1 /* pad with zero */
-#define SIGN 2 /* unsigned/signed long */
-#define PLUS 4 /* show plus */
-#define SPACE 8 /* space if plus */
-#define LEFT 16 /* left justified */
-#define SPECIAL 32 /* 0x */
-#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
-
-#ifndef __sparc__
-#define do_div(n,base) ({ \
-int __res; \
-__res = ((unsigned long) n) % (unsigned) base; \
-n = ((unsigned long) n) / (unsigned) base; \
-__res; })
-#else
-#define do_div(n,base) _dl_div ((n)/(base))
-#define do_div(n,base) ({ \
-int __res; \
-__res = _dl_urem(((unsigned long) n),(unsigned) base); \
-n = _dl_udiv(((unsigned long) n),(unsigned) base); \
-__res; })
-#endif
-
-#define ADD_CHAR(s,n,c) ( ((n) > 1) ? *(s)++ = (c), (n)-- : (c) )
-
-static char * number(char * str, int *bufsize, long num, int base, int size, int precision
- ,int type)
-{
- char c,sign,tmp[66];
- const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
- int i;
-
- if (type & LARGE)
- digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- if (type & LEFT)
- type &= ~ZEROPAD;
- if (base < 2 || base > 36)
- return 0;
- c = (type & ZEROPAD) ? '0' : ' ';
- sign = 0;
- if (type & SIGN) {
- if (num < 0) {
- sign = '-';
- num = -num;
- size--;
- } else if (type & PLUS) {
- sign = '+';
- size--;
- } else if (type & SPACE) {
- sign = ' ';
- size--;
- }
- }
- if (type & SPECIAL) {
- if (base == 16)
- size -= 2;
- else if (base == 8)
- size--;
- }
- i = 0;
- if (num == 0)
- tmp[i++]='0';
- else while (num != 0)
- tmp[i++] = digits[do_div(num,base)];
- if (i > precision)
- precision = i;
- size -= precision;
- if (!(type&(ZEROPAD+LEFT)))
- while(size-->0)
- ADD_CHAR(str, *bufsize, ' ');
- if (sign)
- ADD_CHAR(str, *bufsize, sign);
- if (type & SPECIAL) {
- if (base==8)
- ADD_CHAR(str, *bufsize, '0');
- else if (base==16) {
- ADD_CHAR(str, *bufsize, '0');
- ADD_CHAR(str, *bufsize, digits[33]);
- }
- }
- if (!(type & LEFT))
- while (size-- > 0)
- ADD_CHAR(str, *bufsize, c);
- while (i < precision--)
- ADD_CHAR(str, *bufsize, '0');
- while (i-- > 0)
- ADD_CHAR(str, *bufsize, tmp[i]);
- while (size-- > 0)
- ADD_CHAR(str, *bufsize, ' ');
- return str;
-}
-
-int _dl_fdprintf(int fd, const char *fmt, ...)
-{
- int len;
- unsigned long num;
- int i, base;
- char * str;
- const char *s;
-
- int flags; /* flags to number() */
-
- int field_width; /* width of output field */
- int precision; /* min. # of digits for integers; max
- number of chars for from string */
- int qualifier; /* 'h', 'l', or 'L' for integer fields */
-
- int bufsize;
- char buf[2048];
- va_list(args);
-
- va_start(args, fmt);
-
- for (str=buf, bufsize=sizeof buf ; *fmt ; ++fmt) {
- if (*fmt != '%') {
- ADD_CHAR(str, bufsize, *fmt);
- continue;
- }
-
- /* process flags */
- flags = 0;
- repeat:
- ++fmt; /* this also skips first '%' */
- switch (*fmt) {
- case '-': flags |= LEFT; goto repeat;
- case '+': flags |= PLUS; goto repeat;
- case ' ': flags |= SPACE; goto repeat;
- case '#': flags |= SPECIAL; goto repeat;
- case '0': flags |= ZEROPAD; goto repeat;
- }
-
- /* get field width */
- field_width = -1;
- if (is_digit(*fmt))
- field_width = skip_atoi(&fmt);
- else if (*fmt == '*') {
- ++fmt;
- /* it's the next argument */
- field_width = va_arg(args, int);
- if (field_width < 0) {
- field_width = -field_width;
- flags |= LEFT;
- }
- }
-
- /* get the precision */
- precision = -1;
- if (*fmt == '.') {
- ++fmt;
- if (is_digit(*fmt))
- precision = skip_atoi(&fmt);
- else if (*fmt == '*') {
- ++fmt;
- /* it's the next argument */
- precision = va_arg(args, int);
- }
- if (precision < 0)
- precision = 0;
- }
-
- /* get the conversion qualifier */
- qualifier = -1;
- if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
- qualifier = *fmt;
- ++fmt;
- }
-
- /* default base */
- base = 10;
-
- switch (*fmt) {
- case 'c':
- if (!(flags & LEFT))
- while (--field_width > 0)
- ADD_CHAR(str, bufsize, ' ');
- ADD_CHAR(str, bufsize, (unsigned char) va_arg(args, int));
- while (--field_width > 0)
- ADD_CHAR(str, bufsize, ' ');
- continue;
-
- case 's':
- s = va_arg(args, char *);
- if (!s)
- s = "<NULL>";
-
- len = _dl_strlen(s);
-
- if (!(flags & LEFT))
- while (len < field_width--)
- ADD_CHAR(str, bufsize, ' ');
- for (i = 0; i < len; ++i)
- ADD_CHAR(str, bufsize, *s++);
- while (len < field_width--)
- ADD_CHAR(str, bufsize, ' ');
- continue;
-
- case 'p':
- if (field_width == -1) {
- field_width = 2*sizeof(void *);
- flags |= ZEROPAD;
- }
- str = number(str, &bufsize,
- (unsigned long) va_arg(args, void *), 16,
- field_width, precision, flags);
- continue;
-
-
- case 'n':
- if (qualifier == 'l') {
- long * ip = va_arg(args, long *);
- *ip = (str - buf);
- } else {
- int * ip = va_arg(args, int *);
- *ip = (str - buf);
- }
- continue;
-
- /* integer number formats - set up the flags and "break" */
- case 'o':
- base = 8;
- break;
-
- case 'X':
- flags |= LARGE;
- case 'x':
- base = 16;
- break;
-
- case 'd':
- case 'i':
- flags |= SIGN;
- case 'u':
- break;
-
- default:
- if (*fmt != '%')
- ADD_CHAR(str, bufsize, '%');
- if (*fmt)
- ADD_CHAR(str, bufsize, *fmt);
- else
- --fmt;
- continue;
- }
- if (qualifier == 'l')
- num = va_arg(args, unsigned long);
-#ifndef __powerpc__
- else if (qualifier == 'h')
- if (flags & SIGN)
- num = va_arg(args, short);
- else
- num = va_arg(args, unsigned short);
-#endif
- else if (flags & SIGN)
- num = va_arg(args, int);
- else
- num = va_arg(args, unsigned int);
- str = number(str, &bufsize, num, base, field_width, precision, flags);
- }
- *str = '\0';
- _dl_write(fd, buf, str-buf);
- return str-buf;
-}
-