summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2013-01-29 22:03:39 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2013-01-29 22:03:39 +0000
commite68f90355c15c276c0f92a7c1cef6db4c9b89237 (patch)
tree0dbc9b766fbb2953aa6e5cfcc9b95c44048bce8f
parentf50ab84bb1f49f1931ddfe7eaa9f1924738ac2fc (diff)
downloadbcm5719-llvm-e68f90355c15c276c0f92a7c1cef6db4c9b89237.tar.gz
bcm5719-llvm-e68f90355c15c276c0f92a7c1cef6db4c9b89237.zip
[ELF] Chop the ELF prefix off of most things.
llvm-svn: 173838
-rw-r--r--lld/include/lld/ReaderWriter/ELFTargetInfo.h13
-rw-r--r--lld/lib/ReaderWriter/ELF/Atoms.h (renamed from lld/lib/ReaderWriter/ELF/AtomsELF.h)64
-rw-r--r--lld/lib/ReaderWriter/ELF/CMakeLists.txt4
-rw-r--r--lld/lib/ReaderWriter/ELF/Chunk.h (renamed from lld/lib/ReaderWriter/ELF/ELFChunk.h)26
-rw-r--r--lld/lib/ReaderWriter/ELF/DefaultLayout.h (renamed from lld/lib/ReaderWriter/ELF/DefaultELFLayout.h)95
-rw-r--r--lld/lib/ReaderWriter/ELF/DefaultTargetHandler.h (renamed from lld/lib/ReaderWriter/ELF/DefaultELFTargetHandler.h)35
-rw-r--r--lld/lib/ReaderWriter/ELF/ELFTargetInfo.cpp12
-rw-r--r--lld/lib/ReaderWriter/ELF/ExecutableAtoms.h36
-rw-r--r--lld/lib/ReaderWriter/ELF/File.h (renamed from lld/lib/ReaderWriter/ELF/FileELF.h)40
-rw-r--r--lld/lib/ReaderWriter/ELF/HeaderChunks.h (renamed from lld/lib/ReaderWriter/ELF/ELFHeaderChunks.h)66
-rw-r--r--lld/lib/ReaderWriter/ELF/Hexagon/HexagonTarget.h (renamed from lld/lib/ReaderWriter/ELF/X86_64/X86_64ELFTarget.h)4
-rw-r--r--lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetInfo.h (renamed from lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFTargetInfo.h)10
-rw-r--r--lld/lib/ReaderWriter/ELF/Layout.h (renamed from lld/lib/ReaderWriter/ELF/ELFLayout.h)26
-rw-r--r--lld/lib/ReaderWriter/ELF/PPC/PPCTarget.h (renamed from lld/lib/ReaderWriter/ELF/PPC/PPCELFTarget.h)5
-rw-r--r--lld/lib/ReaderWriter/ELF/PPC/PPCTargetInfo.h (renamed from lld/lib/ReaderWriter/ELF/PPC/PPCELFTargetInfo.h)10
-rw-r--r--lld/lib/ReaderWriter/ELF/Reader.cpp (renamed from lld/lib/ReaderWriter/ELF/ReaderELF.cpp)41
-rw-r--r--lld/lib/ReaderWriter/ELF/SectionChunks.h (renamed from lld/lib/ReaderWriter/ELF/ELFSectionChunks.h)83
-rw-r--r--lld/lib/ReaderWriter/ELF/SegmentChunks.h (renamed from lld/lib/ReaderWriter/ELF/ELFSegmentChunks.h)34
-rw-r--r--lld/lib/ReaderWriter/ELF/TargetHandler.h (renamed from lld/lib/ReaderWriter/ELF/ELFTargetHandler.h)41
-rw-r--r--lld/lib/ReaderWriter/ELF/TargetLayout.h (renamed from lld/lib/ReaderWriter/ELF/ELFTargetLayout.h)14
-rw-r--r--lld/lib/ReaderWriter/ELF/Targets.h (renamed from lld/lib/ReaderWriter/ELF/ELFTargets.h)10
-rw-r--r--lld/lib/ReaderWriter/ELF/Writer.cpp (renamed from lld/lib/ReaderWriter/ELF/WriterELF.cpp)130
-rw-r--r--lld/lib/ReaderWriter/ELF/Writer.h (renamed from lld/lib/ReaderWriter/ELF/ELFWriter.h)19
-rw-r--r--lld/lib/ReaderWriter/ELF/X86/X86Target.h (renamed from lld/lib/ReaderWriter/ELF/X86/X86ELFTarget.h)5
-rw-r--r--lld/lib/ReaderWriter/ELF/X86/X86TargetInfo.h (renamed from lld/lib/ReaderWriter/ELF/X86/X86ELFTargetInfo.h)23
-rw-r--r--lld/lib/ReaderWriter/ELF/X86_64/X86_64Target.h (renamed from lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFTarget.h)5
-rw-r--r--lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp12
-rw-r--r--lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.h (renamed from lld/lib/ReaderWriter/ELF/X86_64/X86_64ELFTargetInfo.h)12
28 files changed, 434 insertions, 441 deletions
diff --git a/lld/include/lld/ReaderWriter/ELFTargetInfo.h b/lld/include/lld/ReaderWriter/ELFTargetInfo.h
index ee1631be3ac..078ea1b6f3d 100644
--- a/lld/include/lld/ReaderWriter/ELFTargetInfo.h
+++ b/lld/include/lld/ReaderWriter/ELFTargetInfo.h
@@ -21,11 +21,11 @@ namespace lld {
class DefinedAtom;
class Reference;
-namespace elf { template <typename ELFT> class ELFTargetHandler; }
+namespace elf { template <typename ELFT> class TargetHandler; }
-class ELFTargetHandlerBase {
+class TargetHandlerBase {
public:
- virtual ~ELFTargetHandlerBase() {}
+ virtual ~TargetHandlerBase() {}
};
class ELFTargetInfo : public TargetInfo {
@@ -47,13 +47,12 @@ public:
static std::unique_ptr<ELFTargetInfo> create(const LinkerOptions &lo);
template <typename ELFT>
- lld::elf::ELFTargetHandler<ELFT> &getTargetHandler() const {
- return static_cast<
- lld::elf::ELFTargetHandler<ELFT> &>(*_targetHandler.get());
+ lld::elf::TargetHandler<ELFT> &getTargetHandler() const {
+ return static_cast<lld::elf::TargetHandler<ELFT> &>(*_targetHandler.get());
}
protected:
- std::unique_ptr<ELFTargetHandlerBase> _targetHandler;
+ std::unique_ptr<TargetHandlerBase> _targetHandler;
};
} // end namespace lld
diff --git a/lld/lib/ReaderWriter/ELF/AtomsELF.h b/lld/lib/ReaderWriter/ELF/Atoms.h
index e35358bb522..cd6a1c9275f 100644
--- a/lld/lib/ReaderWriter/ELF/AtomsELF.h
+++ b/lld/lib/ReaderWriter/ELF/Atoms.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/AtomELF.h -------------------------------------===//
+//===- lib/ReaderWriter/ELF/Atoms.h ---------------------------------------===//
//
// The LLVM Linker
//
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_READER_WRITER_ELF_ATOMS_ELF_H
-#define LLD_READER_WRITER_ELF_ATOMS_ELF_H
+#ifndef LLD_READER_WRITER_ELF_ATOMS_H
+#define LLD_READER_WRITER_ELF_ATOMS_H
-#include "ELFTargetHandler.h"
+#include "TargetHandler.h"
#include "lld/Core/LLVM.h"
@@ -20,10 +20,10 @@
#include <vector>
namespace lld {
+namespace elf {
+template <typename ELFT> class ELFFile;
+template <typename ELFT> class TargetAtomHandler;
-template <typename ELFT> class FileELF;
-
-namespace elf { template <typename ELFT> class ELFTargetAtomHandler; }
/// \brief Relocation References: Defined Atoms may contain references that will
/// need to be patched before the executable is written.
template <class ELFT> class ELFReference LLVM_FINAL : public Reference {
@@ -93,12 +93,12 @@ class ELFAbsoluteAtom LLVM_FINAL : public AbsoluteAtom {
typedef llvm::object::Elf_Sym_Impl<ELFT> Elf_Sym;
public:
- ELFAbsoluteAtom(const FileELF<ELFT> &file, llvm::StringRef name,
+ ELFAbsoluteAtom(const ELFFile<ELFT> &file, StringRef name,
const Elf_Sym *symbol, uint64_t value)
: _owningFile(file), _name(name), _symbol(symbol), _value(value) {
}
- virtual const class FileELF<ELFT> &file() const {
+ virtual const class ELFFile<ELFT> &file() const {
return _owningFile;
} virtual Scope scope() const {
if (_symbol->st_other == llvm::ELF::STV_HIDDEN)
@@ -109,7 +109,7 @@ public:
return scopeGlobal;
}
- virtual llvm::StringRef name() const {
+ virtual StringRef name() const {
return _name;
}
@@ -118,8 +118,8 @@ public:
}
private:
- const FileELF<ELFT> &_owningFile;
- llvm::StringRef _name;
+ const ELFFile<ELFT> &_owningFile;
+ StringRef _name;
const Elf_Sym *_symbol;
uint64_t _value;
};
@@ -127,19 +127,19 @@ private:
/// \brief ELFUndefinedAtom: These atoms store undefined symbols and are place
/// holders that will be replaced by defined atoms later in the linking process.
template<class ELFT>
-class ELFUndefinedAtom LLVM_FINAL : public UndefinedAtom {
+class ELFUndefinedAtom LLVM_FINAL : public lld::UndefinedAtom {
typedef llvm::object::Elf_Sym_Impl<ELFT> Elf_Sym;
public:
- ELFUndefinedAtom(const FileELF<ELFT> &file, llvm::StringRef name,
+ ELFUndefinedAtom(const ELFFile<ELFT> &file, StringRef name,
const Elf_Sym *symbol)
: _owningFile(file), _name(name), _symbol(symbol) {}
- virtual const class FileELF<ELFT> &file() const {
+ virtual const class ELFFile<ELFT> &file() const {
return _owningFile;
}
- virtual llvm::StringRef name() const {
+ virtual StringRef name() const {
return _name;
}
@@ -154,8 +154,8 @@ public:
}
private:
- const FileELF<ELFT> &_owningFile;
- llvm::StringRef _name;
+ const ELFFile<ELFT> &_owningFile;
+ StringRef _name;
const Elf_Sym *_symbol;
};
@@ -167,9 +167,9 @@ class ELFDefinedAtom LLVM_FINAL : public DefinedAtom {
typedef llvm::object::Elf_Shdr_Impl<ELFT> Elf_Shdr;
public:
- ELFDefinedAtom(const FileELF<ELFT> &file,
- llvm::StringRef symbolName,
- llvm::StringRef sectionName,
+ ELFDefinedAtom(const ELFFile<ELFT> &file,
+ StringRef symbolName,
+ StringRef sectionName,
const Elf_Sym *symbol,
const Elf_Shdr *section,
llvm::ArrayRef<uint8_t> contentData,
@@ -190,11 +190,11 @@ public:
_ordinal = ++orderNumber;
}
- virtual const class FileELF<ELFT> &file() const {
+ virtual const class ELFFile<ELFT> &file() const {
return _owningFile;
}
- virtual llvm::StringRef name() const {
+ virtual StringRef name() const {
return _symbolName;
}
@@ -246,10 +246,10 @@ public:
_symbol->st_shndx < llvm::ELF::SHN_HIPROC) {
const ELFTargetInfo &eti =
(_owningFile.getTargetInfo());
- elf::ELFTargetHandler<ELFT> &elfTargetHandler =
+ TargetHandler<ELFT> &TargetHandler =
eti.getTargetHandler<ELFT>();
- elf::ELFTargetAtomHandler<ELFT> &elfAtomHandler =
- elfTargetHandler.targetAtomHandler();
+ TargetAtomHandler<ELFT> &elfAtomHandler =
+ TargetHandler.targetAtomHandler();
return elfAtomHandler.contentType(this);
}
@@ -315,7 +315,7 @@ public:
return sectionCustomRequired;
}
- virtual llvm::StringRef customSectionName() const {
+ virtual StringRef customSectionName() const {
if ((contentType() == typeZeroFill) ||
(_symbol->st_shndx == llvm::ELF::SHN_COMMON))
return ".bss";
@@ -418,9 +418,9 @@ public:
private:
- const FileELF<ELFT> &_owningFile;
- llvm::StringRef _symbolName;
- llvm::StringRef _sectionName;
+ const ELFFile<ELFT> &_owningFile;
+ StringRef _symbolName;
+ StringRef _sectionName;
const Elf_Sym *_symbol;
const Elf_Shdr *_section;
/// \brief Holds the bits that make up the atom.
@@ -432,5 +432,7 @@ private:
std::vector<ELFReference<ELFT>*> &
_referenceList;
};
-} // namespace lld
+} // end namespace elf
+} // end namespace lld
+
#endif
diff --git a/lld/lib/ReaderWriter/ELF/CMakeLists.txt b/lld/lib/ReaderWriter/ELF/CMakeLists.txt
index ba10c668f29..05deea13dcd 100644
--- a/lld/lib/ReaderWriter/ELF/CMakeLists.txt
+++ b/lld/lib/ReaderWriter/ELF/CMakeLists.txt
@@ -2,9 +2,9 @@ add_lld_library(lldELF
ELFTargetInfo.cpp
HexagonReference.cpp
PPCReference.cpp
- ReaderELF.cpp
+ Reader.cpp
ReferenceKinds.cpp
- WriterELF.cpp
+ Writer.cpp
X86Reference.cpp
X86_64Reference.cpp
)
diff --git a/lld/lib/ReaderWriter/ELF/ELFChunk.h b/lld/lib/ReaderWriter/ELF/Chunk.h
index cfed0ec7d03..312818387bf 100644
--- a/lld/lib/ReaderWriter/ELF/ELFChunk.h
+++ b/lld/lib/ReaderWriter/ELF/Chunk.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ELFChunks.h ---------------------------------===//
+//===- lib/ReaderWriter/ELF/Chunks.h --------------------------------------===//
//
// The LLVM Linker
//
@@ -7,8 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_READER_WRITER_ELF_CHUNKS_H_
-#define LLD_READER_WRITER_ELF_CHUNKS_H_
+#ifndef LLD_READER_WRITER_ELF_CHUNKS_H
+#define LLD_READER_WRITER_ELF_CHUNKS_H
+
+#include "lld/Core/LLVM.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringRef.h"
@@ -32,13 +34,13 @@ public:
/// \brief Describes the type of Chunk
enum Kind {
- K_ELFHeader, // ELF Header
- K_ELFProgramHeader, // Program Header
+ K_Header, // ELF Header
+ K_ProgramHeader, // Program Header
K_ELFSegment, // Segment
K_ELFSection, // Section
- K_ELFSectionHeader // Section header
+ K_SectionHeader // Section header
};
- Chunk(llvm::StringRef name, Kind kind, const ELFTargetInfo &ti)
+ Chunk(StringRef name, Kind kind, const ELFTargetInfo &ti)
: _name(name), _kind(kind), _fsize(0), _msize(0), _align2(0), _order(0),
_ordinal(1), _start(0), _fileoffset(0), _targetInfo(ti) {
}
@@ -48,7 +50,7 @@ public:
return false;
}
// The name of the chunk
- llvm::StringRef name() const { return _name; }
+ StringRef name() const { return _name; }
// Kind of chunk
Kind kind() const { return _kind; }
uint64_t fileSize() const { return _fsize; }
@@ -76,7 +78,7 @@ public:
virtual void finalize() = 0;
protected:
- llvm::StringRef _name;
+ StringRef _name;
Kind _kind;
uint64_t _fsize;
uint64_t _msize;
@@ -88,7 +90,7 @@ protected:
const ELFTargetInfo &_targetInfo;
};
-} // elf
-} // lld
+} // end namespace elf
+} // end namespace lld
-#endif // LLD_READER_WRITER_ELF_CHUNKS_H_
+#endif
diff --git a/lld/lib/ReaderWriter/ELF/DefaultELFLayout.h b/lld/lib/ReaderWriter/ELF/DefaultLayout.h
index cd05d2ce442..090271e43f5 100644
--- a/lld/lib/ReaderWriter/ELF/DefaultELFLayout.h
+++ b/lld/lib/ReaderWriter/ELF/DefaultLayout.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/DefaultELFLayout.h ---------------------------===//
+//===- lib/ReaderWriter/ELF/DefaultLayout.h -------------------------------===//
//
// The LLVM Linker
//
@@ -7,14 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_READER_WRITER_DEFAULT_ELF_LAYOUT_H_
-#define LLD_READER_WRITER_DEFAULT_ELF_LAYOUT_H_
+#ifndef LLD_READER_WRITER_ELF_DEFAULT_LAYOUT_H
+#define LLD_READER_WRITER_ELF_DEFAULT_LAYOUT_H
-#include "ELFChunk.h"
-#include "ELFHeaderChunks.h"
-#include "ELFLayout.h"
-#include "ELFSectionChunks.h"
-#include "ELFSegmentChunks.h"
+#include "Chunk.h"
+#include "HeaderChunks.h"
+#include "Layout.h"
+#include "SectionChunks.h"
+#include "SegmentChunks.h"
#include "lld/Core/LinkerOptions.h"
@@ -32,16 +32,14 @@
#include <tuple>
#include <unordered_map>
-/// \brief The DefaultELFLayout class is used by the Writer to arrange
-/// sections and segments in the order determined by the target ELF
-/// format. The writer creates a single instance of the DefaultELFLayout
-/// class
-
namespace lld {
namespace elf {
-
+/// \brief The DefaultLayout class is used by the Writer to arrange
+/// sections and segments in the order determined by the target ELF
+/// format. The writer creates a single instance of the DefaultLayout
+/// class
template<class ELFT>
-class DefaultELFLayout : public ELFLayout {
+class DefaultLayout : public Layout {
public:
// The order in which the sections appear in the output file
@@ -163,7 +161,7 @@ public:
typedef typename std::vector<AbsoluteAtomPair>::iterator AbsoluteAtomIterT;
- DefaultELFLayout(const ELFTargetInfo &ti) : _targetInfo(ti) {}
+ DefaultLayout(const ELFTargetInfo &ti) : _targetInfo(ti) {}
/// \brief Return the section order for a input section
virtual SectionOrder getSectionOrder
@@ -176,7 +174,7 @@ public:
const int32_t contentType);
/// \brief Gets the segment for a output section
- virtual ELFLayout::SegmentType getSegmentType(Section<ELFT> *section) const;
+ virtual Layout::SegmentType getSegmentType(Section<ELFT> *section) const;
/// \brief Returns true/false depending on whether the section has a Output
// segment or not
@@ -230,11 +228,11 @@ public:
return false;
}
- inline void setELFHeader(ELFHeader<ELFT> *e) {
- _elfHeader = e;
+ inline void setHeader(Header<ELFT> *e) {
+ _header = e;
}
- inline void setProgramHeader(ELFProgramHeader<ELFT> *p) {
+ inline void setProgramHeader(ProgramHeader<ELFT> *p) {
_programHeader = p;
}
@@ -244,19 +242,19 @@ public:
inline range<ChunkIter> segments() { return _segments; }
- inline ELFHeader<ELFT> *elfHeader() {
- return _elfHeader;
+ inline Header<ELFT> *getHeader() {
+ return _header;
}
- inline ELFProgramHeader<ELFT> *elfProgramHeader() {
+ inline ProgramHeader<ELFT> *getProgramHeader() {
return _programHeader;
}
- ELFRelocationTable<ELFT> *getRelocationTable() {
+ RelocationTable<ELFT> *getRelocationTable() {
// Only create the relocation table if it is needed.
if (!_relocationTable) {
_relocationTable = new (_allocator)
- ELFRelocationTable<ELFT>(_targetInfo, ".rela.plt", ORDER_REL);
+ RelocationTable<ELFT>(_targetInfo, ".rela.plt", ORDER_REL);
addSection(_relocationTable);
}
return _relocationTable;
@@ -269,17 +267,17 @@ private:
std::vector<Chunk<ELFT> *> _sections;
std::vector<Segment<ELFT> *> _segments;
std::vector<MergedSections<ELFT> *> _mergedSections;
- ELFHeader<ELFT> *_elfHeader;
- ELFProgramHeader<ELFT> *_programHeader;
- ELFRelocationTable<ELFT> *_relocationTable;
+ Header<ELFT> *_header;
+ ProgramHeader<ELFT> *_programHeader;
+ RelocationTable<ELFT> *_relocationTable;
std::vector<AbsoluteAtomPair> _absoluteAtoms;
llvm::BumpPtrAllocator _allocator;
const ELFTargetInfo &_targetInfo;
};
template<class ELFT>
-ELFLayout::SectionOrder
-DefaultELFLayout<ELFT>::getSectionOrder(const StringRef name,
+Layout::SectionOrder
+DefaultLayout<ELFT>::getSectionOrder(const StringRef name,
int32_t contentType,
int32_t contentPermissions)
{
@@ -322,7 +320,7 @@ DefaultELFLayout<ELFT>::getSectionOrder(const StringRef name,
/// \brief This maps the input sections to the output section names
template<class ELFT>
StringRef
-DefaultELFLayout<ELFT>::getSectionName(const StringRef name,
+DefaultLayout<ELFT>::getSectionName(const StringRef name,
const int32_t contentType) {
if (contentType == DefinedAtom::typeZeroFill)
return ".bss";
@@ -335,8 +333,8 @@ DefaultELFLayout<ELFT>::getSectionName(const StringRef name,
/// \brief Gets the segment for a output section
template<class ELFT>
-ELFLayout::SegmentType
-DefaultELFLayout<ELFT>::getSegmentType(Section<ELFT> *section) const {
+Layout::SegmentType
+DefaultLayout<ELFT>::getSegmentType(Section<ELFT> *section) const {
switch(section->order()) {
case ORDER_INTERP:
return llvm::ELF::PT_INTERP;
@@ -379,7 +377,7 @@ DefaultELFLayout<ELFT>::getSegmentType(Section<ELFT> *section) const {
template<class ELFT>
bool
-DefaultELFLayout<ELFT>::hasOutputSegment(Section<ELFT> *section) {
+DefaultLayout<ELFT>::hasOutputSegment(Section<ELFT> *section) {
switch(section->order()) {
case ORDER_INTERP:
case ORDER_HASH:
@@ -412,13 +410,13 @@ DefaultELFLayout<ELFT>::hasOutputSegment(Section<ELFT> *section) {
template<class ELFT>
error_code
-DefaultELFLayout<ELFT>::addAtom(const Atom *atom) {
+DefaultLayout<ELFT>::addAtom(const Atom *atom) {
if (const DefinedAtom *definedAtom = dyn_cast<DefinedAtom>(atom)) {
const StringRef sectionName = getSectionName(
definedAtom->customSectionName(), definedAtom->contentType());
- const lld::DefinedAtom::ContentPermissions permissions =
+ const DefinedAtom::ContentPermissions permissions =
definedAtom->permissions();
- const lld::DefinedAtom::ContentType contentType =
+ const DefinedAtom::ContentType contentType =
definedAtom->contentType();
const SectionKey sectionKey(sectionName, permissions);
Section<ELFT> *section;
@@ -453,7 +451,7 @@ DefaultELFLayout<ELFT>::addAtom(const Atom *atom) {
/// Merge sections with the same name into a MergedSections
template<class ELFT>
void
-DefaultELFLayout<ELFT>::mergeSimiliarSections() {
+DefaultLayout<ELFT>::mergeSimiliarSections() {
MergedSections<ELFT> *mergedSection;
for (auto &si : _sections) {
@@ -476,7 +474,7 @@ DefaultELFLayout<ELFT>::mergeSimiliarSections() {
template<class ELFT>
void
-DefaultELFLayout<ELFT>::assignSectionsToSegments() {
+DefaultLayout<ELFT>::assignSectionsToSegments() {
// sort the sections by their order as defined by the layout
std::stable_sort(_sections.begin(), _sections.end(),
[](Chunk<ELFT> *A, Chunk<ELFT> *B) {
@@ -524,7 +522,7 @@ DefaultELFLayout<ELFT>::assignSectionsToSegments() {
template<class ELFT>
void
-DefaultELFLayout<ELFT>::assignFileOffsets() {
+DefaultLayout<ELFT>::assignFileOffsets() {
std::sort(_segments.begin(), _segments.end(),
Segment<ELFT>::compareSegments);
int ordinal = 0;
@@ -541,7 +539,7 @@ DefaultELFLayout<ELFT>::assignFileOffsets() {
template<class ELFT>
void
-DefaultELFLayout<ELFT>::assignVirtualAddress() {
+DefaultLayout<ELFT>::assignVirtualAddress() {
if (_segments.empty())
return;
@@ -553,7 +551,7 @@ DefaultELFLayout<ELFT>::assignVirtualAddress() {
// at runtime. To do this we simply prepend them to the first Segment and
// let the layout logic take care of it.
_segments[0]->prepend(_programHeader);
- _segments[0]->prepend(_elfHeader);
+ _segments[0]->prepend(_header);
bool newSegmentHeaderAdded = true;
while (true) {
@@ -589,7 +587,7 @@ DefaultELFLayout<ELFT>::assignVirtualAddress() {
// Fix the offsets of all the atoms within a section
for (auto &si : _sections) {
section = dyn_cast<Section<ELFT>>(si);
- if (section && DefaultELFLayout<ELFT>::hasOutputSegment(section))
+ if (section && DefaultLayout<ELFT>::hasOutputSegment(section))
section->assignOffsets(section->fileOffset());
}
// Set the size of the merged Sections
@@ -632,7 +630,7 @@ DefaultELFLayout<ELFT>::assignVirtualAddress() {
template<class ELFT>
void
-DefaultELFLayout<ELFT>::assignOffsetsForMiscSections() {
+DefaultLayout<ELFT>::assignOffsetsForMiscSections() {
uint64_t fileoffset = 0;
uint64_t size = 0;
for (auto si : _segments) {
@@ -643,7 +641,7 @@ DefaultELFLayout<ELFT>::assignOffsetsForMiscSections() {
Section<ELFT> *section;
for (auto si : _sections) {
section = dyn_cast<Section<ELFT>>(si);
- if (section && DefaultELFLayout<ELFT>::hasOutputSegment(section))
+ if (section && DefaultLayout<ELFT>::hasOutputSegment(section))
continue;
fileoffset = llvm::RoundUpToAlignment(fileoffset, si->align2());
si->setFileOffset(fileoffset);
@@ -651,8 +649,7 @@ DefaultELFLayout<ELFT>::assignOffsetsForMiscSections() {
fileoffset += si->fileSize();
}
}
+} // end namespace elf
+} // end namespace lld
-} // elf
-} // lld
-
-#endif // LLD_READER_WRITER_DEFAULT_ELF_LAYOUT_H_
+#endif
diff --git a/lld/lib/ReaderWriter/ELF/DefaultELFTargetHandler.h b/lld/lib/ReaderWriter/ELF/DefaultTargetHandler.h
index acbe55f2196..938b80f7acf 100644
--- a/lld/lib/ReaderWriter/ELF/DefaultELFTargetHandler.h
+++ b/lld/lib/ReaderWriter/ELF/DefaultTargetHandler.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/DefaultELFTargetHandler.h ---------------------===//
+//===- lib/ReaderWriter/ELF/DefaultTargetHandler.h ------------------------===//
//
// The LLVM Linker
//
@@ -6,11 +6,12 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_READER_WRITER_DEFAULT_ELF_TARGETHANDLER_H
-#define LLD_READER_WRITER_DEFAULT_ELF_TARGETHANDLER_H
-#include "DefaultELFLayout.h"
-#include "ELFTargetHandler.h"
+#ifndef LLD_READER_WRITER_ELF_DEFAULT_TARGETHANDLER_H
+#define LLD_READER_WRITER_ELF_DEFAULT_TARGETHANDLER_H
+
+#include "DefaultLayout.h"
+#include "TargetHandler.h"
#include "lld/Core/LinkerOptions.h"
#include "lld/ReaderWriter/ELFTargetInfo.h"
@@ -20,28 +21,27 @@
namespace lld {
namespace elf {
-
template <class ELFT>
-class DefaultELFTargetHandler : public ELFTargetHandler<ELFT> {
+class DefaultTargetHandler : public TargetHandler<ELFT> {
public:
- DefaultELFTargetHandler(ELFTargetInfo &targetInfo)
- : ELFTargetHandler<ELFT>(targetInfo) {
+ DefaultTargetHandler(ELFTargetInfo &targetInfo)
+ : TargetHandler<ELFT>(targetInfo) {
}
- bool doesOverrideELFHeader() { return false; }
+ bool doesOverrideHeader() { return false; }
- void setELFHeaderInfo(ELFHeader<ELFT> *elfHeader) {
+ void setHeaderInfo(Header<ELFT> *Header) {
llvm_unreachable("Target should provide implementation for function ");
}
- /// ELFTargetLayout
- ELFTargetLayout<ELFT> &targetLayout() {
+ /// TargetLayout
+ TargetLayout<ELFT> &targetLayout() {
llvm_unreachable("Target should provide implementation for function ");
}
- /// ELFTargetAtomHandler
- ELFTargetAtomHandler<ELFT> &targetAtomHandler() {
+ /// TargetAtomHandler
+ TargetAtomHandler<ELFT> &targetAtomHandler() {
llvm_unreachable("Target should provide implementation for function ");
}
@@ -61,8 +61,7 @@ public:
/// symbols over to small data, this would also be used
void allocateCommons() {}
};
-
-} // elf
-} // lld
+} // end namespace elf
+} // end namespace lld
#endif
diff --git a/lld/lib/ReaderWriter/ELF/ELFTargetInfo.cpp b/lld/lib/ReaderWriter/ELF/ELFTargetInfo.cpp
index 97526aa281a..68aa19ba8cb 100644
--- a/lld/lib/ReaderWriter/ELF/ELFTargetInfo.cpp
+++ b/lld/lib/ReaderWriter/ELF/ELFTargetInfo.cpp
@@ -9,8 +9,8 @@
#include "lld/ReaderWriter/ELFTargetInfo.h"
-#include "ELFTargetHandler.h"
-#include "ELFTargets.h"
+#include "TargetHandler.h"
+#include "Targets.h"
#include "lld/Core/LinkerOptions.h"
@@ -55,15 +55,15 @@ uint16_t ELFTargetInfo::getOutputMachine() const {
std::unique_ptr<ELFTargetInfo> ELFTargetInfo::create(const LinkerOptions &lo) {
switch (llvm::Triple(llvm::Triple::normalize(lo._target)).getArch()) {
case llvm::Triple::x86:
- return std::unique_ptr<ELFTargetInfo>(new lld::elf::X86ELFTargetInfo(lo));
+ return std::unique_ptr<ELFTargetInfo>(new lld::elf::X86TargetInfo(lo));
case llvm::Triple::x86_64:
return std::unique_ptr<
- ELFTargetInfo>(new lld::elf::X86_64ELFTargetInfo(lo));
+ ELFTargetInfo>(new lld::elf::X86_64TargetInfo(lo));
case llvm::Triple::hexagon:
return std::unique_ptr<
- ELFTargetInfo>(new lld::elf::HexagonELFTargetInfo(lo));
+ ELFTargetInfo>(new lld::elf::HexagonTargetInfo(lo));
case llvm::Triple::ppc:
- return std::unique_ptr<ELFTargetInfo>(new lld::elf::PPCELFTargetInfo(lo));
+ return std::unique_ptr<ELFTargetInfo>(new lld::elf::PPCTargetInfo(lo));
default:
return std::unique_ptr<ELFTargetInfo>();
}
diff --git a/lld/lib/ReaderWriter/ELF/ExecutableAtoms.h b/lld/lib/ReaderWriter/ELF/ExecutableAtoms.h
index 3276bb4efc0..525d3607a39 100644
--- a/lld/lib/ReaderWriter/ELF/ExecutableAtoms.h
+++ b/lld/lib/ReaderWriter/ELF/ExecutableAtoms.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ExecutableAtoms.h ----------------------------===//
+//===- lib/ReaderWriter/ELF/ExecutableAtoms.h -----------------------------===//
//
// The LLVM Linker
//
@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_READER_WRITER_ELF_EXECUTABLE_ATOM_H_
-#define LLD_READER_WRITER_ELF_EXECUTABLE_ATOM_H_
+#ifndef LLD_READER_WRITER_ELF_EXECUTABLE_ATOM_H
+#define LLD_READER_WRITER_ELF_EXECUTABLE_ATOM_H
-#include "AtomsELF.h"
-#include "FileELF.h"
+#include "Atoms.h"
+#include "File.h"
#include "lld/Core/DefinedAtom.h"
#include "lld/Core/File.h"
@@ -21,16 +21,15 @@
namespace lld {
namespace elf {
-
/// \brief All atoms are owned by a File. To add linker specific atoms
/// the atoms need to be inserted to a file called (CRuntimeFile) which
/// are basically additional symbols required by libc and other runtime
/// libraries part of executing a program. This class provides support
/// for adding absolute symbols and undefined symbols
-template <class ELFT> class CRuntimeFileELF : public FileELF<ELFT> {
+template <class ELFT> class CRuntimeFile : public ELFFile<ELFT> {
public:
typedef llvm::object::Elf_Sym_Impl<ELFT> Elf_Sym;
- CRuntimeFileELF(const ELFTargetInfo &ti) : FileELF<ELFT>(ti, "C runtime") {}
+ CRuntimeFile(const ELFTargetInfo &ti) : ELFFile<ELFT>(ti, "C runtime") {}
/// \brief add a global absolute atom
void addAbsoluteAtom(const StringRef symbolName) {
@@ -42,25 +41,21 @@ public:
llvm::ELF::STT_OBJECT);
symbol->st_other = llvm::ELF::STV_DEFAULT;
symbol->st_size = 0;
- auto *newAtom = new (_allocator.Allocate<
- ELFAbsoluteAtom<ELFT> > ())
- ELFAbsoluteAtom<ELFT>(
- *this, symbolName, symbol, -1);
+ auto *newAtom =
+ new (_allocator) ELFAbsoluteAtom<ELFT>(*this, symbolName, symbol, -1);
_absoluteAtoms._atoms.push_back(newAtom);
}
/// \brief add an undefined atom
void addUndefinedAtom(const StringRef symbolName) {
- Elf_Sym *symbol = new(_allocator.Allocate<Elf_Sym>()) Elf_Sym;
+ Elf_Sym *symbol = new (_allocator) Elf_Sym;
symbol->st_name = 0;
symbol->st_value = 0;
symbol->st_shndx = llvm::ELF::SHN_UNDEF;
symbol->st_other = llvm::ELF::STV_DEFAULT;
symbol->st_size = 0;
- auto *newAtom = new (_allocator.Allocate<
- ELFUndefinedAtom<ELFT> > ())
- ELFUndefinedAtom<ELFT>(
- *this, symbolName, symbol);
+ auto *newAtom =
+ new (_allocator) ELFUndefinedAtom<ELFT>(*this, symbolName, symbol);
_undefinedAtoms._atoms.push_back(newAtom);
}
@@ -92,8 +87,7 @@ private:
File::atom_collection_vector<SharedLibraryAtom> _sharedLibraryAtoms;
File::atom_collection_vector<AbsoluteAtom> _absoluteAtoms;
};
+} // end namespace elf
+} // end namespace lld
-} // namespace elf
-} // namespace lld
-
-#endif // LLD_READER_WRITER_ELF_EXECUTABLE_ATOM_H_
+#endif
diff --git a/lld/lib/ReaderWriter/ELF/FileELF.h b/lld/lib/ReaderWriter/ELF/File.h
index 7b66a78cc0d..7413cc4681e 100644
--- a/lld/lib/ReaderWriter/ELF/FileELF.h
+++ b/lld/lib/ReaderWriter/ELF/File.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/FileELF.h ------------------------------------===//
+//===- lib/ReaderWriter/ELF/File.h ----------------------------------------===//
//
// The LLVM Linker
//
@@ -6,14 +6,13 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-/// \brief Read a binary, find out based on the symbol table contents what kind
-/// of symbol it is and create corresponding atoms for it
-#ifndef LLD_READER_WRITER_FILE_ELF_H
-#define LLD_READER_WRITER_FILE_ELF_H
+#ifndef LLD_READER_WRITER_ELF_FILE_H
+#define LLD_READER_WRITER_ELF_FILE_H
-#include "AtomsELF.h"
+#include "Atoms.h"
+#include "lld/Core/File.h"
#include "lld/Core/Reference.h"
#include "lld/ReaderWriter/ELFTargetInfo.h"
#include "lld/ReaderWriter/ReaderArchive.h"
@@ -39,19 +38,21 @@
#include <map>
namespace lld {
-
-template <class ELFT> class FileELF : public File {
+namespace elf {
+/// \brief Read a binary, find out based on the symbol table contents what kind
+/// of symbol it is and create corresponding atoms for it
+template <class ELFT> class ELFFile : public File {
typedef llvm::object::Elf_Sym_Impl<ELFT> Elf_Sym;
typedef llvm::object::Elf_Shdr_Impl<ELFT> Elf_Shdr;
typedef llvm::object::Elf_Rel_Impl<ELFT, false> Elf_Rel;
typedef llvm::object::Elf_Rel_Impl<ELFT, true> Elf_Rela;
public:
- FileELF(const ELFTargetInfo &ti, const StringRef name)
+ ELFFile(const ELFTargetInfo &ti, const StringRef name)
: File(name), _elfTargetInfo(ti) {
}
- FileELF(const ELFTargetInfo &ti, std::unique_ptr<llvm::MemoryBuffer> MB,
+ ELFFile(const ELFTargetInfo &ti, std::unique_ptr<llvm::MemoryBuffer> MB,
llvm::error_code &EC)
: File(MB->getBufferIdentifier()), _elfTargetInfo(ti) {
static uint32_t lastOrdinal = 0;
@@ -87,7 +88,7 @@ public:
const Elf_Shdr *section = _objFile->getElfSection(sit);
if (section->sh_type == llvm::ELF::SHT_RELA) {
- llvm::StringRef sectionName;
+ StringRef sectionName;
if ((EC = _objFile->getSectionName(section, sectionName)))
return;
// Get rid of the leading .rela so Atoms can use their own section
@@ -104,7 +105,7 @@ public:
}
if (section->sh_type == llvm::ELF::SHT_REL) {
- llvm::StringRef sectionName;
+ StringRef sectionName;
if ((EC = _objFile->getSectionName(section, sectionName)))
return;
// Get rid of the leading .rel so Atoms can use their own section
@@ -136,7 +137,7 @@ public:
const Elf_Shdr *section = _objFile->getElfSection(sit);
const Elf_Sym *symbol = _objFile->getElfSymbol(it);
- llvm::StringRef symbolName;
+ StringRef symbolName;
if ((EC = _objFile->getSymbolName(section, symbol, symbolName)))
return;
@@ -185,13 +186,13 @@ public:
if ((EC = _objFile->getSectionContents(i.first, sectionContents)))
return;
- llvm::StringRef sectionName;
+ StringRef sectionName;
if ((EC = _objFile->getSectionName(i.first, sectionName)))
return;
// i.first is the section the symbol lives in
for (auto si = symbols.begin(), se = symbols.end(); si != se; ++si) {
- llvm::StringRef symbolName;
+ StringRef symbolName;
if ((EC = _objFile->getSymbolName(i.first, *si, symbolName)))
return;
@@ -202,10 +203,10 @@ public:
if (((*si)->st_shndx >= llvm::ELF::SHN_LOPROC) &&
((*si)->st_shndx <= llvm::ELF::SHN_HIPROC)) {
- elf::ELFTargetHandler<ELFT> &elfTargetHandler =
+ TargetHandler<ELFT> &TargetHandler =
_elfTargetInfo.getTargetHandler<ELFT>();
- elf::ELFTargetAtomHandler<ELFT> &elfAtomHandler =
- elfTargetHandler.targetAtomHandler();
+ TargetAtomHandler<ELFT> &elfAtomHandler =
+ TargetHandler.targetAtomHandler();
c = elfAtomHandler.contentType(*si);
if (c == DefinedAtom::typeZeroFill)
@@ -331,6 +332,7 @@ private:
llvm::BumpPtrAllocator _readerStorage;
const ELFTargetInfo &_elfTargetInfo;
};
-} // lld
+} // end namespace elf
+} // end namespace lld
#endif
diff --git a/lld/lib/ReaderWriter/ELF/ELFHeaderChunks.h b/lld/lib/ReaderWriter/ELF/HeaderChunks.h
index 50f2dba2b9a..e2512b55e74 100644
--- a/lld/lib/ReaderWriter/ELF/ELFHeaderChunks.h
+++ b/lld/lib/ReaderWriter/ELF/HeaderChunks.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ELFHeaderChunks.h -----------------------------===//
+//===- lib/ReaderWriter/ELF/HeaderChunks.h --------------------------------===//
//
// The LLVM Linker
//
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_READER_WRITER_ELF_HEADER_CHUNKS_H_
-#define LLD_READER_WRITER_ELF_HEADER_CHUNKS_H_
+#ifndef LLD_READER_WRITER_ELF_HEADER_CHUNKS_H
+#define LLD_READER_WRITER_ELF_HEADER_CHUNKS_H
-#include "ELFSegmentChunks.h"
+#include "SegmentChunks.h"
#include "llvm/Object/ELF.h"
#include "llvm/Support/Allocator.h"
@@ -19,17 +19,16 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileOutputBuffer.h"
-/// \brief An ELFHeader represents the Elf[32/64]_Ehdr structure at the
+/// \brief An Header represents the Elf[32/64]_Ehdr structure at the
/// start of an ELF executable file.
namespace lld {
namespace elf {
-
template<class ELFT>
-class ELFHeader : public Chunk<ELFT> {
+class Header : public Chunk<ELFT> {
public:
typedef llvm::object::Elf_Ehdr_Impl<ELFT> Elf_Ehdr;
- ELFHeader(const ELFTargetInfo &);
+ Header(const ELFTargetInfo &);
void e_ident(int I, unsigned char C) { _eh.e_ident[I] = C; }
void e_type(uint16_t type) { _eh.e_type = type; }
@@ -48,7 +47,7 @@ public:
uint64_t fileSize() { return sizeof (Elf_Ehdr); }
static inline bool classof(const Chunk<ELFT> *c) {
- return c->Kind() == Chunk<ELFT>::K_ELFHeader;
+ return c->Kind() == Chunk<ELFT>::K_Header;
}
void write(ELFWriter *writer, llvm::FileOutputBuffer &buffer);
@@ -60,8 +59,8 @@ private:
};
template <class ELFT>
-ELFHeader<ELFT>::ELFHeader(const ELFTargetInfo &ti)
- : Chunk<ELFT>("elfhdr", Chunk<ELFT>::K_ELFHeader, ti) {
+Header<ELFT>::Header(const ELFTargetInfo &ti)
+ : Chunk<ELFT>("elfhdr", Chunk<ELFT>::K_Header, ti) {
this->_align2 = ELFT::Is64Bits ? 8 : 4;
this->_fsize = sizeof(Elf_Ehdr);
this->_msize = sizeof(Elf_Ehdr);
@@ -75,16 +74,16 @@ ELFHeader<ELFT>::ELFHeader(const ELFTargetInfo &ti)
}
template <class ELFT>
-void ELFHeader<ELFT>::write(ELFWriter *writer, llvm::FileOutputBuffer &buffer) {
+void Header<ELFT>::write(ELFWriter *writer, llvm::FileOutputBuffer &buffer) {
uint8_t *chunkBuffer = buffer.getBufferStart();
uint8_t *atomContent = chunkBuffer + this->fileOffset();
memcpy(atomContent, &_eh, fileSize());
}
-/// \brief An ELFProgramHeader represents the Elf[32/64]_Phdr structure at the
+/// \brief An ProgramHeader represents the Elf[32/64]_Phdr structure at the
/// start of an ELF executable file.
template<class ELFT>
-class ELFProgramHeader : public Chunk<ELFT> {
+class ProgramHeader : public Chunk<ELFT> {
public:
typedef llvm::object::Elf_Phdr_Impl<ELFT> Elf_Phdr;
typedef typename std::vector<Elf_Phdr *>::iterator PhIterT;
@@ -110,8 +109,8 @@ public:
uint64_t _flagsClear;
};
- ELFProgramHeader(const ELFTargetInfo &ti)
- : Chunk<ELFT>("elfphdr", Chunk<ELFT>::K_ELFProgramHeader, ti) {
+ ProgramHeader(const ELFTargetInfo &ti)
+ : Chunk<ELFT>("elfphdr", Chunk<ELFT>::K_ProgramHeader, ti) {
this->_align2 = ELFT::Is64Bits ? 8 : 4;
resetProgramHeaders();
}
@@ -127,7 +126,7 @@ public:
}
static inline bool classof(const Chunk<ELFT> *c) {
- return c->Kind() == Chunk<ELFT>::K_ELFProgramHeader;
+ return c->Kind() == Chunk<ELFT>::K_ProgramHeader;
}
void write(ELFWriter *writer, llvm::FileOutputBuffer &buffer);
@@ -164,7 +163,7 @@ private:
template<class ELFT>
bool
-ELFProgramHeader<ELFT>::addSegment(Segment<ELFT> *segment) {
+ProgramHeader<ELFT>::addSegment(Segment<ELFT> *segment) {
Elf_Phdr *phdr = nullptr;
bool ret = false;
@@ -195,7 +194,7 @@ ELFProgramHeader<ELFT>::addSegment(Segment<ELFT> *segment) {
}
template <class ELFT>
-void ELFProgramHeader<ELFT>::write(ELFWriter *writer,
+void ProgramHeader<ELFT>::write(ELFWriter *writer,
llvm::FileOutputBuffer &buffer) {
uint8_t *chunkBuffer = buffer.getBufferStart();
uint8_t *dest = chunkBuffer + this->fileOffset();
@@ -205,24 +204,24 @@ void ELFProgramHeader<ELFT>::write(ELFWriter *writer,
}
}
-/// \brief An ELFSectionHeader represents the Elf[32/64]_Shdr structure
+/// \brief An SectionHeader represents the Elf[32/64]_Shdr structure
/// at the end of the file
template<class ELFT>
-class ELFSectionHeader : public Chunk<ELFT> {
+class SectionHeader : public Chunk<ELFT> {
public:
typedef llvm::object::Elf_Shdr_Impl<ELFT> Elf_Shdr;
- ELFSectionHeader(const ELFTargetInfo &, int32_t order);
+ SectionHeader(const ELFTargetInfo &, int32_t order);
void appendSection(MergedSections<ELFT> *section);
void updateSection(Section<ELFT> *section);
static inline bool classof(const Chunk<ELFT> *c) {
- return c->getChunkKind() == Chunk<ELFT>::K_ELFSectionHeader;
+ return c->getChunkKind() == Chunk<ELFT>::K_SectionHeader;
}
- void setStringSection(ELFStringTable<ELFT> *s) {
+ void setStringSection(StringTable<ELFT> *s) {
_stringSection = s;
}
@@ -243,14 +242,14 @@ public:
}
private:
- ELFStringTable<ELFT> *_stringSection;
+ StringTable<ELFT> *_stringSection;
std::vector<Elf_Shdr*> _sectionInfo;
llvm::BumpPtrAllocator _sectionAllocate;
};
template <class ELFT>
-ELFSectionHeader<ELFT>::ELFSectionHeader(const ELFTargetInfo &ti, int32_t order)
- : Chunk<ELFT>("shdr", Chunk<ELFT>::K_ELFSectionHeader, ti) {
+SectionHeader<ELFT>::SectionHeader(const ELFTargetInfo &ti, int32_t order)
+ : Chunk<ELFT>("shdr", Chunk<ELFT>::K_SectionHeader, ti) {
this->_fsize = 0;
this->_align2 = 8;
this->setOrder(order);
@@ -263,7 +262,7 @@ ELFSectionHeader<ELFT>::ELFSectionHeader(const ELFTargetInfo &ti, int32_t order)
template<class ELFT>
void
-ELFSectionHeader<ELFT>::appendSection(MergedSections<ELFT> *section) {
+SectionHeader<ELFT>::appendSection(MergedSections<ELFT> *section) {
Elf_Shdr *shdr = new (_sectionAllocate.Allocate<Elf_Shdr>()) Elf_Shdr;
shdr->sh_name = _stringSection->addString(section->name());
shdr->sh_type = section->type();
@@ -280,7 +279,7 @@ ELFSectionHeader<ELFT>::appendSection(MergedSections<ELFT> *section) {
template<class ELFT>
void
-ELFSectionHeader<ELFT>::updateSection(Section<ELFT> *section) {
+SectionHeader<ELFT>::updateSection(Section<ELFT> *section) {
Elf_Shdr *shdr = _sectionInfo[section->ordinal()];
shdr->sh_type = section->type();
shdr->sh_flags = section->flags();
@@ -294,7 +293,7 @@ ELFSectionHeader<ELFT>::updateSection(Section<ELFT> *section) {
}
template <class ELFT>
-void ELFSectionHeader<ELFT>::write(ELFWriter *writer,
+void SectionHeader<ELFT>::write(ELFWriter *writer,
llvm::FileOutputBuffer &buffer) {
uint8_t *chunkBuffer = buffer.getBufferStart();
uint8_t *dest = chunkBuffer + this->fileOffset();
@@ -304,8 +303,7 @@ void ELFSectionHeader<ELFT>::write(ELFWriter *writer,
}
_stringSection->write(writer, buffer);
}
+} // end namespace elf
+} // end namespace lld
-} // elf
-} // lld
-
-#endif // LLD_READER_WRITER_ELF_HEADER_CHUNKS_H_
+#endif
diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64ELFTarget.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTarget.h
index 383cfafd95d..8d7e61093b1 100644
--- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64ELFTarget.h
+++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTarget.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/Hexagon/X86ELFTarget.h -----------------------===//
+//===- lib/ReaderWriter/ELF/Hexagon/HexagonTarget.h -----------------------===//
//
// The LLVM Linker
//
@@ -7,4 +7,4 @@
//
//===----------------------------------------------------------------------===//
-#include "X86_64ELFTargetInfo.h"
+#include "HexagonTargetInfo.h"
diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFTargetInfo.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetInfo.h
index 7201a899492..b5dfeb8c5e6 100644
--- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFTargetInfo.h
+++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetInfo.h
@@ -15,15 +15,15 @@
#include "llvm/Object/ELF.h"
#include "llvm/Support/ELF.h"
-#include "DefaultELFTargetHandler.h"
+#include "DefaultTargetHandler.h"
namespace lld {
namespace elf {
-class HexagonELFTargetInfo LLVM_FINAL : public ELFTargetInfo {
+class HexagonTargetInfo LLVM_FINAL : public ELFTargetInfo {
public:
- HexagonELFTargetInfo(const LinkerOptions &lo) : ELFTargetInfo(lo) {
- _targetHandler = std::unique_ptr<ELFTargetHandlerBase>(
- new DefaultELFTargetHandler<llvm::object::ELFType<llvm::support::little,
+ HexagonTargetInfo(const LinkerOptions &lo) : ELFTargetInfo(lo) {
+ _targetHandler = std::unique_ptr<TargetHandlerBase>(
+ new DefaultTargetHandler<llvm::object::ELFType<llvm::support::little,
4, false> >(*this));
}
diff --git a/lld/lib/ReaderWriter/ELF/ELFLayout.h b/lld/lib/ReaderWriter/ELF/Layout.h
index 48754abdb4f..5ff59ab0650 100644
--- a/lld/lib/ReaderWriter/ELF/ELFLayout.h
+++ b/lld/lib/ReaderWriter/ELF/Layout.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ELFLayout.h ---------------------------------===//
+//===- lib/ReaderWriter/ELF/Layout.h --------------------------------------===//
//
// The LLVM Linker
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_READER_WRITER_ELF_LAYOUT_H_
-#define LLD_READER_WRITER_ELF_LAYOUT_H_
+#ifndef LLD_READER_WRITER_ELF_LAYOUT_H
+#define LLD_READER_WRITER_ELF_LAYOUT_H
#include "lld/Core/DefinedAtom.h"
@@ -20,12 +20,12 @@
namespace lld {
namespace elf {
-/// \brief The ELFLayout is an abstract class for managing the final layout for
+/// \brief The Layout is an abstract class for managing the final layout for
/// the kind of binaries(Shared Libraries / Relocatables / Executables 0
/// Each architecture (Hexagon, PowerPC, MIPS) would have a concrete
-/// subclass derived from ELFLayout for generating each binary thats
+/// subclass derived from Layout for generating each binary thats
// needed by the lld linker
-class ELFLayout {
+class Layout {
public:
typedef uint32_t SectionOrder;
typedef uint32_t SegmentType;
@@ -34,13 +34,13 @@ public:
public:
/// Return the order the section would appear in the output file
virtual SectionOrder getSectionOrder
- (const llvm::StringRef name,
+ (const StringRef name,
int32_t contentType,
int32_t contentPerm) = 0;
/// append the Atom to the layout and create appropriate sections
virtual error_code addAtom(const Atom *atom) = 0;
/// find the Atom Address in the current layout
- virtual bool findAtomAddrByName(const llvm::StringRef name,
+ virtual bool findAtomAddrByName(const StringRef name,
uint64_t &addr) = 0;
/// associates a section to a segment
virtual void assignSectionsToSegments() = 0;
@@ -50,9 +50,9 @@ public:
virtual void assignFileOffsets() = 0;
public:
- ELFLayout() {}
+ Layout() {}
- virtual ~ELFLayout() { }
+ virtual ~Layout() { }
};
struct AtomLayout {
@@ -66,7 +66,7 @@ struct AtomLayout {
uint64_t _fileOffset;
uint64_t _virtualAddr;
};
-} // lld
-} // elf
+} // end namespace elf
+} // end namespace lld
-#endif // LLD_READER_WRITER_ELF_LAYOUT_H_
+#endif
diff --git a/lld/lib/ReaderWriter/ELF/PPC/PPCELFTarget.h b/lld/lib/ReaderWriter/ELF/PPC/PPCTarget.h
index 78051906184..56bbdc9888c 100644
--- a/lld/lib/ReaderWriter/ELF/PPC/PPCELFTarget.h
+++ b/lld/lib/ReaderWriter/ELF/PPC/PPCTarget.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/PPC/PPCELFTarget.h ---------------------------===//
+//===- lib/ReaderWriter/ELF/PPC/PPCTarget.h -------------------------------===//
//
// The LLVM Linker
//
@@ -6,4 +6,5 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include "PPCELFTargetInfo.h"
+
+#include "PPCTargetInfo.h"
diff --git a/lld/lib/ReaderWriter/ELF/PPC/PPCELFTargetInfo.h b/lld/lib/ReaderWriter/ELF/PPC/PPCTargetInfo.h
index 9a6cb837b06..23f648737c0 100644
--- a/lld/lib/ReaderWriter/ELF/PPC/PPCELFTargetInfo.h
+++ b/lld/lib/ReaderWriter/ELF/PPC/PPCTargetInfo.h
@@ -15,15 +15,15 @@
#include "llvm/Object/ELF.h"
#include "llvm/Support/ELF.h"
-#include "DefaultELFTargetHandler.h"
+#include "DefaultTargetHandler.h"
namespace lld {
namespace elf {
-class PPCELFTargetInfo LLVM_FINAL : public ELFTargetInfo {
+class PPCTargetInfo LLVM_FINAL : public ELFTargetInfo {
public:
- PPCELFTargetInfo(const LinkerOptions &lo) : ELFTargetInfo(lo) {
- _targetHandler = std::unique_ptr<ELFTargetHandlerBase>(
- new DefaultELFTargetHandler<
+ PPCTargetInfo(const LinkerOptions &lo) : ELFTargetInfo(lo) {
+ _targetHandler = std::unique_ptr<TargetHandlerBase>(
+ new DefaultTargetHandler<
llvm::object::ELFType<llvm::support::big, 4, false> >(*this));
}
diff --git a/lld/lib/ReaderWriter/ELF/ReaderELF.cpp b/lld/lib/ReaderWriter/ELF/Reader.cpp
index 3439b96634e..9ab57df6cef 100644
--- a/lld/lib/ReaderWriter/ELF/ReaderELF.cpp
+++ b/lld/lib/ReaderWriter/ELF/Reader.cpp
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ReaderELF.cpp ---------------------------------===//
+//===- lib/ReaderWriter/ELF/Reader.cpp ------------------------------------===//
//
// The LLVM Linker
//
@@ -15,8 +15,8 @@
#include "lld/ReaderWriter/Reader.h"
-#include "AtomsELF.h"
-#include "FileELF.h"
+#include "Atoms.h"
+#include "File.h"
#include "lld/Core/Reference.h"
#include "lld/ReaderWriter/ELFTargetInfo.h"
@@ -43,17 +43,17 @@
#include <map>
#include <vector>
-using namespace lld;
using llvm::support::endianness;
using namespace llvm::object;
-namespace {
-/// \brief A reader object that will instantiate correct FileELF by examining the
+namespace lld {
+namespace elf {
+/// \brief A reader object that will instantiate correct File by examining the
/// memory buffer for ELF class and bit width
-class ReaderELF : public Reader {
+class ELFReader : public Reader {
public:
- ReaderELF(const ELFTargetInfo &ti, std::function<ReaderFunc> read)
- : Reader(ti), _elfTargetInfo(ti), _readerArchive(ti, read) {
+ ELFReader(const ELFTargetInfo &ti, std::function<ReaderFunc> read)
+ : lld::Reader(ti), _elfTargetInfo(ti), _readerArchive(ti, read) {
}
error_code parseFile(std::unique_ptr<MemoryBuffer> mb,
@@ -71,46 +71,46 @@ public:
case llvm::sys::ELF_Relocatable_FileType: {
std::pair<unsigned char, unsigned char> Ident = getElfArchType(&*mb);
std::unique_ptr<File> f;
- // Instantiate the correct FileELF template instance based on the Ident
+ // Instantiate the correct File template instance based on the Ident
// pair. Once the File is created we push the file to the vector of files
// already created during parser's life.
if (Ident.first == llvm::ELF::ELFCLASS32 &&
Ident.second == llvm::ELF::ELFDATA2LSB) {
if (MaxAlignment >= 4)
- f.reset(new FileELF<ELFType<llvm::support::little, 4, false> >(
+ f.reset(new ELFFile<ELFType<llvm::support::little, 4, false> >(
_elfTargetInfo, std::move(mb), ec));
else if (MaxAlignment >= 2)
- f.reset(new FileELF<ELFType<llvm::support::little, 2, false> >(
+ f.reset(new ELFFile<ELFType<llvm::support::little, 2, false> >(
_elfTargetInfo, std::move(mb), ec));
else
llvm_unreachable("Invalid alignment for ELF file!");
} else if (Ident.first == llvm::ELF::ELFCLASS32 &&
Ident.second == llvm::ELF::ELFDATA2MSB) {
if (MaxAlignment >= 4)
- f.reset(new FileELF<ELFType<llvm::support::big, 4, false> >(
+ f.reset(new ELFFile<ELFType<llvm::support::big, 4, false> >(
_elfTargetInfo, std::move(mb), ec));
else if (MaxAlignment >= 2)
- f.reset(new FileELF<ELFType<llvm::support::big, 2, false> >(
+ f.reset(new ELFFile<ELFType<llvm::support::big, 2, false> >(
_elfTargetInfo, std::move(mb), ec));
else
llvm_unreachable("Invalid alignment for ELF file!");
} else if (Ident.first == llvm::ELF::ELFCLASS64 &&
Ident.second == llvm::ELF::ELFDATA2MSB) {
if (MaxAlignment >= 8)
- f.reset(new FileELF<ELFType<llvm::support::big, 8, true> >(
+ f.reset(new ELFFile<ELFType<llvm::support::big, 8, true> >(
_elfTargetInfo, std::move(mb), ec));
else if (MaxAlignment >= 2)
- f.reset(new FileELF<ELFType<llvm::support::big, 2, true> >(
+ f.reset(new ELFFile<ELFType<llvm::support::big, 2, true> >(
_elfTargetInfo, std::move(mb), ec));
else
llvm_unreachable("Invalid alignment for ELF file!");
} else if (Ident.first == llvm::ELF::ELFCLASS64 &&
Ident.second == llvm::ELF::ELFDATA2LSB) {
if (MaxAlignment >= 8)
- f.reset(new FileELF<ELFType<llvm::support::little, 8, true> >(
+ f.reset(new ELFFile<ELFType<llvm::support::little, 8, true> >(
_elfTargetInfo, std::move(mb), ec));
else if (MaxAlignment >= 2)
- f.reset(new FileELF<ELFType<llvm::support::little, 2, true> >(
+ f.reset(new ELFFile<ELFType<llvm::support::little, 2, true> >(
_elfTargetInfo, std::move(mb), ec));
else
llvm_unreachable("Invalid alignment for ELF file!");
@@ -137,11 +137,10 @@ private:
const ELFTargetInfo &_elfTargetInfo;
ReaderArchive _readerArchive;
};
-} // end anon namespace.
+} // end namespace elf
-namespace lld {
std::unique_ptr<Reader> createReaderELF(const ELFTargetInfo &eti,
std::function<ReaderFunc> read) {
- return std::unique_ptr<Reader>(new ReaderELF(eti, std::move(read)));
+ return std::unique_ptr<Reader>(new elf::ELFReader(eti, std::move(read)));
}
} // end namespace lld
diff --git a/lld/lib/ReaderWriter/ELF/ELFSectionChunks.h b/lld/lib/ReaderWriter/ELF/SectionChunks.h
index 0a645ad8f54..ffb38c53740 100644
--- a/lld/lib/ReaderWriter/ELF/ELFSectionChunks.h
+++ b/lld/lib/ReaderWriter/ELF/SectionChunks.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ELFSectionChunks.h -----------------------------===//
+//===- lib/ReaderWriter/ELF/SectionChunks.h -------------------------------===//
//
// The LLVM Linker
//
@@ -7,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_READER_WRITER_ELF_SECTION_CHUNKS_H_
-#define LLD_READER_WRITER_ELF_SECTION_CHUNKS_H_
+#ifndef LLD_READER_WRITER_ELF_SECTION_CHUNKS_H
+#define LLD_READER_WRITER_ELF_SECTION_CHUNKS_H
-#include "ELFChunk.h"
-#include "ELFLayout.h"
-#include "ELFTargetHandler.h"
-#include "ELFWriter.h"
+#include "Chunk.h"
+#include "Layout.h"
+#include "TargetHandler.h"
+#include "Writer.h"
#include "lld/Core/DefinedAtom.h"
#include "lld/Core/range.h"
@@ -45,7 +45,7 @@ public:
};
// Create a section object, the section is set to the default type if the
// caller doesnot set it
- Section(const ELFTargetInfo &, const llvm::StringRef sectionName,
+ Section(const ELFTargetInfo &, const StringRef sectionName,
const int32_t contentType, const int32_t contentPermissions,
const int32_t order, const SectionKind kind = K_Default);
@@ -83,7 +83,7 @@ public:
/// \brief Find the Atom address given a name, this is needed to to properly
/// apply relocation. The section class calls this to find the atom address
/// to fix the relocation
- inline bool findAtomAddrByName(const llvm::StringRef name, uint64_t &addr) {
+ inline bool findAtomAddrByName(const StringRef name, uint64_t &addr) {
for (auto ai : _atoms) {
if (ai._atom->name() == name) {
addr = ai._virtualAddr;
@@ -113,7 +113,7 @@ public:
/// \brief convert the segment type to a String for diagnostics
/// and printing purposes
- llvm::StringRef segmentKindToStr() const;
+ StringRef segmentKindToStr() const;
/// \brief Return the raw flags, we need this to sort segments
inline int64_t atomflags() const {
@@ -143,7 +143,7 @@ public:
}
/// \brief Records the segmentType, that this section belongs to
- inline void setSegment(const ELFLayout::SegmentType segmentType) {
+ inline void setSegment(const Layout::SegmentType segmentType) {
_segmentType = segmentType;
}
@@ -168,7 +168,7 @@ protected:
int32_t _contentPermissions;
SectionKind _sectionKind;
std::vector<AtomLayout> _atoms;
- ELFLayout::SegmentType _segmentType;
+ Layout::SegmentType _segmentType;
int64_t _entSize;
int64_t _shInfo;
int64_t _link;
@@ -382,7 +382,7 @@ public:
// Iterators
typedef typename std::vector<Chunk<ELFT> *>::iterator ChunkIter;
- MergedSections(llvm::StringRef name);
+ MergedSections(StringRef name);
// Appends a section into the list of sections that are part of this Merged
// Section
@@ -422,7 +422,7 @@ public:
// The below functions returns the properties of the MergeSection
inline bool hasSegment() const { return _hasSegment; }
- inline llvm::StringRef name() const { return _name; }
+ inline StringRef name() const { return _name; }
inline int64_t shinfo() const { return _shInfo; }
@@ -449,7 +449,7 @@ public:
inline uint64_t memSize() { return _memSize; }
private:
- llvm::StringRef _name;
+ StringRef _name;
bool _hasSegment;
uint64_t _ordinal;
int64_t _flags;
@@ -504,26 +504,26 @@ MergedSections<ELFT>::appendSection(Chunk<ELFT> *c) {
/// \brief The class represents the ELF String Table
template<class ELFT>
-class ELFStringTable : public Section<ELFT> {
+class StringTable : public Section<ELFT> {
public:
- ELFStringTable(const ELFTargetInfo &, const char *str, int32_t order);
+ StringTable(const ELFTargetInfo &, const char *str, int32_t order);
static inline bool classof(const Chunk<ELFT> *c) {
return c->kind() == Section<ELFT>::K_StringTable;
}
- uint64_t addString(const llvm::StringRef symname);
+ uint64_t addString(const StringRef symname);
void write(ELFWriter *writer, llvm::FileOutputBuffer &buffer);
inline void finalize() { }
private:
- std::vector<llvm::StringRef> _strings;
+ std::vector<StringRef> _strings;
};
template <class ELFT>
-ELFStringTable<ELFT>::ELFStringTable(const ELFTargetInfo &ti, const char *str,
+StringTable<ELFT>::StringTable(const ELFTargetInfo &ti, const char *str,
int32_t order)
: Section<ELFT>(ti, str, llvm::ELF::SHT_STRTAB, DefinedAtom::perm___, order,
Section<ELFT>::K_StringTable) {
@@ -537,7 +537,7 @@ ELFStringTable<ELFT>::ELFStringTable(const ELFTargetInfo &ti, const char *str,
template<class ELFT>
uint64_t
-ELFStringTable<ELFT>::addString(const StringRef symname) {
+StringTable<ELFT>::addString(const StringRef symname) {
_strings.push_back(symname);
uint64_t offset = this->_fsize;
this->_fsize += symname.size() + 1;
@@ -545,7 +545,7 @@ ELFStringTable<ELFT>::addString(const StringRef symname) {
}
template <class ELFT>
-void ELFStringTable<ELFT>::write(ELFWriter *writer,
+void StringTable<ELFT>::write(ELFWriter *writer,
llvm::FileOutputBuffer &buffer) {
uint8_t *chunkBuffer = buffer.getBufferStart();
uint8_t *dest = chunkBuffer + this->fileOffset();
@@ -557,13 +557,13 @@ void ELFStringTable<ELFT>::write(ELFWriter *writer,
}
}
-/// \brief The ELFSymbolTable class represents the symbol table in a ELF file
+/// \brief The SymbolTable class represents the symbol table in a ELF file
template<class ELFT>
-class ELFSymbolTable : public Section<ELFT> {
+class SymbolTable : public Section<ELFT> {
public:
typedef llvm::object::Elf_Sym_Impl<ELFT> Elf_Sym;
- ELFSymbolTable(const ELFTargetInfo &ti, const char *str, int32_t order);
+ SymbolTable(const ELFTargetInfo &ti, const char *str, int32_t order);
void addSymbol(const Atom *atom, int32_t sectionIndex, uint64_t addr = 0);
@@ -575,12 +575,12 @@ public:
return c->kind() == Section<ELFT>::K_SymbolTable;
}
- inline void setStringSection(ELFStringTable<ELFT> *s) {
+ inline void setStringSection(StringTable<ELFT> *s) {
_stringSection = s;
}
private:
- ELFStringTable<ELFT> *_stringSection;
+ StringTable<ELFT> *_stringSection;
std::vector<Elf_Sym*> _symbolTable;
llvm::BumpPtrAllocator _symbolAllocate;
int64_t _link;
@@ -588,7 +588,7 @@ private:
/// ELF Symbol Table
template <class ELFT>
-ELFSymbolTable<ELFT>::ELFSymbolTable(const ELFTargetInfo &ti, const char *str,
+SymbolTable<ELFT>::SymbolTable(const ELFTargetInfo &ti, const char *str,
int32_t order)
: Section<ELFT>(ti, str, llvm::ELF::SHT_SYMTAB, 0, order,
Section<ELFT>::K_SymbolTable) {
@@ -603,7 +603,7 @@ ELFSymbolTable<ELFT>::ELFSymbolTable(const ELFTargetInfo &ti, const char *str,
template<class ELFT>
void
-ELFSymbolTable<ELFT>::addSymbol(const Atom *atom,
+SymbolTable<ELFT>::addSymbol(const Atom *atom,
int32_t sectionIndex,
uint64_t addr) {
Elf_Sym *symbol = new(_symbolAllocate.Allocate<Elf_Sym>()) Elf_Sym;
@@ -615,9 +615,9 @@ ELFSymbolTable<ELFT>::addSymbol(const Atom *atom,
symbol->st_other = llvm::ELF::STV_DEFAULT;
if (const DefinedAtom *da = dyn_cast<const DefinedAtom>(atom)){
symbol->st_size = da->size();
- lld::DefinedAtom::ContentType ct;
+ DefinedAtom::ContentType ct;
switch (ct = da->contentType()){
- case DefinedAtom::typeCode:
+ case DefinedAtom::typeCode:
case DefinedAtom::typeStub:
symbol->st_value = addr;
type = llvm::ELF::STT_FUNC;
@@ -626,13 +626,13 @@ ELFSymbolTable<ELFT>::addSymbol(const Atom *atom,
symbol->st_value = addr;
type = llvm::ELF::STT_GNU_IFUNC;
break;
- case DefinedAtom::typeData:
- case DefinedAtom::typeConstant:
+ case DefinedAtom::typeData:
+ case DefinedAtom::typeConstant:
case DefinedAtom::typeGOT:
symbol->st_value = addr;
type = llvm::ELF::STT_OBJECT;
break;
- case DefinedAtom::typeZeroFill:
+ case DefinedAtom::typeZeroFill:
type = llvm::ELF::STT_OBJECT;
symbol->st_value = addr;
break;
@@ -671,7 +671,7 @@ ELFSymbolTable<ELFT>::addSymbol(const Atom *atom,
template<class ELFT>
void
-ELFSymbolTable<ELFT>::finalize() {
+SymbolTable<ELFT>::finalize() {
// sh_info should be one greater than last symbol with STB_LOCAL binding
// we sort the symbol table to keep all local symbols at the beginning
std::stable_sort(_symbolTable.begin(), _symbolTable.end(),
@@ -689,7 +689,7 @@ ELFSymbolTable<ELFT>::finalize() {
}
template <class ELFT>
-void ELFSymbolTable<ELFT>::write(ELFWriter *writer,
+void SymbolTable<ELFT>::write(ELFWriter *writer,
llvm::FileOutputBuffer &buffer) {
uint8_t *chunkBuffer = buffer.getBufferStart();
uint8_t *dest = chunkBuffer + this->fileOffset();
@@ -699,11 +699,11 @@ void ELFSymbolTable<ELFT>::write(ELFWriter *writer,
}
}
-template <class ELFT> class ELFRelocationTable : public Section<ELFT> {
+template <class ELFT> class RelocationTable : public Section<ELFT> {
public:
typedef llvm::object::Elf_Rel_Impl<ELFT, true> Elf_Rela;
- ELFRelocationTable(const ELFTargetInfo &ti, StringRef str, int32_t order)
+ RelocationTable(const ELFTargetInfo &ti, StringRef str, int32_t order)
: Section<ELFT>(ti, str, llvm::ELF::SHT_RELA, DefinedAtom::permR__, order,
Section<ELFT>::K_Default) {
this->setOrder(order);
@@ -738,8 +738,7 @@ public:
private:
std::vector<std::pair<const DefinedAtom &, const Reference &>> _relocs;
};
+} // end namespace elf
+} // end namespace lld
-} // elf
-} // lld
-
-#endif //LLD_READER_WRITER_ELF_SECTION_CHUNKS_H_
+#endif
diff --git a/lld/lib/ReaderWriter/ELF/ELFSegmentChunks.h b/lld/lib/ReaderWriter/ELF/SegmentChunks.h
index 849a62b8643..77a023a6b28 100644
--- a/lld/lib/ReaderWriter/ELF/ELFSegmentChunks.h
+++ b/lld/lib/ReaderWriter/ELF/SegmentChunks.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ELFSegmentChunks.h -----------------------------===//
+//===- lib/ReaderWriter/ELF/SegmentChunks.h -------------------------------===//
//
// The LLVM Linker
//
@@ -7,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_READER_WRITER_ELF_SEGMENT_CHUNKS_H_
-#define LLD_READER_WRITER_ELF_SEGMENT_CHUNKS_H_
+#ifndef LLD_READER_WRITER_ELF_SEGMENT_CHUNKS_H
+#define LLD_READER_WRITER_ELF_SEGMENT_CHUNKS_H
-#include "ELFChunk.h"
-#include "ELFLayout.h"
-#include "ELFSectionChunks.h"
-#include "ELFWriter.h"
+#include "Chunk.h"
+#include "Layout.h"
+#include "SectionChunks.h"
+#include "Writer.h"
#include "lld/Core/range.h"
#include "lld/ReaderWriter/Writer.h"
@@ -28,11 +28,10 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileOutputBuffer.h"
-/// \brief A segment can be divided into segment slices
-/// depending on how the segments can be split
namespace lld {
namespace elf {
-
+/// \brief A segment can be divided into segment slices
+/// depending on how the segments can be split
template<class ELFT>
class SegmentSlice {
public:
@@ -110,7 +109,7 @@ public:
typedef typename std::vector<Chunk<ELFT> *>::iterator SectionIter;
Segment(const ELFTargetInfo &ti, const StringRef name,
- const ELFLayout::SegmentType type);
+ const Layout::SegmentType type);
/// append a section to a segment
void append(Section<ELFT> *section);
@@ -163,7 +162,7 @@ public:
return _sections.size();
}
- inline ELFLayout::SegmentType segmentType() { return _segmentType; }
+ inline Layout::SegmentType segmentType() { return _segmentType; }
inline int pageSize() const { return this->_targetInfo.getPageSize(); }
@@ -189,7 +188,7 @@ protected:
/// \brief Section or some other chunk type.
std::vector<Chunk<ELFT> *> _sections;
std::vector<SegmentSlice<ELFT> *> _segmentSlices;
- ELFLayout::SegmentType _segmentType;
+ Layout::SegmentType _segmentType;
int64_t _flags;
int64_t _atomflags;
llvm::BumpPtrAllocator _segmentAllocate;
@@ -197,7 +196,7 @@ protected:
template <class ELFT>
Segment<ELFT>::Segment(const ELFTargetInfo &ti, const StringRef name,
- const ELFLayout::SegmentType type)
+ const Layout::SegmentType type)
: Chunk<ELFT>(name, Chunk<ELFT>::K_ELFSegment, ti), _segmentType(type),
_flags(0), _atomflags(0) {
this->_align2 = 0;
@@ -367,8 +366,7 @@ Segment<ELFT>::flags() const {
fl |= llvm::ELF::PF_X;
return fl;
}
+} // end namespace elf
+} // end namespace lld
-} // elf
-} // lld
-
-#endif // LLD_READER_WRITER_ELF_SEGMENT_CHUNKS_H_
+#endif
diff --git a/lld/lib/ReaderWriter/ELF/ELFTargetHandler.h b/lld/lib/ReaderWriter/ELF/TargetHandler.h
index 196f143fb74..45afb9418c7 100644
--- a/lld/lib/ReaderWriter/ELF/ELFTargetHandler.h
+++ b/lld/lib/ReaderWriter/ELF/TargetHandler.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ELFTargetHandler.h -----------------------------===//
+//===- lib/ReaderWriter/ELF/TargetHandler.h -------------------------------===//
//
// The LLVM Linker
//
@@ -13,8 +13,8 @@
///
//===----------------------------------------------------------------------===//
-#ifndef LLD_READER_WRITER_ELF_TARGETHANDLER_H
-#define LLD_READER_WRITER_ELF_TARGETHANDLER_H
+#ifndef LLD_READER_WRITER_ELF_TARGET_HANDLER_H
+#define LLD_READER_WRITER_ELF_TARGET_HANDLER_H
#include "lld/Core/InputFiles.h"
#include "lld/Core/LinkerOptions.h"
@@ -29,21 +29,21 @@
#include <unordered_map>
namespace lld {
-template <class ELFT> class ELFDefinedAtom;
namespace elf {
-template <class ELFT> class ELFTargetLayout;
-template <class ELFT> class ELFHeader;
+template <class ELFT> class ELFDefinedAtom;
+template <class ELFT> class Header;
template <class ELFT> class Section;
+template <class ELFT> class TargetLayout;
/// \brief The target registers a set of handlers for overriding target specific
/// attributes for a DefinedAtom. The Reader uses this class to query for the
/// type of atom and its permissions
-template <class ELFT> class ELFTargetAtomHandler {
+template <class ELFT> class TargetAtomHandler {
public:
typedef llvm::object::Elf_Sym_Impl<ELFT> Elf_Sym;
virtual DefinedAtom::ContentType contentType(
- const lld::ELFDefinedAtom<ELFT> *atom) const {
+ const ELFDefinedAtom<ELFT> *atom) const {
return atom->contentType();
}
@@ -52,17 +52,17 @@ public:
}
virtual DefinedAtom::ContentPermissions contentPermissions(
- const lld::ELFDefinedAtom<ELFT> *atom) const {
+ const ELFDefinedAtom<ELFT> *atom) const {
return atom->permissions();
}
};
/// \brief An interface to override functions that are provided by the
/// the default ELF Layout
-template <class ELFT> class ELFTargetHandler : public ELFTargetHandlerBase {
+template <class ELFT> class TargetHandler : public TargetHandlerBase {
public:
- ELFTargetHandler(ELFTargetInfo &targetInfo) : _targetInfo(targetInfo) {}
+ TargetHandler(ELFTargetInfo &targetInfo) : _targetInfo(targetInfo) {}
/// Register a Target, so that the target backend may choose on how to merge
/// individual atoms within the section, this is a way to control output order
@@ -91,16 +91,16 @@ public:
/// If the target overrides ELF header information, this API would
/// return true, so that the target can set all fields specific to
/// that target
- virtual bool doesOverrideELFHeader() = 0;
+ virtual bool doesOverrideHeader() = 0;
/// Set the ELF Header information
- virtual void setELFHeaderInfo(ELFHeader<ELFT> *elfHeader) = 0;
+ virtual void setHeaderInfo(Header<ELFT> *Header) = 0;
- /// ELFTargetLayout
- virtual ELFTargetLayout<ELFT> &targetLayout() = 0;
+ /// TargetLayout
+ virtual TargetLayout<ELFT> &targetLayout() = 0;
- /// ELFTargetAtomHandler
- virtual ELFTargetAtomHandler<ELFT> &targetAtomHandler() = 0;
+ /// TargetAtomHandler
+ virtual TargetAtomHandler<ELFT> &targetAtomHandler() = 0;
/// Create a set of Default target sections that a target might needj
virtual void createDefaultSections() = 0;
@@ -150,8 +150,7 @@ protected:
const ELFTargetInfo &_targetInfo;
RegisteredTargetSectionMapT _registeredTargetSections;
};
+} // end namespace elf
+} // end namespace lld
-} // elf
-} // lld
-
-#endif // LLD_READER_WRITER_ELF_TARGETHANDLER_H
+#endif
diff --git a/lld/lib/ReaderWriter/ELF/ELFTargetLayout.h b/lld/lib/ReaderWriter/ELF/TargetLayout.h
index 5416c029691..e4f17b8b5fd 100644
--- a/lld/lib/ReaderWriter/ELF/ELFTargetLayout.h
+++ b/lld/lib/ReaderWriter/ELF/TargetLayout.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ELFTargetLayout.h -----------------------------===//
+//===- lib/ReaderWriter/ELF/TargetLayout.h --------------------------------===//
//
// The LLVM Linker
//
@@ -10,18 +10,18 @@
#ifndef LLD_READER_WRITER_ELF_TARGET_LAYOUT_H
#define LLD_READER_WRITER_ELF_TARGET_LAYOUT_H
-#include "DefaultELFLayout.h"
+#include "DefaultLayout.h"
#include "lld/Core/LLVM.h"
namespace lld {
namespace elf {
-/// \brief The target can override certain functions in the DefaultELFLayout
+/// \brief The target can override certain functions in the DefaultLayout
/// class so that the order, the name of the section and the segment type could
/// be changed in the final layout
-template <class ELFT> class ELFTargetLayout : public DefaultELFLayout<ELFT> {
+template <class ELFT> class TargetLayout : public DefaultLayout<ELFT> {
public:
- ELFTargetLayout(ELFTargetInfo &targetInfo)
+ TargetLayout(ELFTargetInfo &targetInfo)
: DefaultELFLayout<ELFT>(targetInfo) {
}
@@ -42,12 +42,12 @@ public:
/// The target may want to override the section order that has been
/// set by the DefaultLayout
- virtual ELFLayout::SectionOrder getSectionOrder(
+ virtual Layout::SectionOrder getSectionOrder(
const StringRef name, int32_t contentType,
int32_t contentPermissions) = 0;
/// The target can set the segment type for a Section
- virtual ELFLayout::SegmentType segmentType(Section<ELFT> *section) const = 0;
+ virtual Layout::SegmentType segmentType(Section<ELFT> *section) const = 0;
/// Returns true/false depending on whether the section has a Output
// segment or not
diff --git a/lld/lib/ReaderWriter/ELF/ELFTargets.h b/lld/lib/ReaderWriter/ELF/Targets.h
index d87be821770..8b2ec9e76d1 100644
--- a/lld/lib/ReaderWriter/ELF/ELFTargets.h
+++ b/lld/lib/ReaderWriter/ELF/Targets.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ELFTargets.h ----------------------------------===//
+//===- lib/ReaderWriter/ELF/Targets.h -------------------------------------===//
//
// The LLVM Linker
//
@@ -10,9 +10,9 @@
#ifndef LLD_READER_WRITER_ELF_TARGETS_H
#define LLD_READER_WRITER_ELF_TARGETS_H
-#include "Hexagon/HexagonELFTarget.h"
-#include "PPC/PPCELFTarget.h"
-#include "X86/X86ELFTarget.h"
-#include "X86_64/X86_64ELFTarget.h"
+#include "Hexagon/HexagonTarget.h"
+#include "PPC/PPCTarget.h"
+#include "X86/X86Target.h"
+#include "X86_64/X86_64Target.h"
#endif
diff --git a/lld/lib/ReaderWriter/ELF/WriterELF.cpp b/lld/lib/ReaderWriter/ELF/Writer.cpp
index f9d70bd70c9..2318cd8ebef 100644
--- a/lld/lib/ReaderWriter/ELF/WriterELF.cpp
+++ b/lld/lib/ReaderWriter/ELF/Writer.cpp
@@ -9,7 +9,7 @@
#include "lld/ReaderWriter/Writer.h"
-#include "DefaultELFLayout.h"
+#include "DefaultLayout.h"
#include "ExecutableAtoms.h"
#include "lld/ReaderWriter/ELFTargetInfo.h"
@@ -19,28 +19,28 @@ using namespace llvm::object;
namespace lld {
namespace elf {
template<class ELFT>
-class ELFExecutableWriter;
+class ExecutableWriter;
//===----------------------------------------------------------------------===//
-// ELFExecutableWriter Class
+// ExecutableWriter Class
//===----------------------------------------------------------------------===//
template<class ELFT>
-class ELFExecutableWriter : public ELFWriter {
+class ExecutableWriter : public ELFWriter {
public:
typedef Elf_Shdr_Impl<ELFT> Elf_Shdr;
typedef Elf_Sym_Impl<ELFT> Elf_Sym;
- ELFExecutableWriter(const ELFTargetInfo &ti);
+ ExecutableWriter(const ELFTargetInfo &ti);
private:
// build the sections that need to be created
- void buildChunks(const lld::File &file);
- virtual error_code writeFile(const lld::File &File, StringRef path);
+ void buildChunks(const File &file);
+ virtual error_code writeFile(const File &File, StringRef path);
void buildAtomToAddressMap();
void buildSymbolTable ();
void buildSectionHeaderTable();
void assignSectionsWithNoSegments();
- void addAbsoluteUndefinedSymbols(const lld::File &File);
+ void addAbsoluteUndefinedSymbols(const File &File);
void addDefaultAtoms();
void addFiles(InputFiles&);
void finalizeDefaultAtomValues();
@@ -59,30 +59,30 @@ private:
std::unique_ptr<KindHandler> _referenceKindHandler;
AtomToAddress _atomToAddressMap;
llvm::BumpPtrAllocator _chunkAllocate;
- DefaultELFLayout<ELFT> *_layout;
- ELFHeader<ELFT> *_elfHeader;
- ELFProgramHeader<ELFT> *_programHeader;
- ELFSymbolTable<ELFT> * _symtab;
- ELFStringTable<ELFT> *_strtab;
- ELFStringTable<ELFT> *_shstrtab;
- ELFSectionHeader<ELFT> *_shdrtab;
- CRuntimeFileELF<ELFT> _runtimeFile;
+ DefaultLayout<ELFT> *_layout;
+ Header<ELFT> *_Header;
+ ProgramHeader<ELFT> *_programHeader;
+ SymbolTable<ELFT> * _symtab;
+ StringTable<ELFT> *_strtab;
+ StringTable<ELFT> *_shstrtab;
+ SectionHeader<ELFT> *_shdrtab;
+ CRuntimeFile<ELFT> _runtimeFile;
};
//===----------------------------------------------------------------------===//
-// ELFExecutableWriter
+// ExecutableWriter
//===----------------------------------------------------------------------===//
template<class ELFT>
-ELFExecutableWriter<ELFT>::ELFExecutableWriter(const ELFTargetInfo &ti)
+ExecutableWriter<ELFT>::ExecutableWriter(const ELFTargetInfo &ti)
: _targetInfo(ti)
, _referenceKindHandler(KindHandler::makeHandler(
ti.getTriple().getArch(), ti.isLittleEndian()))
, _runtimeFile(ti) {
- _layout = new DefaultELFLayout<ELFT>(ti);
+ _layout = new DefaultLayout<ELFT>(ti);
}
template<class ELFT>
-void ELFExecutableWriter<ELFT>::buildChunks(const lld::File &file){
+void ExecutableWriter<ELFT>::buildChunks(const File &file){
for (const DefinedAtom *definedAtom : file.defined() ) {
_layout->addAtom(definedAtom);
}
@@ -93,7 +93,7 @@ void ELFExecutableWriter<ELFT>::buildChunks(const lld::File &file){
}
template<class ELFT>
-void ELFExecutableWriter<ELFT>::buildSymbolTable () {
+void ExecutableWriter<ELFT>::buildSymbolTable () {
for (auto sec : _layout->sections())
if (auto section = dyn_cast<Section<ELFT>>(sec))
for (const auto &atom : section->atoms())
@@ -102,7 +102,7 @@ void ELFExecutableWriter<ELFT>::buildSymbolTable () {
template<class ELFT>
void
-ELFExecutableWriter<ELFT>::addAbsoluteUndefinedSymbols(const lld::File &file) {
+ExecutableWriter<ELFT>::addAbsoluteUndefinedSymbols(const File &file) {
// add all the absolute symbols that the layout contains to the output symbol
// table
for (auto &atom : _layout->absoluteAtoms())
@@ -112,7 +112,7 @@ ELFExecutableWriter<ELFT>::addAbsoluteUndefinedSymbols(const lld::File &file) {
}
template<class ELFT>
-void ELFExecutableWriter<ELFT>::buildAtomToAddressMap () {
+void ExecutableWriter<ELFT>::buildAtomToAddressMap () {
for (auto sec : _layout->sections())
if (auto section = dyn_cast<Section<ELFT>>(sec))
for (const auto &atom : section->atoms())
@@ -123,7 +123,7 @@ void ELFExecutableWriter<ELFT>::buildAtomToAddressMap () {
}
template<class ELFT>
-void ELFExecutableWriter<ELFT>::buildSectionHeaderTable() {
+void ExecutableWriter<ELFT>::buildSectionHeaderTable() {
for (auto mergedSec : _layout->mergedSections()) {
if (mergedSec->kind() != Chunk<ELFT>::K_ELFSection)
continue;
@@ -133,7 +133,7 @@ void ELFExecutableWriter<ELFT>::buildSectionHeaderTable() {
}
template<class ELFT>
-void ELFExecutableWriter<ELFT>::assignSectionsWithNoSegments() {
+void ExecutableWriter<ELFT>::assignSectionsWithNoSegments() {
for (auto mergedSec : _layout->mergedSections()) {
if (mergedSec->kind() != Chunk<ELFT>::K_ELFSection)
continue;
@@ -143,14 +143,14 @@ void ELFExecutableWriter<ELFT>::assignSectionsWithNoSegments() {
_layout->assignOffsetsForMiscSections();
for (auto sec : _layout->sections())
if (auto section = dyn_cast<Section<ELFT>>(sec))
- if (!DefaultELFLayout<ELFT>::hasOutputSegment(section))
+ if (!DefaultLayout<ELFT>::hasOutputSegment(section))
_shdrtab->updateSection(section);
}
/// \brief Add absolute symbols by default. These are linker added
/// absolute symbols
template<class ELFT>
-void ELFExecutableWriter<ELFT>::addDefaultAtoms() {
+void ExecutableWriter<ELFT>::addDefaultAtoms() {
_runtimeFile.addUndefinedAtom(_targetInfo.getEntry());
_runtimeFile.addAbsoluteAtom("__bss_start");
_runtimeFile.addAbsoluteAtom("__bss_end");
@@ -164,7 +164,7 @@ void ELFExecutableWriter<ELFT>::addDefaultAtoms() {
/// \brief Hook in lld to add CRuntime file
template<class ELFT>
-void ELFExecutableWriter<ELFT>::addFiles(InputFiles &inputFiles) {
+void ExecutableWriter<ELFT>::addFiles(InputFiles &inputFiles) {
addDefaultAtoms();
inputFiles.prependFile(_runtimeFile);
}
@@ -172,7 +172,7 @@ void ELFExecutableWriter<ELFT>::addFiles(InputFiles &inputFiles) {
/// Finalize the value of all the absolute symbols that we
/// created
template<class ELFT>
-void ELFExecutableWriter<ELFT>::finalizeDefaultAtomValues() {
+void ExecutableWriter<ELFT>::finalizeDefaultAtomValues() {
auto bssStartAtomIter = _layout->findAbsoluteAtom("__bss_start");
auto bssEndAtomIter = _layout->findAbsoluteAtom("__bss_end");
auto underScoreEndAtomIter = _layout->findAbsoluteAtom("_end");
@@ -182,8 +182,8 @@ void ELFExecutableWriter<ELFT>::finalizeDefaultAtomValues() {
auto realIpltStartIter = _layout->findAbsoluteAtom("__rela_iplt_start");
auto realIpltEndIter = _layout->findAbsoluteAtom("__rela_iplt_end");
- auto startEnd = [&](typename DefaultELFLayout<ELFT>::AbsoluteAtomIterT start,
- typename DefaultELFLayout<ELFT>::AbsoluteAtomIterT end,
+ auto startEnd = [&](typename DefaultLayout<ELFT>::AbsoluteAtomIterT start,
+ typename DefaultLayout<ELFT>::AbsoluteAtomIterT end,
StringRef sec) -> void {
auto section = _layout->findOutputSection(sec);
if (section) {
@@ -218,7 +218,7 @@ void ELFExecutableWriter<ELFT>::finalizeDefaultAtomValues() {
template<class ELFT>
error_code
-ELFExecutableWriter<ELFT>::writeFile(const lld::File &file, StringRef path) {
+ExecutableWriter<ELFT>::writeFile(const File &file, StringRef path) {
buildChunks(file);
// Create the default sections like the symbol table, string table, and the
// section string table
@@ -260,31 +260,31 @@ ELFExecutableWriter<ELFT>::writeFile(const lld::File &file, StringRef path) {
if (ec)
return ec;
- _elfHeader->e_ident(ELF::EI_CLASS, _targetInfo.is64Bits() ? ELF::ELFCLASS64
+ _Header->e_ident(ELF::EI_CLASS, _targetInfo.is64Bits() ? ELF::ELFCLASS64
: ELF::ELFCLASS32);
- _elfHeader->e_ident(ELF::EI_DATA, _targetInfo.isLittleEndian()
+ _Header->e_ident(ELF::EI_DATA, _targetInfo.isLittleEndian()
? ELF::ELFDATA2LSB : ELF::ELFDATA2MSB);
- _elfHeader->e_ident(ELF::EI_VERSION, 1);
- _elfHeader->e_ident(ELF::EI_OSABI, 0);
- _elfHeader->e_type(_targetInfo.getOutputType());
- _elfHeader->e_machine(_targetInfo.getOutputMachine());
- _elfHeader->e_version(1);
- _elfHeader->e_entry(0ULL);
- _elfHeader->e_phoff(_programHeader->fileOffset());
- _elfHeader->e_shoff(_shdrtab->fileOffset());
- _elfHeader->e_phentsize(_programHeader->entsize());
- _elfHeader->e_phnum(_programHeader->numHeaders());
- _elfHeader->e_shentsize(_shdrtab->entsize());
- _elfHeader->e_shnum(_shdrtab->numHeaders());
- _elfHeader->e_shstrndx(_shstrtab->ordinal());
+ _Header->e_ident(ELF::EI_VERSION, 1);
+ _Header->e_ident(ELF::EI_OSABI, 0);
+ _Header->e_type(_targetInfo.getOutputType());
+ _Header->e_machine(_targetInfo.getOutputMachine());
+ _Header->e_version(1);
+ _Header->e_entry(0ULL);
+ _Header->e_phoff(_programHeader->fileOffset());
+ _Header->e_shoff(_shdrtab->fileOffset());
+ _Header->e_phentsize(_programHeader->entsize());
+ _Header->e_phnum(_programHeader->numHeaders());
+ _Header->e_shentsize(_shdrtab->entsize());
+ _Header->e_shnum(_shdrtab->numHeaders());
+ _Header->e_shstrndx(_shstrtab->ordinal());
uint64_t virtualAddr = 0;
_layout->findAtomAddrByName(_targetInfo.getEntry(), virtualAddr);
- _elfHeader->e_entry(virtualAddr);
+ _Header->e_entry(virtualAddr);
// HACK: We have to write out the header and program header here even though
// they are a member of a segment because only sections are written in the
// following loop.
- _elfHeader->write(this, *buffer);
+ _Header->write(this, *buffer);
_programHeader->write(this, *buffer);
for (auto section : _layout->sections())
@@ -294,20 +294,20 @@ ELFExecutableWriter<ELFT>::writeFile(const lld::File &file, StringRef path) {
}
template<class ELFT>
-void ELFExecutableWriter<ELFT>::createDefaultSections() {
- _elfHeader = new ELFHeader<ELFT>(_targetInfo);
- _programHeader = new ELFProgramHeader<ELFT>(_targetInfo);
- _layout->setELFHeader(_elfHeader);
+void ExecutableWriter<ELFT>::createDefaultSections() {
+ _Header = new Header<ELFT>(_targetInfo);
+ _programHeader = new ProgramHeader<ELFT>(_targetInfo);
+ _layout->setHeader(_Header);
_layout->setProgramHeader(_programHeader);
- _symtab = new ELFSymbolTable<
- ELFT>(_targetInfo, ".symtab", DefaultELFLayout<ELFT>::ORDER_SYMBOL_TABLE);
- _strtab = new ELFStringTable<
- ELFT>(_targetInfo, ".strtab", DefaultELFLayout<ELFT>::ORDER_STRING_TABLE);
- _shstrtab = new ELFStringTable<ELFT>(
- _targetInfo, ".shstrtab", DefaultELFLayout<ELFT>::ORDER_SECTION_STRINGS);
- _shdrtab = new ELFSectionHeader<
- ELFT>(_targetInfo, DefaultELFLayout<ELFT>::ORDER_SECTION_HEADERS);
+ _symtab = new SymbolTable<
+ ELFT>(_targetInfo, ".symtab", DefaultLayout<ELFT>::ORDER_SYMBOL_TABLE);
+ _strtab = new StringTable<
+ ELFT>(_targetInfo, ".strtab", DefaultLayout<ELFT>::ORDER_STRING_TABLE);
+ _shstrtab = new StringTable<ELFT>(
+ _targetInfo, ".shstrtab", DefaultLayout<ELFT>::ORDER_SECTION_STRINGS);
+ _shdrtab = new SectionHeader<
+ ELFT>(_targetInfo, DefaultLayout<ELFT>::ORDER_SECTION_HEADERS);
_layout->addSection(_symtab);
_layout->addSection(_strtab);
_layout->addSection(_shstrtab);
@@ -325,16 +325,16 @@ std::unique_ptr<Writer> createWriterELF(const ELFTargetInfo &TI) {
if (!TI.is64Bits() && TI.isLittleEndian())
return std::unique_ptr<Writer>(new
- elf::ELFExecutableWriter<ELFType<support::little, 4, false>>(TI));
+ elf::ExecutableWriter<ELFType<support::little, 4, false>>(TI));
else if (TI.is64Bits() && TI.isLittleEndian())
return std::unique_ptr<Writer>(new
- elf::ELFExecutableWriter<ELFType<support::little, 8, true>>(TI));
+ elf::ExecutableWriter<ELFType<support::little, 8, true>>(TI));
else if (!TI.is64Bits() && !TI.isLittleEndian())
return std::unique_ptr<Writer>(new
- elf::ELFExecutableWriter<ELFType<support::big, 4, false>>(TI));
+ elf::ExecutableWriter<ELFType<support::big, 4, false>>(TI));
else if (TI.is64Bits() && !TI.isLittleEndian())
return std::unique_ptr<Writer>(new
- elf::ELFExecutableWriter<ELFType<support::big, 8, true>>(TI));
+ elf::ExecutableWriter<ELFType<support::big, 8, true>>(TI));
llvm_unreachable("Invalid Options!");
}
diff --git a/lld/lib/ReaderWriter/ELF/ELFWriter.h b/lld/lib/ReaderWriter/ELF/Writer.h
index 44e54711865..b621856f5c1 100644
--- a/lld/lib/ReaderWriter/ELF/ELFWriter.h
+++ b/lld/lib/ReaderWriter/ELF/Writer.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ELFWriter.h ---------------------------------===//
+//===- lib/ReaderWriter/ELF/Writer.h --------------------------------------===//
//
// The LLVM Linker
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_READER_WRITER_ELF_WRITER_H_
-#define LLD_READER_WRITER_ELF_WRITER_H_
+#ifndef LLD_READER_WRITER_ELF_WRITER_H
+#define LLD_READER_WRITER_ELF_WRITER_H
#include "ReferenceKinds.h"
@@ -18,7 +18,7 @@
namespace lld {
namespace elf {
-/// \brief The ELFWriter class is a base class for the linker to write
+/// \brief The Writer class is a base class for the linker to write
/// various kinds of ELF files.
class ELFWriter : public Writer {
public:
@@ -27,10 +27,10 @@ public:
public:
/// \brief builds the chunks that needs to be written to the output
/// ELF file
- virtual void buildChunks(const lld::File &file) = 0;
+ virtual void buildChunks(const File &file) = 0;
/// \brief Writes the chunks into the output file specified by path
- virtual error_code writeFile(const lld::File &File, StringRef path) = 0;
+ virtual error_code writeFile(const File &File, StringRef path) = 0;
/// \brief Get the virtual address of \p atom after layout.
virtual uint64_t addressOfAtom(const Atom *atom) = 0;
@@ -38,8 +38,7 @@ public:
/// \brief Return the processing function to apply Relocations
virtual KindHandler *kindHandler() = 0;
};
+} // end namespace elf
+} // end namespace lld
-} // elf
-} // lld
-
-#endif // LLD_READER_WRITER_ELF_WRITER_H_
+#endif
diff --git a/lld/lib/ReaderWriter/ELF/X86/X86ELFTarget.h b/lld/lib/ReaderWriter/ELF/X86/X86Target.h
index 30a0cdd067e..bc5c0162537 100644
--- a/lld/lib/ReaderWriter/ELF/X86/X86ELFTarget.h
+++ b/lld/lib/ReaderWriter/ELF/X86/X86Target.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/Hexagon/X86ELFTarget.h -----------------------===//
+//===- lib/ReaderWriter/ELF/X86/X86Target.h -------------------------------===//
//
// The LLVM Linker
//
@@ -6,4 +6,5 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include "X86ELFTargetInfo.h"
+
+#include "X86TargetInfo.h"
diff --git a/lld/lib/ReaderWriter/ELF/X86/X86ELFTargetInfo.h b/lld/lib/ReaderWriter/ELF/X86/X86TargetInfo.h
index 071e0756951..7036daaecb8 100644
--- a/lld/lib/ReaderWriter/ELF/X86/X86ELFTargetInfo.h
+++ b/lld/lib/ReaderWriter/ELF/X86/X86TargetInfo.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/Hexagon/X86TargetInfo.h -----------------------===//
+//===- lib/ReaderWriter/ELF/X86/X86TargetInfo.h ---------------------------===//
//
// The LLVM Linker
//
@@ -10,25 +10,26 @@
#ifndef LLD_READER_WRITER_ELF_X86_TARGETINFO_H
#define LLD_READER_WRITER_ELF_X86_TARGETINFO_H
-#include "lld/ReaderWriter/ELFTargetInfo.h"
+#include "DefaultTargetHandler.h"
+
#include "lld/Core/LinkerOptions.h"
+#include "lld/ReaderWriter/ELFTargetInfo.h"
+
#include "llvm/Object/ELF.h"
#include "llvm/Support/ELF.h"
-#include "DefaultELFTargetHandler.h"
-
namespace lld {
namespace elf {
-class X86ELFTargetInfo LLVM_FINAL : public ELFTargetInfo {
+class X86TargetInfo LLVM_FINAL : public ELFTargetInfo {
public:
- X86ELFTargetInfo(const LinkerOptions &lo) : ELFTargetInfo(lo) {
- _targetHandler = std::unique_ptr<ELFTargetHandlerBase>(
- new DefaultELFTargetHandler<llvm::object::ELFType<llvm::support::little,
+ X86TargetInfo(const LinkerOptions &lo) : ELFTargetInfo(lo) {
+ _targetHandler = std::unique_ptr<TargetHandlerBase>(
+ new DefaultTargetHandler<llvm::object::ELFType<llvm::support::little,
4, false> >(*this));
}
virtual uint64_t getPageSize() const { return 0x1000; }
};
-} // elf
-} // lld
-#endif // LLD_READER_WRITER_ELF_X86_TARGETINFO_H
+} // end namespace elf
+} // end namespace lld
+#endif
diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFTarget.h b/lld/lib/ReaderWriter/ELF/X86_64/X86_64Target.h
index 28b9245a052..17f42c95519 100644
--- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFTarget.h
+++ b/lld/lib/ReaderWriter/ELF/X86_64/X86_64Target.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/Hexagon/HexagonELFTarget.h ---------------------===//
+//===- lib/ReaderWriter/ELF/Hexagon/X86Target.h ---------------------------===//
//
// The LLVM Linker
//
@@ -6,4 +6,5 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include "HexagonELFTargetInfo.h"
+
+#include "X86_64TargetInfo.h"
diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp b/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
index c3d585632e6..11f47f4528a 100644
--- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
+++ b/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/X86_64/X86_64ELFTargetInfo.cpp ----------------===//
+//===- lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp -------------------===//
//
// The LLVM Linker
//
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "X86_64ELFTargetInfo.h"
+#include "X86_64TargetInfo.h"
#include "lld/Core/File.h"
#include "lld/Core/Pass.h"
@@ -128,13 +128,14 @@ private:
};
} // end anon namespace
-void elf::X86_64ELFTargetInfo::addPasses(PassManager &pm) const {
+void elf::X86_64TargetInfo::addPasses(PassManager &pm) const {
pm.add(std::unique_ptr<Pass>(new PLTPass(*this)));
}
#define LLD_CASE(name) .Case(#name, llvm::ELF::name)
-ErrorOr<int32_t> elf::X86_64ELFTargetInfo::relocKindFromString(StringRef str) const {
+ErrorOr<int32_t> elf::X86_64TargetInfo::relocKindFromString(
+ StringRef str) const {
int32_t ret = llvm::StringSwitch<int32_t>(str)
LLD_CASE(R_X86_64_NONE)
LLD_CASE(R_X86_64_64)
@@ -185,7 +186,8 @@ ErrorOr<int32_t> elf::X86_64ELFTargetInfo::relocKindFromString(StringRef str) co
#define LLD_CASE(name) case llvm::ELF::name: return std::string(#name);
-ErrorOr<std::string> elf::X86_64ELFTargetInfo::stringFromRelocKind(int32_t kind) const {
+ErrorOr<std::string> elf::X86_64TargetInfo::stringFromRelocKind(
+ int32_t kind) const {
switch (kind) {
LLD_CASE(R_X86_64_NONE)
LLD_CASE(R_X86_64_64)
diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64ELFTargetInfo.h b/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.h
index 98cc43fdc8c..dccc750bad1 100644
--- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64ELFTargetInfo.h
+++ b/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.h
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/Hexagon/X86_64TargetInfo.h -----------------------===//
+//===- lib/ReaderWriter/ELF/Hexagon/X86_64TargetInfo.h --------------------===//
//
// The LLVM Linker
//
@@ -10,7 +10,7 @@
#ifndef LLD_READER_WRITER_ELF_X86_64_TARGETINFO_H
#define LLD_READER_WRITER_ELF_X86_64_TARGETINFO_H
-#include "DefaultELFTargetHandler.h"
+#include "DefaultTargetHandler.h"
#include "lld/Core/LinkerOptions.h"
#include "lld/ReaderWriter/ELFTargetInfo.h"
@@ -20,11 +20,11 @@
namespace lld {
namespace elf {
-class X86_64ELFTargetInfo LLVM_FINAL : public ELFTargetInfo {
+class X86_64TargetInfo LLVM_FINAL : public ELFTargetInfo {
public:
- X86_64ELFTargetInfo(const LinkerOptions &lo) : ELFTargetInfo(lo) {
- _targetHandler = std::unique_ptr<ELFTargetHandlerBase>(
- new DefaultELFTargetHandler<llvm::object::ELFType<llvm::support::little,
+ X86_64TargetInfo(const LinkerOptions &lo) : ELFTargetInfo(lo) {
+ _targetHandler = std::unique_ptr<TargetHandlerBase>(
+ new DefaultTargetHandler<llvm::object::ELFType<llvm::support::little,
8, false> >(*this));
}
OpenPOWER on IntegriCloud