[lld-macho] Folded symbols should have size zero in linker map

This matches ld64's behavior.

I also extended the icf-stabs.s test to demonstrate that even though
folded symbols have size zero, we cannot use the size-zero property in
lieu of `wasIdenticalCodeFolded`, because size zero symbols should still
get STABS entries.

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D136001
This commit is contained in:
Jez Ng
2022-10-18 17:21:43 -04:00
parent 16d784159f
commit 316d4f96f2
3 changed files with 47 additions and 15 deletions

View File

@@ -138,8 +138,10 @@ void ConcatInputSection::foldIdentical(ConcatInputSection *copy) {
copy->live = false;
copy->wasCoalesced = true;
copy->replacement = this;
for (auto &copySym : copy->symbols)
for (auto &copySym : copy->symbols) {
copySym->wasIdenticalCodeFolded = true;
copySym->size = 0;
}
symbols.insert(symbols.end(), copy->symbols.begin(), copy->symbols.end());
copy->symbols.clear();