Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lld/COFF
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2015-06-29 21:50:11 +0300
committerChandler Carruth <chandlerc@gmail.com>2015-06-29 21:50:11 +0300
commitbe6e80b01261ef02a169daf10b5e36c18696dbc0 (patch)
treee921d4bd1fc77411ca55ef1669150312423d03e3 /lld/COFF
parent80189d2d150909c318b24fc26d3b21d8d3901584 (diff)
[opt] Hoist the call throuh SymbolBody::getReplacement out of the inline
method to get a SymbolBody and into the callers, and kill now dead includes. This removes the need to have the SymbolBody definition when we're defining the inline method and makes it a better inline method. That was the only reason for a lot of header includes here. Removing these and using forward declarations actually uncovers a bunch of cross-header dependencies that I've fixed while I'm here, and will allow me to introduce some *important* inline code into Chunks.h that requires the definition of ObjectFile. No functionality changed at this point. Differential Revision: http://reviews.llvm.org/D10789 llvm-svn: 240982
Diffstat (limited to 'lld/COFF')
-rw-r--r--lld/COFF/Chunks.cpp13
-rw-r--r--lld/COFF/InputFiles.h8
-rw-r--r--lld/COFF/SymbolTable.cpp1
-rw-r--r--lld/COFF/SymbolTable.h6
4 files changed, 20 insertions, 8 deletions
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index 7a068eebf102..bd7b1aebbf30 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -58,7 +58,8 @@ void SectionChunk::writeTo(uint8_t *Buf) {
// 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<Defined>(Body)->getRVA();
uint64_t P = RVA + Rel.VirtualAddress;
switch (Rel.Type) {
@@ -85,7 +86,7 @@ void SectionChunk::mark() {
// 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<DefinedRegular>(B))
D->markLive();
}
@@ -114,7 +115,8 @@ void SectionChunk::getBaserels(std::vector<uint32_t> *Res, Defined *ImageBase) {
// 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 @@ bool SectionChunk::equals(const SectionChunk *X) const {
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<DefinedRegular>(B1);
diff --git a/lld/COFF/InputFiles.h b/lld/COFF/InputFiles.h
index 12e4f79bde0c..b0fb80b210c0 100644
--- a/lld/COFF/InputFiles.h
+++ b/lld/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 @@ namespace coff {
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 @@ public:
// 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.
diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp
index 82bd17a068a4..0d164cf70336 100644
--- a/lld/COFF/SymbolTable.cpp
+++ b/lld/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"
diff --git a/lld/COFF/SymbolTable.h b/lld/COFF/SymbolTable.h
index b7c8888238c8..6b4fcbf4a2bd 100644
--- a/lld/COFF/SymbolTable.h
+++ b/lld/COFF/SymbolTable.h
@@ -23,6 +23,12 @@ struct LTOCodeGenerator;
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).