This repository contains a library version of the TLSF (Two-Level Segregated Fit) allocator.
- This repository can be cloned using the following commands:
git clone git@github.com:secure-rewind-and-discard/libtlsf.git
- To compile libtlsf, Run
makein src/.
cd ./libtlsf/src
make
Before running applications that rely on the TLSF library (libtlsf.so) add the TLSF src/ directory containing the shared object to the Linux dynamic linker search path:
export LD_LIBRARY_PATH='/path/to/libtlsf/src'
If the application relies on pre-built binaries which make calls to the malloc() family of functions, you additionally need to ensure that libtlsf.so is loaded before all other shared libraries to ensure it can override the malloc() functions with its own versions. This can be achieved, for example, by setting the LD_PRELOAD environmental variable to point to libtlsf.so to instruct the Linux dynamic linker to preload libtlsf.so before glibc.
LD_PRELOAD=/path/to/libtlsf/src/libtlsf.so
We provide an example that demonstrate the library's use example/
By default, the heap domain size is set to 0x200000000 (8GB). You can customize this number by using the APP_HEAP_SIZE environmental variable.
To support multithread application, the library should be compiled with TLSF_MULTITHREAD option.
LIBTLSF is also compatible with CHERI architecture. To do this, set the CHERI variable to 1 during compilation:
gmake CHERI=1
Important
Use gmake to compile, not make.
© Ericsson AB 2022-2024
BSD 3-Clause License
The original TLSF implementation by mattconte/tlsf licensed under BSD 3-Clause License