From ef59379c63cfa86f18b9eec9ec17f8ee810ddc7a Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Fri, 25 Apr 2025 11:36:20 +1200 Subject: [PATCH] Restore intended behavior of markUsedLocalSymbols when both --gc-sections and -r are specified. This was previously fixed in f9b039e25bc1d78c98a5c34880f0f4d60fb6b927 but regressed in the recent upstream merge. --- lld/ELF/Writer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index bf501e473a7e6..bde9c1aa2fd63 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -433,9 +433,9 @@ static void markUsedLocalSymbolsImpl(ObjFile *file, // The function ensures that the "used" field of local symbols reflects the fact // that the symbol is used in a relocation from a live section. template static void markUsedLocalSymbols(Ctx &ctx) { - // With --gc-sections, the field is already filled. + // With --gc-sections, the field is already filled, unless -r is specified. // See MarkLive::resolveReloc(). - if (ctx.arg.gcSections) + if (ctx.arg.gcSections && !ctx.arg.relocatable) return; for (ELFFileBase *file : ctx.objectFiles) { ObjFile *f = cast>(file);