On Fri, 18 Aug 2017, Martell Malone wrote:


LGTM, although it might be good to adjust it in the way David suggested
(avoiding the direct comparisons with *_END__, which is technically
undefined behaviour, and just checking the sentinel element value instead).

I have seen __CTOR_END__ used and counted backwards by many crt startups.
example https://code.woboq.org/gcc/libgcc/config/m32r/initfini.c.html
The only difference here is that is doesn't do a compare with __CTOR_LIST__
and looks for the -1 marker at the beginning.
I could do that instead if this resolves the same concern?
I would prefer faster startup times instead of iterating through the list
up and back.
By definition the linker script should also provide __CTOR_END__ as
described here
https://sourceware.org/binutils/docs-2.25/ld/Output-Section-Keywords.html

Yup, that resolves the concern.

As long as you just use one or the other of *_LIST__ or *_END__ in each function and use the sentinel values instead of comparing the pointers, it should be fine. Otherwise the compiler is free to regard the comparison as nonsense.

// Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to