Merge change 8281 into donut

* changes:
  linker: remove newlines from DL_ERR so that dlerror works correctly
This commit is contained in:
Android (Google) Code Review 2009-07-28 17:35:12 -07:00
commit 22b5eb858d

View file

@ -123,7 +123,7 @@ static char __linker_dl_err_buf[768];
do { \
snprintf(__linker_dl_err_buf, sizeof(__linker_dl_err_buf), \
"%s[%d]: " fmt, __func__, __LINE__, ##x); \
ERROR(fmt, ##x); \
ERROR(fmt "\n", ##x); \
} while(0)
const char *linker_get_error(void)
@ -234,7 +234,7 @@ static soinfo *alloc_info(const char *name)
soinfo *si;
if(strlen(name) >= SOINFO_NAME_LEN) {
DL_ERR("%5d library name %s too long\n", pid, name);
DL_ERR("%5d library name %s too long", pid, name);
return 0;
}
@ -243,7 +243,7 @@ static soinfo *alloc_info(const char *name)
*/
if (!freelist) {
if(socount == SO_MAX) {
DL_ERR("%5d too many libraries when loading %s\n", pid, name);
DL_ERR("%5d too many libraries when loading %s", pid, name);
return NULL;
}
freelist = sopool + socount++;
@ -279,7 +279,7 @@ static void free_info(soinfo *si)
}
if (trav == NULL) {
/* si was not ni solist */
DL_ERR("%5d name %s is not in solist!\n", pid, si->name);
DL_ERR("%5d name %s is not in solist!", pid, si->name);
return;
}
@ -560,7 +560,7 @@ is_prelinked(int fd, const char *name)
sz = lseek(fd, -sizeof(prelink_info_t), SEEK_END);
if (sz < 0) {
DL_ERR("lseek() failed!\n");
DL_ERR("lseek() failed!");
return 0;
}
@ -636,7 +636,7 @@ get_lib_extents(int fd, const char *name, void *__hdr, unsigned *total_sz)
TRACE("[ %5d Computing extents for '%s'. ]\n", pid, name);
if (verify_elf_object(_hdr, name) < 0) {
DL_ERR("%5d - %s is not a valid ELF object\n", pid, name);
DL_ERR("%5d - %s is not a valid ELF object", pid, name);
return (unsigned)-1;
}
@ -664,7 +664,7 @@ get_lib_extents(int fd, const char *name, void *__hdr, unsigned *total_sz)
}
if ((min_vaddr == 0xffffffff) && (max_vaddr == 0)) {
DL_ERR("%5d - No loadable segments found in %s.\n", pid, name);
DL_ERR("%5d - No loadable segments found in %s.", pid, name);
return (unsigned)-1;
}
@ -701,13 +701,13 @@ static int reserve_mem_region(soinfo *si)
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (base == MAP_FAILED) {
DL_ERR("%5d can NOT map (%sprelinked) library '%s' at 0x%08x "
"as requested, will try general pool: %d (%s)\n",
"as requested, will try general pool: %d (%s)",
pid, (si->base ? "" : "non-"), si->name, si->base,
errno, strerror(errno));
return -1;
} else if (base != (void *)si->base) {
DL_ERR("OOPS: %5d %sprelinked library '%s' mapped at 0x%08x, "
"not at 0x%08x\n", pid, (si->base ? "" : "non-"),
"not at 0x%08x", pid, (si->base ? "" : "non-"),
si->name, (unsigned)base, si->base);
munmap(base, si->size);
return -1;
@ -744,7 +744,7 @@ alloc_mem_region(soinfo *si)
}
err:
DL_ERR("OOPS: %5d cannot map library '%s'. no vspace available.\n",
DL_ERR("OOPS: %5d cannot map library '%s'. no vspace available.",
pid, si->name);
return -1;
}
@ -804,7 +804,7 @@ load_segments(int fd, void *header, soinfo *si)
phdr->p_offset & (~PAGE_MASK));
if (pbase == MAP_FAILED) {
DL_ERR("%d failed to map segment from '%s' @ 0x%08x (0x%08x). "
"p_vaddr=0x%08x p_offset=0x%08x\n", pid, si->name,
"p_vaddr=0x%08x p_offset=0x%08x", pid, si->name,
(unsigned)tmp, len, phdr->p_vaddr, phdr->p_offset);
goto fail;
}
@ -860,7 +860,7 @@ load_segments(int fd, void *header, soinfo *si)
-1, 0);
if (extra_base == MAP_FAILED) {
DL_ERR("[ %5d - failed to extend segment from '%s' @ 0x%08x"
" (0x%08x) ]\n", pid, si->name, (unsigned)tmp,
" (0x%08x) ]", pid, si->name, (unsigned)tmp,
extra_len);
goto fail;
}
@ -913,7 +913,7 @@ load_segments(int fd, void *header, soinfo *si)
/* Sanity check */
if (total_sz > si->size) {
DL_ERR("%5d - Total length (0x%08x) of mapped segments from '%s' is "
"greater than what was allocated (0x%08x). THIS IS BAD!\n",
"greater than what was allocated (0x%08x). THIS IS BAD!",
pid, total_sz, si->name, si->size);
goto fail;
}
@ -980,19 +980,19 @@ load_library(const char *name)
Elf32_Ehdr *hdr;
if(fd == -1) {
DL_ERR("Library '%s' not found\n", name);
DL_ERR("Library '%s' not found", name);
return NULL;
}
/* We have to read the ELF header to figure out what to do with this image
*/
if (lseek(fd, 0, SEEK_SET) < 0) {
DL_ERR("lseek() failed!\n");
DL_ERR("lseek() failed!");
goto fail;
}
if ((cnt = read(fd, &__header[0], PAGE_SIZE)) < 0) {
DL_ERR("read() failed!\n");
DL_ERR("read() failed!");
goto fail;
}
@ -1083,7 +1083,7 @@ soinfo *find_library(const char *name)
if(!strcmp(name, si->name)) {
if(si->flags & FLAG_ERROR) return 0;
if(si->flags & FLAG_LINKED) return si;
DL_ERR("OOPS: %5d recursive link to '%s'\n", pid, si->name);
DL_ERR("OOPS: %5d recursive link to '%s'", pid, si->name);
return NULL;
}
}
@ -1115,7 +1115,7 @@ unsigned unload_library(soinfo *si)
if(lsi)
unload_library(lsi);
else
DL_ERR("%5d could not unload '%s'\n",
DL_ERR("%5d could not unload '%s'",
pid, si->strtab + d[1]);
}
}
@ -1165,20 +1165,20 @@ static int reloc_library(soinfo *si, Elf32_Rel *rel, unsigned count)
sym_name = (char *)(strtab + symtab[sym].st_name);
s = _do_lookup(si, sym_name, &base);
if(s == 0) {
DL_ERR("%5d cannot locate '%s'...\n", pid, sym_name);
DL_ERR("%5d cannot locate '%s'...", pid, sym_name);
return -1;
}
#if 0
if((base == 0) && (si->base != 0)){
/* linking from libraries to main image is bad */
DL_ERR("%5d cannot locate '%s'...\n",
DL_ERR("%5d cannot locate '%s'...",
pid, strtab + symtab[sym].st_name);
return -1;
}
#endif
if ((s->st_shndx == SHN_UNDEF) && (s->st_value != 0)) {
DL_ERR("%5d In '%s', shndx=%d && value=0x%08x. We do not "
"handle this yet\n", pid, si->name, s->st_shndx,
"handle this yet", pid, si->name, s->st_shndx,
s->st_value);
return -1;
}
@ -1239,7 +1239,7 @@ static int reloc_library(soinfo *si, Elf32_Rel *rel, unsigned count)
COUNT_RELOC(RELOC_RELATIVE);
MARK(rel->r_offset);
if(sym){
DL_ERR("%5d odd RELATIVE form...\n", pid);
DL_ERR("%5d odd RELATIVE form...", pid);
return -1;
}
TRACE_TYPE(RELO, "%5d RELO RELATIVE %08x <- +%08x\n", pid,
@ -1280,7 +1280,7 @@ static int reloc_library(soinfo *si, Elf32_Rel *rel, unsigned count)
#endif /* ANDROID_ARM_LINKER */
default:
DL_ERR("%5d unknown reloc type %d @ %p (%d)\n",
DL_ERR("%5d unknown reloc type %d @ %p (%d)",
pid, type, rel, (int) (rel - start));
return -1;
}
@ -1338,7 +1338,7 @@ static void call_constructors(soinfo *si)
} else {
if (si->preinit_array) {
DL_ERR("%5d Shared library '%s' has a preinit_array table @ 0x%08x."
" This is INVALID.\n", pid, si->name,
" This is INVALID.", pid, si->name,
(unsigned)si->preinit_array);
}
}
@ -1385,7 +1385,7 @@ static int nullify_closed_stdio (void)
dev_null = open("/dev/null", O_RDWR);
if (dev_null < 0) {
DL_ERR("Cannot open /dev/null.\n");
DL_ERR("Cannot open /dev/null.");
return -1;
}
TRACE("[ %5d Opened /dev/null file-descriptor=%d]\n", pid, dev_null);
@ -1411,7 +1411,7 @@ static int nullify_closed_stdio (void)
/* The only error we allow is that the file descriptor does not
exist, in which case we dup /dev/null to it. */
if (errno != EBADF) {
DL_ERR("nullify_stdio: unhandled error %s\n", strerror(errno));
DL_ERR("nullify_stdio: unhandled error %s", strerror(errno));
return_value = -1;
continue;
}
@ -1424,7 +1424,7 @@ static int nullify_closed_stdio (void)
} while (status < 0 && errno == EINTR);
if (status < 0) {
DL_ERR("nullify_stdio: dup2 error %s\n", strerror(errno));
DL_ERR("nullify_stdio: dup2 error %s", strerror(errno));
return_value = -1;
continue;
}
@ -1438,7 +1438,7 @@ static int nullify_closed_stdio (void)
} while (status < 0 && errno == EINTR);
if (status < 0) {
DL_ERR("nullify_stdio: close error %s\n", strerror(errno));
DL_ERR("nullify_stdio: close error %s", strerror(errno));
return_value = -1;
}
}
@ -1507,7 +1507,7 @@ static int link_image(soinfo *si, unsigned wr_offset)
} else if (phdr->p_type == PT_DYNAMIC) {
if (si->dynamic != (unsigned *)-1) {
DL_ERR("%5d multiple PT_DYNAMIC segments found in '%s'. "
"Segment at 0x%08x, previously one found at 0x%08x\n",
"Segment at 0x%08x, previously one found at 0x%08x",
pid, si->name, si->base + phdr->p_vaddr,
(unsigned)si->dynamic);
goto fail;
@ -1519,7 +1519,7 @@ static int link_image(soinfo *si, unsigned wr_offset)
}
if (si->dynamic == (unsigned *)-1) {
DL_ERR("%5d missing PT_DYNAMIC?!\n", pid);
DL_ERR("%5d missing PT_DYNAMIC?!", pid);
goto fail;
}
@ -1543,7 +1543,7 @@ static int link_image(soinfo *si, unsigned wr_offset)
break;
case DT_PLTREL:
if(*d != DT_REL) {
DL_ERR("DT_RELA not supported\n");
DL_ERR("DT_RELA not supported");
goto fail;
}
break;
@ -1568,7 +1568,7 @@ static int link_image(soinfo *si, unsigned wr_offset)
*d = (int) &_r_debug;
break;
case DT_RELA:
DL_ERR("%5d DT_RELA not supported\n", pid);
DL_ERR("%5d DT_RELA not supported", pid);
goto fail;
case DT_INIT:
si->init_func = (void (*)(void))(si->base + *d);
@ -1620,7 +1620,7 @@ static int link_image(soinfo *si, unsigned wr_offset)
pid, si->base, si->strtab, si->symtab);
if((si->strtab == 0) || (si->symtab == 0)) {
DL_ERR("%5d missing essential tables\n", pid);
DL_ERR("%5d missing essential tables", pid);
goto fail;
}
@ -1630,7 +1630,7 @@ static int link_image(soinfo *si, unsigned wr_offset)
soinfo *lsi = find_library(si->strtab + d[1]);
if(lsi == 0) {
strlcpy(tmp_err_buf, linker_get_error(), sizeof(tmp_err_buf));
DL_ERR("%5d could not load needed library '%s' for '%s' (%s)\n",
DL_ERR("%5d could not load needed library '%s' for '%s' (%s)",
pid, si->strtab + d[1], si->name, tmp_err_buf);
goto fail;
}