42 Libasm reimplements selected libc functions in hand-rolled x86-64 NASM assembly for Linux (System V AMD64 ABI).
Requirements: nasm, gcc, and libbsd-dev for the C test driver.
make help # list Makefile targets
make # mandatory libasm.a and libasm_test
make bonus # rebuild libasm.a with bonus symbols
make re # clean rebuild
make fclean # remove generated filesmake is the canonical 42 build. CMake is available for IDEs:
cmake -S . -B build && cmake --build buildmake test # mandatory functions and read/write error paths
make test_bonus # ft_atoi_base and linked-list bonuses
valgrind --leak-check=full --error-exitcode=1 ./libasm_test
valgrind --leak-check=full --error-exitcode=1 ./libasm_bonus_testmake test_bonus leaves libasm.a with bonus symbols. Return to the
mandatory archive with:
make fclean && makeBuild the interactive driver, which exercises all mandatory functions:
make manual
./libasm_manual
printf 'hello from stdin\n' | ./libasm_manualInspect the archive and function symbols:
ar t libasm.a
readelf -sW libasm.a | grep ' ft_'Trace the test driver's real read(2) and write(2) calls, or debug an
assembly function:
strace -e trace=read,write ./libasm_test
gdb ./libasm_test
# (gdb) break ft_strlen
# (gdb) runHeaders: include/libasm.h and
include/libasm_bonus.h. Link client code with
-Iinclude -L. -lasm.
- Source: NASM Intel syntax, 64-bit only.
ft_readandft_writereturn-1and seterrnoon syscall failure.- Bonus sources are
_bonus.sfiles undersrc/bonus/. docs/contains ABI, x86-64, NASM, and reference notes.