Refactor linker/Android.bp for native-bridge
Define a "linker_bin_template" cc_defaults module that a native bridge
implementation can inherit to define a guest linker.
Break the debuggerd_init call off into separate
linker_debuggerd_{android,stub}.cpp files to allow opting in/out of the
debuggerd integration without needing to change how linker_main.cpp is
compiled. (This is necessary for a later commit that moves
linker_main.cpp into a new static library.)
Test: bionic unit tests
Bug: none
Merged-In: I7c5d79281bce1e69817b266dd91d43ea40f78522
Change-Id: I7c5d79281bce1e69817b266dd91d43ea40f78522
(cherry picked from commit 5adf402ee9d65c803b71d93b9e3de77b36ccb027)
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index bea2e3c..3b950a3 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -32,6 +32,7 @@
#include <sys/auxv.h>
#include "linker_debug.h"
+#include "linker_debuggerd.h"
#include "linker_cfi.h"
#include "linker_gdb_support.h"
#include "linker_globals.h"
@@ -46,9 +47,6 @@
#include "android-base/unique_fd.h"
#include "android-base/strings.h"
#include "android-base/stringprintf.h"
-#ifdef __ANDROID__
-#include "debuggerd/handler.h"
-#endif
#include <async_safe/log.h>
#include <bionic/libc_init_common.h>
@@ -311,15 +309,7 @@
__system_properties_init(); // may use 'environ'
// Register the debuggerd signal handler.
-#ifdef __ANDROID__
- debuggerd_callbacks_t callbacks = {
- .get_abort_message = []() {
- return __libc_shared_globals()->abort_msg;
- },
- .post_dump = ¬ify_gdb_of_libraries,
- };
- debuggerd_init(&callbacks);
-#endif
+ linker_debuggerd_init();
g_linker_logger.ResetState();