41#if !defined(_MSC_VER) && !defined(__MINGW32__)
52 std::map<std::string, uint16_t>
Map;
53 std::map<std::string, uint16_t>
ECMap;
58 MemberName(BufRef.getBufferIdentifier()) {}
61 auto MemBufferRef = this->
Buf->getMemBufferRef();
66 if (isa<object::MachOObjectFile>(**OptionalObject))
68 if (isa<object::XCOFFObjectFile>(**OptionalObject))
70 if (isa<object::COFFObjectFile>(**OptionalObject) ||
71 isa<object::COFFImportFile>(**OptionalObject))
85 auto &IRObject = cast<object::IRObjectFile>(**ObjOrErr);
86 auto TargetTriple =
Triple(IRObject.getTargetTriple());
106 M.MemberName = M.Buf->getBufferIdentifier();
107 if (!Deterministic) {
110 return ModTimeOrErr.takeError();
111 M.ModTime = ModTimeOrErr.get();
115 M.UID = UIDOrErr.
get();
119 M.GID = GIDOrErr.
get();
121 if (!AccessModeOrErr)
123 M.Perms = AccessModeOrErr.
get();
129 bool Deterministic) {
133 return FDOrErr.takeError();
148 if (!MemberBufferOrErr)
155 M.Buf = std::move(*MemberBufferOrErr);
156 M.MemberName = M.Buf->getBufferIdentifier();
157 if (!Deterministic) {
158 M.ModTime = std::chrono::time_point_cast<std::chrono::seconds>(
159 Status.getLastModificationTime());
161 M.GID =
Status.getGroup();
162 M.Perms =
Status.permissions();
171 unsigned SizeSoFar =
OS.
tell() - OldPos;
172 assert(SizeSoFar <=
Size &&
"Data doesn't fit in Size");
217 unsigned UID,
unsigned GID,
unsigned Perms,
uint64_t Size) {
233 unsigned UID,
unsigned GID,
unsigned Perms,
242 unsigned UID,
unsigned GID,
unsigned Perms,
uint64_t Size) {
246 unsigned NameWithPadding =
Name.size() + Pad;
249 NameWithPadding +
Size);
252 Out.
write(uint8_t(0));
258 unsigned UID,
unsigned GID,
unsigned Perms,
261 unsigned NameLen =
Name.size();
275 Out.
write(uint8_t(0));
281 return Thin ||
Name.size() >= 16 ||
Name.contains(
'/');
313 NamePos = StringTable.tell();
314 StringTable << M.MemberName <<
"/\n";
317 if (Insertion.second) {
318 Insertion.first->second = StringTable.tell();
319 StringTable << M.MemberName;
323 StringTable <<
"/\n";
325 NamePos = Insertion.first->second;
333 std::vector<unsigned> Symbols;
338 std::unique_ptr<SymbolicFile> SymFile =
nullptr;
351 return {{}, std::move(Header), Names, Pad ?
"\n" :
""};
355 using namespace std::chrono;
358 return time_point_cast<seconds>(system_clock::now());
379 print<uint64_t>(Out,
Kind, Val);
381 print<uint32_t>(Out,
Kind, Val);
388 assert((OffsetSize == 4 || OffsetSize == 8) &&
"Unsupported OffsetSize");
391 Size += NumSyms * OffsetSize * 2;
393 Size += NumSyms * OffsetSize;
396 Size += StringTableSize;
452 PrevMemberOffset, NextMemberOffset);
466 auto computeSymbolTableHeaderSize = [=] {
470 return TmpBuf.
size();
472 uint32_t HeaderSize = computeSymbolTableHeaderSize();
473 uint64_t Size = strlen(
"!<arch>\n") + HeaderSize + SymtabSize;
481 return Size + StringMemberSize;
515 Warn(ObjOrErr.takeError());
521 return ObjOrErr.takeError();
524 return std::move(*ObjOrErr);
528 return ObjOrErr.takeError();
529 return std::move(*ObjOrErr);
534 return SymObj !=
nullptr ? SymObj->
is64Bit() :
false;
546template <
typename AuxiliaryHeader>
551 if (AuxHeader ==
nullptr)
558 if (AuxHeaderSize <
offsetof(AuxiliaryHeader, ModuleType))
563 if (AuxHeader->SecNumOfLoader == 0)
572 std::max(AuxHeader->MaxAlignOfText, AuxHeader->MaxAlignOfData);
598 unsigned NumSyms,
uint64_t PrevMemberOffset = 0,
600 bool Is64Bit =
false) {
609 StringTable.size(), &Pad);
619 for (
const MemberData &M : Members) {
621 Pos += M.PreHeadPadSize;
623 Pos += M.Header.size() + M.Data.size() + M.Padding.size();
628 for (
unsigned StringOffset : M.Symbols) {
633 Pos += M.Header.size() + M.Data.size() + M.Padding.size();
642 Out.
write(uint8_t(0));
654 printLE<uint32_t>(Out, Members.
size());
655 for (
const MemberData &M : Members) {
657 Pos += M.Header.size() + M.Data.size() + M.Padding.size();
660 printLE<uint32_t>(Out,
SymMap.
Map.size());
665 Out << S.first <<
'\0';
668 Out.
write(uint8_t(0));
684 Out << S.first <<
'\0';
686 Out.
write(uint8_t(0));
691 return cast<llvm::object::COFFObjectFile>(&Obj)->getMachine() !=
695 return cast<llvm::object::COFFImportFile>(&Obj)->getMachine() !=
740 std::vector<unsigned> Ret;
745 std::map<std::string, uint16_t> *Map =
nullptr;
755 if (
Error E = S.printName(NameStream))
757 if (Map->find(
Name) != Map->end())
761 Ret.push_back(SymNames.
tell());
762 SymNames <<
Name <<
'\0';
769 Ret.push_back(SymNames.
tell());
770 if (
Error E = S.printName(SymNames))
784 static char PaddingData[8] = {
'\n',
'\n',
'\n',
'\n',
'\n',
'\n',
'\n',
'\n'};
789 std::vector<MemberData> Ret;
790 bool HasObject =
false;
838 bool UniqueTimestamps = Deterministic &&
isDarwin(
Kind);
839 std::map<StringRef, unsigned> FilenameCount;
840 if (UniqueTimestamps) {
842 FilenameCount[M.MemberName]++;
843 for (
auto &Entry : FilenameCount)
844 Entry.second = Entry.second > 1 ? 1 : 0;
847 std::vector<std::unique_ptr<SymbolicFile>> SymFiles;
852 M.Buf->getMemBufferRef(), Context,
Kind, [&](
Error Err) {
853 Warn(createFileError(M.MemberName, std::move(Err)));
857 SymFiles.push_back(std::move(*SymFileOrErr));
869 bool HaveArm64 =
false, HaveEC =
false;
870 for (std::unique_ptr<SymbolicFile> &SymFile : SymFiles) {
877 if (HaveArm64 && HaveEC) {
902 unsigned MemberPadding =
904 unsigned TailPadding =
909 if (UniqueTimestamps)
913 ModTime = M->ModTime;
917 std::string StringMsg =
918 "File " + M->MemberName.str() +
" exceeds size limit";
919 return make_error<object::GenericBinaryError>(
923 std::unique_ptr<SymbolicFile> CurSymFile;
924 if (!SymFiles.empty())
925 CurSymFile = std::move(SymFiles[
Index]);
931 alignTo(M->MemberName.size(), 2);
933 if (M == NewMembers.
begin())
939 MemHeadPadSize = NextMemHeadPadSize;
940 Pos += MemHeadPadSize;
946 if (
Index + 1 != SymFiles.size()) {
954 NextOffset += NextMemHeadPadSize;
957 M->Perms,
Size, PrevOffset, NextOffset);
965 std::vector<unsigned> Symbols;
971 Symbols = std::move(*SymbolsOrErr);
976 Pos += Header.size() +
Data.size() + Padding.size();
977 Ret.push_back({std::move(Symbols), std::move(Header),
Data, Padding,
978 MemHeadPadSize, std::move(CurSymFile)});
984 SymNames <<
'\0' <<
'\0' <<
'\0';
985 return std::move(Ret);
1003 if (!PathToOrErr || !DirFromOrErr)
1017 auto FromI = FromTo.first;
1018 auto ToI = FromTo.second;
1022 for (
auto FromE =
sys::path::end(DirFrom); FromI != FromE; ++FromI)
1028 return std::string(Relative);
1035 bool Thin, std::optional<bool> IsEC,
1057 StringTable, SymNames,
Kind, Thin, Deterministic, WriteSymtab,
1061 std::vector<MemberData> &
Data = *DataOrErr;
1064 MemberData StringTableMember;
1067 StringTableSize = StringTableMember.Header.size() +
1068 StringTableMember.Data.size() +
1069 StringTableMember.Padding.size();
1074 uint64_t LastMemberHeaderOffset = 0;
1078 for (
const auto &M :
Data) {
1080 LastMemberEndOffset += M.PreHeadPadSize;
1081 LastMemberHeaderOffset = LastMemberEndOffset;
1083 LastMemberEndOffset += M.Header.size() + M.Data.size() + M.Padding.size();
1084 NumSyms += M.Symbols.size();
1093 NumSyms32 += M.Symbols.size();
1097 std::optional<uint64_t> HeadersSize;
1104 NumSyms, SymNamesBuf.
size(),
1114 uint64_t Sym64Threshold = 1ULL << 32;
1115 const char *Sym64Env = std::getenv(
"SYM64_THRESHOLD");
1122 if (*HeadersSize + LastMemberHeaderOffset >= Sym64Threshold) {
1127 HeadersSize.reset();
1139 if (ShouldWriteSymtab) {
1142 Kind,
Data.size(), StringTableSize, NumSyms, SymNamesBuf.
size(),
1145 *HeadersSize, NumSyms);
1151 if (StringTableSize)
1152 Out << StringTableMember.Header << StringTableMember.Data
1153 << StringTableMember.Padding;
1158 for (
const MemberData &M :
Data)
1159 Out << M.Header << M.Data << M.Padding;
1162 LastMemberEndOffset += *HeadersSize;
1163 LastMemberHeaderOffset += *HeadersSize;
1167 uint64_t MemberTableNameStrTblSize = 0;
1168 std::vector<size_t> MemberOffsets;
1169 std::vector<StringRef> MemberNames;
1174 MemberTableNameStrTblSize += Member.MemberName.size() + 1;
1175 MemberEndOffset +=
Data[
I].PreHeadPadSize;
1176 MemberOffsets.push_back(MemberEndOffset);
1177 MemberNames.push_back(Member.MemberName);
1182 alignTo(Member.MemberName.size(), 2);
1187 20 * MemberOffsets.size() +
1188 MemberTableNameStrTblSize;
1195 if (ShouldWriteSymtab && NumSyms)
1197 for (
const auto &M :
Data) {
1207 LastMemberEndOffset +
1214 (ShouldWriteSymtab &&
1216 ? MemberTableEndOffset
1220 uint64_t NumSyms64 = NumSyms - NumSyms32;
1223 if (GlobalSymbolOffset == 0)
1224 GlobalSymbolOffset64 = MemberTableEndOffset;
1228 GlobalSymbolOffset64 =
1230 (NumSyms32 + 1) * 8 +
alignTo(SymNamesBuf32.
size(), 2);
1243 Data[0].PreHeadPadSize
1252 for (
const MemberData &M :
Data) {
1253 Out << std::string(M.PreHeadPadSize,
'\0');
1254 Out << M.Header << M.Data;
1255 if (M.Data.size() % 2)
1259 if (NewMembers.
size()) {
1262 MemberTableSize, LastMemberHeaderOffset,
1263 GlobalSymbolOffset ? GlobalSymbolOffset
1264 : GlobalSymbolOffset64);
1266 for (
uint64_t MemberOffset : MemberOffsets)
1269 for (
StringRef MemberName : MemberNames)
1270 Out << MemberName <<
'\0';
1272 if (MemberTableNameStrTblSize % 2)
1276 if (ShouldWriteSymtab) {
1278 if (GlobalSymbolOffset) {
1280 *HeadersSize, NumSyms32, LastMemberEndOffset,
1281 GlobalSymbolOffset64);
1283 if (GlobalSymbolOffset64 && (SymNamesBuf32.
size() % 2))
1288 if (GlobalSymbolOffset64)
1290 *HeadersSize, NumSyms64,
1291 GlobalSymbolOffset ? GlobalSymbolOffset
1292 : LastMemberEndOffset,
1307 bool Deterministic,
bool Thin,
1308 std::unique_ptr<MemoryBuffer> OldArchiveBuf,
1317 Deterministic, Thin, IsEC, Warn)) {
1318 if (
Error DiscardError = Temp->discard())
1319 return joinErrors(std::move(E), std::move(DiscardError));
1333 OldArchiveBuf.reset();
1335 return Temp->keep(ArcName);
1341 bool Deterministic,
bool Thin,
1348 Deterministic, Thin, std::nullopt, Warn))
1349 return std::move(E);
1351 return std::make_unique<SmallVectorMemoryBuffer>(
1352 std::move(ArchiveBufferVector),
false);
This file defines the StringMap class.
#define offsetof(TYPE, MEMBER)
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 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 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 printMemberHeader(raw_ostream &Out, uint64_t Pos, raw_ostream &StringTable, StringMap< uint64_t > &MemberNames, object::Archive::Kind Kind, bool Thin, const NewArchiveMember &M, sys::TimePoint< std::chrono::seconds > ModTime, uint64_t Size)
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)
BlockVerifier::State From
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - 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.
size_t getBufferSize() const
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...
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.
StringRef - Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
constexpr size_t size() const
size - Get the string size.
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
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 getDefaultKindForTriple(Triple &T)
static object::Archive::Kind getDefaultKind()
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)
bool isCOFFImportFile() const
MemoryBufferRef getMemoryBufferRef() const
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
basic_symbol_iterator_range symbols() const
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 & write(unsigned char C)
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 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)
constexpr std::string_view NullImportDescriptorSymbolName
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.
void make_absolute(const Twine ¤t_directory, SmallVectorImpl< char > &path)
Make path an absolute path.
const file_t kInvalidFile
std::error_code closeFile(file_t &F)
Close the file object.
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
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.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
const_iterator end(StringRef path)
Get end iterator over path.
bool remove_dots(SmallVectorImpl< char > &path, bool remove_dot_dot=false, Style style=Style::native)
In-place remove any '.
StringRef root_name(StringRef path, Style style=Style::native)
Get root name.
StringRef parent_path(StringRef path, Style style=Style::native)
Get parent path.
std::string convert_to_slash(StringRef path, Style style=Style::native)
Replaces backslashes with slashes if Windows.
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to 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.
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
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.
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)
Expected< std::string > getBitcodeTargetTriple(MemoryBufferRef Buffer)
Read the header of the specified bitcode buffer and extract just the triple information.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr)
Error joinErrors(Error E1, Error E2)
Concatenate errors.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
constexpr T alignToPowerOf2(U Value, V Align)
Will overflow only if result is not representable in T.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
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...
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void warnToStderr(Error Err)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Expected< std::string > computeArchiveRelativePath(StringRef From, StringRef To)
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.
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.
object::Archive::Kind detectKindFromObject() const
NewArchiveMember()=default
static Expected< NewArchiveMember > getFile(StringRef FileName, bool Deterministic)
static 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)...