lld Atoms from STT_SECTION type symbols.


It's a real problem when section GC is active. It's not very common, but, typically, global constructors and destructors are the primary instances that may be incorrectly discarded.

The statement KEEP in GNU linker scripts specifies which sections should be kept in the final output even if GC judges that it could be discarded.

Perhaps, at this moment, it would suffice to provide an option to specify which sections must be kept. Additionally, perhaps the ELF reader or writer could always keep the .init{.*,_array}, .fini{.*,_array} and preinit_array sections.