[profile][test] Improve coverage-linkage.cpp with ld.lld --gc-sections
authorFangrui Song <i@maskray.me>
Tue, 6 Jul 2021 18:08:47 +0000 (11:08 -0700)
committerFangrui Song <i@maskray.me>
Tue, 6 Jul 2021 18:08:47 +0000 (11:08 -0700)
commit7b6b15e010664ec444f3c20a9b15ff4324c8971c
tree4fbea37c9f98aced1527946196ff1d378ade6fe0
parent4ec7c021970d83ce49273ca5623953665720515f
[profile][test] Improve coverage-linkage.cpp with ld.lld --gc-sections

The __llvm_prf_names section uses SHF_GNU_RETAIN.  However, GNU ld before 2015-10
(https://sourceware.org/bugzilla/show_bug.cgi?id=19161) neither supports it nor
retains __llvm_prf_names according to __start___llvm_prf_names. So --gc-sections
does not work on such old GNU ld.

This is not a problem for gold and sufficiently new lld.
compiler-rt/test/profile/Linux/coverage-linkage.cpp