Don't give an address to sections that are not allocated.
llvm-svn: 244900
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index b754ba3..79ab880 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -174,9 +174,11 @@
std::stable_sort(OutputSections.begin(), OutputSections.end(), compSec<ELFT>);
for (OutputSection<ELFT> *Sec : OutputSections) {
- Sec->setVA(VA);
+ if (Sec->getFlags() & SHF_ALLOC) {
+ Sec->setVA(VA);
+ VA += RoundUpToAlignment(Sec->getSize(), PageSize);
+ }
Sec->setFileOffset(FileOff);
- VA += RoundUpToAlignment(Sec->getSize(), PageSize);
FileOff += RoundUpToAlignment(Sec->getSize(), 8);
StrTabBuilder.add(Sec->getName());
}