error linking to libgcc.a when cross-compiling for Android, but symbols exists?

前端 未结 2 1791
-上瘾入骨i
-上瘾入骨i 2020-12-17 05:51

I am trying to cross-compile a very simple program for Android that worked with android-ndk-r6b and prior, but does not work on android-ndk-r7 and newer:

2条回答
  •  余生分开走
    2020-12-17 06:04

    Where to find: __aeabi_unwind_cpp_pr0 and other mysterious, undefined functions

    (I had a similar problem error to what you describe, but found a different solution, that may be helpful to you or others)

    I found 'libgccunwind.a' library in the Google NDK package which defines a number of these mysterious functions (they are functions referenced by libc.a and other libraries in the NDK package, but not defined in a standard library) I found them defined in a libgccunwind.a library in:

    \sources\android\gccunwind\libs\armeabi

    NM shows that they are defined in that lib from an 'unwind-arm.o' file:

    nm libgccunwind.a
    
    unwind-arm.o:
             U _GLOBAL_OFFSET_TABLE_
    00000cf8 T _Unwind_Complete
    00000cfc T _Unwind_DeleteException
    00000ba4 T _Unwind_GetCFA
    00000408 t _Unwind_GetGR
    00000474 t _Unwind_SetGR
    000003c4 T _Unwind_VRS_Get
    0000084c T _Unwind_VRS_Pop
    00000430 T _Unwind_VRS_Set
    00000844 T __aeabi_unwind_cpp_pr0
    0000083c W __aeabi_unwind_cpp_pr1
    00000834 W __aeabi_unwind_cpp_pr2
             w __cxa_begin_cleanup
             w __cxa_call_unexpected
             w __cxa_type_match
             U __exidx_end
             U __exidx_start
    00000d1c T __gnu_Unwind_Backtrace
             w __gnu_Unwind_Find_exidx
    

    Independant of the libgccunwind.a above, I searched for __aeabi_unwind_cpp_pr0 and unwind-arm.c and unwind.c, and found various c source, for example:

    http://lxr.free-electrons.com/source/arch/arm/kernel/unwind.c?a=arm

    http://opensource.apple.com/source/gcc/gcc-5646/gcc/config/arm/unwind-arm.c

    These programs seem to be derived from a similar source. My guess is that these 'unwind_cpp' (and related functions) are called by the functions in libc.a when a function returns or on certain events so that these functions can perform some debugging or tracing operation.

    In any event, adding that directory in a -L linker option and -lgccunwind linker option (after the -lc linker option) allowed the linker to find those 'undefined' functions -- and let me get to the next problem I have in cross compiling to ARM systems.

提交回复
热议问题