Section garbage collection (gc-sections)
The linker flag that throws away every code and data section nobody references — the cheapest way to make firmware suddenly fit in flash.
Linkers deal in sections, not functions. If the compiler puts an entire object file into a single .text, all of it comes along the moment one function in that file is used. With -ffunction-sections -fdata-sections every function and global gets its own section, and -Wl,--gc-sections lets GNU ld or LLD walk the reference graph from the entry point and drop whatever it can't reach. For a project that pulls in a whole vendor HAL but uses three drivers, that can halve the binary.
The trap is anything only the hardware ever calls. Nothing in C references the interrupt vector table, so the linker decides it is dead and discards it, leaving a chip that never boots. That is why it sits inside KEEP() in the linker script. --print-gc-sections shows what was removed; the map file shows what survived.