Randomized implementation of standard C and C++ library dynamic memory management functions:
See usage examples in examples directory.
$ git clone https://github.com/hse-malloc/malloc.git
$ cd malloc$ cmake \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=Release \
-B buildCmake builds libraries as static by default. To build shared libraries pass while generation:
-DBUILD_SHARED_LIBS=OnThen after build you can use LD_PRELOAD to make other program to use malloc:
LD_PRELOAD="/path/to/libmalloc.so:/path/to/libhse_malloc.so" <program>By default, address randomization is enabled.
You can disable it by passing following argument while generation:
-DHSE_MALLOC_NO_RANDOM=TRUE$ cmake --build build$ cmake --install buildRegenerate with following:
- Enable
Debugbuild mode:-DCMAKE_BUILD_TYPE=Debug- Pass
libc++ >= 11.0.0headers and library location:-DCMAKE_CXX_FLAGS="-I<libcxx-install-prefix>/include/c++/v1" \ -DCMAKE_EXE_LINKER_FLAGS="-L<libcxx-install-prefix>/lib -Wl,-rpath,<libcxx-install-prefix>/lib"
$ cd build
$ ctest --output-on-failureAvailable targets:
test: tests (default)example-c: usage example in C usingmallocexample-cpp: usage example in C++ usingstd::mallocexample-cpp-new: usage example in C++ usingnewanddeleteoperators
$ docker build --target <TARGET> -t malloc_<TARGET> .
$ docker run --rm malloc_<TARGET>