mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 22:00:10 +00:00
[lld-macho][nfc] Add final
to classes where possible
I wanted to see if we would get any perf wins out of this, but it doesn't seem to be the case. But it still seems worth committing. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D104200
This commit is contained in:
parent
c5c05ffa45
commit
da24e6d43e
@ -24,7 +24,7 @@ class Defined;
|
||||
// files that are labeled with the same segment and section name. This class
|
||||
// contains all such sections and writes the data from each section sequentially
|
||||
// in the final binary.
|
||||
class ConcatOutputSection : public OutputSection {
|
||||
class ConcatOutputSection final : public OutputSection {
|
||||
public:
|
||||
explicit ConcatOutputSection(StringRef name)
|
||||
: OutputSection(ConcatKind, name) {}
|
||||
|
@ -96,7 +96,7 @@ private:
|
||||
};
|
||||
|
||||
// .o file
|
||||
class ObjFile : public InputFile {
|
||||
class ObjFile final : public InputFile {
|
||||
public:
|
||||
ObjFile(MemoryBufferRef mb, uint32_t modTime, StringRef archiveName);
|
||||
static bool classof(const InputFile *f) { return f->kind() == ObjKind; }
|
||||
@ -121,14 +121,14 @@ private:
|
||||
};
|
||||
|
||||
// command-line -sectcreate file
|
||||
class OpaqueFile : public InputFile {
|
||||
class OpaqueFile final : public InputFile {
|
||||
public:
|
||||
OpaqueFile(MemoryBufferRef mb, StringRef segName, StringRef sectName);
|
||||
static bool classof(const InputFile *f) { return f->kind() == OpaqueKind; }
|
||||
};
|
||||
|
||||
// .dylib or .tbd file
|
||||
class DylibFile : public InputFile {
|
||||
class DylibFile final : public InputFile {
|
||||
public:
|
||||
// Mach-O dylibs can re-export other dylibs as sub-libraries, meaning that the
|
||||
// symbols in those sub-libraries will be available under the umbrella
|
||||
@ -181,7 +181,7 @@ private:
|
||||
};
|
||||
|
||||
// .a file
|
||||
class ArchiveFile : public InputFile {
|
||||
class ArchiveFile final : public InputFile {
|
||||
public:
|
||||
explicit ArchiveFile(std::unique_ptr<llvm::object::Archive> &&file);
|
||||
static bool classof(const InputFile *f) { return f->kind() == ArchiveKind; }
|
||||
@ -194,7 +194,7 @@ private:
|
||||
llvm::DenseSet<uint64_t> seen;
|
||||
};
|
||||
|
||||
class BitcodeFile : public InputFile {
|
||||
class BitcodeFile final : public InputFile {
|
||||
public:
|
||||
explicit BitcodeFile(MemoryBufferRef mb);
|
||||
static bool classof(const InputFile *f) { return f->kind() == BitcodeKind; }
|
||||
|
@ -76,7 +76,7 @@ private:
|
||||
// ConcatInputSections are combined into (Concat)OutputSections through simple
|
||||
// concatenation, in contrast with literal sections which may have their
|
||||
// contents merged before output.
|
||||
class ConcatInputSection : public InputSection {
|
||||
class ConcatInputSection final : public InputSection {
|
||||
public:
|
||||
ConcatInputSection(StringRef segname, StringRef name)
|
||||
: InputSection(ConcatKind, segname, name) {}
|
||||
@ -136,7 +136,7 @@ static_assert(sizeof(StringPiece) == 16, "StringPiece is too big!");
|
||||
// ld64 is more conservative and does not do that. This was mostly done for
|
||||
// implementation simplicity; if we find programs that need the more
|
||||
// conservative behavior we can certainly implement that.
|
||||
class CStringInputSection : public InputSection {
|
||||
class CStringInputSection final : public InputSection {
|
||||
public:
|
||||
CStringInputSection(StringRef segname, StringRef name, InputFile *file,
|
||||
ArrayRef<uint8_t> data, uint32_t align, uint32_t flags)
|
||||
@ -168,7 +168,7 @@ public:
|
||||
std::vector<StringPiece> pieces;
|
||||
};
|
||||
|
||||
class WordLiteralInputSection : public InputSection {
|
||||
class WordLiteralInputSection final : public InputSection {
|
||||
public:
|
||||
WordLiteralInputSection(StringRef segname, StringRef name, InputFile *file,
|
||||
ArrayRef<uint8_t> data, uint32_t align,
|
||||
|
@ -774,7 +774,7 @@ uint32_t SymtabSection::getNumSymbols() const {
|
||||
}
|
||||
|
||||
// This serves to hide (type-erase) the template parameter from SymtabSection.
|
||||
template <class LP> class SymtabSectionImpl : public SymtabSection {
|
||||
template <class LP> class SymtabSectionImpl final : public SymtabSection {
|
||||
public:
|
||||
SymtabSectionImpl(StringTableSection &stringTableSection)
|
||||
: SymtabSection(stringTableSection) {}
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
};
|
||||
|
||||
// The header of the Mach-O file, which must have a file offset of zero.
|
||||
class MachHeaderSection : public SyntheticSection {
|
||||
class MachHeaderSection final : public SyntheticSection {
|
||||
public:
|
||||
MachHeaderSection();
|
||||
bool isHidden() const override { return true; }
|
||||
@ -97,7 +97,7 @@ protected:
|
||||
|
||||
// A hidden section that exists solely for the purpose of creating the
|
||||
// __PAGEZERO segment, which is used to catch null pointer dereferences.
|
||||
class PageZeroSection : public SyntheticSection {
|
||||
class PageZeroSection final : public SyntheticSection {
|
||||
public:
|
||||
PageZeroSection();
|
||||
bool isHidden() const override { return true; }
|
||||
@ -134,7 +134,7 @@ private:
|
||||
llvm::SetVector<const Symbol *> entries;
|
||||
};
|
||||
|
||||
class GotSection : public NonLazyPointerSectionBase {
|
||||
class GotSection final : public NonLazyPointerSectionBase {
|
||||
public:
|
||||
GotSection()
|
||||
: NonLazyPointerSectionBase(segment_names::dataConst,
|
||||
@ -144,7 +144,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class TlvPointerSection : public NonLazyPointerSectionBase {
|
||||
class TlvPointerSection final : public NonLazyPointerSectionBase {
|
||||
public:
|
||||
TlvPointerSection()
|
||||
: NonLazyPointerSectionBase(segment_names::data,
|
||||
@ -163,7 +163,7 @@ struct Location {
|
||||
// Stores rebase opcodes, which tell dyld where absolute addresses have been
|
||||
// encoded in the binary. If the binary is not loaded at its preferred address,
|
||||
// dyld has to rebase these addresses by adding an offset to them.
|
||||
class RebaseSection : public LinkEditSection {
|
||||
class RebaseSection final : public LinkEditSection {
|
||||
public:
|
||||
RebaseSection();
|
||||
void finalizeContents() override;
|
||||
@ -190,7 +190,7 @@ struct BindingEntry {
|
||||
};
|
||||
|
||||
// Stores bind opcodes for telling dyld which symbols to load non-lazily.
|
||||
class BindingSection : public LinkEditSection {
|
||||
class BindingSection final : public LinkEditSection {
|
||||
public:
|
||||
BindingSection();
|
||||
void finalizeContents() override;
|
||||
@ -226,7 +226,7 @@ struct WeakBindingEntry {
|
||||
// coalesce to a non-weak definition if one is found. Note that unlike the
|
||||
// entries in the BindingSection, the bindings here only refer to these
|
||||
// symbols by name, but do not specify which dylib to load them from.
|
||||
class WeakBindingSection : public LinkEditSection {
|
||||
class WeakBindingSection final : public LinkEditSection {
|
||||
public:
|
||||
WeakBindingSection();
|
||||
void finalizeContents() override;
|
||||
@ -287,7 +287,7 @@ private:
|
||||
// appropriate symbol is found at runtime. However, the bound addresses will
|
||||
// still be written (non-lazily) into the LazyPointerSection.
|
||||
|
||||
class StubsSection : public SyntheticSection {
|
||||
class StubsSection final : public SyntheticSection {
|
||||
public:
|
||||
StubsSection();
|
||||
uint64_t getSize() const override;
|
||||
@ -313,7 +313,7 @@ private:
|
||||
llvm::SetVector<Symbol *> entries;
|
||||
};
|
||||
|
||||
class StubHelperSection : public SyntheticSection {
|
||||
class StubHelperSection final : public SyntheticSection {
|
||||
public:
|
||||
StubHelperSection();
|
||||
uint64_t getSize() const override;
|
||||
@ -328,7 +328,7 @@ public:
|
||||
|
||||
// Note that this section may also be targeted by non-lazy bindings. In
|
||||
// particular, this happens when branch relocations target weak symbols.
|
||||
class LazyPointerSection : public SyntheticSection {
|
||||
class LazyPointerSection final : public SyntheticSection {
|
||||
public:
|
||||
LazyPointerSection();
|
||||
uint64_t getSize() const override;
|
||||
@ -336,7 +336,7 @@ public:
|
||||
void writeTo(uint8_t *buf) const override;
|
||||
};
|
||||
|
||||
class LazyBindingSection : public LinkEditSection {
|
||||
class LazyBindingSection final : public LinkEditSection {
|
||||
public:
|
||||
LazyBindingSection();
|
||||
void finalizeContents() override;
|
||||
@ -357,7 +357,7 @@ private:
|
||||
};
|
||||
|
||||
// Stores a trie that describes the set of exported symbols.
|
||||
class ExportSection : public LinkEditSection {
|
||||
class ExportSection final : public LinkEditSection {
|
||||
public:
|
||||
ExportSection();
|
||||
void finalizeContents() override;
|
||||
@ -372,7 +372,7 @@ private:
|
||||
};
|
||||
|
||||
// Stores ULEB128 delta encoded addresses of functions.
|
||||
class FunctionStartsSection : public LinkEditSection {
|
||||
class FunctionStartsSection final : public LinkEditSection {
|
||||
public:
|
||||
FunctionStartsSection();
|
||||
void finalizeContents() override;
|
||||
@ -384,7 +384,7 @@ private:
|
||||
};
|
||||
|
||||
// Stores the strings referenced by the symbol table.
|
||||
class StringTableSection : public LinkEditSection {
|
||||
class StringTableSection final : public LinkEditSection {
|
||||
public:
|
||||
StringTableSection();
|
||||
// Returns the start offset of the added string.
|
||||
@ -463,7 +463,7 @@ template <class LP> SymtabSection *makeSymtabSection(StringTableSection &);
|
||||
// contiguous sequences of symbol references. These references can be pointers
|
||||
// (e.g. those in the GOT and TLVP sections) or assembly sequences (e.g.
|
||||
// function stubs).
|
||||
class IndirectSymtabSection : public LinkEditSection {
|
||||
class IndirectSymtabSection final : public LinkEditSection {
|
||||
public:
|
||||
IndirectSymtabSection();
|
||||
void finalizeContents() override;
|
||||
@ -476,7 +476,7 @@ public:
|
||||
};
|
||||
|
||||
// The code signature comes at the very end of the linked output file.
|
||||
class CodeSignatureSection : public LinkEditSection {
|
||||
class CodeSignatureSection final : public LinkEditSection {
|
||||
public:
|
||||
static constexpr uint8_t blockSizeShift = 12;
|
||||
static constexpr size_t blockSize = (1 << blockSizeShift); // 4 KiB
|
||||
@ -498,7 +498,7 @@ public:
|
||||
void writeHashes(uint8_t *buf) const;
|
||||
};
|
||||
|
||||
class BitcodeBundleSection : public SyntheticSection {
|
||||
class BitcodeBundleSection final : public SyntheticSection {
|
||||
public:
|
||||
BitcodeBundleSection();
|
||||
uint64_t getSize() const override { return xarSize; }
|
||||
@ -510,7 +510,7 @@ private:
|
||||
uint64_t xarSize;
|
||||
};
|
||||
|
||||
class CStringSection : public SyntheticSection {
|
||||
class CStringSection final : public SyntheticSection {
|
||||
public:
|
||||
CStringSection();
|
||||
void addInput(CStringInputSection *);
|
||||
@ -529,7 +529,7 @@ private:
|
||||
* This section contains deduplicated literal values. The 16-byte values are
|
||||
* laid out first, followed by the 8- and then the 4-byte ones.
|
||||
*/
|
||||
class WordLiteralSection : public SyntheticSection {
|
||||
class WordLiteralSection final : public SyntheticSection {
|
||||
public:
|
||||
using UInt128 = std::pair<uint64_t, uint64_t>;
|
||||
// I don't think the standard guarantees the size of a pair, so let's make
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
};
|
||||
|
||||
// LC_DYLD_INFO_ONLY stores the offsets of symbol import/export information.
|
||||
class LCDyldInfo : public LoadCommand {
|
||||
class LCDyldInfo final : public LoadCommand {
|
||||
public:
|
||||
LCDyldInfo(RebaseSection *rebaseSection, BindingSection *bindingSection,
|
||||
WeakBindingSection *weakBindingSection,
|
||||
@ -123,7 +123,7 @@ public:
|
||||
ExportSection *exportSection;
|
||||
};
|
||||
|
||||
class LCFunctionStarts : public LoadCommand {
|
||||
class LCFunctionStarts final : public LoadCommand {
|
||||
public:
|
||||
explicit LCFunctionStarts(FunctionStartsSection *functionStartsSection)
|
||||
: functionStartsSection(functionStartsSection) {}
|
||||
@ -142,7 +142,7 @@ private:
|
||||
FunctionStartsSection *functionStartsSection;
|
||||
};
|
||||
|
||||
class LCDysymtab : public LoadCommand {
|
||||
class LCDysymtab final : public LoadCommand {
|
||||
public:
|
||||
LCDysymtab(SymtabSection *symtabSection,
|
||||
IndirectSymtabSection *indirectSymtabSection)
|
||||
@ -170,7 +170,7 @@ public:
|
||||
IndirectSymtabSection *indirectSymtabSection;
|
||||
};
|
||||
|
||||
template <class LP> class LCSegment : public LoadCommand {
|
||||
template <class LP> class LCSegment final : public LoadCommand {
|
||||
public:
|
||||
LCSegment(StringRef name, OutputSegment *seg) : name(name), seg(seg) {}
|
||||
|
||||
@ -226,7 +226,7 @@ private:
|
||||
OutputSegment *seg;
|
||||
};
|
||||
|
||||
class LCMain : public LoadCommand {
|
||||
class LCMain final : public LoadCommand {
|
||||
uint32_t getSize() const override {
|
||||
return sizeof(structs::entry_point_command);
|
||||
}
|
||||
@ -246,7 +246,7 @@ class LCMain : public LoadCommand {
|
||||
}
|
||||
};
|
||||
|
||||
class LCSymtab : public LoadCommand {
|
||||
class LCSymtab final : public LoadCommand {
|
||||
public:
|
||||
LCSymtab(SymtabSection *symtabSection, StringTableSection *stringTableSection)
|
||||
: symtabSection(symtabSection), stringTableSection(stringTableSection) {}
|
||||
@ -271,7 +271,7 @@ public:
|
||||
// * LC_LOAD_DYLIB
|
||||
// * LC_ID_DYLIB
|
||||
// * LC_REEXPORT_DYLIB
|
||||
class LCDylib : public LoadCommand {
|
||||
class LCDylib final : public LoadCommand {
|
||||
public:
|
||||
LCDylib(LoadCommandType type, StringRef path,
|
||||
uint32_t compatibilityVersion = 0, uint32_t currentVersion = 0)
|
||||
@ -311,7 +311,7 @@ private:
|
||||
|
||||
uint32_t LCDylib::instanceCount = 0;
|
||||
|
||||
class LCLoadDylinker : public LoadCommand {
|
||||
class LCLoadDylinker final : public LoadCommand {
|
||||
public:
|
||||
uint32_t getSize() const override {
|
||||
return alignTo(sizeof(dylinker_command) + path.size() + 1, 8);
|
||||
@ -335,7 +335,7 @@ private:
|
||||
const StringRef path = "/usr/lib/dyld";
|
||||
};
|
||||
|
||||
class LCRPath : public LoadCommand {
|
||||
class LCRPath final : public LoadCommand {
|
||||
public:
|
||||
explicit LCRPath(StringRef path) : path(path) {}
|
||||
|
||||
@ -359,7 +359,7 @@ private:
|
||||
StringRef path;
|
||||
};
|
||||
|
||||
class LCMinVersion : public LoadCommand {
|
||||
class LCMinVersion final : public LoadCommand {
|
||||
public:
|
||||
explicit LCMinVersion(const PlatformInfo &platformInfo)
|
||||
: platformInfo(platformInfo) {}
|
||||
@ -397,7 +397,7 @@ private:
|
||||
const PlatformInfo &platformInfo;
|
||||
};
|
||||
|
||||
class LCBuildVersion : public LoadCommand {
|
||||
class LCBuildVersion final : public LoadCommand {
|
||||
public:
|
||||
explicit LCBuildVersion(const PlatformInfo &platformInfo)
|
||||
: platformInfo(platformInfo) {}
|
||||
@ -432,7 +432,7 @@ private:
|
||||
// offsets to be calculated correctly. We resolve this circular paradox by
|
||||
// first writing an LC_UUID with an all-zero UUID, then updating the UUID with
|
||||
// its real value later.
|
||||
class LCUuid : public LoadCommand {
|
||||
class LCUuid final : public LoadCommand {
|
||||
public:
|
||||
uint32_t getSize() const override { return sizeof(uuid_command); }
|
||||
|
||||
@ -465,7 +465,7 @@ public:
|
||||
mutable uint8_t *uuidBuf;
|
||||
};
|
||||
|
||||
template <class LP> class LCEncryptionInfo : public LoadCommand {
|
||||
template <class LP> class LCEncryptionInfo final : public LoadCommand {
|
||||
public:
|
||||
uint32_t getSize() const override {
|
||||
return sizeof(typename LP::encryption_info_command);
|
||||
@ -486,7 +486,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class LCCodeSignature : public LoadCommand {
|
||||
class LCCodeSignature final : public LoadCommand {
|
||||
public:
|
||||
LCCodeSignature(CodeSignatureSection *section) : section(section) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user