Index: lld/trunk/COFF/Chunks.cpp =================================================================== --- lld/trunk/COFF/Chunks.cpp +++ lld/trunk/COFF/Chunks.cpp @@ -58,7 +58,8 @@ // Apply relocations. for (const coff_relocation &Rel : Relocs) { uint8_t *Off = Buf + FileOff + Rel.VirtualAddress; - SymbolBody *Body = File->getSymbolBody(Rel.SymbolTableIndex); + SymbolBody *Body = + File->getSymbolBody(Rel.SymbolTableIndex)->getReplacement(); uint64_t S = cast(Body)->getRVA(); uint64_t P = RVA + Rel.VirtualAddress; switch (Rel.Type) { @@ -85,7 +86,7 @@ // Mark all symbols listed in the relocation table for this section. for (const coff_relocation &Rel : Relocs) { - SymbolBody *B = File->getSymbolBody(Rel.SymbolTableIndex); + SymbolBody *B = File->getSymbolBody(Rel.SymbolTableIndex)->getReplacement(); if (auto *D = dyn_cast(B)) D->markLive(); } @@ -114,7 +115,8 @@ // address never changes even if image is relocated. if (Rel.Type != IMAGE_REL_AMD64_ADDR64) continue; - SymbolBody *Body = File->getSymbolBody(Rel.SymbolTableIndex); + SymbolBody *Body = + File->getSymbolBody(Rel.SymbolTableIndex)->getReplacement(); if (Body == ImageBase) continue; Res->push_back(RVA + Rel.VirtualAddress); @@ -186,8 +188,9 @@ return false; if (R1.VirtualAddress != R2.VirtualAddress) return false; - SymbolBody *B1 = File->getSymbolBody(R1.SymbolTableIndex); - SymbolBody *B2 = X->File->getSymbolBody(R2.SymbolTableIndex); + SymbolBody *B1 = File->getSymbolBody(R1.SymbolTableIndex)->getReplacement(); + SymbolBody *B2 = + X->File->getSymbolBody(R2.SymbolTableIndex)->getReplacement(); if (B1 == B2) return true; auto *D1 = dyn_cast(B1); Index: lld/trunk/COFF/InputFiles.h =================================================================== --- lld/trunk/COFF/InputFiles.h +++ lld/trunk/COFF/InputFiles.h @@ -10,8 +10,6 @@ #ifndef LLD_COFF_INPUT_FILES_H #define LLD_COFF_INPUT_FILES_H -#include "Chunks.h" -#include "Symbols.h" #include "lld/Core/LLVM.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/LTO/LTOModule.h" @@ -28,6 +26,10 @@ using llvm::LTOModule; using llvm::object::Archive; using llvm::object::COFFObjectFile; +using llvm::object::COFFSymbolRef; + +class Chunk; +class SymbolBody; // The root class of input files. class InputFile { @@ -102,7 +104,7 @@ // Returns a SymbolBody object for the SymbolIndex'th symbol in the // underlying object file. SymbolBody *getSymbolBody(uint32_t SymbolIndex) { - return SparseSymbolBodies[SymbolIndex]->getReplacement(); + return SparseSymbolBodies[SymbolIndex]; } // Returns the underying COFF file. Index: lld/trunk/COFF/SymbolTable.h =================================================================== --- lld/trunk/COFF/SymbolTable.h +++ lld/trunk/COFF/SymbolTable.h @@ -23,6 +23,12 @@ namespace lld { namespace coff { +class Chunk; +class Defined; +class Lazy; +class SymbolBody; +struct Symbol; + // SymbolTable is a bucket of all known symbols, including defined, // undefined, or lazy symbols (the last one is symbols in archive // files whose archive members are not yet loaded). Index: lld/trunk/COFF/SymbolTable.cpp =================================================================== --- lld/trunk/COFF/SymbolTable.cpp +++ lld/trunk/COFF/SymbolTable.cpp @@ -11,6 +11,7 @@ #include "Driver.h" #include "Error.h" #include "SymbolTable.h" +#include "Symbols.h" #include "llvm/ADT/STLExtras.h" #include "llvm/LTO/LTOCodeGenerator.h" #include "llvm/Support/Debug.h"