Implementing Stack Smashing Protection for Microcontrollers (and Embedded Artistry’s libc)

Stack buffer overflows are a category of error that can wreak havoc on our programs, resulting in sporadic crashes or strange and unexpected program behaviors. A stack buffer overflow occurs when a program writes to a memory address on the stack which is outside of its current stack frame, often triggered by a buffer overflow on a local …

libc: stdlib, pt. 1

The C standard library is a widely used resource, as it provides the base functionality for many more advanced features. The C standard library provides functionality like: string-to-number conversion math features like division and absolute value memory allocation (malloc, calloc, realloc) random number generation abort/exit However, the usefulness of the standard library doesn’t stop at …

libc: Useful Headers (memory, stdbool, endian, limits)

Continuing on with our libc bringup, today we’ll look at a few simple headers that we need: memory.h stdbool.h endian.h limits.h memory.h memory.h is probably the easiest header we will write. We simply need to use it as an alias for string.h: #include <string.h> stdbool.h Next up is stdbool.h, also a very simple header. Since …

libc: ctype

Next up the libc implementation list are the ctype functions. The ctype functions are pretty simple, covering functions like islower and isalpha. These functions also have "wide" equivalents for increased character sizes (like UTF), but I have just ported the standard versions for now. ctype.h I ported the ctype.h header from musl libc. I removed …

compiler-rt

As we're exploring bringing up a C/C++ runtime on our system, I'd like to share a very helpful resource for those using clang/llvm: compiler-rt. Compiler-rt is an LLVM project that provides implementations of various builtin functions for a variety of architectures. This saves us a lot of heavy lifting when bringing up a new platform, …