linker: log only real dlerrors

Currently linker reports all potential dlerrors
for example if library was not found in 'this'
namespace - it initializes linker error buffer
with not found message but when consequent
search in linked namespace succeeds this message
is droped because dlopen was successful.

This commit avoids logging false positive error
messages when debug.ld.* set to dlerror.

Test: manual
Change-Id: I480694a1b1bbacd6bd1d8505cd2ee491710964cc
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index 5ccd656..96dd477 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -48,6 +48,7 @@
 
   char* old_value = *dlerror_slot;
   *dlerror_slot = new_value;
+  LD_LOG(kLogErrors, "%s\n", new_value);
   return old_value;
 }
 
diff --git a/linker/linker_globals.h b/linker/linker_globals.h
index b6f8a04..e4e3d97 100644
--- a/linker/linker_globals.h
+++ b/linker/linker_globals.h
@@ -38,7 +38,6 @@
     do { \
       __libc_format_buffer(linker_get_error_buffer(), linker_get_error_buffer_size(), fmt, ##x); \
       /* If LD_DEBUG is set high enough, log every dlerror(3) message. */ \
-      LD_LOG(kLogErrors, "%s\n", linker_get_error_buffer()); \
     } while (false)
 
 #define DL_WARN(fmt, x...) \