On Mon, Mar 21, 2016 at 09:21:20AM +0100, Martin Husemann wrote: > On Mon, Mar 21, 2016 at 01:36:22AM +0100, Joerg Sonnenberger wrote: > > In short, this is a real problem and the assumption is not specific to > > clang. Revert now, please. > > Is there any other hack around the issue? Marking the symbol weak is a > very strange way to stop the compiler making this assumption.
Actually, it is the most natural way given the constraints. It is pretty much the only attribute around to define that one object is actually a different object altogether. > I have trouble seeing how the mis-optimization can be justified for external > symbols anyway, but this may depend on the type they point to and the > fine print. Your example with local/auto symbols certainly is very > differnent to the link sets case. There are no local / auto symbols involved here. Just global variables. That's *exactly* what the linker set case is using. > How about making the start/end symbols uintptr_t, then calculating the count > upfront and casting start for the iteration? The symbols reference the start and end of the section. They have no natural value associated. Joerg