https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70713
Joe Seymour <joe.s+bugzilla at somniumtech dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |joe.s+bugzilla@somniumtech. | |com --- Comment #1 from Joe Seymour <joe.s+bugzilla at somniumtech dot com> --- The test case provided in the initial report requires the msp430-gcc-support-files (headers and linker scripts) provided by TI. I believe the issue being described is that when you provide an interrupt attribute that specifies the name/number of the interrupt, the compiler generates a section named "__interrupt_vector_<number>" containing the address of the function. It expects the linker script to use these sections to construct the vector table. The linker doesn't know that these sections are related to specific functions, so it doesn't know to discard the section corresponding to the weak version of the function when it discards the weak function. IIUC while making the sections comdat will ensure that all but one of them is discarded, the section it keeps won't necessarily correspond to the version of the function that was kept, so the resulting vector table may be incorrect in some cases. A workaround might be to to use /DISCARD/ in a linker script, to explicitly discard the versions of the section that you don't want. Alternatively, it might be easier and cleaner to omit the name/number of the interrupt, so that the compiler doesn't generate a section, then populate the vector table explicitly. Both workarounds however require you to explicitly tell the linker which version of the function is being used, at which point there might not be any benefit to using the weak attribute. Perhaps the msp430 backend should produce an error if a function is marked and weak and specifies a particular interrupt number (instead of just "interrupt")? I'll submit a patch to gcc-patches.