linker: remove newlines from DL_ERR so that dlerror works correctly

Signed-off-by: Erik Gilling <konkers@android.com>
diff --git a/linker/linker.c b/linker/linker.c
index e235498..0c1af9d 100644
--- a/linker/linker.c
+++ b/linker/linker.c
@@ -123,7 +123,7 @@
     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 @@
     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 @@
     */
     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 @@
     }
     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 @@
 
     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 @@
 
     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 @@
     }
 
     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 @@
                       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 @@
     }
 
 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 @@
                          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 @@
                                   -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 @@
     /* 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 @@
     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 @@
         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 @@
                 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 @@
             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 @@
             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 @@
 #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 @@
     } 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 @@
 
     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 @@
         /* 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 @@
         } 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 @@
         } 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 @@
             } 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 @@
     }
 
     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 @@
             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 @@
             *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 @@
            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 @@
             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;
             }