42#if !defined(_MSC_VER) && !defined(__MINGW32__)
53 std::map<std::string, uint16_t>
Map;
54 std::map<std::string, uint16_t>
ECMap;
62 auto MemBufferRef = this->
Buf->getMemBufferRef();
89 auto TargetTriple =
Triple(IRObject.getTargetTriple());
102 bool Deterministic) {
109 M.MemberName = M.Buf->getBufferIdentifier();
110 if (!Deterministic) {
113 return ModTimeOrErr.takeError();
114 M.ModTime = ModTimeOrErr.get();
118 M.UID = UIDOrErr.
get();
122 M.GID = GIDOrErr.
get();
124 if (!AccessModeOrErr)
126 M.Perms = AccessModeOrErr.
get();
132 bool Deterministic) {
136 return FDOrErr.takeError();
151 if (!MemberBufferOrErr)
158 M.Buf = std::move(*MemberBufferOrErr);
159 M.MemberName = M.Buf->getBufferIdentifier();
160 if (!Deterministic) {
161 M.ModTime = std::chrono::time_point_cast<std::chrono::seconds>(
162 Status.getLastModificationTime());
164 M.GID =
Status.getGroup();
165 M.Perms =
Status.permissions();
174 unsigned SizeSoFar = OS.
tell() - OldPos;
175 assert(SizeSoFar <=
Size &&
"Data doesn't fit in Size");
225 unsigned UID,
unsigned GID,
unsigned Perms,
uint64_t Size) {
241 unsigned UID,
unsigned GID,
unsigned Perms,
250 unsigned UID,
unsigned GID,
unsigned Perms,
uint64_t Size) {
251 uint64_t PosAfterHeader = Pos + 60 + Name.size();
254 unsigned NameWithPadding = Name.size() + Pad;
257 NameWithPadding +
Size);
266 unsigned UID,
unsigned GID,
unsigned Perms,
270 if (Name.size() <= 16) {
283 Twine(
"failed to convert z/OS member header to EBCDIC: ") +
285 Out << EHeader.
str();
291 unsigned UID,
unsigned GID,
unsigned Perms,
294 unsigned NameLen = Name.size();
314 return Thin || Name.size() >= 16 || Name.contains(
'/');
354 if (Insertion.second) {
362 NamePos = Insertion.first->second;
373 std::vector<uint32_t> SymbolAttrs;
378 std::unique_ptr<SymbolicFile> SymFile =
nullptr;
379 std::string HybridName =
"";
380 std::unique_ptr<MemoryBuffer> NativeBuf =
nullptr;
392 return {{}, {}, std::move(Header), Names, Pad ?
"\n" :
""};
396 using namespace std::chrono;
399 return time_point_cast<seconds>(system_clock::now());
429 assert((OffsetSize == 4 || OffsetSize == 8) &&
"Unsupported OffsetSize");
435 Size += NumSyms * OffsetSize * 2;
437 Size += NumSyms * OffsetSize;
440 Size += StringTableSize;
496 PrevMemberOffset, NextMemberOffset);
498 const char *Name =
"__.SYMDEF";
513 auto computeSymbolTableHeaderSize = [=] {
517 return TmpBuf.
size();
519 uint32_t HeaderSize = computeSymbolTableHeaderSize();
520 uint64_t Size = strlen(
"!<arch>\n") + HeaderSize + SymtabSize;
528 return Size + StringMemberSize;
562 Warn(ObjOrErr.takeError());
569 return ObjOrErr.takeError();
572 return std::move(*ObjOrErr);
576 return ObjOrErr.takeError();
577 return std::move(*ObjOrErr);
582 return SymObj !=
nullptr ? SymObj->
is64Bit() :
false;
594template <
typename AuxiliaryHeader>
599 if (AuxHeader ==
nullptr)
606 if (AuxHeaderSize <
offsetof(AuxiliaryHeader, ModuleType))
611 if (AuxHeader->SecNumOfLoader == 0)
620 std::max(AuxHeader->MaxAlignOfText, AuxHeader->MaxAlignOfData);
646 unsigned NumSyms,
uint64_t PrevMemberOffset = 0,
648 bool Is64Bit =
false) {
661 int64_t HeaderSize =
Size;
674 for (
const MemberData &M : Members) {
676 Pos += M.PreHeadPadSize;
678 Pos += M.Header.size() + M.Data.size() + M.Padding.size();
684 "Incorrect number of symbol attributes!");
685 for (
size_t I = 0,
E = M.Symbols.size();
I !=
E; ++
I) {
692 Pos += M.Header.size() + M.Data.size() + M.Padding.size();
700 if (std::error_code EC =
703 Twine(
"failed to convert z/OS symbol table to EBCDIC: ") +
705 Out << EStringTable.
str();
724 for (
const MemberData &M : Members) {
726 Pos += M.Header.size() + M.Data.size() + M.Padding.size();
734 Out << S.first <<
'\0';
753 Out << S.first <<
'\0';
763 if (Obj.isCOFFImportFile())
772 Triple T(std::move(*TripleStr));
783 if (Obj.isCOFFImportFile())
791 Triple T(std::move(*TripleStr));
809 std::vector<unsigned> Ret;
814 std::map<std::string, uint16_t> *Map =
nullptr;
824 if (
Error E = S.printName(NameStream))
826 if (!Map->try_emplace(Name, Index).second)
829 Ret.push_back(SymNames.
tell());
830 SymNames << Name <<
'\0';
837 Ret.push_back(SymNames.
tell());
838 if (
Error E = S.printName(SymNames))
852 static char PaddingData[8] = {
'\n',
'\n',
'\n',
'\n',
'\n',
'\n',
'\n',
'\n'};
853 static char ZOSPaddingData[8] = {0x15, 0x15, 0x15, 0x15,
854 0x15, 0x15, 0x15, 0x15};
858 std::vector<MemberData> Ret;
859 bool HasObject =
false;
907 bool UniqueTimestamps = Deterministic &&
isDarwin(
Kind);
908 std::map<StringRef, unsigned> FilenameCount;
909 if (UniqueTimestamps) {
911 FilenameCount[M.MemberName]++;
912 for (
auto &Entry : FilenameCount)
913 Entry.second = Entry.second > 1 ? 1 : 0;
920 MemberData &
D = Ret.emplace_back();
921 D.Data = M.Buf->getBuffer();
925 M.Buf->getMemBufferRef(), Context,
Kind, [&](
Error Err) {
926 Warn(createFileError(M.MemberName, std::move(Err)));
930 D.SymFile = std::move(*SymFileOrErr);
932 if (
SymMap &&
D.SymFile.get()) {
934 std::optional<MemoryBufferRef> HybridView;
935 if (COFFObj && (HybridView = COFFObj->findHybridObjectSection())) {
937 D.NativeBuf = COFFObj->stripHybridSection();
938 D.Data =
D.NativeBuf->getBuffer();
941 MemberData &ECData = Ret.emplace_back();
942 ECData.Data = HybridView->getBuffer();
950 ECData.SymFile = std::move(*SymFileOrErr);
953 size_t Pos = M.MemberName.find_last_of(
"/\\");
955 ECData.HybridName = (M.MemberName.substr(0, Pos) +
"obj.arm64ec/" +
956 M.MemberName.substr(Pos))
962 LastZosObjIndex = Ret.size() - 1;
974 bool HaveArm64 =
false, HaveEC =
false;
975 for (
const MemberData &
D : Ret) {
982 if (HaveArm64 && HaveEC) {
995 for (
uint32_t Index = 0, MemberIndex = 0; Index < Ret.size(); ++Index) {
996 MemberData &
D = Ret[Index];
1001 if (!
D.NativeBuf.get())
1013 unsigned MemberPadding =
1016 StringRef MemberName =
D.HybridName.size() ?
D.HybridName : M->MemberName;
1020 uint64_t PaddingBase =
D.Data.size() + MemberPadding;
1022 PaddingBase += MemberName.
size();
1025 MemberPadding + TailPadding);
1028 if (UniqueTimestamps)
1032 ModTime = M->ModTime;
1034 Size += MemberPadding;
1036 std::string StringMsg =
1037 "File " + MemberName.
str() +
" exceeds size limit";
1049 NextMemHeadPadSize =
1054 D.PreHeadPadSize = NextMemHeadPadSize;
1055 Pos +=
D.PreHeadPadSize;
1061 if (Index + 1 != Ret.size()) {
1064 alignTo(NewMembers[MemberIndex].MemberName.
size(), 2);
1065 NextMemHeadPadSize =
1068 OffsetToNextMemData;
1069 NextOffset += NextMemHeadPadSize;
1072 M->Perms,
Size, PrevOffset, NextOffset);
1076 MemberName, ModTime,
Size);
1084 D.Symbols = std::move(*SymbolsOrErr);
1093 D.SymbolAttrs.push_back(
1094 GOFFObj->getZOSSymbolArchiveAttributes(S.getRawDataRefImpl()));
1100 D.SymbolAttrs.resize(
D.Symbols.size());
1111 (SymNames.
tell() == 0)) {
1112 D.Symbols.push_back(0);
1113 D.SymbolAttrs.push_back(0);
1114 SymNames <<
' ' <<
'\0';
1118 Pos +=
D.Header.size() +
D.Data.size() +
D.Padding.size();
1124 SymNames <<
'\0' <<
'\0' <<
'\0';
1125 return std::move(Ret);
1143 if (!PathToOrErr || !DirFromOrErr)
1157 auto FromI = FromTo.first;
1158 auto ToI = FromTo.second;
1162 for (
auto FromE =
sys::path::end(DirFrom); FromI != FromE; ++FromI)
1168 return std::string(Relative);
1175 bool Thin, std::optional<bool> IsEC,
1201 std::vector<MemberData> &
Data = *DataOrErr;
1203 uint64_t StringTableSize = 0;
1204 MemberData StringTableMember;
1207 StringTableSize = StringTableMember.Header.size() +
1208 StringTableMember.Data.
size() +
1209 StringTableMember.Padding.
size();
1213 uint64_t LastMemberEndOffset = 0;
1214 uint64_t LastMemberHeaderOffset = 0;
1215 uint64_t NumSyms = 0;
1216 uint64_t NumSyms32 = 0;
1218 for (
const auto &M :
Data) {
1220 LastMemberEndOffset += M.PreHeadPadSize;
1221 LastMemberHeaderOffset = LastMemberEndOffset;
1223 LastMemberEndOffset += M.Header.size() + M.Data.size() + M.Padding.size();
1224 NumSyms += M.Symbols.size();
1233 NumSyms32 += M.Symbols.size();
1237 std::optional<uint64_t> HeadersSize;
1244 NumSyms, SymNamesBuf.
size(),
1254 uint64_t Sym64Threshold = 1ULL << 32;
1255 const char *Sym64Env = std::getenv(
"SYM64_THRESHOLD");
1262 if (*HeadersSize + LastMemberHeaderOffset >= Sym64Threshold) {
1270 "Archive is too large: ARM64X does not support archives larger "
1283 HeadersSize.reset();
1297 if (ShouldWriteSymtab) {
1300 Kind,
Data.size(), StringTableSize, NumSyms, SymNamesBuf.
size(),
1303 *HeadersSize, NumSyms);
1309 if (StringTableSize)
1310 Out << StringTableMember.Header << StringTableMember.Data
1311 << StringTableMember.Padding;
1316 for (
const MemberData &M :
Data)
1317 Out << M.Header << M.Data << M.Padding;
1320 LastMemberEndOffset += *HeadersSize;
1321 LastMemberHeaderOffset += *HeadersSize;
1325 uint64_t MemberTableNameStrTblSize = 0;
1326 std::vector<size_t> MemberOffsets;
1327 std::vector<StringRef> MemberNames;
1332 MemberTableNameStrTblSize += Member.MemberName.size() + 1;
1333 MemberEndOffset +=
Data[
I].PreHeadPadSize;
1334 MemberOffsets.push_back(MemberEndOffset);
1335 MemberNames.push_back(Member.MemberName);
1340 alignTo(Member.MemberName.size(), 2);
1344 uint64_t MemberTableSize = 20 +
1345 20 * MemberOffsets.size() +
1346 MemberTableNameStrTblSize;
1353 if (ShouldWriteSymtab && NumSyms)
1355 for (
const auto &M :
Data) {
1364 uint64_t MemberTableEndOffset =
1365 LastMemberEndOffset +
1371 uint64_t GlobalSymbolOffset =
1372 (ShouldWriteSymtab &&
1374 ? MemberTableEndOffset
1377 uint64_t GlobalSymbolOffset64 = 0;
1378 uint64_t NumSyms64 = NumSyms - NumSyms32;
1381 if (GlobalSymbolOffset == 0)
1382 GlobalSymbolOffset64 = MemberTableEndOffset;
1386 GlobalSymbolOffset64 =
1388 (NumSyms32 + 1) * 8 +
alignTo(SymNamesBuf32.
size(), 2);
1401 Data[0].PreHeadPadSize
1410 for (
const MemberData &M :
Data) {
1411 Out << std::string(M.PreHeadPadSize,
'\0');
1412 Out << M.Header << M.Data;
1413 if (M.Data.size() % 2)
1417 if (NewMembers.
size()) {
1420 MemberTableSize, LastMemberHeaderOffset,
1421 GlobalSymbolOffset ? GlobalSymbolOffset
1422 : GlobalSymbolOffset64);
1424 for (uint64_t MemberOffset : MemberOffsets)
1427 for (
StringRef MemberName : MemberNames)
1428 Out << MemberName <<
'\0';
1430 if (MemberTableNameStrTblSize % 2)
1434 if (ShouldWriteSymtab) {
1436 if (GlobalSymbolOffset) {
1438 *HeadersSize, NumSyms32, LastMemberEndOffset,
1439 GlobalSymbolOffset64);
1441 if (GlobalSymbolOffset64 && (SymNamesBuf32.
size() % 2))
1446 if (GlobalSymbolOffset64)
1448 *HeadersSize, NumSyms64,
1449 GlobalSymbolOffset ? GlobalSymbolOffset
1450 : LastMemberEndOffset,
1465 bool Deterministic,
bool Thin,
1466 std::unique_ptr<MemoryBuffer> OldArchiveBuf,
1475 Deterministic, Thin, IsEC, Warn)) {
1476 if (
Error DiscardError = Temp->discard())
1477 return joinErrors(std::move(E), std::move(DiscardError));
1491 OldArchiveBuf.reset();
1493 return Temp->keep(ArcName);
1499 bool Deterministic,
bool Thin,
1506 Deterministic, Thin, std::nullopt, Warn))
1507 return std::move(E);
1509 return std::make_unique<SmallVectorMemoryBuffer>(
1510 std::move(ArchiveBufferVector),
false);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
static void printZOSMemberHeader(raw_ostream &Out, StringRef Name, const sys::TimePoint< std::chrono::seconds > &ModTime, unsigned UID, unsigned GID, unsigned Perms, uint64_t Size)
static void printNBits(raw_ostream &Out, object::Archive::Kind Kind, uint64_t Val)
bool isImportDescriptor(StringRef Name)
static sys::TimePoint< std::chrono::seconds > now(bool Deterministic)
static bool isDarwin(object::Archive::Kind Kind)
static uint64_t computeECSymbolsSize(SymMap &SymMap, uint32_t *Padding=nullptr)
static Expected< std::vector< unsigned > > getSymbols(SymbolicFile *Obj, uint16_t Index, raw_ostream &SymNames, SymMap *SymMap)
static bool is64BitSymbolicFile(const SymbolicFile *SymObj)
static void printMemberHeader(raw_ostream &Out, uint64_t Pos, raw_ostream &StringTable, StringMap< uint64_t > &MemberNames, object::Archive::Kind Kind, bool Thin, const NewArchiveMember &M, StringRef MemberName, sys::TimePoint< std::chrono::seconds > ModTime, uint64_t Size)
static uint64_t computeHeadersSize(object::Archive::Kind Kind, uint64_t NumMembers, uint64_t StringMemberSize, uint64_t NumSyms, uint64_t SymNamesSize, SymMap *SymMap)
static bool isBSDLike(object::Archive::Kind Kind)
static void printBSDMemberHeader(raw_ostream &Out, uint64_t Pos, StringRef Name, const sys::TimePoint< std::chrono::seconds > &ModTime, unsigned UID, unsigned GID, unsigned Perms, uint64_t Size)
static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind, bool Deterministic, ArrayRef< MemberData > Members, StringRef StringTable, uint64_t MembersOffset, unsigned NumSyms, uint64_t PrevMemberOffset=0, uint64_t NextMemberOffset=0, bool Is64Bit=false)
static const uint32_t MinBigArchiveMemDataAlign
static void writeSymbolMap(raw_ostream &Out, object::Archive::Kind Kind, bool Deterministic, ArrayRef< MemberData > Members, SymMap &SymMap, uint64_t MembersOffset)
static MemberData computeStringTable(StringRef Names)
uint16_t getAuxMaxAlignment(uint16_t AuxHeaderSize, AuxiliaryHeader *AuxHeader, uint16_t Log2OfMaxAlign)
static const uint32_t Log2OfAIXPageSize
static bool isZOSArchive(object::Archive::Kind Kind)
static bool isECObject(object::SymbolicFile &Obj)
static Expected< std::unique_ptr< SymbolicFile > > getSymbolicFile(MemoryBufferRef Buf, LLVMContext &Context, object::Archive::Kind Kind, function_ref< void(Error)> Warn)
static bool isAIXBigArchive(object::Archive::Kind Kind)
static void writeSymbolTableHeader(raw_ostream &Out, object::Archive::Kind Kind, bool Deterministic, uint64_t Size, uint64_t PrevMemberOffset=0, uint64_t NextMemberOffset=0)
static void printRestOfMemberHeader(raw_ostream &Out, const sys::TimePoint< std::chrono::seconds > &ModTime, unsigned UID, unsigned GID, unsigned Perms, uint64_t Size)
static uint64_t computeSymbolTableSize(object::Archive::Kind Kind, uint64_t NumSyms, uint64_t OffsetSize, uint64_t StringTableSize, uint32_t *Padding=nullptr)
static bool isArchiveSymbol(const object::BasicSymbolRef &S)
static bool isCOFFArchive(object::Archive::Kind Kind)
static Expected< std::vector< MemberData > > computeMemberData(raw_ostream &StringTable, raw_ostream &SymNames, object::Archive::Kind Kind, bool Thin, bool Deterministic, SymtabWritingMode NeedSymbols, SymMap *SymMap, LLVMContext &Context, ArrayRef< NewArchiveMember > NewMembers, std::optional< bool > IsEC, function_ref< void(Error)> Warn)
static void writeECSymbols(raw_ostream &Out, object::Archive::Kind Kind, bool Deterministic, ArrayRef< MemberData > Members, SymMap &SymMap)
static uint64_t computeSymbolMapSize(uint64_t NumObj, SymMap &SymMap, uint32_t *Padding=nullptr)
static void printLE(raw_ostream &Out, T Val)
static void printGNUSmallMemberHeader(raw_ostream &Out, StringRef Name, const sys::TimePoint< std::chrono::seconds > &ModTime, unsigned UID, unsigned GID, unsigned Perms, uint64_t Size)
static bool useStringTable(bool Thin, StringRef Name)
static bool is64BitKind(object::Archive::Kind Kind)
static uint32_t getMemberAlignment(SymbolicFile *SymObj)
static void printBigArchiveMemberHeader(raw_ostream &Out, StringRef Name, const sys::TimePoint< std::chrono::seconds > &ModTime, unsigned UID, unsigned GID, unsigned Perms, uint64_t Size, uint64_t PrevOffset, uint64_t NextOffset)
static void printWithSpacePadding(raw_ostream &OS, T Data, unsigned Size)
static bool isAnyArm64COFF(object::SymbolicFile &Obj)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define offsetof(TYPE, MEMBER)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
Represents either an error or a value T.
std::error_code getError() const
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
This is an important class for using LLVM in a threaded context.
StringRef getBuffer() const
This interface provides simple read-only access to a block of memory, and provides simple methods for...
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Given an already-open file descriptor, read the file and return a MemoryBuffer.
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef str() const
Explicit conversion to StringRef.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Represent a constant reference to a string, i.e.
static constexpr size_t npos
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
std::string str() const
Get the contents as an std::string.
constexpr size_t size() const
Get the string size.
A table of densely packed, null-terminated strings indexed by offset.
constexpr size_t size() const
Returns the byte size of the table.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
An efficient, type-erasing, non-owning reference to a callable.
Expected< unsigned > getGID() const
LLVM_ABI Expected< MemoryBufferRef > getMemoryBufferRef() const
Expected< unsigned > getUID() const
Expected< sys::fs::perms > getAccessMode() const
Expected< sys::TimePoint< std::chrono::seconds > > getLastModified() const
static object::Archive::Kind getDefaultKind()
static object::Archive::Kind getDefaultKindForTriple(const Triple &T)
static const uint64_t MaxMemberSize
Size field is 10 decimal digits long.
This is a value type class that represents a single symbol in the list of symbols in the object file.
Expected< uint32_t > getFlags() const
Get symbol flags (bitwise OR of SymbolRef::Flags)
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
static Expected< std::unique_ptr< SymbolicFile > > createSymbolicFile(MemoryBufferRef Object, llvm::file_magic Type, LLVMContext *Context, bool InitContent=true)
virtual bool is64Bit() const =0
static bool isSymbolicFile(file_magic Type, const LLVMContext *Context)
const XCOFFAuxiliaryHeader32 * auxiliaryHeader32() const
const XCOFFFileHeader64 * fileHeader64() const
const XCOFFFileHeader32 * fileHeader32() const
const XCOFFAuxiliaryHeader64 * auxiliaryHeader64() const
bool is64Bit() const override
A raw_ostream that writes to a file descriptor.
This class implements an extremely fast bulk output stream that can only output to a stream.
uint64_t tell() const
tell - Return the current offset with the file.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
A raw_ostream that writes to an std::string.
A raw_ostream that writes to an SmallVector or SmallString.
static LLVM_ABI Expected< TempFile > create(const Twine &Model, unsigned Mode=all_read|all_write, OpenFlags ExtraFlags=OF_None)
This creates a temporary file with createUniqueFile and schedules it for deletion with sys::RemoveFil...
Represents the result of a call to sys::fs::status().
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_FILE_MACHINE_ARM64
bool isAnyArm64(T Machine)
LLVM_ABI std::error_code convertToEBCDIC(StringRef Source, SmallVectorImpl< char > &Result)
constexpr std::string_view NullImportDescriptorSymbolName
const char ZOSArchiveMagic[]
constexpr std::string_view NullThunkDataPrefix
constexpr std::string_view NullThunkDataSuffix
constexpr std::string_view ImportDescriptorPrefix
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
LLVM_ABI std::error_code closeFile(file_t &F)
Close the file object.
LLVM_ABI const file_t kInvalidFile
LLVM_ABI Expected< file_t > openNativeFileForRead(const Twine &Name, OpenFlags Flags=OF_None, SmallVectorImpl< char > *RealPath=nullptr)
Opens the file with the given name in a read-only mode, returning its open file descriptor.
LLVM_ABI std::error_code make_absolute(SmallVectorImpl< char > &path)
Make path an absolute path.
LLVM_ABI std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
LLVM_ABI const_iterator begin(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get begin iterator over path.
LLVM_ABI bool remove_dots(SmallVectorImpl< char > &path, bool remove_dot_dot=false, Style style=Style::native)
Remove '.
LLVM_ABI StringRef parent_path(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get parent path.
LLVM_ABI std::string convert_to_slash(StringRef path, Style style=Style::native)
Replaces backslashes with slashes if Windows.
LLVM_ABI StringRef root_name(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get root name.
LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
LLVM_ABI const_iterator end(StringRef path LLVM_LIFETIME_BOUND)
Get end iterator over path.
std::chrono::time_point< std::chrono::system_clock, D > TimePoint
A time point on the system clock.
TimePoint< std::chrono::seconds > toTimePoint(std::time_t T)
Convert a std::time_t to a TimePoint.
std::time_t toTimeT(TimePoint<> TP)
Convert a TimePoint to std::time_t.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
LLVM_ABI void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
LLVM_ABI Expected< std::unique_ptr< MemoryBuffer > > writeArchiveToBuffer(ArrayRef< NewArchiveMember > NewMembers, SymtabWritingMode WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, function_ref< void(Error)> Warn=warnToStderr)
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
LLVM_ABI Error writeArchive(StringRef ArcName, ArrayRef< NewArchiveMember > NewMembers, SymtabWritingMode WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, std::unique_ptr< MemoryBuffer > OldArchiveBuf=nullptr, std::optional< bool > IsEC=std::nullopt, function_ref< void(Error)> Warn=warnToStderr)
std::error_code make_error_code(BitcodeError E)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI Expected< std::string > getBitcodeTargetTriple(MemoryBufferRef Buffer)
Read the header of the specified bitcode buffer and extract just the triple information.
auto dyn_cast_or_null(const Y &Val)
Error joinErrors(Error E1, Error E2)
Concatenate errors.
constexpr T alignToPowerOf2(U Value, V Align)
Will overflow only if result is not representable in T.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
uint64_t offsetToAlignment(uint64_t Value, Align Alignment)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_ABI void warnToStderr(Error Err)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI Expected< std::string > computeArchiveRelativePath(StringRef From, StringRef To)
LLVM_ABI Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
static ErrorOr< SmallString< 128 > > canonicalizePath(StringRef P)
std::error_code errnoAsErrorCode()
Helper to get errno as an std::error_code.
LLVM_ABI Error writeArchiveToStream(raw_ostream &Out, ArrayRef< NewArchiveMember > NewMembers, SymtabWritingMode WriteSymtab, object::Archive::Kind Kind, bool Deterministic, bool Thin, std::optional< bool > IsEC=std::nullopt, function_ref< void(Error)> Warn=warnToStderr)
void consumeError(Error Err)
Consume a Error without doing anything.
std::map< std::string, uint16_t > ECMap
std::map< std::string, uint16_t > Map
This struct is a compact representation of a valid (non-zero power of two) alignment.
LLVM_ABI object::Archive::Kind detectKindFromObject() const
NewArchiveMember()=default
static LLVM_ABI Expected< NewArchiveMember > getFile(StringRef FileName, bool Deterministic)
static LLVM_ABI Expected< NewArchiveMember > getOldMember(const object::Archive::Child &OldMember, bool Deterministic)
std::unique_ptr< MemoryBuffer > Buf
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...