Currently, per-function instrumentation data don't use section groups
except for functions that already are in one and symbols with external
linkage. Consequentially, profiling instrumentation doesn't support
--gc-sections: if the function symbol is discarded, linker doesn't know
what other (instrumentation) data needs to be discarded as well. This
breaks any code that relies on --gc-sections semantics, and even for
other code that doesn't can lead to size increase.
This change moves per-function instrumentation data into its own section
group together with the function itself. This allows all instrumentation
to "travel together" with the symbol. If linker decides to discard the
symbol, it'll discard the entire group including all sections with the
instrumentation. The same strategy is already used by sancov.
See the comments in the code deleted by this patch.
Here you reverse the logic. IIRC, it will greatly increase the size of the profile data as the counter and per function data for externally available symbols won't be commoned.