This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGa2684acfb61d: [HWASan] use hwasan linker for Android 14+ (authored by fmayer).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151388/new/ https://reviews.llvm.org/D151388 Files: clang/lib/Driver/ToolChains/Linux.cpp clang/test/Driver/linux-ld.c Index: clang/test/Driver/linux-ld.c =================================================================== --- clang/test/Driver/linux-ld.c +++ clang/test/Driver/linux-ld.c @@ -1259,6 +1259,22 @@ // CHECK-ANDROID-32: "-dynamic-linker" "/system/bin/linker" // CHECK-ANDROID-64: "-dynamic-linker" "/system/bin/linker64" // +// Test that Android 14 and newer use linker_hwasan64 for hwasan builds +// RUN: %clang -### %s -no-pie 2>&1 \ +// RUN: -fsanitize=hwaddress \ +// RUN: --target=x86_64-linux-android33 \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-OLD %s +// RUN: %clang -### %s -no-pie 2>&1 \ +// RUN: -fsanitize=hwaddress \ +// RUN: --target=x86_64-linux-android34 \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-NEW %s +// CHECK-ANDROID-OLD: "-dynamic-linker" "/system/bin/linker64" +// CHECK-ANDROID-NEW: "-dynamic-linker" "/system/bin/linker_hwasan64" +// // Test that -pthread does not add -lpthread on Android. // RUN: %clang -### %s -no-pie 2>&1 \ // RUN: --target=arm-linux-androideabi -pthread \ Index: clang/lib/Driver/ToolChains/Linux.cpp =================================================================== --- clang/lib/Driver/ToolChains/Linux.cpp +++ clang/lib/Driver/ToolChains/Linux.cpp @@ -426,9 +426,17 @@ const Distro Distro(getDriver().getVFS(), Triple); - if (Triple.isAndroid()) + if (Triple.isAndroid()) { + if (getSanitizerArgs(Args).needsHwasanRt() && + !Triple.isAndroidVersionLT(34) && Triple.isArch64Bit()) { + // On Android 14 and newer, there is a special linker_hwasan64 that + // allows to run HWASan binaries on non-HWASan system images. This + // is also available on HWASan system images, so we can just always + // use that instead. + return "/system/bin/linker_hwasan64"; + } return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker"; - + } if (Triple.isMusl()) { std::string ArchName; bool IsArm = false;
Index: clang/test/Driver/linux-ld.c =================================================================== --- clang/test/Driver/linux-ld.c +++ clang/test/Driver/linux-ld.c @@ -1259,6 +1259,22 @@ // CHECK-ANDROID-32: "-dynamic-linker" "/system/bin/linker" // CHECK-ANDROID-64: "-dynamic-linker" "/system/bin/linker64" // +// Test that Android 14 and newer use linker_hwasan64 for hwasan builds +// RUN: %clang -### %s -no-pie 2>&1 \ +// RUN: -fsanitize=hwaddress \ +// RUN: --target=x86_64-linux-android33 \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-OLD %s +// RUN: %clang -### %s -no-pie 2>&1 \ +// RUN: -fsanitize=hwaddress \ +// RUN: --target=x86_64-linux-android34 \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-NEW %s +// CHECK-ANDROID-OLD: "-dynamic-linker" "/system/bin/linker64" +// CHECK-ANDROID-NEW: "-dynamic-linker" "/system/bin/linker_hwasan64" +// // Test that -pthread does not add -lpthread on Android. // RUN: %clang -### %s -no-pie 2>&1 \ // RUN: --target=arm-linux-androideabi -pthread \ Index: clang/lib/Driver/ToolChains/Linux.cpp =================================================================== --- clang/lib/Driver/ToolChains/Linux.cpp +++ clang/lib/Driver/ToolChains/Linux.cpp @@ -426,9 +426,17 @@ const Distro Distro(getDriver().getVFS(), Triple); - if (Triple.isAndroid()) + if (Triple.isAndroid()) { + if (getSanitizerArgs(Args).needsHwasanRt() && + !Triple.isAndroidVersionLT(34) && Triple.isArch64Bit()) { + // On Android 14 and newer, there is a special linker_hwasan64 that + // allows to run HWASan binaries on non-HWASan system images. This + // is also available on HWASan system images, so we can just always + // use that instead. + return "/system/bin/linker_hwasan64"; + } return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker"; - + } if (Triple.isMusl()) { std::string ArchName; bool IsArm = false;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits