Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
d92871e
[LowFat] Add LowFatSanitizer pass skeleton with debug logging
duckyfuz Jan 20, 2026
bc1546a
[LowFat] Initialize LowFatSanitizerPass with empty options
duckyfuz Jan 21, 2026
5a3e08e
[LowFat] Create stub runtime lib
duckyfuz Jan 21, 2026
47a57cc
[LowFat] Add lowfat to clang and allow link with LowFat runtime library
duckyfuz Jan 21, 2026
513eda0
[LowFat] Add -fsanitize=lowfat linker support for Clang
duckyfuz Jan 21, 2026
2b585b1
[LowFat] Add sanitizer infrastructure
duckyfuz Jan 31, 2026
19b9784
[LowFat] Resolve linker issues on Darwin
duckyfuz Jan 31, 2026
f61ee70
[LowFat] Implement memory regions and bound check functions
duckyfuz Feb 10, 2026
3fbb158
[LowFat] Implement memory alloc and dealloc with free list
duckyfuz Feb 11, 2026
ba40391
[LowFat] Add transform pass basic test
duckyfuz Feb 11, 2026
e89c30b
[LowFat] Add basic testcases for lf_rtl
duckyfuz Feb 11, 2026
a4f469c
[LowFat] Implement malloc/free interceptors
duckyfuz Feb 13, 2026
b96c246
[LowFat] Implement inline bounds checking
duckyfuz Feb 16, 2026
19efaf9
[LowFat] Update tests for inline bounds checking
duckyfuz Feb 16, 2026
749aa9e
[LowFat] Remove __lf_check_bounds from runtime
duckyfuz Feb 16, 2026
eccdb9b
Merge branch 'main' into lowfat-bounds-checking-implementation
duckyfuz Feb 16, 2026
c9b7afe
[LowFat] Add options parsing and warnings for recover
duckyfuz Mar 1, 2026
443b769
[LowFat] Add spinlocks for thread safety on mem alloc and dealloc
duckyfuz Mar 1, 2026
10fa2f4
[LowFat] Report write/read, overflow, and size on OOB
duckyfuz Mar 1, 2026
2605f0c
[LowFat] Temporary fix for lipo arch tag for x86_64h
duckyfuz Mar 2, 2026
e8df018
[LowFat] Detect OOB for memcpy and memset
duckyfuz Mar 2, 2026
6b381e6
[LowFat] Fix OOB overflow sign by passing AccessEnd
duckyfuz Mar 2, 2026
0528297
[LowFat] Remove commented prints
duckyfuz Mar 3, 2026
dd45c7a
[LowFat] Kill process with internal__exit instead of Die()
duckyfuz Mar 3, 2026
6793bde
[LowFat] Move LowFat to run before optimization
duckyfuz Mar 3, 2026
73a11fc
[LowFat] Fix test with new error text
duckyfuz Mar 3, 2026
cb646b5
[LowFat] Scaffold testing infrastructure
duckyfuz Mar 3, 2026
5ccd449
[LowFat] Initialize flags to Die() on error and resolve workaround
duckyfuz Mar 3, 2026
068ff0d
[LowFat] Add tests for libc memcpy, memsetand memmove
duckyfuz Mar 3, 2026
7e539bf
[LowFat] Run tests with 3 optimization levels
duckyfuz Mar 3, 2026
fff71f4
[LowFat] Add libc interceptors for memset, memcopy and memmove
duckyfuz Mar 3, 2026
f2cace4
[LowFat] Create Safe to combat DAE and DCE
duckyfuz Mar 4, 2026
fed9bd9
[LowFat] Fix tests to run on all optimizations
duckyfuz Mar 4, 2026
e03580c
[LowFat] Add tests to differentiate between fast and safe mode
duckyfuz Mar 4, 2026
bc09502
[LowFat] Use recover flag for rtl check_bounds
duckyfuz Mar 4, 2026
d43345c
[LowFat] Enable custom memory config mode
duckyfuz Mar 7, 2026
639359c
[LowFat] Add tests for custom mem sizes
duckyfuz Mar 7, 2026
528eadb
[LowFat] Refactor LowFat custom cmake propagation into sep file
duckyfuz Mar 7, 2026
808047b
[LowFat] Set fast mode as default in tests
duckyfuz Mar 7, 2026
bf1dadf
[LowFat] Update comments in tests
duckyfuz Mar 7, 2026
47ab9c4
[LowFat] Simplify documentation for tests
duckyfuz Mar 7, 2026
acd4559
[LowFat] Refactor tests into folders
duckyfuz Mar 7, 2026
d01af7a
[LowFat] Add tmp initialization script for building and testing LowFat
duckyfuz Mar 8, 2026
c185eaf
[LowFat] Optimize initialization script for llvm config
duckyfuz Mar 8, 2026
28f012f
[LowFat] Add __lf_get_offset and __lf_get_usable_size
duckyfuz Mar 9, 2026
ec5d9c5
[LowFat] Create more tests for oob, underflow
duckyfuz Mar 9, 2026
6568356
[LowFat] Omit mul path for pow2 mode
duckyfuz Mar 11, 2026
3c594f5
Merge branch 'lowfat-bounds-checking-implementation' of github.com:du…
duckyfuz Mar 11, 2026
eea6367
[LowFat] Use magic numbers for all custom sizes
duckyfuz Mar 11, 2026
4bf6249
[LowFat] Use absolute address for metadata and optimize region checking
duckyfuz Mar 11, 2026
907be35
[LowFat] Use compact bounds check for access
duckyfuz Mar 11, 2026
e532797
[LowFat] Add original sizes configuration
duckyfuz Mar 18, 2026
0d2ad6c
[LowFat] Implement right-align mode with transform
duckyfuz Mar 19, 2026
d732363
[LowFat] Add tests for right-alignn mode
duckyfuz Mar 19, 2026
05bdf47
[LowFat] Guard metadata loads with region range check on Darwin
duckyfuz Mar 24, 2026
52875f3
[LowFat] Move metadata tables to a higher fixed address
duckyfuz Mar 24, 2026
354ce9a
[LowFat] Add stack traces upon error
duckyfuz Mar 24, 2026
1ebfef2
Merge branch 'lowfat-bounds-checking-implementation' of github.com:du…
duckyfuz Mar 24, 2026
7aa7e88
[compiler-rt][FlexFat] Preserve malloc alignment in right-align mode
duckyfuz Mar 30, 2026
808c41b
[compiler-rt][FlexFat] Add right-align realloc regression test
duckyfuz Mar 30, 2026
1640105
[compiler-rt][FlexFat] Preserve data on right align realloc
duckyfuz Mar 30, 2026
e86bcbf
[compiler-rt][FlexFat] Fix right-align tests for custom size classes
duckyfuz Mar 30, 2026
695b612
[compiler-rt][FlexFat] Reorganize lowfat tests by category
duckyfuz Mar 30, 2026
78b8988
[compiler-rt][FlexFat] Fix right-align realloc migration copy size
duckyfuz Apr 4, 2026
5c83ed0
[compiler-rt][LowFat] Split pow2 and custom base-recovery paths
duckyfuz Apr 8, 2026
148bd2c
Merge branch 'flexfat/main' of github.com:duckyfuz/llvm-project-light…
duckyfuz Apr 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/Sanitizers.def
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ SANITIZER("kcfi", KCFI)
// Safe Stack
SANITIZER("safe-stack", SafeStack)

// LowFat Pointer Bounds Checking
SANITIZER("lowfat", LowFat)

// Shadow Call Stack
SANITIZER("shadow-call-stack", ShadowCallStack)

Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Driver/SanitizerArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class SanitizerArgs {
return Sanitizers.has(SanitizerKind::NumericalStability);
}
bool needsRtsanRt() const { return Sanitizers.has(SanitizerKind::Realtime); }
bool needsLowFatRt() const { return Sanitizers.has(SanitizerKind::LowFat); }

bool hasMemTag() const {
return hasMemtagHeap() || hasMemtagStack() || hasMemtagGlobals();
Expand Down
35 changes: 35 additions & 0 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
#include "llvm/Transforms/Instrumentation/TypeSanitizer.h"
#include "llvm/Transforms/Instrumentation/LowFatSanitizer.h"
#include "llvm/Transforms/ObjCARC.h"
#include "llvm/Transforms/Scalar/EarlyCSE.h"
#include "llvm/Transforms/Scalar/GVN.h"
Expand All @@ -107,6 +108,17 @@ static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP(
"sanitizer-early-opt-ep", cl::Optional,
cl::desc("Insert sanitizers on OptimizerEarlyEP."));

static cl::opt<LowFatSanitizerOptions::LowFatMode> LowFatMode(
"lowfat-mode", cl::init(LowFatSanitizerOptions::LowFatMode::Fast),
cl::desc("Controls the placement and strictness of the LowFat pass"),
cl::values(
clEnumValN(LowFatSanitizerOptions::LowFatMode::Fast, "fast",
"Instrument at OptimizerLastEP (least overhead)"),
clEnumValN(LowFatSanitizerOptions::LowFatMode::Safe, "safe",
"Barrier at PipelineStartEP + instrument at OptimizerLastEP"),
clEnumValN(LowFatSanitizerOptions::LowFatMode::RightAlign, "right-align",
"Right-align allocations within class slots to catch right-side OOB")));

// Experiment to mark cold functions as optsize/minsize/optnone.
// TODO: remove once this is exposed as a proper driver flag.
static cl::opt<PGOOptions::ColdFuncOpt> ClPGOColdFuncAttr(
Expand Down Expand Up @@ -767,6 +779,12 @@ static void addSanitizers(const Triple &TargetTriple,
MPM.addPass(DataFlowSanitizerPass(LangOpts.NoSanitizeFiles,
PB.getVirtualFileSystemPtr()));
}
if (LangOpts.Sanitize.has(SanitizerKind::LowFat)) {
LowFatSanitizerOptions LFOpts;
LFOpts.Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::LowFat);
LFOpts.Mode = LowFatMode;
MPM.addPass(LowFatSanitizerPass(LFOpts));
}
};
if (ClSanitizeOnOptimizerEarlyEP) {
PB.registerOptimizerEarlyEPCallback(
Expand All @@ -784,6 +802,23 @@ static void addSanitizers(const Triple &TargetTriple,
// LastEP does not need GlobalsAA.
PB.registerOptimizerLastEPCallback(SanitizersCallback);
}

if (LangOpts.Sanitize.has(SanitizerKind::LowFat)) {
LowFatSanitizerOptions LFOpts;
LFOpts.Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::LowFat);
LFOpts.Mode = LowFatMode;

if (LFOpts.Mode == LowFatSanitizerOptions::LowFatMode::Safe) {
// Safe: insert barrier + fake.use at PipelineStartEP to preserve loads
// through Dead Argument Elimination, then instrument at OptimizerLastEP.
LowFatSanitizerOptions BarrierOpts = LFOpts;
BarrierOpts.InternalBarrierOnly_ = true;
PB.registerPipelineStartEPCallback(
[BarrierOpts](ModulePassManager &MPM, OptimizationLevel) {
MPM.addPass(LowFatSanitizerPass(BarrierOpts));
});
}
}
}

void addLowerAllowCheckPass(const CodeGenOptions &CodeGenOpts,
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Driver/SanitizerArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,9 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
SanitizerKind::Address | SanitizerKind::HWAddress |
SanitizerKind::KernelAddress |
SanitizerKind::KernelHWAddress |
SanitizerKind::Memory),
std::make_pair(SanitizerKind::LowFat,
SanitizerKind::Address | SanitizerKind::HWAddress |
SanitizerKind::Memory)};

// Enable toolchain specific default sanitizers if not explicitly disabled.
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,8 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
if (SanArgs.linkCXXRuntimes())
StaticRuntimes.push_back("scudo_standalone_cxx");
}
if (SanArgs.needsLowFatRt())
StaticRuntimes.push_back("lowfat");
if (SanArgs.needsUbsanLoopDetectRt())
NonWholeStaticRuntimes.push_back("ubsan_loop_detect");
}
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,9 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
AddLinkRuntimeLib(Args, CmdArgs, "stats_client", RLO_AlwaysLink);
AddLinkSanitizerLibArgs(Args, CmdArgs, "stats");
}
if (Sanitize.needsLowFatRt()) {
AddLinkSanitizerLibArgs(Args, CmdArgs, "lowfat");
}
}

if (Sanitize.needsMemProfRt())
Expand Down Expand Up @@ -3917,6 +3920,9 @@ SanitizerMask Darwin::getSupportedSanitizers() const {
if (IsX86_64)
Res |= SanitizerKind::NumericalStability;

if (IsX86_64 || IsAArch64)
Res |= SanitizerKind::LowFat;

return Res;
}

Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Driver/ToolChains/Linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,8 @@ SanitizerMask Linux::getSupportedSanitizers() const {
}
if (IsX86_64)
Res |= SanitizerKind::NumericalStability;
if (IsX86_64 || IsAArch64)
Res |= SanitizerKind::LowFat;
if (!IsAndroid)
Res |= SanitizerKind::Memory;

Expand Down
1 change: 1 addition & 0 deletions compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ set(ALL_XRAY_SUPPORTED_ARCH ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64}
endif()
set(ALL_XRAY_DSO_SUPPORTED_ARCH ${X86_64} ${ARM64})
set(ALL_SHADOWCALLSTACK_SUPPORTED_ARCH ${ARM64})
set(ALL_LOWFAT_SUPPORTED_ARCH ${X86_64} ${ARM64})

if (UNIX)
if (OS_NAME MATCHES "Linux")
Expand Down
7 changes: 7 additions & 0 deletions compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ function(darwin_test_archs os valid_archs)
endif()
endif()

# x86_64h maps to the same lipo architecture tag as x86_64, causing fat
# binary creation to fail when both are present. Sanitizer runtimes gain
# no benefit from Haswell-specific codegen, so drop it for macOS as well.
if(${os} STREQUAL "osx")
list(REMOVE_ITEM archs "x86_64h")
endif()

if(${os} MATCHES "^ios$")
message(STATUS "Disabling sanitizers armv7* slice for ios")
list(FILTER archs EXCLUDE REGEX "armv7.*")
Expand Down
13 changes: 12 additions & 1 deletion compiler-rt/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,9 @@ if(APPLE)
list_intersect(SHADOWCALLSTACK_SUPPORTED_ARCH
ALL_SHADOWCALLSTACK_SUPPORTED_ARCH
SANITIZER_COMMON_SUPPORTED_ARCH)
list_intersect(LOWFAT_SUPPORTED_ARCH
ALL_LOWFAT_SUPPORTED_ARCH
SANITIZER_COMMON_SUPPORTED_ARCH)
list_intersect(ORC_SUPPORTED_ARCH
ALL_ORC_SUPPORTED_ARCH
SANITIZER_COMMON_SUPPORTED_ARCH)
Expand Down Expand Up @@ -724,6 +727,7 @@ else()
filter_available_targets(XRAY_DSO_SUPPORTED_ARCH ${ALL_XRAY_DSO_SUPPORTED_ARCH})
filter_available_targets(SHADOWCALLSTACK_SUPPORTED_ARCH
${ALL_SHADOWCALLSTACK_SUPPORTED_ARCH})
filter_available_targets(LOWFAT_SUPPORTED_ARCH ${ALL_LOWFAT_SUPPORTED_ARCH})
filter_available_targets(GWP_ASAN_SUPPORTED_ARCH ${ALL_GWP_ASAN_SUPPORTED_ARCH})
filter_available_targets(NSAN_SUPPORTED_ARCH ${ALL_NSAN_SUPPORTED_ARCH})
filter_available_targets(ORC_SUPPORTED_ARCH ${ALL_ORC_SUPPORTED_ARCH})
Expand Down Expand Up @@ -760,7 +764,7 @@ if(COMPILER_RT_SUPPORTED_ARCH)
endif()
message(STATUS "Compiler-RT supported architectures: ${COMPILER_RT_SUPPORTED_ARCH}")

set(ALL_SANITIZERS asan;rtsan;dfsan;msan;hwasan;tsan;tysan;safestack;cfi;scudo_standalone;ubsan_minimal;gwp_asan;nsan;asan_abi)
set(ALL_SANITIZERS asan;rtsan;dfsan;msan;hwasan;tsan;tysan;safestack;cfi;scudo_standalone;ubsan_minimal;gwp_asan;nsan;asan_abi;lowfat)
set(COMPILER_RT_SANITIZERS_TO_BUILD all CACHE STRING
"sanitizers to build if supported on the target (all;${ALL_SANITIZERS})")
list_replace(COMPILER_RT_SANITIZERS_TO_BUILD all "${ALL_SANITIZERS}")
Expand Down Expand Up @@ -902,6 +906,13 @@ else()
set(COMPILER_RT_HAS_SAFESTACK FALSE)
endif()

if (COMPILER_RT_HAS_SANITIZER_COMMON AND LOWFAT_SUPPORTED_ARCH AND
OS_NAME MATCHES "Darwin|Linux")
set(COMPILER_RT_HAS_LOWFAT TRUE)
else()
set(COMPILER_RT_HAS_LOWFAT FALSE)
endif()

if (COMPILER_RT_HAS_SANITIZER_COMMON AND CFI_SUPPORTED_ARCH)
set(COMPILER_RT_HAS_CFI TRUE)
else()
Expand Down
113 changes: 113 additions & 0 deletions compiler-rt/lib/lowfat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
include_directories(..)

set(LOWFAT_COMMON_DEFINITIONS)

#===------------------------------------------------------------------------===
# Custom size-class configuration (non-POW2 support)
#
# Set -DLOWFAT_SIZES_CFG=/path/to/sizes.cfg at cmake time to enable.
# This builds the lf_config_gen host tool, runs it to produce
# lf_config_generated.h, and compiles the runtime with LOWFAT_CUSTOM_CONFIG.
#===------------------------------------------------------------------------===
set(LOWFAT_SIZES_CFG "" CACHE FILEPATH
"Path to sizes.cfg for non-POW2 LowFat size class generation. Empty = POW2-only mode.")

if(LOWFAT_SIZES_CFG)
# ---- Build the generator tool (host compiler, no LLVM deps) ----
# Use add_custom_target / add_custom_command rather than add_executable so
# this host tool is never cross-compiled.
set(LOWFAT_CONFIG_GEN_SRC
${CMAKE_CURRENT_SOURCE_DIR}/tools/lf_config_gen.c)
set(LOWFAT_CONFIG_GEN_BIN
${CMAKE_CURRENT_BINARY_DIR}/lf_config_gen${CMAKE_EXECUTABLE_SUFFIX})
set(LOWFAT_GENERATED_HEADER
${CMAKE_CURRENT_BINARY_DIR}/lf_config_generated.h)

add_custom_command(
OUTPUT ${LOWFAT_CONFIG_GEN_BIN}
COMMAND ${CMAKE_C_COMPILER} -std=c11 -O2
${LOWFAT_CONFIG_GEN_SRC}
-o ${LOWFAT_CONFIG_GEN_BIN}
DEPENDS ${LOWFAT_CONFIG_GEN_SRC}
COMMENT "Compiling lf_config_gen host tool"
VERBATIM
)

add_custom_command(
OUTPUT ${LOWFAT_GENERATED_HEADER}
COMMAND ${LOWFAT_CONFIG_GEN_BIN} ${LOWFAT_SIZES_CFG} ${LOWFAT_GENERATED_HEADER}
DEPENDS ${LOWFAT_CONFIG_GEN_BIN} ${LOWFAT_SIZES_CFG}
COMMENT "Generating LowFat size tables from ${LOWFAT_SIZES_CFG}"
VERBATIM
)

add_custom_target(lowfat_config_generated DEPENDS ${LOWFAT_GENERATED_HEADER})
set(LOWFAT_DEPS lowfat_config_generated)

# Make the generated header visible to all sources in this directory.
include_directories(${CMAKE_CURRENT_BINARY_DIR})

# Activate the custom-config code paths in the runtime AND the LLVM pass.
list(APPEND LOWFAT_COMMON_DEFINITIONS LOWFAT_CUSTOM_CONFIG=1)

message(STATUS "LowFat: custom config enabled: ${LOWFAT_SIZES_CFG}")
message(STATUS "LowFat: generated header: ${LOWFAT_GENERATED_HEADER}")
else()
message(STATUS "LowFat: using default POW2-only mode (no LOWFAT_SIZES_CFG set)")
set(LOWFAT_DEPS)
endif()
set(LOWFAT_SOURCES
lf_rtl.cpp
lf_interceptors.cpp
lf_stack.cpp
)

set(LOWFAT_HEADERS
lf_allocator.h
lf_config.h
lf_interface.h
lf_stack.h
)

set(LOWFAT_CFLAGS ${SANITIZER_COMMON_CFLAGS})
append_rtti_flag(OFF LOWFAT_CFLAGS)

# Static runtime library.
add_compiler_rt_component(lowfat)

if(COMPILER_RT_HAS_LOWFAT)
if(APPLE)
add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS)

add_compiler_rt_runtime(clang_rt.lowfat
SHARED
OS ${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${LOWFAT_SUPPORTED_ARCH}
SOURCES ${LOWFAT_SOURCES}
ADDITIONAL_HEADERS ${LOWFAT_HEADERS}
OBJECT_LIBS RTInterception
RTSanitizerCommon
RTSanitizerCommonLibc
RTSanitizerCommonSymbolizer
CFLAGS ${LOWFAT_CFLAGS}
LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
DEFS ${LOWFAT_COMMON_DEFINITIONS}
DEPS ${LOWFAT_DEPS}
PARENT_TARGET lowfat)
else()
add_compiler_rt_runtime(clang_rt.lowfat
STATIC
ARCHS ${LOWFAT_SUPPORTED_ARCH}
SOURCES ${LOWFAT_SOURCES}
ADDITIONAL_HEADERS ${LOWFAT_HEADERS}
OBJECT_LIBS RTInterception
RTSanitizerCommon
RTSanitizerCommonLibc
RTSanitizerCommonSymbolizer
RTSanitizerCommonSymbolizerInternal
CFLAGS ${LOWFAT_CFLAGS}
DEFS ${LOWFAT_COMMON_DEFINITIONS}
DEPS ${LOWFAT_DEPS}
PARENT_TARGET lowfat)
endif()
endif()
33 changes: 33 additions & 0 deletions compiler-rt/lib/lowfat/lf_allocator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//===-- lf_allocator.h - LowFat Allocator Internal Interface ----*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Internal allocator interface shared between lf_rtl.cpp and
// lf_interceptors.cpp.
//
//===----------------------------------------------------------------------===//
#ifndef LF_ALLOCATOR_H
#define LF_ALLOCATOR_H

#include "sanitizer_common/sanitizer_internal_defs.h"

namespace __lowfat {

using __sanitizer::uptr;

// Allocate from a LowFat region. Returns nullptr if size exceeds max.
void *Allocate(uptr size);

// Free a LowFat allocation.
void Deallocate(void *ptr);

// Initialize interceptors (called from __lf_init).
void InitializeInterceptors();

} // namespace __lowfat

#endif // LF_ALLOCATOR_H
Loading