aboutsummaryrefslogtreecommitdiff
path: root/lld/COFF
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2024-04-18 13:30:29 +0300
committerGitHub <noreply@github.com>2024-04-18 13:30:29 +0300
commitd17db6066d2524856fab493dd894f8396e896bc7 (patch)
treeaa22f243eabce980795deaf195738fc9d86f74ad /lld/COFF
parent750de326ef0408df4a5f91773c355ded1a1b1b77 (diff)
downloadllvm-d17db6066d2524856fab493dd894f8396e896bc7.zip
llvm-d17db6066d2524856fab493dd894f8396e896bc7.tar.gz
llvm-d17db6066d2524856fab493dd894f8396e896bc7.tar.bz2
[LLD] [COFF] Don't create pseudo relocations for discardable sections (#89043)
This extends on the case from 9c970d5ecd6a85188cd2b0a941fcd4d60063ef81; if a section is marked discardable, it won't be mapped into memory at runtime, so there's no point in creating runtime pseudo relocations for such sections.
Diffstat (limited to 'lld/COFF')
-rw-r--r--lld/COFF/Writer.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 7269d15..6899323 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -2060,6 +2060,10 @@ void Writer::createRuntimePseudoRelocs() {
auto *sc = dyn_cast<SectionChunk>(c);
if (!sc || !sc->live)
continue;
+ // Don't create pseudo relocations for sections that won't be
+ // mapped at runtime.
+ if (sc->header->Characteristics & IMAGE_SCN_MEM_DISCARDABLE)
+ continue;
sc->getRuntimePseudoRelocs(rels);
}