summaryrefslogtreecommitdiffstats
path: root/linker
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-03-15 15:30:25 -0700
committerElliott Hughes <enh@google.com>2013-03-15 16:12:58 -0700
commit8f2a5a0b40fc82126c691d5c30131d908772aab7 (patch)
tree0b29a5dc82395c076387edb5af9ca271a91264c0 /linker
parente23ed8c6441389a79c6504295184f7249e01a197 (diff)
downloadbionic-8f2a5a0b40fc82126c691d5c30131d908772aab7.tar.gz
bionic-8f2a5a0b40fc82126c691d5c30131d908772aab7.tar.bz2
bionic-8f2a5a0b40fc82126c691d5c30131d908772aab7.zip
Clean up internal libc logging.
We only need one logging API, and I prefer the one that does no allocation and is thus safe to use in any context. Also use O_CLOEXEC when opening the /dev/log files. Move everything logging-related into one header file. Change-Id: Ic1e3ea8e9b910dc29df351bff6c0aa4db26fbb58
Diffstat (limited to 'linker')
-rw-r--r--linker/debugger.cpp15
-rwxr-xr-xlinker/linker.cpp13
-rw-r--r--linker/linker.h2
-rw-r--r--linker/linker_debug.h2
4 files changed, 14 insertions, 18 deletions
diff --git a/linker/debugger.cpp b/linker/debugger.cpp
index 586cd2f8f..6fddb1c75 100644
--- a/linker/debugger.cpp
+++ b/linker/debugger.cpp
@@ -37,9 +37,6 @@
#include <sys/socket.h>
#include <sys/un.h>
-#include <private/debug_format.h>
-#include <private/logd.h>
-
extern "C" int tgkill(int tgid, int tid, int sig);
#define DEBUGGER_SOCKET_NAME "android:debuggerd"
@@ -157,15 +154,15 @@ static bool haveSiginfo(int signum) {
sigemptyset(&newact.sa_mask);
if (sigaction(signum, &newact, &oldact) < 0) {
- __libc_android_log_write(ANDROID_LOG_FATAL, "libc",
- "Failed testing for SA_SIGINFO");
- return 0;
+ __libc_format_log(ANDROID_LOG_FATAL, "libc", "Failed testing for SA_SIGINFO: %s",
+ strerror(errno));
+ return 0;
}
bool ret = (oldact.sa_flags & SA_SIGINFO) != 0;
- if (sigaction(signum, &oldact, NULL) < 0) {
- __libc_android_log_write(ANDROID_LOG_FATAL, "libc",
- "Restore failed in test for SA_SIGINFO");
+ if (sigaction(signum, &oldact, NULL) == -1) {
+ __libc_format_log(ANDROID_LOG_FATAL, "libc", "Restore failed in test for SA_SIGINFO: %s",
+ strerror(errno));
}
return ret;
}
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 2f119e44a..3afd31405 100755
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -42,7 +42,6 @@
// Private C library headers.
#include <private/bionic_tls.h>
#include <private/KernelArgumentBlock.h>
-#include <private/logd.h>
#include <private/ScopedPthreadMutexLocker.h>
#include "linker.h"
@@ -141,13 +140,13 @@ static unsigned bitmask[4096];
// You shouldn't try to call memory-allocating functions in the dynamic linker.
// Guard against the most obvious ones.
-#define DISALLOW_ALLOCATION(return_type, name, ...) \
- return_type name __VA_ARGS__ \
- { \
+#define DISALLOW_ALLOCATION(return_type, name, ...) \
+ return_type name __VA_ARGS__ \
+ { \
const char* msg = "ERROR: " #name " called from the dynamic linker!\n"; \
- __libc_android_log_write(ANDROID_LOG_FATAL, "linker", msg); \
- write(2, msg, strlen(msg)); \
- abort(); \
+ __libc_format_log(ANDROID_LOG_FATAL, "linker", "%s", msg); \
+ write(2, msg, strlen(msg)); \
+ abort(); \
}
#define UNUSED __attribute__((unused))
DISALLOW_ALLOCATION(void*, malloc, (size_t u UNUSED));
diff --git a/linker/linker.h b/linker/linker.h
index d6a4fc502..6196bec02 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -36,7 +36,7 @@
#include <link.h>
-#include <private/debug_format.h>
+#include "private/libc_logging.h"
#define DL_ERR(fmt, x...) \
do { \
diff --git a/linker/linker_debug.h b/linker/linker_debug.h
index 8fc235fbb..7d2485342 100644
--- a/linker/linker_debug.h
+++ b/linker/linker_debug.h
@@ -58,7 +58,7 @@
/*********************************************************************/
-#include <private/debug_format.h>
+#include "private/libc_logging.h"
__LIBC_HIDDEN__ extern int gLdDebugVerbosity;