On Fri, Oct 18, 2019 at 12:47:49PM +0200, Florian Weimer wrote: > > #define symbol_set_declare(set) \ > > extern char const __start_##set[] __symbol_set_attribute; \ > > extern char const __stop_##set[] __symbol_set_attribute; > > > > Due to symbol_set_declare, those symbols expand to two unrelated > > symbols. Using unrelated symbols for pointer arithmetic again violates the > > standard. > > Ah. So we need more uintptr_t casts here. Using reserved names (like those starting with two underscores) is UB already. And those particular names actually clash with names GNU LD already creates! > > Thus, the issue that Martin mentioned applies here, too. > > > > To get this conforming, the linker would need to export a symbol to the start > > of the section and the length of the section, IMHO. > > Right, but we do not have that today. 8-( We have had it since over 25 years: Thu Aug 18 15:37:45 1994 Ian Lance Taylor (ian@xxxxxxxxxxxxxxxxxxx) Make the ELF linker handle orphaned sections reasonably. Also, define __start_SECNAME and __stop_SECNAME around sections whose names can be represented in C, for the benefit of symbol sets in glibc. You just need to have linker scripts that do not sabotage this :-) > An explicit size also helps targets where there are restrictions on > alignment for global symbols, and the section size is actually measured > in bytes. (Which of course leads to the old question whether an object > can have a size which is not a multiple of its alignment.) It can. This is common, even, for example a .rodata.str1.8 section has alignment 8, but its size can be anything. Segher