Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ exceptions not handled when building on ARM32 #785

Closed
goutnet opened this issue Sep 4, 2018 · 5 comments
Closed

C++ exceptions not handled when building on ARM32 #785

goutnet opened this issue Sep 4, 2018 · 5 comments

Comments

@goutnet
Copy link

goutnet commented Sep 4, 2018

Description

I am trying to build an application that relies on the NDK for several libs.

Our lib (that I will call libmylib.so) depends on libzip.so which in turns relies on libz.so

In short, libmylib.so -> libzip.so -> libz.so

I am not using ndkbuild or CMake, but rather integrated the last NDK (ndk 17) directly in our build system (custom makefiles that we have total control over).

The problem I am encountering only happens on ARM32, (all works fine on the other archs, x86, x86_64 and aarch64).

What happens is that exceptions are not working properly, catching an exception in the same function works, but not from a function to another, in other word:

    void throwSomething()
    {
        throw(std::exception());
     }
    
    void test()
    {
        try {
            throw(std::exception());
        } catch (const std::exception& e) {
            // This code will be called, no issue we survived this one
        }

        // But the next will die in the unwind:
        try {
            throwSomething();
        } catch (const std::exception& e) {
            // This code will not be called, and crash SIGSEGV
        }
    }
09-04 23:43:27.869 29647-29647/com.example.exception A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 29647 (exception)
09-04 23:43:27.979 485-485/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Build fingerprint: 'samsung/trlteuc/trlteatt:6.0.1/MMB29M/N910AUCS2EPK2:user/release-keys'
    Revision: '12'
    ABI: 'arm'
    pid: 29647, tid: 29647, name: exception  >>> com.example.exception <<<
    signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
09-04 23:43:27.999 485-485/? A/DEBUG:     r0 00000000  r1 000073cf  r2 00000006  r3 b6f75b94
        r4 b6f75b9c  r5 b6f75b4c  r6 0000000b  r7 0000010c
        r8 9e53e200  r9 a0b42c80  sl 00000001  fp 00000001
        ip 00000006  sp bec6b490  lr b6cd5c09  pc b6cd7ff8  cpsr 400b0010
09-04 23:43:28.009 485-485/? A/DEBUG: backtrace:
        #00 pc 00041ff8  /system/lib/libc.so (tgkill+12)
        #01 pc 0003fc05  /system/lib/libc.so (pthread_kill+32)
        #02 pc 0001c39f  /system/lib/libc.so (raise+10)
        #03 pc 0001961d  /system/lib/libc.so (__libc_android_abort+34)
        #04 pc 00017570  /system/lib/libc.so (abort+4)
        #05 pc 00194de3  /data/app/com.example.exception-1/lib/arm/libmylib.so (_ZN10__cxxabiv1L18readEncodedPointerEPPKhh+222)
        #06 pc 0019474b  /data/app/com.example.exception-1/lib/arm/libmylib.so (_ZN10__cxxabiv1L11scan_eh_tabERNS_12_GLOBAL__N_112scan_resultsE14_Unwind_ActionbP21_Unwind_Control_BlockP15_Unwind_Context+174)
        #07 pc 0019456b  /data/app/com.example.exception-1/lib/arm/libmylib.so  (__gxx_personality_v0+114)
        #08 pc 001aa3a1  /data/app/com.example.exception-1/lib/arm/libmylib.so  (__gnu_Unwind_RaiseException+64)
        #09 pc 001aaaf3  /data/app/com.example.exception-1/lib/arm/libmylib.so  (___Unwind_RaiseException+22)
09-04 23:43:28.509 485-485/? A/DEBUG: Tombstone written to: /data/tombstones/tombstone_07
09-04 23:43:28.509 485-485/? E/DEBUG: AM write failed: Broken pipe

In our build system, we use libc++_shared, I build libzip with clang, and use libz on the device. (that mean, we ship libzip.so, but not libz.so, as we are using the one on the device).

After digging several issues that seems similar: #289 #774 It seems I am running in the same issue with the unwinder being used from two different places:

$ readelf -sW libmylib.so  | grep _Unwind           
  2526: 00000000     0 FUNC    WEAK   DEFAULT  UND __gnu_Unwind_Find_exidx
  4695: 00193d95    24 FUNC    LOCAL  DEFAULT   11 _ZN10__cxxabiv1L22exception_cleanup_funcE19_Unwind_Reason_CodeP21_Unwind_Control_Block
  4696: 00194141    36 FUNC    LOCAL  DEFAULT   11 _ZN10__cxxabiv1L27dependent_exception_cleanupE19_Unwind_Reason_CodeP21_Unwind_Control_Block
  5550: 0019469d  1024 FUNC    LOCAL  DEFAULT   11 _ZN10__cxxabiv1L11scan_eh_tabERNS_12_GLOBAL__N_112scan_resultsE14_Unwind_ActionbP21_Unwind_Control_BlockP15_Unwind_Context
  5551: 00194ab9   144 FUNC    LOCAL  DEFAULT   11 _ZN10__cxxabiv1L13set_registersEP21_Unwind_Control_BlockP15_Unwind_ContextRKNS_12_GLOBAL__N_112scan_resultsE
  5552: 00194a9d    28 FUNC    LOCAL  DEFAULT   11 _ZN10__cxxabiv1L14call_terminateEbP21_Unwind_Control_Block
  5554: 00194de9   132 FUNC    LOCAL  DEFAULT   11 _ZN10__cxxabiv1L24exception_spec_can_catchExPKhhPKNS_16__shim_type_infoEPvP21_Unwind_Control_Block
  9403: 001aa253    12 FUNC    LOCAL  DEFAULT   11 _Unwind_decode_typeinfo_ptr.isra.0
  9405: 001aa263     2 FUNC    LOCAL  DEFAULT   11 _Unwind_DebugHook
  9409: 001aa465    24 FUNC    LOCAL  DEFAULT   11 _Unwind_GetGR
  9411: 001aa4ab    26 FUNC    LOCAL  DEFAULT   11 _Unwind_SetGR
  9428: 001aabbd    24 FUNC    LOCAL  DEFAULT   11 _Unwind_GetGR.constprop.0
  9981: 001aa35d     4 FUNC    LOCAL  HIDDEN    11 _Unwind_GetCFA
  9982: 001aa361    98 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_RaiseException
  9983: 001aa3c3    20 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_ForcedUnwind
  9984: 001aa3d7    66 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Resume
  9985: 001aa419    16 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Resume_or_Rethrow
  9986: 001aa429     2 FUNC    LOCAL  HIDDEN    11 _Unwind_Complete
  9987: 001aa42b    12 FUNC    LOCAL  HIDDEN    11 _Unwind_DeleteException
  9988: 001aa437    46 FUNC    LOCAL  HIDDEN    11 _Unwind_VRS_Get
  9989: 001aa47d    46 FUNC    LOCAL  HIDDEN    11 _Unwind_VRS_Set
  9990: 001aa4c5   122 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Backtrace
  9991: 001aa7b5   558 FUNC    LOCAL  HIDDEN    11 _Unwind_VRS_Pop
  9994: 001aa9fd     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Restore_VFP
  9995: 001aaa05     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Save_VFP
  9996: 001aaa0d     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Restore_VFP_D
  9997: 001aaa15     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Save_VFP_D
  9998: 001aaa1d     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Restore_VFP_D_16_to_31
  9999: 001aaa25     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Save_VFP_D_16_to_31
 10000: 001aaa2d     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Restore_WMMXD
 10001: 001aaa71     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Save_WMMXD
 10002: 001aaab5     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Restore_WMMXC
 10003: 001aaac9     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Save_WMMXC
 10004: 001aaadd    34 FUNC    LOCAL  HIDDEN    11 ___Unwind_RaiseException
 10005: 001aaadd    34 FUNC    LOCAL  HIDDEN    11 _Unwind_RaiseException
 10006: 001aab01    34 FUNC    LOCAL  HIDDEN    11 ___Unwind_Resume
 10007: 001aab01    34 FUNC    LOCAL  HIDDEN    11 _Unwind_Resume
 10008: 001aab25    34 FUNC    LOCAL  HIDDEN    11 ___Unwind_Resume_or_Rethrow
 10009: 001aab25    34 FUNC    LOCAL  HIDDEN    11 _Unwind_Resume_or_Rethrow
 10010: 001aab49    34 FUNC    LOCAL  HIDDEN    11 ___Unwind_ForcedUnwind
 10011: 001aab49    34 FUNC    LOCAL  HIDDEN    11 _Unwind_ForcedUnwind
 10012: 001aab6d    34 FUNC    LOCAL  HIDDEN    11 ___Unwind_Backtrace
 10013: 001aab6d    34 FUNC    LOCAL  HIDDEN    11 _Unwind_Backtrace
 10016: 001aae77    10 FUNC    LOCAL  HIDDEN    11 _Unwind_GetRegionStart
 10017: 001aae81    18 FUNC    LOCAL  HIDDEN    11 _Unwind_GetLanguageSpecificData
 10018: 001aae93     6 FUNC    LOCAL  HIDDEN    11 _Unwind_GetDataRelBase
 10019: 001aae99     6 FUNC    LOCAL  HIDDEN    11 _Unwind_GetTextRelBase
 12550: 00000000     0 FUNC    WEAK   DEFAULT  UND __gnu_Unwind_Find_exidx

My understanding is that the issue I have is due to these two unreferenced symbols:

  2526: 00000000     0 FUNC    WEAK   DEFAULT  UND __gnu_Unwind_Find_exidx
 12550: 00000000     0 FUNC    WEAK   DEFAULT  UND __gnu_Unwind_Find_exidx

Checking libzip.so, and sure enough:

$ readelf -sW libzip.so  | grep _Unwind | grep UND   
   166: 00000000     0 FUNC    WEAK   DEFAULT  UND __gnu_Unwind_Find_exidx
   840: 00000000     0 FUNC    WEAK   DEFAULT  UND __gnu_Unwind_Find_exidx

full output:

$ readelf -sW out/s1controller/arm-linux-androideabi/jni/armeabi-v7a/libzip.so  | grep _Unwind
   166: 00000000     0 FUNC    WEAK   DEFAULT  UND __gnu_Unwind_Find_exidx
   408: 0001fefb    12 FUNC    LOCAL  DEFAULT   11 _Unwind_decode_typeinfo_ptr.isra.0
   410: 0001ff0b     2 FUNC    LOCAL  DEFAULT   11 _Unwind_DebugHook
   414: 0002010d    24 FUNC    LOCAL  DEFAULT   11 _Unwind_GetGR
   416: 00020153    26 FUNC    LOCAL  DEFAULT   11 _Unwind_SetGR
   433: 00020865    24 FUNC    LOCAL  DEFAULT   11 _Unwind_GetGR.constprop.0
   625: 00020005     4 FUNC    LOCAL  HIDDEN    11 _Unwind_GetCFA
   626: 00020009    98 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_RaiseException
   627: 0002006b    20 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_ForcedUnwind
   628: 0002007f    66 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Resume
   629: 000200c1    16 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Resume_or_Rethrow
   630: 000200d1     2 FUNC    LOCAL  HIDDEN    11 _Unwind_Complete
   631: 000200d3    12 FUNC    LOCAL  HIDDEN    11 _Unwind_DeleteException
   632: 000200df    46 FUNC    LOCAL  HIDDEN    11 _Unwind_VRS_Get
   633: 00020125    46 FUNC    LOCAL  HIDDEN    11 _Unwind_VRS_Set
   634: 0002016d   122 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Backtrace
   635: 0002045d   558 FUNC    LOCAL  HIDDEN    11 _Unwind_VRS_Pop
   638: 000206a5     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Restore_VFP
   639: 000206ad     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Save_VFP
   640: 000206b5     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Restore_VFP_D
   641: 000206bd     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Save_VFP_D
   642: 000206c5     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Restore_VFP_D_16_to_31
   643: 000206cd     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Save_VFP_D_16_to_31
   644: 000206d5     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Restore_WMMXD
   645: 00020719     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Save_WMMXD
   646: 0002075d     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Restore_WMMXC
   647: 00020771     0 FUNC    LOCAL  HIDDEN    11 __gnu_Unwind_Save_WMMXC
   648: 00020785    34 FUNC    LOCAL  HIDDEN    11 ___Unwind_RaiseException
   649: 00020785    34 FUNC    LOCAL  HIDDEN    11 _Unwind_RaiseException
   650: 000207a9    34 FUNC    LOCAL  HIDDEN    11 ___Unwind_Resume
   651: 000207a9    34 FUNC    LOCAL  HIDDEN    11 _Unwind_Resume
   652: 000207cd    34 FUNC    LOCAL  HIDDEN    11 ___Unwind_Resume_or_Rethrow
   653: 000207cd    34 FUNC    LOCAL  HIDDEN    11 _Unwind_Resume_or_Rethrow
   654: 000207f1    34 FUNC    LOCAL  HIDDEN    11 ___Unwind_ForcedUnwind
   655: 000207f1    34 FUNC    LOCAL  HIDDEN    11 _Unwind_ForcedUnwind
   656: 00020815    34 FUNC    LOCAL  HIDDEN    11 ___Unwind_Backtrace
   657: 00020815    34 FUNC    LOCAL  HIDDEN    11 _Unwind_Backtrace
   660: 00020b1f    10 FUNC    LOCAL  HIDDEN    11 _Unwind_GetRegionStart
   661: 00020b29    18 FUNC    LOCAL  HIDDEN    11 _Unwind_GetLanguageSpecificData
   662: 00020b3b     6 FUNC    LOCAL  HIDDEN    11 _Unwind_GetDataRelBase
   663: 00020b41     6 FUNC    LOCAL  HIDDEN    11 _Unwind_GetTextRelBase
   840: 00000000     0 FUNC    WEAK   DEFAULT  UND __gnu_Unwind_Find_exidx

as my readelf output shows, I do have a mix of gnu symbols with clang, but what bothers me is that the only C++ library is our lib, libzip is a pure C library, and should not embed any exception unwinder (unless I am wrong somewhere…).

I have tried all the solutions proposed in #289 #774 #379 but could not resolve those two symbols :/

the NDK sits in /usr/local/toolchains/android-ndk-r17b

Here is the link command for libzip (output of clang -v) :

$ /usr/local/toolchains/android-ndk-r17b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang  -fPIC  -target arm-linux-androideabi --sysroot=/usr/local/toolchains/android-ndk-r17b/sysroot/ --gcc-toolchain=/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -isystem /usr/local/toolchains/android-ndk-r17b -I/usr/local/toolchains/android-ndk-r17b/sources/cxx-stl/llvm-libc++/include/ -I/usr/local/toolchains/android-ndk-r17b/sysroot//usr/include/arm-linux-androideabi/ -I/usr/include/libusb-1.0   -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libunwind.a -Wl,--exclude-libs,libsupport.a -Wl,--exclude-libs,libc++_static.a -Wl,--exclude-libs,libc++abi.a --sysroot=/usr/local/toolchains/android-ndk-r17b/platforms/android-21/arch-arm -nostdlib++ -stdlib=libc++ -Wl,--no-undefined -lz -L/usr/local/toolchains/android-ndk-r17b/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/ -L/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb -shared -Wl,-soname,libzip.so -o libzip.so CMakeFiles/zip.dir/zip_add.c.o CMakeFiles/zip.dir/zip_add_dir.c.o CMakeFiles/zip.dir/zip_add_entry.c.o CMakeFiles/zip.dir/zip_algorithm_deflate.c.o CMakeFiles/zip.dir/zip_buffer.c.o CMakeFiles/zip.dir/zip_close.c.o CMakeFiles/zip.dir/zip_delete.c.o CMakeFiles/zip.dir/zip_dir_add.c.o CMakeFiles/zip.dir/zip_dirent.c.o CMakeFiles/zip.dir/zip_discard.c.o CMakeFiles/zip.dir/zip_entry.c.o CMakeFiles/zip.dir/zip_err_str.c.o CMakeFiles/zip.dir/zip_error.c.o CMakeFiles/zip.dir/zip_error_clear.c.o CMakeFiles/zip.dir/zip_error_get.c.o CMakeFiles/zip.dir/zip_error_get_sys_type.c.o CMakeFiles/zip.dir/zip_error_strerror.c.o CMakeFiles/zip.dir/zip_error_to_str.c.o CMakeFiles/zip.dir/zip_extra_field.c.o CMakeFiles/zip.dir/zip_extra_field_api.c.o CMakeFiles/zip.dir/zip_fclose.c.o CMakeFiles/zip.dir/zip_fdopen.c.o CMakeFiles/zip.dir/zip_file_add.c.o CMakeFiles/zip.dir/zip_file_error_clear.c.o CMakeFiles/zip.dir/zip_file_error_get.c.o CMakeFiles/zip.dir/zip_file_get_comment.c.o CMakeFiles/zip.dir/zip_file_get_external_attributes.c.o CMakeFiles/zip.dir/zip_file_get_offset.c.o CMakeFiles/zip.dir/zip_file_rename.c.o CMakeFiles/zip.dir/zip_file_replace.c.o CMakeFiles/zip.dir/zip_file_set_comment.c.o CMakeFiles/zip.dir/zip_file_set_encryption.c.o CMakeFiles/zip.dir/zip_file_set_external_attributes.c.o CMakeFiles/zip.dir/zip_file_set_mtime.c.o CMakeFiles/zip.dir/zip_file_strerror.c.o CMakeFiles/zip.dir/zip_filerange_crc.c.o CMakeFiles/zip.dir/zip_fopen.c.o CMakeFiles/zip.dir/zip_fopen_encrypted.c.o CMakeFiles/zip.dir/zip_fopen_index.c.o CMakeFiles/zip.dir/zip_fopen_index_encrypted.c.o CMakeFiles/zip.dir/zip_fread.c.o CMakeFiles/zip.dir/zip_fseek.c.o CMakeFiles/zip.dir/zip_ftell.c.o CMakeFiles/zip.dir/zip_get_archive_comment.c.o CMakeFiles/zip.dir/zip_get_archive_flag.c.o CMakeFiles/zip.dir/zip_get_encryption_implementation.c.o CMakeFiles/zip.dir/zip_get_file_comment.c.o CMakeFiles/zip.dir/zip_get_name.c.o CMakeFiles/zip.dir/zip_get_num_entries.c.o CMakeFiles/zip.dir/zip_get_num_files.c.o CMakeFiles/zip.dir/zip_hash.c.o CMakeFiles/zip.dir/zip_io_util.c.o CMakeFiles/zip.dir/zip_libzip_version.c.o CMakeFiles/zip.dir/zip_memdup.c.o CMakeFiles/zip.dir/zip_name_locate.c.o CMakeFiles/zip.dir/zip_new.c.o CMakeFiles/zip.dir/zip_open.c.o CMakeFiles/zip.dir/zip_progress.c.o CMakeFiles/zip.dir/zip_rename.c.o CMakeFiles/zip.dir/zip_replace.c.o CMakeFiles/zip.dir/zip_set_archive_comment.c.o CMakeFiles/zip.dir/zip_set_archive_flag.c.o CMakeFiles/zip.dir/zip_set_default_password.c.o CMakeFiles/zip.dir/zip_set_file_comment.c.o CMakeFiles/zip.dir/zip_set_file_compression.c.o CMakeFiles/zip.dir/zip_set_name.c.o CMakeFiles/zip.dir/zip_source_begin_write.c.o CMakeFiles/zip.dir/zip_source_begin_write_cloning.c.o CMakeFiles/zip.dir/zip_source_buffer.c.o CMakeFiles/zip.dir/zip_source_call.c.o CMakeFiles/zip.dir/zip_source_close.c.o CMakeFiles/zip.dir/zip_source_commit_write.c.o CMakeFiles/zip.dir/zip_source_compress.c.o CMakeFiles/zip.dir/zip_source_crc.c.o CMakeFiles/zip.dir/zip_source_error.c.o CMakeFiles/zip.dir/zip_source_filep.c.o CMakeFiles/zip.dir/zip_source_free.c.o CMakeFiles/zip.dir/zip_source_function.c.o CMakeFiles/zip.dir/zip_source_get_compression_flags.c.o CMakeFiles/zip.dir/zip_source_is_deleted.c.o CMakeFiles/zip.dir/zip_source_layered.c.o CMakeFiles/zip.dir/zip_source_open.c.o CMakeFiles/zip.dir/zip_source_pkware.c.o CMakeFiles/zip.dir/zip_source_read.c.o CMakeFiles/zip.dir/zip_source_remove.c.o CMakeFiles/zip.dir/zip_source_rollback_write.c.o CMakeFiles/zip.dir/zip_source_seek.c.o CMakeFiles/zip.dir/zip_source_seek_write.c.o CMakeFiles/zip.dir/zip_source_stat.c.o CMakeFiles/zip.dir/zip_source_supports.c.o CMakeFiles/zip.dir/zip_source_tell.c.o CMakeFiles/zip.dir/zip_source_tell_write.c.o CMakeFiles/zip.dir/zip_source_window.c.o CMakeFiles/zip.dir/zip_source_write.c.o CMakeFiles/zip.dir/zip_source_zip.c.o CMakeFiles/zip.dir/zip_source_zip_new.c.o CMakeFiles/zip.dir/zip_stat.c.o CMakeFiles/zip.dir/zip_stat_index.c.o CMakeFiles/zip.dir/zip_stat_init.c.o CMakeFiles/zip.dir/zip_strerror.c.o CMakeFiles/zip.dir/zip_string.c.o CMakeFiles/zip.dir/zip_unchange.c.o CMakeFiles/zip.dir/zip_unchange_all.c.o CMakeFiles/zip.dir/zip_unchange_archive.c.o CMakeFiles/zip.dir/zip_unchange_data.c.o CMakeFiles/zip.dir/zip_utf-8.c.o CMakeFiles/zip.dir/zip_source_file.c.o  -v
Android (4691093 based on r316199) clang version 6.0.2 (https://android.googlesource.com/toolchain/clang 183abd29fc496f55536e7d904e0abae47888fc7f) (https://android.googlesource.com/toolchain/llvm 34361f192e41ed6e4e8f9aca80a4ea7e9856f327) (based on LLVM 6.0.2svn)
Target: arm--linux-android
Thread model: posix
InstalledDir: /usr/local/toolchains/android-ndk-r17b/toolchains/llvm/prebuilt/linux-x86_64/bin
Found candidate GCC installation: /usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x
Selected GCC installation: /usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x
Candidate multilib: thumb;@mthumb
Candidate multilib: armv7-a;@march=armv7-a
Candidate multilib: armv7-a/thumb;@march=armv7-a@mthumb
Candidate multilib: .;
Selected multilib: .;
clang: warning: argument unused during compilation: '-nostdlib++' [-Wunused-command-line-argument]
 "/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld" --sysroot=/usr/local/toolchains/android-ndk-r17b/platforms/android-21/arch-arm -z relro -X --eh-frame-hdr -m armelf_linux_eabi -shared -o libzip.so /usr/local/toolchains/android-ndk-r17b/platforms/android-21/arch-arm/usr/lib/../lib/crtbegin_so.o -L/usr/local/toolchains/android-ndk-r17b/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/ -L/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb -L/usr/local/toolchains/android-ndk-r17b/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/6.0.2/lib/linux/arm -L/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x -L/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/../lib -L/usr/local/toolchains/android-ndk-r17b/platforms/android-21/arch-arm/usr/lib/../lib -L/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib -L/usr/local/toolchains/android-ndk-r17b/platforms/android-21/arch-arm/usr/lib --exclude-libs libgcc.a --exclude-libs libunwind.a --exclude-libs libsupport.a --exclude-libs libc++_static.a --exclude-libs libc++abi.a --no-undefined -lz -soname libzip.so CMakeFiles/zip.dir/zip_add.c.o CMakeFiles/zip.dir/zip_add_dir.c.o CMakeFiles/zip.dir/zip_add_entry.c.o CMakeFiles/zip.dir/zip_algorithm_deflate.c.o CMakeFiles/zip.dir/zip_buffer.c.o CMakeFiles/zip.dir/zip_close.c.o CMakeFiles/zip.dir/zip_delete.c.o CMakeFiles/zip.dir/zip_dir_add.c.o CMakeFiles/zip.dir/zip_dirent.c.o CMakeFiles/zip.dir/zip_discard.c.o CMakeFiles/zip.dir/zip_entry.c.o CMakeFiles/zip.dir/zip_err_str.c.o CMakeFiles/zip.dir/zip_error.c.o CMakeFiles/zip.dir/zip_error_clear.c.o CMakeFiles/zip.dir/zip_error_get.c.o CMakeFiles/zip.dir/zip_error_get_sys_type.c.o CMakeFiles/zip.dir/zip_error_strerror.c.o CMakeFiles/zip.dir/zip_error_to_str.c.o CMakeFiles/zip.dir/zip_extra_field.c.o CMakeFiles/zip.dir/zip_extra_field_api.c.o CMakeFiles/zip.dir/zip_fclose.c.o CMakeFiles/zip.dir/zip_fdopen.c.o CMakeFiles/zip.dir/zip_file_add.c.o CMakeFiles/zip.dir/zip_file_error_clear.c.o CMakeFiles/zip.dir/zip_file_error_get.c.o CMakeFiles/zip.dir/zip_file_get_comment.c.o CMakeFiles/zip.dir/zip_file_get_external_attributes.c.o CMakeFiles/zip.dir/zip_file_get_offset.c.o CMakeFiles/zip.dir/zip_file_rename.c.o CMakeFiles/zip.dir/zip_file_replace.c.o CMakeFiles/zip.dir/zip_file_set_comment.c.o CMakeFiles/zip.dir/zip_file_set_encryption.c.o CMakeFiles/zip.dir/zip_file_set_external_attributes.c.o CMakeFiles/zip.dir/zip_file_set_mtime.c.o CMakeFiles/zip.dir/zip_file_strerror.c.o CMakeFiles/zip.dir/zip_filerange_crc.c.o CMakeFiles/zip.dir/zip_fopen.c.o CMakeFiles/zip.dir/zip_fopen_encrypted.c.o CMakeFiles/zip.dir/zip_fopen_index.c.o CMakeFiles/zip.dir/zip_fopen_index_encrypted.c.o CMakeFiles/zip.dir/zip_fread.c.o CMakeFiles/zip.dir/zip_fseek.c.o CMakeFiles/zip.dir/zip_ftell.c.o CMakeFiles/zip.dir/zip_get_archive_comment.c.o CMakeFiles/zip.dir/zip_get_archive_flag.c.o CMakeFiles/zip.dir/zip_get_encryption_implementation.c.o CMakeFiles/zip.dir/zip_get_file_comment.c.o CMakeFiles/zip.dir/zip_get_name.c.o CMakeFiles/zip.dir/zip_get_num_entries.c.o CMakeFiles/zip.dir/zip_get_num_files.c.o CMakeFiles/zip.dir/zip_hash.c.o CMakeFiles/zip.dir/zip_io_util.c.o CMakeFiles/zip.dir/zip_libzip_version.c.o CMakeFiles/zip.dir/zip_memdup.c.o CMakeFiles/zip.dir/zip_name_locate.c.o CMakeFiles/zip.dir/zip_new.c.o CMakeFiles/zip.dir/zip_open.c.o CMakeFiles/zip.dir/zip_progress.c.o CMakeFiles/zip.dir/zip_rename.c.o CMakeFiles/zip.dir/zip_replace.c.o CMakeFiles/zip.dir/zip_set_archive_comment.c.o CMakeFiles/zip.dir/zip_set_archive_flag.c.o CMakeFiles/zip.dir/zip_set_default_password.c.o CMakeFiles/zip.dir/zip_set_file_comment.c.o CMakeFiles/zip.dir/zip_set_file_compression.c.o CMakeFiles/zip.dir/zip_set_name.c.o CMakeFiles/zip.dir/zip_source_begin_write.c.o CMakeFiles/zip.dir/zip_source_begin_write_cloning.c.o CMakeFiles/zip.dir/zip_source_buffer.c.o CMakeFiles/zip.dir/zip_source_call.c.o CMakeFiles/zip.dir/zip_source_close.c.o CMakeFiles/zip.dir/zip_source_commit_write.c.o CMakeFiles/zip.dir/zip_source_compress.c.o CMakeFiles/zip.dir/zip_source_crc.c.o CMakeFiles/zip.dir/zip_source_error.c.o CMakeFiles/zip.dir/zip_source_filep.c.o CMakeFiles/zip.dir/zip_source_free.c.o CMakeFiles/zip.dir/zip_source_function.c.o CMakeFiles/zip.dir/zip_source_get_compression_flags.c.o CMakeFiles/zip.dir/zip_source_is_deleted.c.o CMakeFiles/zip.dir/zip_source_layered.c.o CMakeFiles/zip.dir/zip_source_open.c.o CMakeFiles/zip.dir/zip_source_pkware.c.o CMakeFiles/zip.dir/zip_source_read.c.o CMakeFiles/zip.dir/zip_source_remove.c.o CMakeFiles/zip.dir/zip_source_rollback_write.c.o CMakeFiles/zip.dir/zip_source_seek.c.o CMakeFiles/zip.dir/zip_source_seek_write.c.o CMakeFiles/zip.dir/zip_source_stat.c.o CMakeFiles/zip.dir/zip_source_supports.c.o CMakeFiles/zip.dir/zip_source_tell.c.o CMakeFiles/zip.dir/zip_source_tell_write.c.o CMakeFiles/zip.dir/zip_source_window.c.o CMakeFiles/zip.dir/zip_source_write.c.o CMakeFiles/zip.dir/zip_source_zip.c.o CMakeFiles/zip.dir/zip_source_zip_new.c.o CMakeFiles/zip.dir/zip_stat.c.o CMakeFiles/zip.dir/zip_stat_index.c.o CMakeFiles/zip.dir/zip_stat_init.c.o CMakeFiles/zip.dir/zip_strerror.c.o CMakeFiles/zip.dir/zip_string.c.o CMakeFiles/zip.dir/zip_unchange.c.o CMakeFiles/zip.dir/zip_unchange_all.c.o CMakeFiles/zip.dir/zip_unchange_archive.c.o CMakeFiles/zip.dir/zip_unchange_data.c.o CMakeFiles/zip.dir/zip_utf-8.c.o CMakeFiles/zip.dir/zip_source_file.c.o -lgcc -ldl -lc -lgcc -ldl /usr/local/toolchains/android-ndk-r17b/platforms/android-21/arch-arm/usr/lib/../lib/crtend_so.o

Here is the link command of our library:

$ clang++ -shared -fPIC -Wl,-soname,libmylib.so.0 [LIST-OF-OUR-OBJECTS.o]   -target arm-linux-androideabi --sysroot=/usr/local/toolchains/android-ndk-r17b/sysroot/ --gcc-toolchain=/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -isystem /usr/local/toolchains/android-ndk-r17b -rdynamic -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libunwind.a -Wl,--exclude-libs,libsupport.a -Wl,--exclude-libs,libc++_static.a -Wl,--exclude-libs,libc++abi.a --sysroot=/usr/local/toolchains/android-ndk-r17b/platforms/android-21/arch-arm -nostdlib++ -stdlib=libc++ -Wl,--no-undefined -D_DEBUG -DTARGET_ANDROID -D__ANDROID_API__=21 -DANDROID  -L/usr/local/toolchains/android-ndk-r17b/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/ -L/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb -Llib -latomic -latomic -lunwind -lc++abi -landroid_support -lgcc -lc++_shared -landroid -llog -lzip -o libmylib.so.0.7.0.1 -v
Android (4691093 based on r316199) clang version 6.0.2 (https://android.googlesource.com/toolchain/clang 183abd29fc496f55536e7d904e0abae47888fc7f) (https://android.googlesource.com/toolchain/llvm 34361f192e41ed6e4e8f9aca80a4ea7e9856f327) (based on LLVM 6.0.2svn)
Target: arm--linux-android
Thread model: posix
InstalledDir: /usr/local/toolchains/android-ndk-r17b/toolchains/llvm/prebuilt/linux-x86_64/bin
Found candidate GCC installation: /usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x
Selected GCC installation: /usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x
Candidate multilib: thumb;@mthumb
Candidate multilib: armv7-a;@march=armv7-a
Candidate multilib: armv7-a/thumb;@march=armv7-a@mthumb
Candidate multilib: .;
Selected multilib: .;
 "/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld" --sysroot=/usr/local/toolchains/android-ndk-r17b/platforms/android-21/arch-arm -export-dynamic -z relro -X --eh-frame-hdr -m armelf_linux_eabi -shared -export-dynamic -o libmylib.so.0.7.0.1 /usr/local/toolchains/android-ndk-r17b/platforms/android-21/arch-arm/usr/lib/../lib/crtbegin_so.o -L/usr/local/toolchains/android-ndk-r17b/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/ -L/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb -Llib -L/usr/local/toolchains/android-ndk-r17b/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/6.0.2/lib/linux/arm -L/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x -L/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/../lib -L/usr/local/toolchains/android-ndk-r17b/platforms/android-21/arch-arm/usr/lib/../lib -L/usr/local/toolchains/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib -L/usr/local/toolchains/android-ndk-r17b/platforms/android-21/arch-arm/usr/lib -soname libmylib.so.0 
[LIST-OF-OUR-OBJECTS.o]  --exclude-libs libgcc.a --exclude-libs libunwind.a --exclude-libs libsupport.a --exclude-libs libc++_static.a --exclude-libs libc++abi.a --no-undefined -latomic -latomic -lunwind -lc++abi -landroid_support -lgcc -lc++_shared -landroid -llog -lzip -lm -lgcc -ldl -lc -lgcc -ldl /usr/local/toolchains/android-ndk-r17b/platforms/android-21/arch-arm/usr/lib/../lib/crtend_so.o

I have been fighting this one for the last week… all works on other platforms, but am32 is giving me a hard time …

Could somebody help me figure out what is my mistake here?

@DanAlbert could I ask you a quick insight since you have been answering very similar questions in the past?

Environment Details

NDK Version: r17b
Minimum API: android-21
ABI: armeabi-v7a
Actual API of the device: android-24
STL: libc++ (shared)
Toolchain: clang

@DanAlbert
Copy link
Member

Checking libzip.so, and sure enough:

$ readelf -sW libzip.so  | grep _Unwind | grep UND   
    166: 00000000     0 FUNC    WEAK   DEFAULT  UND __gnu_Unwind_Find_exidx
    840: 00000000     0 FUNC    WEAK   DEFAULT  UND __gnu_Unwind_Find_exidx

This one is actually okay. The _Unwind* symbols are a problem, but __gnu_Unwind_Find_exidx actually comes from libc (the pedigree of the various unwind functions is complicated to say the least).

It looks like you've got all the unwind symbols properly hidden. Unless there are some other libraries in the dependency chain that aren't mentioned or libz.so is actually a library you ship in your APK rather than the system's, I think you've got that part right. If your build system is building your library correctly, the next guess is usually that one of your third-party dependencies is broken, but it looks like your dependencies are fine too.

-latomic -latomic -lunwind -lc++abi -landroid_support -lgcc -lc++_shared

This looks mostly right, but it's not quite correct for libc++_shared. I'm not 100% certain it'll make a difference, but could you try:

-landroid_support -lunwind -latomic -lgcc -lc++_shared

The NDK includes some linker scripts that can deal with this for you, btw. The same directory that has libc++_shared also has libc++.so.$API files that will link things properly for that API level. Rather than doing what you're doing, you should be able to just link that file (give the full path to the linker script as if it were a library rather than -lc++, since it has a version attached to the name). That should work too and save you the trouble of maintaining the implementation detail.

Another choice would be getting your build system to use a standalone toolchain. If you've got resources to maintain a custom build system that may not actually be a better choice, but it is an option.

@rprichard
Copy link
Collaborator

To add a bit...

as my readelf output shows, I do have a mix of gnu symbols with clang, but what bothers me is that the only C++ library is our lib, libzip is a pure C library, and should not embed any exception unwinder (unless I am wrong somewhere...).

If libzip is compiled with -funwind-tables, then AFAICT the object file's arm32 exception table has an R_ARM_NONE relocation referring to an unwinder routine (like __aeabi_unwind_cpp_pr0). __aeabi_unwind_cpp_pr0 is provided by both libgcc.a and libunwind.a. On other architectures, using -funwind-tables on a C file doesn't automatically link in an unwinder.

The mysolib.so appears to be using the libgcc.a unwinder rather than the one from libunwind.a. Most of the __gnu_Unwind_* functions come from libgcc.a:

$ readelf -sW ./toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/libgcc.a | grep __gnu_Unwind_
    43: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __gnu_Unwind_Find_exidx
    46: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Restore_VFP_D
    47: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Restore_VFP
    48: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Restore_VFP_D_16_to_31
    49: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Restore_WMMXD
    50: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Restore_WMMXC
    55: 0000042c   164 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_RaiseException
    56: 000004d0    28 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_ForcedUnwind
    57: 000004ec   116 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Resume
    58: 00000560    32 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Resume_or_Rethrow
    63: 000006a8   200 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Backtrace
    69: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Save_VFP_D
    70: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Save_VFP
    71: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Save_VFP_D_16_to_31
    72: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Save_WMMXD
    73: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Save_WMMXC
    13: 00000014     0 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Restore_VFP
    14: 0000001c     0 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Save_VFP
    15: 00000024     0 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Restore_VFP_D
    16: 0000002c     0 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Save_VFP_D
    17: 00000034     0 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Restore_VFP_D_16_to_31
    18: 0000003c     0 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Save_VFP_D_16_to_31
    19: 00000044     0 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Restore_WMMXD
    20: 00000088     0 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Save_WMMXD
    21: 000000cc     0 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Restore_WMMXC
    22: 000000e0     0 FUNC    GLOBAL DEFAULT    1 __gnu_Unwind_Save_WMMXC
    24: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_RaiseException
    27: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Resume
    30: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Resume_or_Rethrow
    33: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_ForcedUnwind
    36: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Backtrace
$ readelf -sW ./sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libunwind.a | grep __gnu_Unwind
   851: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gnu_Unwind_Find_exidx

mysolib.so has functions like __gnu_Unwind_Resume in it.

The NDK includes some linker scripts that can deal with this for you, btw. The same directory that has libc++_shared also has libc++.so.$API files that will link things properly for that API level.

The libc++.so.$API files are new in r18. In r17b, there's still just a single libc++.so file. It has the correct library list for API 14 and up:

$ cat /x/android-ndk-r17b/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++.so 
INPUT(-landroid_support -lunwind -latomic -lc++_shared)

It's important that -lgcc only appears after -lunwind, but I'm not sure it matters whether or where it appears other than that. The Clang driver adds two -lgcc arguments to the end of the ld command-line if -lgcc isn't passed explicitly.

@goutnet
Copy link
Author

goutnet commented Sep 5, 2018

ok, you guys are awesome! your comments helped me fixed my problem, :)

For others who may run in a similar issue, here what I had to do to make it work:

  • I removed my direct dependencies to libatomic, libunwind and libgcc
  • Instead, I directly build with -lc++ (which works in r17, but will break in r18 as mentioned, I will adjust this when r18 comes).
  • I had to place my dependency on libzip before the the -lc++ (because libzip.so is pulling the unwinder for some reason, it needs to be before what provides those symbols)

What I also did, but I don't think it did anything to the problem:

  • removed the -funwind-tables (not sure that did anything, since libzip.so is still pulling the unwinder even without this ` @rprichard )
  • removed -ffunction-sections (did not need it actually, and probably unrelated, but I mention it anyway)

End of the day, the unwind symbols now looks like this:

$ readelf -sW libmylib.so  | grep _Unwind 
  2545: 00000000     0 FUNC    GLOBAL DEFAULT  UND __gnu_Unwind_Find_exidx
  4414: 001939e1   296 FUNC    LOCAL  DEFAULT   11 _ZL13unwind_phase2P13unw_context_tP21_Unwind_Control_Blockb
  4415: 001938c5    92 FUNC    LOCAL  DEFAULT   11 _ZN12_GLOBAL__N_114unwindOneFrameEjP21_Unwind_Control_BlockP15_Unwind_Context
  5196: 00193b09     2 FUNC    LOCAL  HIDDEN    11 _Unwind_Complete
  5197: 00193bf1    12 FUNC    LOCAL  HIDDEN    11 _Unwind_DeleteException
  5198: 00193b71    64 FUNC    LOCAL  HIDDEN    11 _Unwind_GetLanguageSpecificData
  5199: 00193bb1    64 FUNC    LOCAL  HIDDEN    11 _Unwind_GetRegionStart
  5200: 00193931   176 FUNC    LOCAL  HIDDEN    11 _Unwind_RaiseException
  5201: 00193b0d   100 FUNC    LOCAL  HIDDEN    11 _Unwind_Resume
  5202: 001935a5   212 FUNC    LOCAL  HIDDEN    11 _Unwind_VRS_Get
  5203: 001932f5   688 FUNC    LOCAL  HIDDEN    11 _Unwind_VRS_Interpret
  5204: 00193755   360 FUNC    LOCAL  HIDDEN    11 _Unwind_VRS_Pop
  5205: 00193679   220 FUNC    LOCAL  HIDDEN    11 _Unwind_VRS_Set
  7917: 00000000     0 FUNC    GLOBAL DEFAULT  UND __gnu_Unwind_Find_exidx

and I still have the two __gnu_Unwind_Find_exidx undefined symbols:

$ readelf -sW libmylib.so  | grep _Unwind  | grep UND
  2545: 00000000     0 FUNC    GLOBAL DEFAULT  UND __gnu_Unwind_Find_exidx
  7917: 00000000     0 FUNC    GLOBAL DEFAULT  UND __gnu_Unwind_Find_exidx

the unwinder symbols embedded in libzip.so did not change, and I still don't really grasp why the unwinder is pulled into libzip (it does not do that on the other archs, and I don't have any option set to bring those in… but well… the linker works in mysterious ways, I guess :/ ; even tried a -Wl,--no-whole-archive just in case, but did not change anything) …

… but now the exceptions are working.

thanks again for the pointers.

@goutnet goutnet closed this as completed Sep 5, 2018
@rprichard
Copy link
Collaborator

Good to hear.

removed the -funwind-tables (not sure that did anything, since libzip.so is still pulling the unwinder even without this ` @rprichard )

I see some R_ARM_NONE references to __aeabi_unwind_cpp_pr{0,1,2} in various object files in libgcc.a, so maybe libzip.so links one of those in? I also see references in the NDK's libz.a, but I think libzip.so uses libz.so instead.

FWIW: I think Android's crash dumper needs the unwinding tables to generate a backtrace in a crash report.

@goutnet
Copy link
Author

goutnet commented Sep 5, 2018

ok thanks, I add back the -funwind-tables in that case (always a good thing to have a somewhat meaningful trace :) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants