[ELF] Add "override" and remove "virtual".

llvm-svn: 205056
This commit is contained in:
Rui Ueyama 2014-03-28 21:26:13 +00:00
parent f83fe5a6dc
commit 9d0698e0f2
18 changed files with 224 additions and 281 deletions

View File

@ -56,26 +56,22 @@ public:
edgeKind), edgeKind),
_target(nullptr), _targetSymbolIndex(0), _offsetInAtom(0), _addend(0) {} _target(nullptr), _targetSymbolIndex(0), _offsetInAtom(0), _addend(0) {}
virtual uint64_t offsetInAtom() const { return _offsetInAtom; } uint64_t offsetInAtom() const override { return _offsetInAtom; }
virtual const Atom *target() const { const Atom *target() const override { return _target; }
return _target;
}
/// \brief The symbol table index that contains the target reference. /// \brief The symbol table index that contains the target reference.
uint64_t targetSymbolIndex() const { uint64_t targetSymbolIndex() const {
return _targetSymbolIndex; return _targetSymbolIndex;
} }
virtual Addend addend() const { Addend addend() const override { return _addend; }
return _addend;
}
virtual void setOffset(uint64_t off) { _offsetInAtom = off; } virtual void setOffset(uint64_t off) { _offsetInAtom = off; }
virtual void setAddend(Addend A) { _addend = A; } void setAddend(Addend A) override { _addend = A; }
virtual void setTarget(const Atom *newAtom) { _target = newAtom; } void setTarget(const Atom *newAtom) override { _target = newAtom; }
private: private:
const Atom *_target; const Atom *_target;
@ -96,11 +92,9 @@ public:
: _owningFile(file), _name(name), _symbol(symbol), _value(value) { : _owningFile(file), _name(name), _symbol(symbol), _value(value) {
} }
virtual const ELFFile<ELFT> &file() const { const ELFFile<ELFT> &file() const override { return _owningFile; }
return _owningFile;
}
virtual Scope scope() const { Scope scope() const override {
if (_symbol->st_other == llvm::ELF::STV_HIDDEN) if (_symbol->st_other == llvm::ELF::STV_HIDDEN)
return scopeLinkageUnit; return scopeLinkageUnit;
if (_symbol->getBinding() == llvm::ELF::STB_LOCAL) if (_symbol->getBinding() == llvm::ELF::STB_LOCAL)
@ -109,13 +103,9 @@ public:
return scopeGlobal; return scopeGlobal;
} }
virtual StringRef name() const { StringRef name() const override { return _name; }
return _name;
}
virtual uint64_t value() const { uint64_t value() const override { return _value; }
return _value;
}
private: private:
const ELFFile<ELFT> &_owningFile; const ELFFile<ELFT> &_owningFile;
@ -133,14 +123,14 @@ public:
ELFUndefinedAtom(const File &file, StringRef name, const Elf_Sym *symbol) ELFUndefinedAtom(const File &file, StringRef name, const Elf_Sym *symbol)
: _owningFile(file), _name(name), _symbol(symbol) {} : _owningFile(file), _name(name), _symbol(symbol) {}
virtual const File &file() const { return _owningFile; } const File &file() const override { return _owningFile; }
virtual StringRef name() const { return _name; } StringRef name() const override { return _name; }
// FIXME: What distinguishes a symbol in ELF that can help decide if the // FIXME: What distinguishes a symbol in ELF that can help decide if the
// symbol is undefined only during build and not runtime? This will make us // symbol is undefined only during build and not runtime? This will make us
// choose canBeNullAtBuildtime and canBeNullAtRuntime. // choose canBeNullAtBuildtime and canBeNullAtRuntime.
virtual CanBeNull canBeNull() const { CanBeNull canBeNull() const override {
if (_symbol->getBinding() == llvm::ELF::STB_WEAK) if (_symbol->getBinding() == llvm::ELF::STB_WEAK)
return CanBeNull::canBeNullAtBuildtime; return CanBeNull::canBeNullAtBuildtime;
else else
@ -173,23 +163,17 @@ public:
~ELFDefinedAtom() {} ~ELFDefinedAtom() {}
virtual const ELFFile<ELFT> &file() const { const ELFFile<ELFT> &file() const override { return _owningFile; }
return _owningFile;
}
virtual StringRef name() const { StringRef name() const override { return _symbolName; }
return _symbolName;
}
virtual uint64_t ordinal() const { uint64_t ordinal() const override { return _ordinal; }
return _ordinal;
}
const Elf_Sym *symbol() const { return _symbol; } const Elf_Sym *symbol() const { return _symbol; }
const Elf_Shdr *section() const { return _section; } const Elf_Shdr *section() const { return _section; }
virtual uint64_t size() const { uint64_t size() const override {
// Common symbols are not allocated in object files, // Common symbols are not allocated in object files,
// so use st_size to tell how many bytes are required. // so use st_size to tell how many bytes are required.
if ((_symbol->getType() == llvm::ELF::STT_COMMON) || if ((_symbol->getType() == llvm::ELF::STT_COMMON) ||
@ -199,7 +183,7 @@ public:
return _contentData.size(); return _contentData.size();
} }
virtual Scope scope() const { Scope scope() const override {
if (_symbol->st_other == llvm::ELF::STV_HIDDEN) if (_symbol->st_other == llvm::ELF::STV_HIDDEN)
return scopeLinkageUnit; return scopeLinkageUnit;
else if (_symbol->getBinding() != llvm::ELF::STB_LOCAL) else if (_symbol->getBinding() != llvm::ELF::STB_LOCAL)
@ -209,12 +193,10 @@ public:
} }
// FIXME: Need to revisit this in future. // FIXME: Need to revisit this in future.
virtual Interposable interposable() const { Interposable interposable() const override { return interposeNo; }
return interposeNo;
}
// FIXME: What ways can we determine this in ELF? // FIXME: What ways can we determine this in ELF?
virtual Merge merge() const { Merge merge() const override {
if (_symbol->getBinding() == llvm::ELF::STB_WEAK) if (_symbol->getBinding() == llvm::ELF::STB_WEAK)
return mergeAsWeak; return mergeAsWeak;
@ -225,7 +207,7 @@ public:
return mergeNo; return mergeNo;
} }
virtual ContentType contentType() const { ContentType contentType() const override {
if (_contentType != typeUnknown) if (_contentType != typeUnknown)
return _contentType; return _contentType;
@ -301,7 +283,7 @@ public:
return _contentType = ret; return _contentType = ret;
} }
virtual Alignment alignment() const { Alignment alignment() const override {
// Unallocated common symbols specify their alignment constraints in // Unallocated common symbols specify their alignment constraints in
// st_value. // st_value.
if ((_symbol->getType() == llvm::ELF::STT_COMMON) || if ((_symbol->getType() == llvm::ELF::STT_COMMON) ||
@ -313,7 +295,7 @@ public:
} }
// Do we have a choice for ELF? All symbols live in explicit sections. // Do we have a choice for ELF? All symbols live in explicit sections.
virtual SectionChoice sectionChoice() const { SectionChoice sectionChoice() const override {
switch (contentType()) { switch (contentType()) {
case typeCode: case typeCode:
case typeData: case typeData:
@ -331,24 +313,22 @@ public:
return sectionCustomRequired; return sectionCustomRequired;
} }
virtual StringRef customSectionName() const { StringRef customSectionName() const override {
if ((contentType() == typeZeroFill) || if ((contentType() == typeZeroFill) ||
(_symbol->st_shndx == llvm::ELF::SHN_COMMON)) (_symbol->st_shndx == llvm::ELF::SHN_COMMON))
return ".bss"; return ".bss";
return _sectionName; return _sectionName;
} }
virtual SectionPosition sectionPosition() const { SectionPosition sectionPosition() const override {
return sectionPositionAny; return sectionPositionAny;
} }
// It isn't clear that __attribute__((used)) is transmitted to the ELF object // It isn't clear that __attribute__((used)) is transmitted to the ELF object
// file. // file.
virtual DeadStripKind deadStrip() const { DeadStripKind deadStrip() const override { return deadStripNormal; }
return deadStripNormal;
}
virtual ContentPermissions permissions() const { ContentPermissions permissions() const override {
if (_permissions != permUnknown) if (_permissions != permUnknown)
return _permissions; return _permissions;
@ -402,34 +382,30 @@ public:
} }
// FIXME: Not Sure if ELF supports alias atoms. Find out more. // FIXME: Not Sure if ELF supports alias atoms. Find out more.
virtual bool isAlias() const { bool isAlias() const override { return false; }
return false;
}
virtual ArrayRef<uint8_t> rawContent() const { ArrayRef<uint8_t> rawContent() const override { return _contentData; }
return _contentData;
}
DefinedAtom::reference_iterator begin() const { DefinedAtom::reference_iterator begin() const override {
uintptr_t index = _referenceStartIndex; uintptr_t index = _referenceStartIndex;
const void *it = reinterpret_cast<const void*>(index); const void *it = reinterpret_cast<const void*>(index);
return reference_iterator(*this, it); return reference_iterator(*this, it);
} }
DefinedAtom::reference_iterator end() const { DefinedAtom::reference_iterator end() const override {
uintptr_t index = _referenceEndIndex; uintptr_t index = _referenceEndIndex;
const void *it = reinterpret_cast<const void*>(index); const void *it = reinterpret_cast<const void*>(index);
return reference_iterator(*this, it); return reference_iterator(*this, it);
} }
const Reference *derefIterator(const void *It) const { const Reference *derefIterator(const void *It) const override {
uintptr_t index = reinterpret_cast<uintptr_t>(It); uintptr_t index = reinterpret_cast<uintptr_t>(It);
assert(index >= _referenceStartIndex); assert(index >= _referenceStartIndex);
assert(index < _referenceEndIndex); assert(index < _referenceEndIndex);
return ((_referenceList)[index]); return ((_referenceList)[index]);
} }
void incrementIterator(const void *&It) const { void incrementIterator(const void *&It) const override {
uintptr_t index = reinterpret_cast<uintptr_t>(It); uintptr_t index = reinterpret_cast<uintptr_t>(It);
++index; ++index;
It = reinterpret_cast<const void *>(index); It = reinterpret_cast<const void *>(index);
@ -471,13 +447,9 @@ public:
_contentData(contentData), _offset(offset) { _contentData(contentData), _offset(offset) {
} }
virtual const ELFFile<ELFT> &file() const { const ELFFile<ELFT> &file() const override { return _owningFile; }
return _owningFile;
}
virtual StringRef name() const { StringRef name() const override { return ""; }
return "";
}
virtual uint64_t section() const { return _section->sh_name; } virtual uint64_t section() const { return _section->sh_name; }
@ -485,53 +457,57 @@ public:
virtual void setOrdinal(uint64_t ord) { _ordinal = ord; } virtual void setOrdinal(uint64_t ord) { _ordinal = ord; }
virtual uint64_t ordinal() const { return _ordinal; } uint64_t ordinal() const override { return _ordinal; }
virtual uint64_t size() const { return _contentData.size(); } uint64_t size() const override { return _contentData.size(); }
virtual Scope scope() const { return scopeTranslationUnit; } Scope scope() const override { return scopeTranslationUnit; }
virtual Interposable interposable() const { return interposeNo; } Interposable interposable() const override { return interposeNo; }
virtual Merge merge() const { return mergeByContent; } Merge merge() const override { return mergeByContent; }
virtual ContentType contentType() const { return typeConstant; } ContentType contentType() const override { return typeConstant; }
virtual Alignment alignment() const { Alignment alignment() const override {
return Alignment(llvm::Log2_64(_section->sh_addralign)); return Alignment(llvm::Log2_64(_section->sh_addralign));
} }
virtual SectionChoice sectionChoice() const { return sectionCustomRequired; } SectionChoice sectionChoice() const override { return sectionCustomRequired; }
virtual StringRef customSectionName() const { return _sectionName; } StringRef customSectionName() const override { return _sectionName; }
virtual SectionPosition sectionPosition() const { return sectionPositionAny; } SectionPosition sectionPosition() const override {
return sectionPositionAny;
}
virtual DeadStripKind deadStrip() const { return deadStripNormal; } DeadStripKind deadStrip() const override { return deadStripNormal; }
virtual ContentPermissions permissions() const { return permR__; } ContentPermissions permissions() const override { return permR__; }
virtual bool isThumb() const { return false; } virtual bool isThumb() const { return false; }
virtual bool isAlias() const { return false; } bool isAlias() const override { return false; }
virtual ArrayRef<uint8_t> rawContent() const { return _contentData; } ArrayRef<uint8_t> rawContent() const override { return _contentData; }
DefinedAtom::reference_iterator begin() const { DefinedAtom::reference_iterator begin() const override {
uintptr_t index = 0; uintptr_t index = 0;
const void *it = reinterpret_cast<const void *>(index); const void *it = reinterpret_cast<const void *>(index);
return reference_iterator(*this, it); return reference_iterator(*this, it);
} }
DefinedAtom::reference_iterator end() const { DefinedAtom::reference_iterator end() const override {
uintptr_t index = 0; uintptr_t index = 0;
const void *it = reinterpret_cast<const void *>(index); const void *it = reinterpret_cast<const void *>(index);
return reference_iterator(*this, it); return reference_iterator(*this, it);
} }
const Reference *derefIterator(const void *It) const { return nullptr; } const Reference *derefIterator(const void *It) const override {
return nullptr;
}
void incrementIterator(const void *&It) const {} void incrementIterator(const void *&It) const override {}
private: private:
@ -554,25 +530,17 @@ public:
_symbolName(symbolName), _symbolName(symbolName),
_symbol(symbol) {} _symbol(symbol) {}
virtual const ELFFile<ELFT> &file() const { const ELFFile<ELFT> &file() const override { return _owningFile; }
return _owningFile;
}
virtual StringRef name() const { StringRef name() const override { return _symbolName; }
return _symbolName;
}
virtual uint64_t ordinal() const { uint64_t ordinal() const override { return _ordinal; }
return _ordinal;
}
virtual void setOrdinal(uint64_t ord) { _ordinal = ord; } virtual void setOrdinal(uint64_t ord) { _ordinal = ord; }
virtual uint64_t size() const { uint64_t size() const override { return _symbol->st_size; }
return _symbol->st_size;
}
virtual Scope scope() const { Scope scope() const override {
if (_symbol->st_other == llvm::ELF::STV_HIDDEN) if (_symbol->st_other == llvm::ELF::STV_HIDDEN)
return scopeLinkageUnit; return scopeLinkageUnit;
else if (_symbol->getBinding() != llvm::ELF::STB_LOCAL) else if (_symbol->getBinding() != llvm::ELF::STB_LOCAL)
@ -581,57 +549,39 @@ public:
return scopeTranslationUnit; return scopeTranslationUnit;
} }
virtual Interposable interposable() const { Interposable interposable() const override { return interposeNo; }
return interposeNo;
}
virtual Merge merge() const { Merge merge() const override { return mergeAsTentative; }
return mergeAsTentative;
}
virtual ContentType contentType() const { ContentType contentType() const override { return typeZeroFill; }
return typeZeroFill;
}
virtual Alignment alignment() const { Alignment alignment() const override {
return Alignment(llvm::Log2_64(_symbol->st_value)); return Alignment(llvm::Log2_64(_symbol->st_value));
} }
virtual SectionChoice sectionChoice() const { SectionChoice sectionChoice() const override { return sectionBasedOnContent; }
return sectionBasedOnContent;
}
virtual StringRef customSectionName() const { StringRef customSectionName() const override { return ".bss"; }
return ".bss";
}
virtual SectionPosition sectionPosition() const { SectionPosition sectionPosition() const override {
return sectionPositionAny; return sectionPositionAny;
} }
virtual DeadStripKind deadStrip() const { DeadStripKind deadStrip() const override { return deadStripNormal; }
return deadStripNormal;
}
virtual ContentPermissions permissions() const { ContentPermissions permissions() const override { return permRW_; }
return permRW_;
}
virtual bool isAlias() const { bool isAlias() const override { return false; }
return false;
}
virtual ArrayRef<uint8_t> rawContent() const { ArrayRef<uint8_t> rawContent() const override { return ArrayRef<uint8_t>(); }
return ArrayRef<uint8_t>();
}
virtual DefinedAtom::reference_iterator begin() const { DefinedAtom::reference_iterator begin() const override {
uintptr_t index = 0; uintptr_t index = 0;
const void *it = reinterpret_cast<const void *>(index); const void *it = reinterpret_cast<const void *>(index);
return reference_iterator(*this, it); return reference_iterator(*this, it);
} }
virtual DefinedAtom::reference_iterator end() const { DefinedAtom::reference_iterator end() const override {
uintptr_t index = 0; uintptr_t index = 0;
const void *it = reinterpret_cast<const void *>(index); const void *it = reinterpret_cast<const void *>(index);
return reference_iterator(*this, it); return reference_iterator(*this, it);
@ -640,11 +590,11 @@ protected:
virtual ~ELFCommonAtom() {} virtual ~ELFCommonAtom() {}
virtual const Reference *derefIterator(const void *iter) const { const Reference *derefIterator(const void *iter) const override {
return nullptr; return nullptr;
} }
virtual void incrementIterator(const void *&iter) const {} void incrementIterator(const void *&iter) const override {}
const ELFFile<ELFT> &_owningFile; const ELFFile<ELFT> &_owningFile;
StringRef _symbolName; StringRef _symbolName;
@ -663,13 +613,9 @@ public:
_symbol(symbol) { _symbol(symbol) {
} }
virtual const DynamicFile<ELFT> &file() const { const DynamicFile<ELFT> &file() const override { return _owningFile; }
return _owningFile;
}
virtual StringRef name() const { StringRef name() const override { return _symbolName; }
return _symbolName;
}
virtual Scope scope() const { virtual Scope scope() const {
if (_symbol->st_other == llvm::ELF::STV_HIDDEN) if (_symbol->st_other == llvm::ELF::STV_HIDDEN)
@ -680,13 +626,13 @@ public:
return scopeTranslationUnit; return scopeTranslationUnit;
} }
virtual StringRef loadName() const { return _loadName; } StringRef loadName() const override { return _loadName; }
virtual bool canBeNullAtRuntime() const { bool canBeNullAtRuntime() const override {
return _symbol->getBinding() == llvm::ELF::STB_WEAK; return _symbol->getBinding() == llvm::ELF::STB_WEAK;
} }
virtual Type type() const { Type type() const override {
switch (_symbol->getType()) { switch (_symbol->getType()) {
case llvm::ELF::STT_FUNC: case llvm::ELF::STT_FUNC:
case llvm::ELF::STT_GNU_IFUNC: case llvm::ELF::STT_GNU_IFUNC:
@ -748,28 +694,26 @@ class ObjectAtom : public SimpleELFDefinedAtom {
public: public:
ObjectAtom(const File &f) : SimpleELFDefinedAtom(f) {} ObjectAtom(const File &f) : SimpleELFDefinedAtom(f) {}
virtual Scope scope() const { return scopeGlobal; } Scope scope() const override { return scopeGlobal; }
virtual SectionChoice sectionChoice() const { return sectionBasedOnContent; } SectionChoice sectionChoice() const override { return sectionBasedOnContent; }
virtual ContentType contentType() const { return typeZeroFill; } ContentType contentType() const override { return typeZeroFill; }
virtual uint64_t size() const { return _size; } uint64_t size() const override { return _size; }
virtual DynamicExport dynamicExport() const { return dynamicExportAlways; } DynamicExport dynamicExport() const override { return dynamicExportAlways; }
virtual ContentPermissions permissions() const { return permRW_; } ContentPermissions permissions() const override { return permRW_; }
virtual ArrayRef<uint8_t> rawContent() const { ArrayRef<uint8_t> rawContent() const override { return ArrayRef<uint8_t>(); }
return ArrayRef<uint8_t>();
}
virtual Alignment alignment() const { Alignment alignment() const override {
// The alignment should be 8 byte aligned // The alignment should be 8 byte aligned
return Alignment(3); return Alignment(3);
} }
virtual StringRef name() const { return _name; } StringRef name() const override { return _name; }
std::string _name; std::string _name;
uint64_t _size; uint64_t _size;
@ -782,27 +726,27 @@ public:
GOTAtom(const File &f, StringRef secName) GOTAtom(const File &f, StringRef secName)
: SimpleELFDefinedAtom(f), _section(secName) {} : SimpleELFDefinedAtom(f), _section(secName) {}
virtual Scope scope() const { return scopeTranslationUnit; } Scope scope() const override { return scopeTranslationUnit; }
virtual SectionChoice sectionChoice() const { return sectionCustomRequired; } SectionChoice sectionChoice() const override { return sectionCustomRequired; }
virtual StringRef customSectionName() const { return _section; } StringRef customSectionName() const override { return _section; }
virtual ContentType contentType() const { return typeGOT; } ContentType contentType() const override { return typeGOT; }
virtual uint64_t size() const { return rawContent().size(); } uint64_t size() const override { return rawContent().size(); }
virtual ContentPermissions permissions() const { return permRW_; } ContentPermissions permissions() const override { return permRW_; }
virtual ArrayRef<uint8_t> rawContent() const = 0; virtual ArrayRef<uint8_t> rawContent() const = 0;
virtual Alignment alignment() const { Alignment alignment() const override {
// The alignment should be 8 byte aligned // The alignment should be 8 byte aligned
return Alignment(3); return Alignment(3);
} }
#ifndef NDEBUG #ifndef NDEBUG
virtual StringRef name() const { return _name; } StringRef name() const override { return _name; }
std::string _name; std::string _name;
#else #else
@ -817,26 +761,26 @@ public:
PLTAtom(const File &f, StringRef secName) PLTAtom(const File &f, StringRef secName)
: SimpleELFDefinedAtom(f), _section(secName) {} : SimpleELFDefinedAtom(f), _section(secName) {}
virtual Scope scope() const { return scopeTranslationUnit; } Scope scope() const override { return scopeTranslationUnit; }
virtual SectionChoice sectionChoice() const { return sectionCustomRequired; } SectionChoice sectionChoice() const override { return sectionCustomRequired; }
virtual StringRef customSectionName() const { return _section; } StringRef customSectionName() const override { return _section; }
virtual ContentType contentType() const { return typeStub; } ContentType contentType() const override { return typeStub; }
virtual uint64_t size() const { return rawContent().size(); } uint64_t size() const override { return rawContent().size(); }
virtual ContentPermissions permissions() const { return permR_X; } ContentPermissions permissions() const override { return permR_X; }
virtual ArrayRef<uint8_t> rawContent() const = 0; virtual ArrayRef<uint8_t> rawContent() const = 0;
virtual Alignment alignment() const { Alignment alignment() const override {
return Alignment(4); // 16 return Alignment(4); // 16
} }
#ifndef NDEBUG #ifndef NDEBUG
virtual StringRef name() const { return _name; } StringRef name() const override { return _name; }
std::string _name; std::string _name;
#else #else
@ -858,78 +802,76 @@ class GLOBAL_OFFSET_TABLEAtom : public SimpleELFDefinedAtom {
public: public:
GLOBAL_OFFSET_TABLEAtom(const File &f) : SimpleELFDefinedAtom(f) {} GLOBAL_OFFSET_TABLEAtom(const File &f) : SimpleELFDefinedAtom(f) {}
virtual StringRef name() const { return "_GLOBAL_OFFSET_TABLE_"; } StringRef name() const override { return "_GLOBAL_OFFSET_TABLE_"; }
virtual Scope scope() const { return scopeGlobal; } Scope scope() const override { return scopeGlobal; }
virtual SectionChoice sectionChoice() const { return sectionCustomRequired; } SectionChoice sectionChoice() const override { return sectionCustomRequired; }
virtual StringRef customSectionName() const { return ".got.plt"; } StringRef customSectionName() const override { return ".got.plt"; }
virtual ContentType contentType() const { return typeGOT; } ContentType contentType() const override { return typeGOT; }
virtual uint64_t size() const { return 0; } uint64_t size() const override { return 0; }
virtual ContentPermissions permissions() const { return permRW_; } ContentPermissions permissions() const override { return permRW_; }
virtual Alignment alignment() const { Alignment alignment() const override {
// Needs 8 byte alignment // Needs 8 byte alignment
return Alignment(3); return Alignment(3);
} }
virtual ArrayRef<uint8_t> rawContent() const { ArrayRef<uint8_t> rawContent() const override { return ArrayRef<uint8_t>(); }
return ArrayRef<uint8_t>();
}
}; };
class TLSGETADDRAtom : public SimpleELFDefinedAtom { class TLSGETADDRAtom : public SimpleELFDefinedAtom {
public: public:
TLSGETADDRAtom(const File &f) : SimpleELFDefinedAtom(f) {} TLSGETADDRAtom(const File &f) : SimpleELFDefinedAtom(f) {}
virtual StringRef name() const { return "__tls_get_addr"; } StringRef name() const override { return "__tls_get_addr"; }
virtual Scope scope() const { return scopeGlobal; } Scope scope() const override { return scopeGlobal; }
virtual Merge merge() const { return mergeAsWeak; } Merge merge() const override { return mergeAsWeak; }
virtual SectionChoice sectionChoice() const { return sectionCustomRequired; } SectionChoice sectionChoice() const override { return sectionCustomRequired; }
virtual StringRef customSectionName() const { return ".text"; } StringRef customSectionName() const override { return ".text"; }
virtual ContentType contentType() const { return typeCode; } ContentType contentType() const override { return typeCode; }
virtual uint64_t size() const { return 0; } uint64_t size() const override { return 0; }
virtual ContentPermissions permissions() const { return permR_X; } ContentPermissions permissions() const override { return permR_X; }
virtual Alignment alignment() const { return Alignment(0); } Alignment alignment() const override { return Alignment(0); }
virtual ArrayRef<uint8_t> rawContent() const { return ArrayRef<uint8_t>(); } ArrayRef<uint8_t> rawContent() const override { return ArrayRef<uint8_t>(); }
}; };
class DYNAMICAtom : public SimpleELFDefinedAtom { class DYNAMICAtom : public SimpleELFDefinedAtom {
public: public:
DYNAMICAtom(const File &f) : SimpleELFDefinedAtom(f) {} DYNAMICAtom(const File &f) : SimpleELFDefinedAtom(f) {}
virtual StringRef name() const { return "_DYNAMIC"; } StringRef name() const override { return "_DYNAMIC"; }
virtual Scope scope() const { return scopeLinkageUnit; } Scope scope() const override { return scopeLinkageUnit; }
virtual Merge merge() const { return mergeNo; } Merge merge() const override { return mergeNo; }
virtual SectionChoice sectionChoice() const { return sectionCustomRequired; } SectionChoice sectionChoice() const override { return sectionCustomRequired; }
virtual StringRef customSectionName() const { return ".dynamic"; } StringRef customSectionName() const override { return ".dynamic"; }
virtual ContentType contentType() const { return typeData; } ContentType contentType() const override { return typeData; }
virtual uint64_t size() const { return 0; } uint64_t size() const override { return 0; }
virtual ContentPermissions permissions() const { return permRW_; } ContentPermissions permissions() const override { return permRW_; }
virtual Alignment alignment() const { return Alignment(0); } Alignment alignment() const override { return Alignment(0); }
virtual ArrayRef<uint8_t> rawContent() const { return ArrayRef<uint8_t>(); } ArrayRef<uint8_t> rawContent() const override { return ArrayRef<uint8_t>(); }
}; };
class InitFiniAtom : public SimpleELFDefinedAtom { class InitFiniAtom : public SimpleELFDefinedAtom {
@ -939,24 +881,24 @@ public:
InitFiniAtom(const File &f, StringRef secName) InitFiniAtom(const File &f, StringRef secName)
: SimpleELFDefinedAtom(f), _section(secName) {} : SimpleELFDefinedAtom(f), _section(secName) {}
virtual Scope scope() const { return scopeGlobal; } Scope scope() const override { return scopeGlobal; }
virtual SectionChoice sectionChoice() const { return sectionCustomRequired; } SectionChoice sectionChoice() const override { return sectionCustomRequired; }
virtual StringRef customSectionName() const { return _section; } StringRef customSectionName() const override { return _section; }
virtual ContentType contentType() const { return typeData; } ContentType contentType() const override { return typeData; }
virtual uint64_t size() const { return rawContent().size(); } uint64_t size() const override { return rawContent().size(); }
virtual ContentPermissions permissions() const { return permRW_; } ContentPermissions permissions() const override { return permRW_; }
virtual ArrayRef<uint8_t> rawContent() const = 0; virtual ArrayRef<uint8_t> rawContent() const = 0;
virtual Alignment alignment() const { return size(); } Alignment alignment() const override { return size(); }
#ifndef NDEBUG #ifndef NDEBUG
virtual StringRef name() const { return _name; } StringRef name() const override { return _name; }
std::string _name; std::string _name;
#else #else

View File

@ -171,8 +171,8 @@ public:
DefaultLayout(const ELFLinkingContext &context) : _context(context) {} DefaultLayout(const ELFLinkingContext &context) : _context(context) {}
/// \brief Return the section order for a input section /// \brief Return the section order for a input section
virtual SectionOrder getSectionOrder(StringRef name, int32_t contentType, SectionOrder getSectionOrder(StringRef name, int32_t contentType,
int32_t contentPermissions); int32_t contentPermissions) override;
/// \brief This maps the input sections to the output section names /// \brief This maps the input sections to the output section names
virtual StringRef getSectionName(const DefinedAtom *da) const; virtual StringRef getSectionName(const DefinedAtom *da) const;
@ -190,7 +190,7 @@ public:
static bool hasOutputSegment(Section<ELFT> *section); static bool hasOutputSegment(Section<ELFT> *section);
// Adds an atom to the section // Adds an atom to the section
virtual ErrorOr<const lld::AtomLayout &> addAtom(const Atom *atom); ErrorOr<const lld::AtomLayout &> addAtom(const Atom *atom) override;
/// \brief Find an output Section given a section name. /// \brief Find an output Section given a section name.
MergedSections<ELFT> *findOutputSection(StringRef name) { MergedSections<ELFT> *findOutputSection(StringRef name) {
@ -209,13 +209,13 @@ public:
// Merge sections with the same name into a MergedSections // Merge sections with the same name into a MergedSections
void mergeSimilarSections(); void mergeSimilarSections();
void assignSectionsToSegments(); void assignSectionsToSegments() override;
void assignVirtualAddress(); void assignVirtualAddress() override;
void assignOffsetsForMiscSections(); void assignOffsetsForMiscSections();
void assignFileOffsets(); void assignFileOffsets() override;
/// Inline functions /// Inline functions
inline range<AbsoluteAtomIterT> absoluteAtoms() { return _absoluteAtoms; } inline range<AbsoluteAtomIterT> absoluteAtoms() { return _absoluteAtoms; }
@ -235,7 +235,7 @@ public:
si->doPreFlight(); si->doPreFlight();
} }
inline bool findAtomAddrByName(StringRef name, uint64_t &addr) { inline bool findAtomAddrByName(StringRef name, uint64_t &addr) override {
for (auto sec : _sections) for (auto sec : _sections)
if (auto section = dyn_cast<Section<ELFT> >(sec)) if (auto section = dyn_cast<Section<ELFT> >(sec))
if (section->findAtomAddrByName(name, addr)) if (section->findAtomAddrByName(name, addr))

View File

@ -27,24 +27,24 @@ public:
static ErrorOr<std::unique_ptr<DynamicFile>> static ErrorOr<std::unique_ptr<DynamicFile>>
create(std::unique_ptr<llvm::MemoryBuffer> mb, bool useShlibUndefines); create(std::unique_ptr<llvm::MemoryBuffer> mb, bool useShlibUndefines);
virtual const atom_collection<DefinedAtom> &defined() const { const atom_collection<DefinedAtom> &defined() const override {
return _definedAtoms; return _definedAtoms;
} }
virtual const atom_collection<UndefinedAtom> &undefined() const { const atom_collection<UndefinedAtom> &undefined() const override {
return _undefinedAtoms; return _undefinedAtoms;
} }
virtual const atom_collection<SharedLibraryAtom> &sharedLibrary() const { const atom_collection<SharedLibraryAtom> &sharedLibrary() const override {
return _sharedLibraryAtoms; return _sharedLibraryAtoms;
} }
virtual const atom_collection<AbsoluteAtom> &absolute() const { const atom_collection<AbsoluteAtom> &absolute() const override {
return _absoluteAtoms; return _absoluteAtoms;
} }
virtual const SharedLibraryAtom *exports(StringRef name, const SharedLibraryAtom *exports(StringRef name,
bool dataSymbolOnly) const { bool dataSymbolOnly) const override {
assert(!dataSymbolOnly && "Invalid option for ELF exports!"); assert(!dataSymbolOnly && "Invalid option for ELF exports!");
// See if we have the symbol. // See if we have the symbol.
auto sym = _nameToSym.find(name); auto sym = _nameToSym.find(name);

View File

@ -141,19 +141,19 @@ public:
/// \brief Create individual atoms /// \brief Create individual atoms
virtual error_code createAtoms(); virtual error_code createAtoms();
virtual const atom_collection<DefinedAtom> &defined() const { const atom_collection<DefinedAtom> &defined() const override {
return _definedAtoms; return _definedAtoms;
} }
virtual const atom_collection<UndefinedAtom> &undefined() const { const atom_collection<UndefinedAtom> &undefined() const override {
return _undefinedAtoms; return _undefinedAtoms;
} }
virtual const atom_collection<SharedLibraryAtom> &sharedLibrary() const { const atom_collection<SharedLibraryAtom> &sharedLibrary() const override {
return _sharedLibraryAtoms; return _sharedLibraryAtoms;
} }
virtual const atom_collection<AbsoluteAtom> &absolute() const { const atom_collection<AbsoluteAtom> &absolute() const override {
return _absoluteAtoms; return _absoluteAtoms;
} }

View File

@ -43,14 +43,14 @@ class ELFObjectReader : public Reader {
public: public:
ELFObjectReader(bool atomizeStrings) : _atomizeStrings(atomizeStrings) {} ELFObjectReader(bool atomizeStrings) : _atomizeStrings(atomizeStrings) {}
virtual bool canParse(file_magic magic, StringRef, bool canParse(file_magic magic, StringRef,
const MemoryBuffer &) const { const MemoryBuffer &) const override {
return (magic == llvm::sys::fs::file_magic::elf_relocatable); return (magic == llvm::sys::fs::file_magic::elf_relocatable);
} }
virtual error_code error_code
parseFile(std::unique_ptr<MemoryBuffer> &mb, const class Registry &, parseFile(std::unique_ptr<MemoryBuffer> &mb, const class Registry &,
std::vector<std::unique_ptr<File>> &result) const { std::vector<std::unique_ptr<File>> &result) const override {
std::size_t maxAlignment = std::size_t maxAlignment =
1ULL << llvm::countTrailingZeros(uintptr_t(mb->getBufferStart())); 1ULL << llvm::countTrailingZeros(uintptr_t(mb->getBufferStart()));
auto f = createELF<ELFFileCreateELFTraits>( auto f = createELF<ELFFileCreateELFTraits>(
@ -70,14 +70,14 @@ class ELFDSOReader : public Reader {
public: public:
ELFDSOReader(bool useUndefines) : _useUndefines(useUndefines) {} ELFDSOReader(bool useUndefines) : _useUndefines(useUndefines) {}
virtual bool canParse(file_magic magic, StringRef, bool canParse(file_magic magic, StringRef,
const MemoryBuffer &) const { const MemoryBuffer &) const override {
return (magic == llvm::sys::fs::file_magic::elf_shared_object); return (magic == llvm::sys::fs::file_magic::elf_shared_object);
} }
virtual error_code error_code
parseFile(std::unique_ptr<MemoryBuffer> &mb, const class Registry &, parseFile(std::unique_ptr<MemoryBuffer> &mb, const class Registry &,
std::vector<std::unique_ptr<File>> &result) const { std::vector<std::unique_ptr<File>> &result) const override {
std::size_t maxAlignment = std::size_t maxAlignment =
1ULL << llvm::countTrailingZeros(uintptr_t(mb->getBufferStart())); 1ULL << llvm::countTrailingZeros(uintptr_t(mb->getBufferStart()));
auto f = createELF<DynamicFileCreateELFTraits>( auto f = createELF<DynamicFileCreateELFTraits>(

View File

@ -43,9 +43,9 @@ public:
HexagonELFObjectReader(bool atomizeStrings) HexagonELFObjectReader(bool atomizeStrings)
: ELFObjectReader(atomizeStrings) {} : ELFObjectReader(atomizeStrings) {}
virtual error_code error_code
parseFile(std::unique_ptr<MemoryBuffer> &mb, const class Registry &, parseFile(std::unique_ptr<MemoryBuffer> &mb, const class Registry &,
std::vector<std::unique_ptr<File>> &result) const { std::vector<std::unique_ptr<File>> &result) const override {
std::size_t maxAlignment = std::size_t maxAlignment =
1ULL << llvm::countTrailingZeros(uintptr_t(mb->getBufferStart())); 1ULL << llvm::countTrailingZeros(uintptr_t(mb->getBufferStart()));
auto f = createELF<HexagonELFFileCreateELFTraits>( auto f = createELF<HexagonELFFileCreateELFTraits>(
@ -62,9 +62,9 @@ class HexagonELFDSOReader : public ELFDSOReader {
public: public:
HexagonELFDSOReader(bool useUndefines) : ELFDSOReader(useUndefines) {} HexagonELFDSOReader(bool useUndefines) : ELFDSOReader(useUndefines) {}
virtual error_code error_code
parseFile(std::unique_ptr<MemoryBuffer> &mb, const class Registry &, parseFile(std::unique_ptr<MemoryBuffer> &mb, const class Registry &,
std::vector<std::unique_ptr<File>> &result) const { std::vector<std::unique_ptr<File>> &result) const override {
std::size_t maxAlignment = std::size_t maxAlignment =
1ULL << llvm::countTrailingZeros(uintptr_t(mb->getBufferStart())); 1ULL << llvm::countTrailingZeros(uintptr_t(mb->getBufferStart()));
auto f = createELF<HexagonDynamicFileCreateELFTraits>( auto f = createELF<HexagonDynamicFileCreateELFTraits>(

View File

@ -24,10 +24,10 @@ class HexagonLinkingContext final : public ELFLinkingContext {
public: public:
HexagonLinkingContext(llvm::Triple triple); HexagonLinkingContext(llvm::Triple triple);
virtual void addPasses(PassManager &); void addPasses(PassManager &) override;
virtual bool isDynamicRelocation(const DefinedAtom &, bool isDynamicRelocation(const DefinedAtom &,
const Reference &r) const { const Reference &r) const override {
if (r.kindNamespace() != Reference::KindNamespace::ELF) if (r.kindNamespace() != Reference::KindNamespace::ELF)
return false; return false;
switch (r.kindValue()) { switch (r.kindValue()) {
@ -39,7 +39,7 @@ public:
} }
} }
virtual bool isPLTRelocation(const DefinedAtom &, const Reference &r) const { bool isPLTRelocation(const DefinedAtom &, const Reference &r) const override {
if (r.kindNamespace() != Reference::KindNamespace::ELF) if (r.kindNamespace() != Reference::KindNamespace::ELF)
return false; return false;
switch (r.kindValue()) { switch (r.kindValue()) {
@ -52,7 +52,7 @@ public:
/// \brief Hexagon has only one relative relocation /// \brief Hexagon has only one relative relocation
/// a) for supporting relative relocs - R_HEX_RELATIVE /// a) for supporting relative relocs - R_HEX_RELATIVE
virtual bool isRelativeReloc(const Reference &r) const { bool isRelativeReloc(const Reference &r) const override {
if (r.kindNamespace() != Reference::KindNamespace::ELF) if (r.kindNamespace() != Reference::KindNamespace::ELF)
return false; return false;
switch (r.kindValue()) { switch (r.kindValue()) {
@ -64,7 +64,8 @@ public:
} }
/// \brief Create Internal files for Init/Fini /// \brief Create Internal files for Init/Fini
void createInternalFiles(std::vector<std::unique_ptr<File> > &result) const; void createInternalFiles(
std::vector<std::unique_ptr<File>> &result) const override;
}; };
} // elf } // elf

View File

@ -24,9 +24,9 @@ public:
HexagonTargetRelocationHandler(HexagonTargetLayout<HexagonELFType> &layout) HexagonTargetRelocationHandler(HexagonTargetLayout<HexagonELFType> &layout)
: _hexagonTargetLayout(layout) {} : _hexagonTargetLayout(layout) {}
virtual error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &, error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
const lld::AtomLayout &, const lld::AtomLayout &,
const Reference &) const; const Reference &) const override;
private: private:
HexagonTargetLayout<HexagonELFType> &_hexagonTargetLayout; HexagonTargetLayout<HexagonELFType> &_hexagonTargetLayout;

View File

@ -108,25 +108,25 @@ class HexagonTargetHandler final :
public: public:
HexagonTargetHandler(HexagonLinkingContext &targetInfo); HexagonTargetHandler(HexagonLinkingContext &targetInfo);
virtual void registerRelocationNames(Registry &registry); void registerRelocationNames(Registry &registry) override;
virtual const HexagonTargetRelocationHandler &getRelocationHandler() const { const HexagonTargetRelocationHandler &getRelocationHandler() const override {
return *(_hexagonRelocationHandler.get()); return *(_hexagonRelocationHandler.get());
} }
virtual HexagonTargetLayout<HexagonELFType> &getTargetLayout() { HexagonTargetLayout<HexagonELFType> &getTargetLayout() override {
return *(_hexagonTargetLayout.get()); return *(_hexagonTargetLayout.get());
} }
virtual std::unique_ptr<Reader> getObjReader(bool atomizeStrings) { std::unique_ptr<Reader> getObjReader(bool atomizeStrings) override {
return std::unique_ptr<Reader>(new HexagonELFObjectReader(atomizeStrings)); return std::unique_ptr<Reader>(new HexagonELFObjectReader(atomizeStrings));
} }
virtual std::unique_ptr<Reader> getDSOReader(bool useShlibUndefines) { std::unique_ptr<Reader> getDSOReader(bool useShlibUndefines) override {
return std::unique_ptr<Reader>(new HexagonELFDSOReader(useShlibUndefines)); return std::unique_ptr<Reader>(new HexagonELFDSOReader(useShlibUndefines));
} }
virtual std::unique_ptr<Writer> getWriter(); std::unique_ptr<Writer> getWriter() override;
private: private:
llvm::BumpPtrAllocator _alloc; llvm::BumpPtrAllocator _alloc;

View File

@ -29,9 +29,9 @@ class MipsELFObjectReader : public ELFObjectReader {
public: public:
MipsELFObjectReader(bool atomizeStrings) : ELFObjectReader(atomizeStrings) {} MipsELFObjectReader(bool atomizeStrings) : ELFObjectReader(atomizeStrings) {}
virtual error_code error_code
parseFile(std::unique_ptr<MemoryBuffer> &mb, const class Registry &, parseFile(std::unique_ptr<MemoryBuffer> &mb, const class Registry &,
std::vector<std::unique_ptr<File>> &result) const { std::vector<std::unique_ptr<File>> &result) const override {
std::size_t maxAlignment = std::size_t maxAlignment =
1ULL << llvm::countTrailingZeros(uintptr_t(mb->getBufferStart())); 1ULL << llvm::countTrailingZeros(uintptr_t(mb->getBufferStart()));
auto f = createELF<MipsELFFileCreateTraits>( auto f = createELF<MipsELFFileCreateTraits>(

View File

@ -49,7 +49,7 @@ protected:
virtual void createDefaultSections(); virtual void createDefaultSections();
// Build all the output sections // Build all the output sections
virtual void buildChunks(const File &file); void buildChunks(const File &file) override;
// Build the output file // Build the output file
virtual error_code buildOutput(const File &file); virtual error_code buildOutput(const File &file);
@ -58,7 +58,7 @@ protected:
virtual error_code setELFHeader(); virtual error_code setELFHeader();
// Write the file to the path specified // Write the file to the path specified
virtual error_code writeFile(const File &File, StringRef path); error_code writeFile(const File &File, StringRef path) override;
// Write to the output file. // Write to the output file.
virtual error_code writeOutput(const File &file, StringRef path); virtual error_code writeOutput(const File &file, StringRef path);
@ -87,13 +87,13 @@ protected:
virtual void addDefaultAtoms() = 0; virtual void addDefaultAtoms() = 0;
// Add any runtime files and their atoms to the output // Add any runtime files and their atoms to the output
virtual bool createImplicitFiles(std::vector<std::unique_ptr<File> > &); bool createImplicitFiles(std::vector<std::unique_ptr<File>> &) override;
// Finalize the default atom values // Finalize the default atom values
virtual void finalizeDefaultAtomValues() = 0; virtual void finalizeDefaultAtomValues() = 0;
// This is called by the write section to apply relocations // This is called by the write section to apply relocations
virtual uint64_t addressOfAtom(const Atom *atom) { uint64_t addressOfAtom(const Atom *atom) override {
auto addr = _atomToAddressMap.find(atom); auto addr = _atomToAddressMap.find(atom);
return addr == _atomToAddressMap.end() ? 0 : addr->second; return addr == _atomToAddressMap.end() ? 0 : addr->second;
} }

View File

@ -26,10 +26,10 @@ public:
: ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>( : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
new PPCTargetHandler(*this))) {} new PPCTargetHandler(*this))) {}
virtual bool isLittleEndian() const { return false; } bool isLittleEndian() const override { return false; }
/// \brief PPC has no relative relocations defined /// \brief PPC has no relative relocations defined
virtual bool isRelativeReloc(const Reference &) const { return false; } bool isRelativeReloc(const Reference &) const override { return false; }
}; };
} // elf } // elf

View File

@ -32,7 +32,7 @@ public:
virtual error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &, virtual error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
const lld::AtomLayout &, const lld::AtomLayout &,
const Reference &) const; const Reference &) const override;
protected: protected:
PPCLinkingContext &_ppcContext; PPCLinkingContext &_ppcContext;
@ -44,17 +44,17 @@ class PPCTargetHandler final
public: public:
PPCTargetHandler(PPCLinkingContext &context); PPCTargetHandler(PPCLinkingContext &context);
virtual PPCTargetLayout<PPCELFType> &getTargetLayout() { PPCTargetLayout<PPCELFType> &getTargetLayout() override {
return *(_ppcTargetLayout.get()); return *(_ppcTargetLayout.get());
} }
virtual void registerRelocationNames(Registry &registry); void registerRelocationNames(Registry &registry) override;
virtual const PPCTargetRelocationHandler &getRelocationHandler() const { const PPCTargetRelocationHandler &getRelocationHandler() const override {
return *(_ppcRelocationHandler.get()); return *(_ppcRelocationHandler.get());
} }
virtual std::unique_ptr<Writer> getWriter(); std::unique_ptr<Writer> getWriter() override;
private: private:
static const Registry::KindStrings kindStrings[]; static const Registry::KindStrings kindStrings[];

View File

@ -28,7 +28,7 @@ public:
/// \brief X86 has only two relative relocation /// \brief X86 has only two relative relocation
/// a) for supporting IFUNC relocs - R_386_IRELATIVE /// a) for supporting IFUNC relocs - R_386_IRELATIVE
/// b) for supporting relative relocs - R_386_RELATIVE /// b) for supporting relative relocs - R_386_RELATIVE
virtual bool isRelativeReloc(const Reference &r) const { bool isRelativeReloc(const Reference &r) const override {
if (r.kindNamespace() != Reference::KindNamespace::ELF) if (r.kindNamespace() != Reference::KindNamespace::ELF)
return false; return false;
assert(r.kindArch() == Reference::KindArch::x86); assert(r.kindArch() == Reference::KindArch::x86);

View File

@ -33,9 +33,9 @@ public:
X86TargetLayout<X86ELFType> &layout) X86TargetLayout<X86ELFType> &layout)
: _x86Context(context), _x86TargetLayout(layout) {} : _x86Context(context), _x86TargetLayout(layout) {}
virtual error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &, error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
const lld::AtomLayout &, const lld::AtomLayout &,
const Reference &) const; const Reference &) const override;
static const Registry::KindStrings kindStrings[]; static const Registry::KindStrings kindStrings[];
@ -49,17 +49,17 @@ class X86TargetHandler final
public: public:
X86TargetHandler(X86LinkingContext &context); X86TargetHandler(X86LinkingContext &context);
virtual X86TargetLayout<X86ELFType> &getTargetLayout() { X86TargetLayout<X86ELFType> &getTargetLayout() override {
return *(_x86TargetLayout.get()); return *(_x86TargetLayout.get());
} }
virtual void registerRelocationNames(Registry &registry); void registerRelocationNames(Registry &registry) override;
virtual const X86TargetRelocationHandler &getRelocationHandler() const { const X86TargetRelocationHandler &getRelocationHandler() const override {
return *(_x86RelocationHandler.get()); return *(_x86RelocationHandler.get());
} }
virtual std::unique_ptr<Writer> getWriter(); std::unique_ptr<Writer> getWriter() override;
protected: protected:
static const Registry::KindStrings kindStrings[]; static const Registry::KindStrings kindStrings[];

View File

@ -33,16 +33,16 @@ public:
: ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>( : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
new X86_64TargetHandler(*this))) {} new X86_64TargetHandler(*this))) {}
virtual void addPasses(PassManager &); void addPasses(PassManager &) override;
virtual uint64_t getBaseAddress() const { uint64_t getBaseAddress() const override {
if (_baseAddress == 0) if (_baseAddress == 0)
return 0x400000; return 0x400000;
return _baseAddress; return _baseAddress;
} }
virtual bool isDynamicRelocation(const DefinedAtom &, bool isDynamicRelocation(const DefinedAtom &,
const Reference &r) const { const Reference &r) const override {
if (r.kindNamespace() != Reference::KindNamespace::ELF) if (r.kindNamespace() != Reference::KindNamespace::ELF)
return false; return false;
assert(r.kindArch() == Reference::KindArch::x86_64); assert(r.kindArch() == Reference::KindArch::x86_64);
@ -56,7 +56,8 @@ public:
} }
} }
virtual bool isPLTRelocation(const DefinedAtom &, const Reference &r) const { virtual bool isPLTRelocation(const DefinedAtom &,
const Reference &r) const override {
if (r.kindNamespace() != Reference::KindNamespace::ELF) if (r.kindNamespace() != Reference::KindNamespace::ELF)
return false; return false;
assert(r.kindArch() == Reference::KindArch::x86_64); assert(r.kindArch() == Reference::KindArch::x86_64);
@ -72,7 +73,7 @@ public:
/// \brief X86_64 has two relative relocations /// \brief X86_64 has two relative relocations
/// a) for supporting IFUNC - R_X86_64_IRELATIVE /// a) for supporting IFUNC - R_X86_64_IRELATIVE
/// b) for supporting relative relocs - R_X86_64_RELATIVE /// b) for supporting relative relocs - R_X86_64_RELATIVE
virtual bool isRelativeReloc(const Reference &r) const { bool isRelativeReloc(const Reference &r) const override {
if (r.kindNamespace() != Reference::KindNamespace::ELF) if (r.kindNamespace() != Reference::KindNamespace::ELF)
return false; return false;
assert(r.kindArch() == Reference::KindArch::x86_64); assert(r.kindArch() == Reference::KindArch::x86_64);
@ -86,8 +87,7 @@ public:
} }
/// \brief Create Internal files for Init/Fini /// \brief Create Internal files for Init/Fini
void createInternalFiles(std::vector<std::unique_ptr<File> > &) const; void createInternalFiles(std::vector<std::unique_ptr<File>> &) const override;
}; };
} // end namespace elf } // end namespace elf
} // end namespace lld } // end namespace lld

View File

@ -24,9 +24,9 @@ public:
X86_64TargetRelocationHandler(X86_64TargetLayout<X86_64ELFType> &layout) X86_64TargetRelocationHandler(X86_64TargetLayout<X86_64ELFType> &layout)
: _tlsSize(0), _x86_64Layout(layout) {} : _tlsSize(0), _x86_64Layout(layout) {}
virtual error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &, error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
const lld::AtomLayout &, const lld::AtomLayout &,
const Reference &) const; const Reference &) const override;
virtual int64_t relocAddend(const Reference &) const; virtual int64_t relocAddend(const Reference &) const;

View File

@ -33,17 +33,17 @@ class X86_64TargetHandler final
public: public:
X86_64TargetHandler(X86_64LinkingContext &context); X86_64TargetHandler(X86_64LinkingContext &context);
virtual X86_64TargetLayout<X86_64ELFType> &getTargetLayout() { X86_64TargetLayout<X86_64ELFType> &getTargetLayout() override {
return *(_x86_64TargetLayout.get()); return *(_x86_64TargetLayout.get());
} }
virtual void registerRelocationNames(Registry &registry); void registerRelocationNames(Registry &registry) override;
virtual const X86_64TargetRelocationHandler &getRelocationHandler() const { const X86_64TargetRelocationHandler &getRelocationHandler() const override {
return *(_x86_64RelocationHandler.get()); return *(_x86_64RelocationHandler.get());
} }
virtual std::unique_ptr<Writer> getWriter(); std::unique_ptr<Writer> getWriter() override;
private: private:
static const Registry::KindStrings kindStrings[]; static const Registry::KindStrings kindStrings[];