Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Now how to use it in android? #61

Closed
eternalsakura opened this issue Dec 20, 2019 · 12 comments
Closed

Now how to use it in android? #61

eternalsakura opened this issue Dec 20, 2019 · 12 comments

Comments

@eternalsakura
Copy link

I see the patch of add android support, is it ready to use on Android?
if yes, can you provide some documentation? thanks

@jonathanmetzman
Copy link
Contributor

Good question. I haven't actually tried at all since I don't (directly) do any Android work.
@JoeyJiao Do you think it is ready for general usage? If it is, would you be willing to write something about this in the docs?

@JoeyJiao
Copy link
Contributor

yes, I can. Maybe sometime later.

For Android users general guide here:

  1. Build AFL in Android
    git clone https://github.com/google/AFL
    cd AFL
    mm
  2. In Android.mk project with AFL
    LOCAL_STATIC_LIBRARIES += afl-llvm-rt
    LOCAL_CC := afl-clang-fast
    LOCAL_CXX := afl-clang-fast++
    AFL_PATH := out/host/linux_x86/bin
  3. In Android.bp project with AFL, you need to modify build/soong to use afl-clang-fast(++) etc.
    static_libs: [
    "afl-llvm-rt",
    ],
    I was using above way for single modules.

@eternalsakura
Copy link
Author

So it is ready for general usage?

@JoeyJiao
Copy link
Contributor

yes, you can try.

@ele7enxxh
Copy link

@JoeyJiao

Hi,

yes, I can. Maybe sometime later.

For Android users general guide here:

  1. Build AFL in Android
    git clone https://github.com/google/AFL
    cd AFL
    mm
  2. In Android.mk project with AFL
    LOCAL_STATIC_LIBRARIES += afl-llvm-rt
    LOCAL_CC := afl-clang-fast
    LOCAL_CXX := afl-clang-fast++
    AFL_PATH := out/host/linux_x86/bin
  3. In Android.bp project with AFL, you need to modify build/soong to use afl-clang-fast(++) etc.
    static_libs: [
    "afl-llvm-rt",
    ],
    I was using above way for single modules.

@JoeyJiao

Hi, how to use afl-clang-fast in Android.bp project, it seems that the soong build system doesn't support LOCAL_CC or LOCAL_CXX. Is there any simpler way besides hacking the soong build system?

@JoeyJiao
Copy link
Contributor

JoeyJiao commented Dec 30, 2019

@ele7enxxh
You are right, I modified soong system similar to your stagefright change.
In this way I modified, there is no need to use cflags (-AFL_MODE=1).
I think google might not accept this kind of modification, so I only keep it for local use at the moment.

https://gist.github.com/JoeyJiao/cca3bc6c440f7000b4969bb1ab4ccfac

@jaiverma
Copy link

jaiverma commented Apr 22, 2020

I had trouble getting this to work. I tried this on an x86 android emulator.
When I build with:

LOCAL_STATIC_LIBRARIES := afl-llvm-rt

the afl symbols are not present in the generated binary and afl-fuzz doesn't detect instrumentation.
I had to compile with:

LOCAL_WHOLE_STATIC_LIBRARIES += afl-llvm-rt

for the symbols to be present.

@Ricardo073
Copy link

Ricardo073 commented Jun 25, 2020

@JoeyJiao
I am trying to instrumentalize the dex2oat in order to fuzz it. I followed the instructions that you mentioned previously and even made the changes to the soong system. However it doesn't detect the instrumentation. I am not sure if I understood everything correctly. So, please correct me if I am wrong.
After building AFL, I must modify Android.mk in the art folder like you mentioned (here I also corrected the small typo in "AFL_PATH := out/host/linux-x86/bin"). Now I only need to modify the Android.bp file under art/dex2oat by adding the "afl-llvm-rt," to the static_libs of the dex2oat component. However even after rebuilding art I could still not detect a instrumentation.

@JoeyJiao
Copy link
Contributor

I'm using my_static_libraries += afl-llvm-rt in build/core/binary.mk for AFL enabled project.

@geekchenwu
Copy link

@JoeyJiao when I add line my_static_libraries += afl-llvm-rt in build/core/binary.mk,then build the target

system/extras/tests/pagingtest/Android.mk: error: "pagingtest (EXECUTABLES android-arm) missing afl-llvm-rt (STATIC_LIBRARIES android-arm)"
Available variants:
afl-llvm-rt (STATIC_LIBRARIES linux-x86_64)
afl-llvm-rt (STATIC_LIBRARIES android-arm64)
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
system/libfmq/benchmarks/Android.mk: error: "mq_benchmark_client (NATIVE_TESTS android-arm) missing afl-llvm-rt (STATIC_LIBRARIES android-arm)"
Available variants:
afl-llvm-rt (STATIC_LIBRARIES linux-x86_64)
afl-llvm-rt (STATIC_LIBRARIES android-arm64)
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
test/mlts/benchmark/jni/Android.mk: error: "libnnbenchmark_jni (SHARED_LIBRARIES android-arm) missing afl-llvm-rt.sdk (STATIC_LIBRARIES android-arm)"
Available variants:
afl-llvm-rt.sdk (STATIC_LIBRARIES android-arm64)
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
test/vts/specification/Android.mk: error: "libvts_interfacespecification (SHARED_LIBRARIES android-arm) missing afl-llvm-rt (STATIC_LIBRARIES android-arm)"
Available variants:
afl-llvm-rt (STATIC_LIBRARIES linux-x86_64)
afl-llvm-rt (STATIC_LIBRARIES android-arm64)
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
build/make/core/main.mk:946: error: exiting from previous errors.
16:36:17 ckati failed with: exit status 1

@geekchenwu
Copy link

and set the ALLOW_MISSING_DEPENDENCIES=true,and then fuzzer it,alse show still not detect a instrumentation.

@geekchenwu
Copy link

@JoeyJiao

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

No branches or pull requests

7 participants