Skip to content

Android NDK支持 #42

@0x1306a94

Description

@0x1306a94
// test_ollvm.c
#include <stdio.h>
#include <stdlib.h>
void testpass(int age) {
    if (age < 18) {
        printf("You are a minor.\n");
    } else {
        printf("You are an adult.\n");
    }
}

int test_func(int a) {
    if (a < 10) return a * a;
    if (a > 10) return a + a;
    return -1;
}

int test_func_fla(int a) {
    if (a < 10) return a * a;
    if (a > 10) return a + a;
    return -1;
}

int test_func_fla_bcf(int a) {
    if (a < 10) return a * a;
    if (a > 10) return a + a;
    return -1;
}

void test_ollvm() {
    printf("Testing OLLVM...\n");
    int age = 20;  // Example age
    testpass(age);
    test_func(5);
    test_func_fla(10);
    test_func_fla_bcf(20);
    printf("Test completed.\n");
}
$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-linux-android23 \
-Xclang -load -Xclang xxx/libObfuscation.so \
-fplugin=xxx/libObfuscation.so \
-shared -fPIC -O2 \
-mllvm -fla -mllvm -bcf -mllvm -bcf_prob=80 -mllvm -bcf_loop=3 -mllvm -sobf -mllvm -icall -mllvm -ibr -mllvm -igv -mllvm -sub -mllvm -sub_loop=3 -mllvm -split -mllvm -split_num=5 \
-o test.so  ../examples/test_ollvm.c
1.	<eof> parser at end of file
2.	Optimizer
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  clang-17                 0x0000000105e63c60 llvm::SmallVectorBase<unsigned long long>::set_size(unsigned long) + 315468
1  clang-17                 0x0000000105e62ebc llvm::SmallVectorBase<unsigned long long>::set_size(unsigned long) + 311976
2  clang-17                 0x0000000105e6426c llvm::SmallVectorBase<unsigned long long>::set_size(unsigned long) + 317016
3  libsystem_platform.dylib 0x0000000186788624 _sigtramp + 56
4  clang-17                 0x0000000105867004 llvm::AnalysisManager<llvm::Module>::getResultImpl(llvm::AnalysisKey*, llvm::Module&) + 248
5  libLLVM.dylib            0x0000000113c0d5d4 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 96
6  libObfuscation.so        0x000000010a0fead8 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 52
7  clang-17                 0x0000000105863fcc llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 208
8  clang-17                 0x0000000106110330 void llvm::DomTreeBuilder::Calculate<llvm::DominatorTreeBase<llvm::VPBlockBase, false>>(llvm::DominatorTreeBase<llvm::VPBlockBase, false>&) + 835820
9  clang-17                 0x000000010610ee1c void llvm::DomTreeBuilder::Calculate<llvm::DominatorTreeBase<llvm::VPBlockBase, false>>(llvm::DominatorTreeBase<llvm::VPBlockBase, false>&) + 830424
10 clang-17                 0x0000000106353df4 void llvm::DomTreeBuilder::Calculate<llvm::DominatorTreeBase<llvm::VPBlockBase, false>>(llvm::DominatorTreeBase<llvm::VPBlockBase, false>&) + 3210160
11 clang-17                 0x000000010719f3bc clang::extractapi::FunctionSignature clang::extractapi::DeclarationFragmentsBuilder::getFunctionSignature<clang::ObjCMethodDecl>(clang::ObjCMethodDecl const*) + 5662560
12 clang-17                 0x000000010656f39c llvm::Registry<clang::PluginASTAction>::begin() + 11788
13 clang-17                 0x0000000106517578 void llvm::DomTreeBuilder::Calculate<llvm::DominatorTreeBase<llvm::VPBlockBase, false>>(llvm::DominatorTreeBase<llvm::VPBlockBase, false>&) + 5059380
14 clang-17                 0x00000001065ba4e8 llvm::Registry<clang::PluginASTAction>::begin() + 319320
15 clang-17                 0x0000000104b23ab4
16 clang-17                 0x0000000104b201a0
17 clang-17                 0x0000000104b1fc24
18 dyld                     0x00000001863aeb98 start + 6076
clang-17: error: unable to execute command: Segmentation fault: 11
clang-17: error: clang frontend command failed due to signal (use -v to see invocation)
Android (11349228, +pgo, +bolt, +lto, -mlgo, based on r487747e) clang version 17.0.2 (https://android.googlesource.com/toolchain/llvm-project d9f89f4d16663d5012e5c09495f3b30ece3d2362)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions