summaryrefslogtreecommitdiffstats
path: root/sigchainlib
diff options
context:
space:
mode:
authorDmitriy Ivanov <dimitry@google.com>2014-10-07 13:43:23 -0700
committerDmitriy Ivanov <dimitry@google.com>2014-10-07 16:52:46 -0700
commitf57874dddefc03fef9ad36fbdd87e39a08a8d641 (patch)
tree4cb51f492558475368ce0df190c12e8f1adf732a /sigchainlib
parent1000e69b7e11348f2e1d3ba67339616a647f53d7 (diff)
downloadandroid_art-f57874dddefc03fef9ad36fbdd87e39a08a8d641.tar.gz
android_art-f57874dddefc03fef9ad36fbdd87e39a08a8d641.tar.bz2
android_art-f57874dddefc03fef9ad36fbdd87e39a08a8d641.zip
Remove libsigchain from LD_PRELOADS
Link sigchain.cc statically with dalvikvm, app_process, surfaceflinger, dex2oat, patchoat and objdump. Replace libsigchain.so with dummy implementaions to avoid situations when it is used incorrectly. Bug: 15345057 Bug: 15426766 Change-Id: If0b7f59a59824e30aa0c33dad76c7a44932180de
Diffstat (limited to 'sigchainlib')
-rw-r--r--sigchainlib/Android.mk6
-rw-r--r--sigchainlib/sigchain.cc17
-rw-r--r--sigchainlib/sigchain.h12
-rw-r--r--sigchainlib/sigchain_dummy.cc59
-rw-r--r--sigchainlib/version-script.txt12
5 files changed, 85 insertions, 21 deletions
diff --git a/sigchainlib/Android.mk b/sigchainlib/Android.mk
index d86735d120..e52adfc651 100644
--- a/sigchainlib/Android.mk
+++ b/sigchainlib/Android.mk
@@ -22,10 +22,10 @@ include $(CLEAR_VARS)
LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS += $(ART_TARGET_CFLAGS)
-LOCAL_SRC_FILES := sigchain.cc
+LOCAL_SRC_FILES := sigchain_dummy.cc
LOCAL_CLANG = $(ART_TARGET_CLANG)
LOCAL_MODULE:= libsigchain
-LOCAL_SHARED_LIBRARIES := liblog libdl
+LOCAL_SHARED_LIBRARIES := liblog
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.common_build.mk
include $(BUILD_SHARED_LIBRARY)
@@ -37,7 +37,7 @@ LOCAL_MODULE_TAGS := optional
LOCAL_IS_HOST_MODULE := true
LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
LOCAL_CLANG = $(ART_HOST_CLANG)
-LOCAL_SRC_FILES := sigchain.cc
+LOCAL_SRC_FILES := sigchain_dummy.cc
LOCAL_MODULE:= libsigchain
LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
LOCAL_LDLIBS = -ldl
diff --git a/sigchainlib/sigchain.cc b/sigchainlib/sigchain.cc
index 74bfb7e9c6..c5015e8d0f 100644
--- a/sigchainlib/sigchain.cc
+++ b/sigchainlib/sigchain.cc
@@ -107,21 +107,20 @@ static void CheckSignalValid(int signal) {
}
}
-
// Claim a signal chain for a particular signal.
-void ClaimSignalChain(int signal, struct sigaction* oldaction) {
+extern "C" void ClaimSignalChain(int signal, struct sigaction* oldaction) {
CheckSignalValid(signal);
user_sigactions[signal].Claim(*oldaction);
}
-void UnclaimSignalChain(int signal) {
+extern "C" void UnclaimSignalChain(int signal) {
CheckSignalValid(signal);
user_sigactions[signal].Unclaim(signal);
}
// Invoke the user's signal handler.
-void InvokeUserSignalHandler(int sig, siginfo_t* info, void* context) {
+extern "C" void InvokeUserSignalHandler(int sig, siginfo_t* info, void* context) {
// Check the arguments.
CheckSignalValid(sig);
@@ -148,10 +147,9 @@ void InvokeUserSignalHandler(int sig, siginfo_t* info, void* context) {
}
}
-extern "C" {
// These functions are C linkage since they replace the functions in libc.
-int sigaction(int signal, const struct sigaction* new_action, struct sigaction* old_action) {
+extern "C" int sigaction(int signal, const struct sigaction* new_action, struct sigaction* old_action) {
// If this signal has been claimed as a signal chain, record the user's
// action but don't pass it on to the kernel.
// Note that we check that the signal number is in range here. An out of range signal
@@ -187,7 +185,7 @@ int sigaction(int signal, const struct sigaction* new_action, struct sigaction*
return linked_sigaction(signal, new_action, old_action);
}
-sighandler_t signal(int signal, sighandler_t handler) {
+extern "C" sighandler_t signal(int signal, sighandler_t handler) {
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_handler = handler;
@@ -226,7 +224,7 @@ sighandler_t signal(int signal, sighandler_t handler) {
return reinterpret_cast<sighandler_t>(sa.sa_handler);
}
-int sigprocmask(int how, const sigset_t* bionic_new_set, sigset_t* bionic_old_set) {
+extern "C" int sigprocmask(int how, const sigset_t* bionic_new_set, sigset_t* bionic_old_set) {
const sigset_t* new_set_ptr = bionic_new_set;
sigset_t tmpset;
if (bionic_new_set != NULL) {
@@ -258,9 +256,8 @@ int sigprocmask(int how, const sigset_t* bionic_new_set, sigset_t* bionic_old_se
SigProcMask linked_sigprocmask= reinterpret_cast<SigProcMask>(linked_sigprocmask_sym);
return linked_sigprocmask(how, new_set_ptr, bionic_old_set);
}
-} // extern "C"
-void InitializeSignalChain() {
+extern "C" void InitializeSignalChain() {
// Warning.
// Don't call this from within a signal context as it makes calls to
// dlsym. Calling into the dynamic linker will result in locks being
diff --git a/sigchainlib/sigchain.h b/sigchainlib/sigchain.h
index 5bc4026850..0de0d080e8 100644
--- a/sigchainlib/sigchain.h
+++ b/sigchainlib/sigchain.h
@@ -19,16 +19,12 @@
#include <signal.h>
-namespace art {
+extern "C" void InitializeSignalChain();
-void InitializeSignalChain();
+extern "C" void ClaimSignalChain(int signal, struct sigaction* oldaction);
-void ClaimSignalChain(int signal, struct sigaction* oldaction);
+extern "C" void UnclaimSignalChain(int signal);
-void UnclaimSignalChain(int signal);
-
-void InvokeUserSignalHandler(int sig, siginfo_t* info, void* context);
-
-} // namespace art
+extern "C" void InvokeUserSignalHandler(int sig, siginfo_t* info, void* context);
#endif // ART_SIGCHAINLIB_SIGCHAIN_H_
diff --git a/sigchainlib/sigchain_dummy.cc b/sigchainlib/sigchain_dummy.cc
new file mode 100644
index 0000000000..7176f052cb
--- /dev/null
+++ b/sigchainlib/sigchain_dummy.cc
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_ANDROID_OS
+#include <android/log.h>
+#else
+#include <stdarg.h>
+#include <iostream>
+#endif
+
+#include <stdlib.h>
+
+#include "sigchain.h"
+
+static void log(const char* format, ...) {
+ char buf[256];
+ va_list ap;
+ va_start(ap, format);
+ vsnprintf(buf, sizeof(buf), format, ap);
+#ifdef HAVE_ANDROID_OS
+ __android_log_write(ANDROID_LOG_ERROR, "libsigchain", buf);
+#else
+ std::cout << buf << "\n";
+#endif
+ va_end(ap);
+}
+
+extern "C" void ClaimSignalChain(int signal, struct sigaction* oldaction) {
+ log("ClaimSignalChain is not exported by the main executable.");
+ abort();
+}
+
+extern "C" void UnclaimSignalChain(int signal) {
+ log("UnclaimSignalChain is not exported by the main executable.");
+ abort();
+}
+
+extern "C" void InvokeUserSignalHandler(int sig, siginfo_t* info, void* context) {
+ log("InvokeUserSignalHandler is not exported by the main executable.");
+ abort();
+}
+
+extern "C" void InitializeSignalChain() {
+ log("InitializeSignalChain is not exported by the main executable.");
+ abort();
+}
diff --git a/sigchainlib/version-script.txt b/sigchainlib/version-script.txt
new file mode 100644
index 0000000000..8030da4d65
--- /dev/null
+++ b/sigchainlib/version-script.txt
@@ -0,0 +1,12 @@
+{
+global:
+ ClaimSignalChain;
+ UnclaimSignalChain;
+ InvokeUserSignalHandler;
+ InitializeSignalChain;
+ sigaction;
+ signal;
+ sigprocmask;
+local:
+ *;
+};