https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118221
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- I'll note that while -ffunction-sections produces different .text sections for different functions but there's still only a single .debug_info section and the behavior when GCing sections might end up having detrimental effects on the relocations from .debug_info (for DW_AT_high/low_pc or ranges) to sections that have been elided. So this would make it a link editor issue which for linux-x86-64 for example results in relocations to NULL for discarded sections. If your embedded project does have functions at NULL that will likely confuse gdb. I think editing out the functions from .debug_info is out-of-scope, so this looks like an implementation limit on the compiler-side to me which might want to have separate .debug_info sections for each function (and data) section as well (maybe with DW_TAG_partial_unit). Alternatively it might be possible to direct the link editor to use a different "not existing" relocation target to not confuse consumers.