[libunwind] Export the unw_* symbols as weak symbols
libunwind defines the _Unwind_* ABI used by libc++abi. This ABI is a
stable quasi-standard common between multiple implementations such as
LLVM and GNU. The _U* symbol name space is also safely within the symbol
name space that standard C & C++ reserve for the implementation.
Futhermore, libunwind also defines several unw_* symbols, and references
these from the _Unwind_* entry points so the standard/reserved part of
the ABI is dependent on the unw_* part of the ABI. This is not OK for a
C or C++ implementation. The unw_* symbols are reserved for C and extern
"C" used by application code.
This change renames each unw_* function to __unw* and adds a weak alias
unw_* to keep the public <libunwind.h> ABI unchanged for backwards
compatibility. Every reference to unw_* in the implementation has been
changed to use __unw* so that if other unw_* definitions are in force
because nothing uses <libunwind.h> in a particular program, no _Unwind*
code path depends on any unw_* symbol. Furthemore, __unw_* symbols are
hidden, which saves PLT overhead in the shared library case.
In the future, we should cconsider untangling the unw_* API/ABI from the
_Unwind_* API/ABI. The internal API backing the _Unwind_* ABI
implementation should not rely on any nonstandard symbols not in the
implementation-reserved name space. This would then allow separating the
_Unwind_* API/ABI from unw_* entirely, but that's a more substantial
change that's going to require more significant refactoring.
Differential Revision: https://reviews.llvm.org/D59921
llvm-svn: 357640
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: e369a989fc37248f4aa05ab2d184270ac27b22e1
diff --git a/src/UnwindLevel1-gcc-ext.c b/src/UnwindLevel1-gcc-ext.c
index fc303a9..63e4083 100644
--- a/src/UnwindLevel1-gcc-ext.c
+++ b/src/UnwindLevel1-gcc-ext.c
@@ -93,10 +93,10 @@
unw_cursor_t cursor;
unw_context_t uc;
unw_proc_info_t info;
- unw_getcontext(&uc);
- unw_init_local(&cursor, &uc);
- unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t) pc);
- if (unw_get_proc_info(&cursor, &info) == UNW_ESUCCESS)
+ __unw_getcontext(&uc);
+ __unw_init_local(&cursor, &uc);
+ __unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t)pc);
+ if (__unw_get_proc_info(&cursor, &info) == UNW_ESUCCESS)
return (void *)(intptr_t) info.start_ip;
else
return NULL;
@@ -108,8 +108,8 @@
_Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
unw_cursor_t cursor;
unw_context_t uc;
- unw_getcontext(&uc);
- unw_init_local(&cursor, &uc);
+ __unw_getcontext(&uc);
+ __unw_init_local(&cursor, &uc);
_LIBUNWIND_TRACE_API("_Unwind_Backtrace(callback=%p)",
(void *)(uintptr_t)callback);
@@ -128,7 +128,7 @@
#if !defined(_LIBUNWIND_ARM_EHABI)
// ask libunwind to get next frame (skip over first frame which is
// _Unwind_Backtrace())
- if (unw_step(&cursor) <= 0) {
+ if (__unw_step(&cursor) <= 0) {
_LIBUNWIND_TRACE_UNWINDING(" _backtrace: ended because cursor reached "
"bottom of stack, returning %d",
_URC_END_OF_STACK);
@@ -137,7 +137,7 @@
#else
// Get the information for this frame.
unw_proc_info_t frameInfo;
- if (unw_get_proc_info(&cursor, &frameInfo) != UNW_ESUCCESS) {
+ if (__unw_get_proc_info(&cursor, &frameInfo) != UNW_ESUCCESS) {
return _URC_END_OF_STACK;
}
@@ -164,8 +164,8 @@
char functionName[512];
unw_proc_info_t frame;
unw_word_t offset;
- unw_get_proc_name(&cursor, functionName, 512, &offset);
- unw_get_proc_info(&cursor, &frame);
+ __unw_get_proc_name(&cursor, functionName, 512, &offset);
+ __unw_get_proc_info(&cursor, &frame);
_LIBUNWIND_TRACE_UNWINDING(
" _backtrace: start_ip=0x%" PRIxPTR ", func=%s, lsda=0x%" PRIxPTR ", context=%p",
frame.start_ip, functionName, frame.lsda,
@@ -191,10 +191,10 @@
unw_cursor_t cursor;
unw_context_t uc;
unw_proc_info_t info;
- unw_getcontext(&uc);
- unw_init_local(&cursor, &uc);
- unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t) pc);
- unw_get_proc_info(&cursor, &info);
+ __unw_getcontext(&uc);
+ __unw_init_local(&cursor, &uc);
+ __unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t)pc);
+ __unw_get_proc_info(&cursor, &info);
bases->tbase = (uintptr_t)info.extra;
bases->dbase = 0; // dbase not used on Mac OS X
bases->func = (uintptr_t)info.start_ip;
@@ -208,7 +208,7 @@
_LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) {
unw_cursor_t *cursor = (unw_cursor_t *)context;
unw_word_t result;
- unw_get_reg(cursor, UNW_REG_SP, &result);
+ __unw_get_reg(cursor, UNW_REG_SP, &result);
_LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p) => 0x%" PRIxPTR,
(void *)context, result);
return (uintptr_t)result;
@@ -233,7 +233,7 @@
/// was broken until 10.6.
_LIBUNWIND_EXPORT void __register_frame(const void *fde) {
_LIBUNWIND_TRACE_API("__register_frame(%p)", fde);
- _unw_add_dynamic_fde((unw_word_t)(uintptr_t) fde);
+ __unw_add_dynamic_fde((unw_word_t)(uintptr_t)fde);
}
@@ -243,7 +243,7 @@
/// was broken until 10.6.
_LIBUNWIND_EXPORT void __deregister_frame(const void *fde) {
_LIBUNWIND_TRACE_API("__deregister_frame(%p)", fde);
- _unw_remove_dynamic_fde((unw_word_t)(uintptr_t) fde);
+ __unw_remove_dynamic_fde((unw_word_t)(uintptr_t)fde);
}