jmpews / Dobby

a lightweight, multi-platform, multi-architecture hook framework.
Apache License 2.0
3.93k stars 809 forks source link

Android Build With SymbolResolver Enabled Fail #92

Closed ghost closed 3 years ago

ghost commented 3 years ago

When i try to build Dobby for Android it fails both from cmake command line and Android Studio.

[42/44] Building CXX object CMakeFiles/dobby.dir/builtin-plugin/AndroidRestriction/android_restriction.cc.o
FAILED: CMakeFiles/dobby.dir/builtin-plugin/AndroidRestriction/android_restriction.cc.o
C:\ProgramData\Android\Sdk\ndk\21.3.6528147\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android28 --gcc-toolchain=C:/ProgramData/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/ProgramData/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Ddobby_EXPORTS -I../builtin-plugin/SymbolResolver -I../. -I.././source -I.././source/UserMode -I.././external -I.././external/logging -I.././external/stdcxx -I../builtin-plugin -I../builtin-plugin/AndroidRestriction -I../builtin-plugin/HideLibrary -I../builtin-plugin/ObjectiveC -I../include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -O2 -DNDEBUG  -fPIC -std=gnu++11 -MD -MT CMakeFiles/dobby.dir/builtin-plugin/AndroidRestriction/android_restriction.cc.o -MF CMakeFiles\dobby.dir\builtin-plugin\AndroidRestriction\android_restriction.cc.o.d -o CMakeFiles/dobby.dir/builtin-plugin/AndroidRestriction/android_restriction.cc.o -c ../builtin-plugin/AndroidRestriction/android_restriction.cc
../builtin-plugin/AndroidRestriction/android_restriction.cc:45:50: error: address of overloaded function 'open' does not match required type 'void'
  return __loader_dlopen(filename, flag, (void *)open);
                                                 ^~~~
C:/ProgramData/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\bits/fortify/fcntl.h:74:5: note: candidate address cannot be taken because parameter 1 has pass_object_size attribute
int open(const char* const __pass_object_size pathname, int flags, mode_t modes)
    ^
C:/ProgramData/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\bits/fortify/fcntl.h:63:5: note: candidate address cannot be taken because parameter 1 has pass_object_size attribute
int open(const char* const __pass_object_size pathname, int flags)
    ^
C:/ProgramData/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\bits/fortify/fcntl.h:53:5: note: candidate function
int open(const char* pathname, int flags, mode_t modes, ...) __overloadable
    ^
C:/ProgramData/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\fcntl.h:84:5: note: candidate function
int open(const char* __path, int __flags, ...);
    ^
1 error generated.

On Android Studio it also complain about it: candidate address cannot be taken because parameter 1 has pass_object_size attribute

There a comment about the "pass_object_size" attribute over the open function:

/*
 * pass_object_size serves two purposes here, neither of which involve __bos: it
 * disqualifies this function from having its address taken (so &open works),
 * and it makes overload resolution prefer open(const char *, int) over
 * open(const char *, int, ...).
 */

Open function:

__BIONIC_FORTIFY_INLINE
int open(const char* const __pass_object_size pathname, int flags)
        __overloadable
        __clang_error_if(__open_modes_useful(flags), "'open' " __open_too_few_args_error) {
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
    return __open_2(pathname, flags);
#else
    return __open_real(pathname, flags);
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
}
jmpews commented 3 years ago

Pull the latest commit, and try again.