[lld] r325445 - Remove an unused accessor and simplify the logic a bit. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 17 12:41:38 PST 2018
Author: ruiu
Date: Sat Feb 17 12:41:38 2018
New Revision: 325445
URL: http://llvm.org/viewvc/llvm-project?rev=325445&view=rev
Log:
Remove an unused accessor and simplify the logic a bit. NFC.
Modified:
lld/trunk/COFF/Chunks.cpp
lld/trunk/COFF/Symbols.cpp
lld/trunk/COFF/Symbols.h
lld/trunk/COFF/Writer.cpp
Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=325445&r1=325444&r2=325445&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Sat Feb 17 12:41:38 2018
@@ -75,10 +75,13 @@ static void applySecRel(const SectionChu
}
static void applySecIdx(uint8_t *Off, OutputSection *OS) {
- // If we have no output section, this must be an absolute symbol. Use the
- // sentinel absolute symbol section index.
- uint16_t SecIdx = OS ? OS->SectionIndex : DefinedAbsolute::OutputSectionIndex;
- add16(Off, SecIdx);
+ // Absolute symbol doesn't have section index, but section index relocation
+ // against absolute symbol should be resolved to one plus the last output
+ // section index. This is required for compatibility with MSVC.
+ if (OS)
+ add16(Off, OS->SectionIndex);
+ else
+ add16(Off, DefinedAbsolute::NumOutputSections + 1);
}
void SectionChunk::applyRelX64(uint8_t *Off, uint16_t Type, OutputSection *OS,
Modified: lld/trunk/COFF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Symbols.cpp?rev=325445&r1=325444&r2=325445&view=diff
==============================================================================
--- lld/trunk/COFF/Symbols.cpp (original)
+++ lld/trunk/COFF/Symbols.cpp Sat Feb 17 12:41:38 2018
@@ -71,7 +71,7 @@ COFFSymbolRef DefinedCOFF::getCOFFSymbol
return COFFSymbolRef(reinterpret_cast<const coff_symbol32 *>(Sym));
}
-uint16_t DefinedAbsolute::OutputSectionIndex = 0;
+uint16_t DefinedAbsolute::NumOutputSections;
static Chunk *makeImportThunk(DefinedImportData *S, uint16_t Machine) {
if (Machine == AMD64)
Modified: lld/trunk/COFF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Symbols.h?rev=325445&r1=325444&r2=325445&view=diff
==============================================================================
--- lld/trunk/COFF/Symbols.h (original)
+++ lld/trunk/COFF/Symbols.h Sat Feb 17 12:41:38 2018
@@ -213,11 +213,10 @@ public:
uint64_t getRVA() { return VA - Config->ImageBase; }
void setVA(uint64_t V) { VA = V; }
- // The sentinel absolute symbol section index. Section index relocations
- // against absolute symbols resolve to this 16 bit number, and it is the
- // largest valid section index plus one. This is written by the Writer.
- static uint16_t OutputSectionIndex;
- uint16_t getSecIdx() { return OutputSectionIndex; }
+ // Section index relocations against absolute symbols resolve to
+ // this 16 bit number, and it is the largest valid section index
+ // plus one. This variable keeps it.
+ static uint16_t NumOutputSections;
private:
uint64_t VA;
Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=325445&r1=325444&r2=325445&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Sat Feb 17 12:41:38 2018
@@ -1008,9 +1008,9 @@ void Writer::setSectionPermissions() {
// Write section contents to a mmap'ed file.
void Writer::writeSections() {
- // Record the section index that should be used when resolving a section
- // relocation against an absolute symbol.
- DefinedAbsolute::OutputSectionIndex = OutputSections.size() + 1;
+ // Record the number of sections to apply section index relocations
+ // against absolute symbols. See applySecIdx in Chunks.cpp..
+ DefinedAbsolute::NumOutputSections = OutputSections.size();
uint8_t *Buf = Buffer->getBufferStart();
for (OutputSection *Sec : OutputSections) {
More information about the llvm-commits
mailing list