llvm::function_ref<Error(Error)> ErrorCallback);
bool isPositiveMatch() const { return IsPositiveMatch; }
- Optional<StringRef> getName() const {
+ std::optional<StringRef> getName() const {
if (!R && !G)
return Name;
return std::nullopt;
if (!Matcher)
return Matcher.takeError();
if (Matcher->isPositiveMatch()) {
- if (Optional<StringRef> MaybeName = Matcher->getName())
+ if (std::optional<StringRef> MaybeName = Matcher->getName())
PosNames.insert(CachedHashStringRef(*MaybeName));
else
PosPatterns.push_back(std::move(*Matcher));
StringRef AddGnuDebugLink;
// Cached gnu_debuglink's target CRC
uint32_t GnuDebugLinkCRC32;
- Optional<StringRef> ExtractPartition;
+ std::optional<StringRef> ExtractPartition;
StringRef SplitDWO;
StringRef SymbolsPrefix;
StringRef AllocSectionsPrefix;
StringRef AuxFile;
ssize_t TargetSectionId;
ssize_t AssociativeComdatTargetSectionId = 0;
- Optional<size_t> WeakTargetSymbolId;
+ std::optional<size_t> WeakTargetSymbolId;
size_t UniqueId;
size_t RawIndex;
bool Referenced;
template <class ELFT>
ELFBuilder<ELFT>::ELFBuilder(const ELFObjectFile<ELFT> &ElfObj, Object &Obj,
- Optional<StringRef> ExtractPartition)
+ std::optional<StringRef> ExtractPartition)
: ElfFile(ElfObj.getELFFile()), Obj(Obj),
ExtractPartition(ExtractPartition) {
Obj.IsMips64EL = ElfFile.isMips64EL();
const ELFFile<ELFT> &ElfFile;
Object &Obj;
size_t EhdrOffset = 0;
- Optional<StringRef> ExtractPartition;
+ std::optional<StringRef> ExtractPartition;
void setParentSegment(Segment &Child);
Error readProgramHeaders(const ELFFile<ELFT> &HeadersFile);
public:
ELFBuilder(const ELFObjectFile<ELFT> &ElfObj, Object &Obj,
- Optional<StringRef> ExtractPartition);
+ std::optional<StringRef> ExtractPartition);
Error build(bool EnsureSymtab);
};
class ELFReader : public Reader {
Binary *Bin;
- Optional<StringRef> ExtractPartition;
+ std::optional<StringRef> ExtractPartition;
public:
Expected<std::unique_ptr<Object>> create(bool EnsureSymtab) const override;
- explicit ELFReader(Binary *B, Optional<StringRef> ExtractPartition)
+ explicit ELFReader(Binary *B, std::optional<StringRef> ExtractPartition)
: Bin(B), ExtractPartition(ExtractPartition) {}
};
// Add the a section into an existing segment.
for (LoadCommand &LC : Obj.LoadCommands) {
- Optional<StringRef> SegName = LC.getSegmentName();
+ std::optional<StringRef> SegName = LC.getSegmentName();
if (SegName && SegName == TargetSegName) {
uint64_t Addr = *LC.getSegmentVMAddr();
for (const std::unique_ptr<Section> &S : LC.Sections)
}
auto IsDead = [&](const std::unique_ptr<SymbolEntry> &S) -> bool {
- Optional<uint32_t> Section = S->section();
+ std::optional<uint32_t> Section = S->section();
return (Section && !OldIndexToSection.count(*Section));
};
strnlen(SegName, sizeof(MachO::segment_command::segname)));
}
-Optional<StringRef> LoadCommand::getSegmentName() const {
+std::optional<StringRef> LoadCommand::getSegmentName() const {
const MachO::macho_load_command &MLC = MachOLoadCommand;
switch (MLC.load_command_data.cmd) {
case MachO::LC_SEGMENT:
}
}
-Optional<uint64_t> LoadCommand::getSegmentVMAddr() const {
+std::optional<uint64_t> LoadCommand::getSegmentVMAddr() const {
const MachO::macho_load_command &MLC = MachOLoadCommand;
switch (MLC.load_command_data.cmd) {
case MachO::LC_SEGMENT:
uint64_t Addr = 0;
uint64_t Size = 0;
// Offset in the input file.
- Optional<uint32_t> OriginalOffset;
+ std::optional<uint32_t> OriginalOffset;
uint32_t Offset = 0;
uint32_t Align = 0;
uint32_t RelOff = 0;
std::vector<std::unique_ptr<Section>> Sections;
// Returns the segment name if the load command is a segment command.
- Optional<StringRef> getSegmentName() const;
+ std::optional<StringRef> getSegmentName() const;
// Returns the segment vm address if the load command is a segment command.
- Optional<uint64_t> getSegmentVMAddr() const;
+ std::optional<uint64_t> getSegmentVMAddr() const;
};
// A symbol information. Fields which starts with "n_" are same as them in the
StringRef(Name).startswith("_$S");
}
- Optional<uint32_t> section() const {
- return n_sect == MachO::NO_SECT ? std::nullopt : Optional<uint32_t>(n_sect);
+ std::optional<uint32_t> section() const {
+ return n_sect == MachO::NO_SECT ? std::nullopt
+ : std::optional<uint32_t>(n_sect);
}
};
uint32_t OriginalIndex;
/// The Symbol referenced by this entry. It's None if the index is
/// INDIRECT_SYMBOL_LOCAL or INDIRECT_SYMBOL_ABS.
- Optional<SymbolEntry *> Symbol;
+ std::optional<SymbolEntry *> Symbol;
- IndirectSymbolEntry(uint32_t OriginalIndex, Optional<SymbolEntry *> Symbol)
+ IndirectSymbolEntry(uint32_t OriginalIndex,
+ std::optional<SymbolEntry *> Symbol)
: OriginalIndex(OriginalIndex), Symbol(Symbol) {}
};
struct RelocationInfo {
// The referenced symbol entry. Set if !Scattered && Extern.
- Optional<const SymbolEntry *> Symbol;
+ std::optional<const SymbolEntry *> Symbol;
// The referenced section. Set if !Scattered && !Extern.
- Optional<const Section *> Sec;
+ std::optional<const Section *> Sec;
// True if Info is a scattered_relocation_info.
bool Scattered;
// True if the type is an ADDEND. r_symbolnum holds the addend instead of a
LinkData ChainedFixups;
LinkData DylibCodeSignDRs;
- Optional<uint32_t> SwiftVersion;
+ std::optional<uint32_t> SwiftVersion;
/// The index of LC_CODE_SIGNATURE load command if present.
- Optional<size_t> CodeSignatureCommandIndex;
+ std::optional<size_t> CodeSignatureCommandIndex;
/// The index of LC_DYLIB_CODE_SIGN_DRS load command if present.
- Optional<size_t> DylibCodeSignDRsIndex;
+ std::optional<size_t> DylibCodeSignDRsIndex;
/// The index of LC_SYMTAB load command if present.
- Optional<size_t> SymTabCommandIndex;
+ std::optional<size_t> SymTabCommandIndex;
/// The index of LC_DYLD_INFO or LC_DYLD_INFO_ONLY load command if present.
- Optional<size_t> DyLdInfoCommandIndex;
+ std::optional<size_t> DyLdInfoCommandIndex;
/// The index LC_DYSYMTAB load command if present.
- Optional<size_t> DySymTabCommandIndex;
+ std::optional<size_t> DySymTabCommandIndex;
/// The index LC_DATA_IN_CODE load command if present.
- Optional<size_t> DataInCodeCommandIndex;
+ std::optional<size_t> DataInCodeCommandIndex;
/// The index of LC_LINKER_OPTIMIZATIN_HINT load command if present.
- Optional<size_t> LinkerOptimizationHintCommandIndex;
+ std::optional<size_t> LinkerOptimizationHintCommandIndex;
/// The index LC_FUNCTION_STARTS load command if present.
- Optional<size_t> FunctionStartsCommandIndex;
+ std::optional<size_t> FunctionStartsCommandIndex;
/// The index LC_DYLD_CHAINED_FIXUPS load command if present.
- Optional<size_t> ChainedFixupsCommandIndex;
+ std::optional<size_t> ChainedFixupsCommandIndex;
/// The index LC_DYLD_EXPORTS_TRIE load command if present.
- Optional<size_t> ExportsTrieCommandIndex;
+ std::optional<size_t> ExportsTrieCommandIndex;
/// The index of the LC_SEGMENT or LC_SEGMENT_64 load command
/// corresponding to the __TEXT segment.
- Optional<size_t> TextSegmentCommandIndex;
+ std::optional<size_t> TextSegmentCommandIndex;
BumpPtrAllocator Alloc;
StringSaver NewSectionsContents;
O.Exports.Trie = Trie;
}
-void MachOReader::readLinkData(Object &O, Optional<size_t> LCIndex,
+void MachOReader::readLinkData(Object &O, std::optional<size_t> LCIndex,
LinkData &LD) const {
if (!LCIndex)
return;
void readWeakBindInfo(Object &O) const;
void readLazyBindInfo(Object &O) const;
void readExportInfo(Object &O) const;
- void readLinkData(Object &O, Optional<size_t> LCIndex, LinkData &LD) const;
+ void readLinkData(Object &O, std::optional<size_t> LCIndex,
+ LinkData &LD) const;
void readCodeSignature(Object &O) const;
void readDataInCodeData(Object &O) const;
void readLinkerOptimizationHint(Object &O) const;
sizeof(uint32_t) * O.IndirectSymTable.Symbols.size());
}
- for (Optional<size_t> LinkEditDataCommandIndex :
+ for (std::optional<size_t> LinkEditDataCommandIndex :
{O.CodeSignatureCommandIndex, O.DylibCodeSignDRsIndex,
O.DataInCodeCommandIndex, O.LinkerOptimizationHintCommandIndex,
O.FunctionStartsCommandIndex, O.ChainedFixupsCommandIndex,
}
}
-void MachOWriter::writeLinkData(Optional<size_t> LCIndex, const LinkData &LD) {
+void MachOWriter::writeLinkData(std::optional<size_t> LCIndex,
+ const LinkData &LD) {
if (!LCIndex)
return;
const MachO::linkedit_data_command &LinkEditDataCommand =
&MachOWriter::writeIndirectSymbolTable);
}
- std::initializer_list<std::pair<Optional<size_t>, WriteHandlerType>>
+ std::initializer_list<std::pair<std::optional<size_t>, WriteHandlerType>>
LinkEditDataCommandWriters = {
{O.CodeSignatureCommandIndex, &MachOWriter::writeCodeSignatureData},
{O.DylibCodeSignDRsIndex, &MachOWriter::writeDylibCodeSignDRsData},
{O.ChainedFixupsCommandIndex, &MachOWriter::writeChainedFixupsData},
{O.ExportsTrieCommandIndex, &MachOWriter::writeExportsTrieData}};
for (const auto &W : LinkEditDataCommandWriters) {
- Optional<size_t> LinkEditDataCommandIndex;
+ std::optional<size_t> LinkEditDataCommandIndex;
WriteHandlerType WriteHandler;
std::tie(LinkEditDataCommandIndex, WriteHandler) = W;
if (LinkEditDataCommandIndex) {
void writeLazyBindInfo();
void writeExportInfo();
void writeIndirectSymbolTable();
- void writeLinkData(Optional<size_t> LCIndex, const LinkData &LD);
+ void writeLinkData(std::optional<size_t> LCIndex, const LinkData &LD);
void writeCodeSignatureData();
void writeDataInCodeData();
void writeLinkerOptimizationHint();