mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 15:26:06 +00:00

The Android LLVM build system builds the arm64 fuzzer lib without HWASan, but then applications that enable HWASan can generated an object file with a HWASan-ified version of some libc++ symbols (e.g. `std::__1::piecewise_construct`). The linker can choose the HWASan-ified definition, but then it cannot resolve the relocation from libclang_rt.fuzzer-aarch64-android.a to this symbol because the high bits of the address are unexpectedly set. This produces an error: ``` relocation R_AARCH64_ADR_PREL_PG_HI21 out of range ``` Fix this problem by linking a custom isolated libc++ into Android's fuzzer library. We need to pass through ANDROID_NATIVE_API_LEVEL so that the libc++ for 32-bit Android (API < 24) uses LLVM_FORCE_SMALLFILE_FOR_ANDROID.
See http://llvm.org/docs/LibFuzzer.html