Bloat Bdscr May 2026
bdscr_t blocks[256]; // 256 * 32 bytes = 8KB Use:
bdscr_t *blocks; blocks = malloc(actual_count * sizeof(bdscr_t)); In release builds:
gcc -DNDEBUG -ffunction-sections -fdata-sections ... ld --gc-sections -o output.elf input.o Or manually strip after linking: bloat bdscr
Reduced alignment to 4 bytes, changed static array to pointer + malloc, and moved non-critical descriptors to a compressed filesystem.
bloaty -d sections firmware.elf | grep bdscr Bloat in bdscr is a subtle but impactful inefficiency in embedded and low-level software. It stems from over-alignment, static allocation, and leftover debug structures. Detecting it requires basic binary inspection tools; fixing it yields measurable gains in size, speed, and maintainability. bdscr_t blocks[256]; // 256 * 32 bytes =
.bdscr : KEEP(*(.bdscr)) . = ALIGN(4096); // Over-alignment > FLASH With:
Always audit your linker scripts and descriptor data structures – especially when porting code across different flash architectures or toolchains. = ALIGN(4096); // Over-alignment > FLASH With: Always
Example bloaty command: