Skip to content

Commit 98c1cd9

Browse files
committed
Restore intended behavior of markUsedLocalSymbols when both --gc-sections and -r are specified.
This was previously fixed in f9b039e but regressed in the recent upstream merge.
1 parent 31b9774 commit 98c1cd9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lld/ELF/Writer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,9 @@ static void markUsedLocalSymbolsImpl(ObjFile<ELFT> *file,
433433
// The function ensures that the "used" field of local symbols reflects the fact
434434
// that the symbol is used in a relocation from a live section.
435435
template <class ELFT> static void markUsedLocalSymbols(Ctx &ctx) {
436-
// With --gc-sections, the field is already filled.
436+
// With --gc-sections, the field is already filled, unless -r is specified.
437437
// See MarkLive<ELFT>::resolveReloc().
438-
if (ctx.arg.gcSections)
438+
if (ctx.arg.gcSections && !ctx.arg.relocatable)
439439
return;
440440
for (ELFFileBase *file : ctx.objectFiles) {
441441
ObjFile<ELFT> *f = cast<ObjFile<ELFT>>(file);

0 commit comments

Comments
 (0)