[compiler-rt] r201545 - [asan] Make __cxa_demangle non-weak symbol on Android.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Wed Mar 5 00:04:04 PST 2014
Looks like it's best to remove the stlport flag from update.sh. This
would result in statically linking parts of libstdc++ related to
symbol demangling into asan runtime, which should be perfectly safe.
I'll see if we can detect this situation and revert to weak binding
for __cxa_demangling.
On Tue, Mar 4, 2014 at 9:36 PM, Hans Wennborg <hans at chromium.org> wrote:
> Hi Evgeniy,
>
> Trying to build the Clang package for Linux/Android in Chromium, I now
> fail to link the Android ASan run-time. I suspect this commit might
> have something to do with it. This is the error I'm getting:
>
> SO: clang_linux/asan-arm-android/arm-android:
> /usr/local/google/work/chromium/src/third_party/llvm-build/tools/clang/runtime/compiler-rt/clang_linux/asan-arm-android/arm-android/libcompiler_rt.so
> ../../../llvm-build/android-toolchain/lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld:
> /usr/local/google/work/chromium/src/third_party/llvm-build/tools/clang/runtime/compiler-rt/clang_linux/asan-arm-android/arm-android/SubDir.lib__sanitizer_common/sanitizer_symbolizer_posix_libcdep.o:
> in function __sanitizer::POSIXSymbolizer::Demangle(char
> const*):/usr/local/google/work/chromium/src/third_party/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc(.text._ZN11__sanitizer15POSIXSymbolizer8DemangleEPKc+0xd0):
> error: undefined reference to '__cxa_demangle'
> clang: error: linker command failed with exit code 1 (use -v to see invocation)
> make[2]: *** [/usr/local/google/work/chromium/src/third_party/llvm-build/tools/clang/runtime/compiler-rt/clang_linux/asan-arm-android/arm-android/libcompiler_rt.so]
> Error 1
>
> Any ideas?
>
> Thanks,
> Hans
>
> On Mon, Feb 17, 2014 at 11:34 PM, Evgeniy Stepanov
> <eugeni.stepanov at gmail.com> wrote:
>> Author: eugenis
>> Date: Tue Feb 18 01:34:52 2014
>> New Revision: 201545
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=201545&view=rev
>> Log:
>> [asan] Make __cxa_demangle non-weak symbol on Android.
>>
>> This fixes global-demangle.cc test on Android.
>>
>> https://code.google.com/p/address-sanitizer/issues/detail?id=264
>>
>> Modified:
>> compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
>>
>> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc?rev=201545&r1=201544&r2=201545&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc (original)
>> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc Tue Feb 18 01:34:52 2014
>> @@ -32,10 +32,18 @@
>> // C++ demangling function, as required by Itanium C++ ABI. This is weak,
>> // because we do not require a C++ ABI library to be linked to a program
>> // using sanitizers; if it's not present, we'll just use the mangled name.
>> +//
>> +// On Android, this is not weak, because we are using shared runtime library
>> +// AND static libstdc++, and there is no good way to conditionally export
>> +// __cxa_demangle. By making this a non-weak symbol, we statically link
>> +// __cxa_demangle into ASan runtime library.
>> namespace __cxxabiv1 {
>> - extern "C" SANITIZER_WEAK_ATTRIBUTE
>> - char *__cxa_demangle(const char *mangled, char *buffer,
>> - size_t *length, int *status);
>> + extern "C"
>> +#if !SANITIZER_ANDROID
>> + SANITIZER_WEAK_ATTRIBUTE
>> +#endif
>> + char *__cxa_demangle(const char *mangled, char *buffer, size_t *length,
>> + int *status);
>> }
>>
>> namespace __sanitizer {
>> @@ -47,7 +55,7 @@ static const char *DemangleCXXABI(const
>> // own demangler (libc++abi's implementation could be adapted so that
>> // it does not allocate). For now, we just call it anyway, and we leak
>> // the returned value.
>> - if (__cxxabiv1::__cxa_demangle)
>> + if (SANITIZER_ANDROID || &__cxxabiv1::__cxa_demangle)
>> if (const char *demangled_name =
>> __cxxabiv1::__cxa_demangle(name, 0, 0, 0))
>> return demangled_name;
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list