diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 0bcf3dec2509ce..a8a08da3b09c13 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -675,14 +675,9 @@ static bool includeInSymtab(const Symbol &b) { if (!sec) return true; - // Exclude symbols pointing to garbage-collected sections. - if (isa(sec) && !sec->isLive()) - return false; - if (auto *s = dyn_cast(sec)) - if (!s->getSectionPiece(d->value)->live) - return false; - return true; + return s->getSectionPiece(d->value)->live; + return sec->isLive(); } return b.used || !config->gcSections; }