Merge "Cleanup linker unwinder integration"
diff --git a/linker/Android.bp b/linker/Android.bp
index 18f2527..bb9d26d 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -96,7 +96,6 @@
name: "linker_sources_arm",
srcs: [
"arch/arm/begin.S",
- "linker_exidx_static.c",
],
}
@@ -233,6 +232,7 @@
arm: {
srcs: [ ":linker_sources_arm" ],
version_script: ":linker_version_script_arm",
+ static_libs: ["libunwind_llvm"],
},
arm64: {
srcs: [":linker_sources_arm64"],
@@ -276,6 +276,17 @@
"liblinker_malloc",
],
+ // Ensure that if the linker needs __gnu_Unwind_Find_exidx, then the linker will have a
+ // definition of the symbol. The linker links against libgcc.a, whose arm32 unwinder has a weak
+ // reference to __gnu_Unwind_Find_exidx, which isn't sufficient to pull in the strong definition
+ // of __gnu_Unwind_Find_exidx from libc. An unresolved weak reference would create a
+ // non-relative dynamic relocation in the linker binary, which complicates linker startup.
+ //
+ // This line should be unnecessary because the linker's dependency on libunwind_llvm.a should
+ // override libgcc.a, but this line provides a simpler guarantee. It can be removed once the
+ // linker stops linking against libgcc.a's arm32 unwinder.
+ whole_static_libs: ["libc_unwind_static"],
+
name: "linker",
symlinks: ["linker_asan"],
recovery_available: true,
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index 18301e0..228e30a 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -31,6 +31,7 @@
#include "linker_globals.h"
#include "linker_dlwarning.h"
+#include <link.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
@@ -193,11 +194,6 @@
return do_dl_iterate_phdr(cb, data);
}
-// This function is needed by libgcc.a
-int dl_iterate_phdr(int (*cb)(dl_phdr_info* info, size_t size, void* data), void* data) {
- return __loader_dl_iterate_phdr(cb, data);
-}
-
#if defined(__arm__)
_Unwind_Ptr __loader_dl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount) {
ScopedPthreadMutexLocker locker(&g_dl_mutex);
diff --git a/linker/linker_exidx_static.c b/linker/linker_exidx_static.c
deleted file mode 100644
index b38ef17..0000000
--- a/linker/linker_exidx_static.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <link.h>
-
-/* Find the .ARM.exidx section (which in the case of a static executable
- * can be identified through its start and end symbols), and return its
- * beginning and numbe of entries to the caller. Note that for static
- * executables we do not need to use the value of the PC to find the
- * EXIDX section.
- */
-
-extern unsigned __exidx_end;
-extern unsigned __exidx_start;
-
-_Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr pc __unused,
- int* pcount)
-{
- *pcount = (__exidx_end-__exidx_start)/8;
- return __exidx_start;
-}