iromise / fans

FANS: Fuzzing Android Native System Services
242 stars 43 forks source link

Android 11 compatibility problems #2

Open BLuFeNiX opened 3 years ago

BLuFeNiX commented 3 years ago

Hi,

I am trying to use this tool with a recent AOSP release (android-11.0.0_r37), and I'm having trouble getting the BinderIface plugin to compile. LLVM has changed, so I have made the following adjustments to CMakeLists.txt

--- a/interface-model-extractor/pre-process/BinderIface/CMakeLists.txt
+++ b/interface-model-extractor/pre-process/BinderIface/CMakeLists.txt
@@ -9,10 +9,10 @@ if( NOT MSVC ) # MSVC mangles symbols differently, and
   endif()
 endif()

-add_llvm_loadable_module(BinderIface BinderIface.cpp PLUGIN_TOOL clang)
+add_llvm_library(BinderIface MODULE BinderIface.cpp PLUGIN_TOOL clang)
 SET(CMAKE_INSTALL_RPATH "")
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
-  target_link_libraries(BinderIface PRIVATE
+  target_link_libraries(BinderIface
     clangAST
     clangBasic
     clangFrontend

Additionally, I had to clone LLVM using these instructions: https://android.googlesource.com/toolchain/llvm_android/+/master/README.md#instructions-to-rebuild-a-particular-toolchain-release This means LLVM source code is coming from a different repo, and the build system is different. I believe we must do this because the repo withing the FANS docs is outdated, and does not contain the current version used by AOSP 11.

After making these changes, I can build clang, but I cannot get any plugins to build. Can you please provide updated instructions?

iromise commented 3 years ago

@BLuFeNiX, I am sorry to reply so late.

Yeah, I haven't tested FANS on Android 11, but I think this issue is not related with Android 11 directly but with the clang/llvm version. As I don't have much time to keep FANS updated with the latest clang/version version in Android, I suggest that you could learn how to build a plugin in a latest version. Besides, you might need to modify the code in BinderIface.

BLuFeNiX commented 3 years ago

@iromise Thank you for the reply. I guess I'll just have to dig a bit deeper!

smehod commented 3 years ago

Hi ,
I am trying to compile it with a recent aosp release(android-11.0.0_r40), Using this command make showcommands 2>&1 >cmd.txt , it succeeds. But inside cmd.txt, there is no contents like this "PWD=/proc/self/cwd prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++ -c -Iframeworks/ ........ frameworks/base/libs/services/src/os/DropBoxManager.cpp". Instead, it just records the command "//frameworks/base/libs/services:libservices clang++ src/os/DropBoxManager.cpp" . All the *.cpp files resemble like this. So I cannot record the real comile comands .

BLuFeNiX commented 3 years ago

Hi , I am trying to compile it with a recent aosp release(android-11.0.0_r40), Using this command make showcommands 2>&1 >cmd.txt , it succeeds. But inside cmd.txt, there is no contents like this "PWD=/proc/self/cwd prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++ -c -Iframeworks/ ........ frameworks/base/libs/services/src/os/DropBoxManager.cpp". Instead, it just records the command "//frameworks/base/libs/services:libservices clang++ src/os/DropBoxManager.cpp" . All the *.cpp files resemble like this. So I cannot record the real comile comands .

showcommands is no longer supported. See here for details: https://stackoverflow.com/a/60602048

smehod commented 3 years ago

Hi , I am trying to compile it with a recent aosp release(android-11.0.0_r40), Using this command make showcommands 2>&1 >cmd.txt , it succeeds. But inside cmd.txt, there is no contents like this "PWD=/proc/self/cwd prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++ -c -Iframeworks/ ........ frameworks/base/libs/services/src/os/DropBoxManager.cpp". Instead, it just records the command "//frameworks/base/libs/services:libservices clang++ src/os/DropBoxManager.cpp" . All the *.cpp files resemble like this. So I cannot record the real comile comands .

showcommands is no longer supported. See here for details: https://stackoverflow.com/a/60602048

Thank you for your reply!

iromise commented 3 years ago

@BLuFeNiX Thanks for your reply. @smehod As showcommands is no longer supported, you can try to use bear or something else to record the compile commands. Then you need to adjust corresponding scripts which are related with compile commands so as to generate the interface model.

smehod commented 3 years ago

@BLuFeNiX Thanks for your reply. @smehod As showcommands is no longer supported, you can try to use bear or something else to record the compile commands. Then you need to adjust corresponding scripts which are related with compile commands so as to generate the interface model.

Thanks !

wrlu commented 2 years ago

Hi , I am trying to compile it with a recent aosp release(android-11.0.0_r40), Using this command make showcommands 2>&1 >cmd.txt , it succeeds. But inside cmd.txt, there is no contents like this "PWD=/proc/self/cwd prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++ -c -Iframeworks/ ........ frameworks/base/libs/services/src/os/DropBoxManager.cpp". Instead, it just records the command "//frameworks/base/libs/services:libservices clang++ src/os/DropBoxManager.cpp" . All the *.cpp files resemble like this. So I cannot record the real comile comands .

On AOSP 10+, the verbose log is always written to a compressed file in the output dir, we can dump compile commands from this file: gzip -cd out/verbose.log.gz > cmd.txt

iromise commented 2 years ago

@wrlu Oh, great! Thanks!