Some design decision worth noting about:
I've noticed a recent mailing discussing about why string literal is not affected by -fdata-sections for ELF target:
http://lists.llvm.org/pipermail/llvm-dev/2020-September/145121.html
But on AIX, our linker could not split the mergeable string like other target.
So I think it would make more sense for us to emit separate csect for every mergeable string in -fdata-sections mode,
as there might not be other ways for linker to do garbage collection on unused mergeable string.
We're currently gating this behavior on the code-gen data-sections option, but AIX common initialization does really function correctly without it, so we should probably adopt this as a default.
Summarizing from off-list discussion:
Variables with common linkage will be emitted as a common-type csect in XCOFF. Per the assembly reference:
"Several modules can share the same common block. If any of those modules have an external Control Section (csect) with the same name and the csect with the same name has a storage mapping class other than BS or UC, then the common block is initialized and becomes that other Control Section.”
Initialization via a non-csect (i.e label-ed data) is not defined, and results in a linker warning: