ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_sbrk_trap.h File Reference

The newlib heap syscall, replaced by a halting trap. More...

#include <stddef.h>
Include dependency graph for ra8_sbrk_trap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void * _sbrk (ptrdiff_t incr)
 Trap that replaces newlib's heap-extension syscall.

Detailed Description

The newlib heap syscall, replaced by a halting trap.

Tag
[Ring 1 / CORE] {World: S}

NASA Power of 10 Rule 3 forbids dynamic allocation after init, and target firmware has no heap at all. Firmware is freestanding and links with -nostdlib without newlib or libnosys. Standard allocator calls fail closed at link time. ra8_sbrk_trap.c provides a defense-in-depth tripwire so any legacy or external routine attempting to invoke _sbrk halts safely via ra8_fatal_error.

Definition in file ra8_sbrk_trap.h.

Function Documentation

◆ _sbrk()

void * _sbrk ( ptrdiff_t incr)

Trap that replaces newlib's heap-extension syscall.

Reports a fatal error and never returns. Reaching this means something called malloc, calloc, realloc, strdup or a C++ operator new on the target, which the firmware's zero-heap design forbids – so it halts at the call site rather than handing back storage that does not exist.

Parameters
[in]incrBytes newlib wants the program break advanced by. Ignored: the trap never satisfies the request.
Returns
Never returns. The signature matches newlib's expectation so the strong definition overrides the library's own.
Return values
NULLUnreachable; present only to satisfy the newlib contract.
Precondition
The fatal-error sink is available (it is from reset).
The image linked this TU, so the trap overrides newlib's _sbrk.
Postcondition
Control never returns to the caller; the firmware halts.
The fatal-error sink has emitted the violation tag.
Note
Not thread-safe and not intended to be – it never returns.
Warning
Do not call this directly. It exists for the C library to resolve and for the host death-test to drive.
Example:
// Host death test: prove the trap never returns.
(void)_sbrk(32); // does not come back
void * _sbrk(ptrdiff_t incr)
Trap that replaces newlib's heap-extension syscall.
See also
ra8_fatal_error()
Since
0.1.0

Definition at line 45 of file ra8_sbrk_trap.c.

References ra8_fatal_error().