https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98121
--- Comment #4 from Jozef Lawrynowicz <jozefl at gcc dot gnu.org> --- (In reply to H.J. Lu from comment #2) > The issue here is that what should happen when definitions marked with used > attribute and unmarked definitions are put in the same section. It has > nothing > to do with .retain. This bug report doesn't mention that. It looks to me that Florian was looking to discuss the conceptual issue of whether the "used" attribute should apply SHF_GNU_RETAIN. I assume you're referring to the glibc bug 27002 with though. (In reply to H.J. Lu from comment #3) > If we cant to use SHF_GNU_RETAIN on used attribute, compiler can do > > 1. Issue an error. > 2. issue a warning and mark the unmarked definition as used. > 3. Silently mark the unmarked definition as used. GAS merges the "R" flag state in .section declarations, silently, and with logical OR, and GCC should do the same. So if you have: int __attribute__((section(".data.foo"))) foo1 = 1; int __attribute__((used,section(".data.foo"))) foo2 = 2; .data.foo should have SECTION_RETAIN set within GCC. The addition of the "used" attribute to the second declaration of section(".data.foo") should not cause any warning/error messages to be emitted either. So option 3 from above. Just need to do something similar to what is already done for SECTION_NOTYPE in varasm.c:get_section.