Skip to content

Commit 4c472d1

Browse files
committed
ICF conditional
1 parent 69ee9db commit 4c472d1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lld/ELF/SyntheticSections.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,14 +667,15 @@ GotSection::GotSection(Ctx &ctx)
667667
void GotSection::addConstant(const Relocation &r) { relocations.push_back(r); }
668668
void GotSection::addEntry(const Symbol &sym) {
669669
assert(sym.auxIdx == ctx.symAux.size() - 1);
670-
if (auto *d = dyn_cast<Defined>(&sym)) {
670+
auto *d = dyn_cast<Defined>(&sym);
671+
if (d && ctx.arg.icf != ICFLevel::None) {
671672
// There may be symbols that have been ICFed in which case d->section
672673
// points to their canonical section and d->value is offset in to that section.
673674
// We add only a single GOT entry for all such symbols.
674675
auto [it, inserted] = gotEntries.insert(
675676
std::make_pair(std::make_pair(d->section, d->value),
676677
numEntries));
677-
if (!inserted) {
678+
if (!inserted && d->folded) {
678679
ctx.symAux.back().gotIdx = it->getSecond();
679680
return;
680681
}

0 commit comments

Comments
 (0)