Files
rpi-buildroot/support/testing/tests/package/test_clang.py
El Mehdi YOUNES df0805618b support/testing: TestClangCompilerRT: Add a kernel fragment for 48 bits virtual adress
Add a kernel fragment to enable
CONFIG_ARM64_VA_BITS_48 for the AARCH64 QEMU platform in the
clang compiler -rt runtime test.

Without this setting, this sanitize-based test fails with clang-20
due to insufficient virtual adress space.

"This might potentially affect ARM platforms with 39-bit address space." from [1]

[1] a588cfe37e

Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Julien Olivain <ju.o@free.fr>
2025-05-25 16:15:41 +02:00

50 lines
1.9 KiB
Python

import os
import infra.basetest
FUZZ_TIMEOUT = 120
class TestClangCompilerRT(infra.basetest.BRTest):
br2_external = [infra.filepath("tests/package/br2-external/clang-compiler-rt")]
# Without this option the test fails due to insufficient address space for 64-bit allocator
va48_fragment = infra.filepath("tests/package/test_clang/linux-arm64-va48.fragment")
config = \
f"""
BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.283"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{va48_fragment}"
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_PACKAGE_COMPILER_RT=y
BR2_PACKAGE_LLVM=y
BR2_TARGET_ROOTFS_CPIO=y
BR2_TARGET_ROOTFS_CPIO_GZIP=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_LIBFUZZER=y
"""
def login(self):
img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
kern = os.path.join(self.builddir, "images", "Image")
# Sanitizers overallocate memory and the minimum that seemed to work was 512MB
self.emulator.boot(arch="aarch64",
kernel=kern,
kernel_cmdline=["console=ttyAMA0"],
options=["-M", "virt", "-cpu", "cortex-a53", "-m", "512", "-initrd", img])
self.emulator.login()
def test_run(self):
self.login()
# The test case verifies the application executes and that
# the symbolizer is working to decode the stack trace.
cmd = "fuzz_me 2>&1 | grep heap-buffer-overflow"
_, exit_code = self.emulator.run(cmd, FUZZ_TIMEOUT)
self.assertEqual(exit_code, 0)