1//===- Archive.cpp - ar File Format implementation ------------------------===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 9// This file defines the ArchiveObjectFile class. 11//===----------------------------------------------------------------------===// 35#include <system_error> 41void Archive::anchor() {}
44 std::string StringMsg =
"truncated or malformed archive (" + Msg.
str() +
")";
45return make_error<GenericBinaryError>(std::move(StringMsg),
52StringRef Msg(
"remaining size of archive too small for next archive " 64template <
class T, std::
size_t N>
88returnreinterpret_cast<constchar *
>(ArMemHdr) - Parent->getData().data();
95constchar *RawHeaderPtr,
99if (RawHeaderPtr ==
nullptr)
114 std::string Msg(
"terminator characters in archive member \"" + Buf +
115"\" not the correct \"`\\n\" values for the archive " 130constchar *RawHeaderPtr,
134if (RawHeaderPtr ==
nullptr)
140 *Err =
malformedError(
"malformed AIX big archive: remaining buffer is " 141"unable to contain next archive member");
148 *Err = std::move(SubErr);
152// This gets the raw name from the ArMemHdr->Name field and checks that it is 153// valid for the kind of archive. If it is not valid it returns an Error. 161returnmalformedError(
"name contains a leading space for archive member " 175// Don't include the EndCond if there is one. 187" field in archive member header are not " 188"all decimal numbers: '" +
191"member header at offset " +
205" field in archive member header are not " 206"all octal numbers: '" +
209"member header at offset " +
223// If the name length is odd, pad with '\0' to get an even length. After 224// padding, there is the name terminator "`\n". 229if (!NameStringWithNameTerminator.
ends_with(NameTerminator)) {
231reinterpret_cast<constchar *
>(
ArMemHdr->
Name + NameLenWithPadding) -
235"name does not have name terminator \"`\\n\" for archive member" 242// member including the header, so the size of any name following the header 243// is checked to make sure it does not overflow. 246// This can be called from the ArchiveMemberHeader constructor when the 247// archive header is truncated to produce an error message with the name. 248// Make sure the name field is not truncated. 252returnmalformedError(
"archive header truncated before the name field " 253"for archive member header at offset " +
254Twine(ArchiveOffset));
257// The raw name itself can be invalid. 263// Check if it's a special name. 265if (
Name.size() == 1)
// Linker member. 267if (
Name.size() == 2 &&
Name[1] ==
'/')
// String table. 269// System libraries from the Windows SDK for Windows 11 contain this symbol. 270// It looks like a CFG guard: we just skip it for now. 271if (
Name ==
"/<XFGHASHMAP>/")
273// Some libraries (e.g., arm64rt.lib) from the Windows WDK 274// (version 10.0.22000.0) contain this undocumented special member. 275if (
Name ==
"/<ECSYMBOLS>/")
278// Get the string table offset. 279 std::size_t StringOffset;
280if (
Name.substr(1).rtrim(
' ').getAsInteger(10, StringOffset)) {
287returnmalformedError(
"long name offset characters after the '/' are " 288"not all decimal numbers: '" +
289 Buf +
"' for archive member header at offset " +
290Twine(ArchiveOffset));
298" past the end of the string table for archive " 299"member header at offset " +
300Twine(ArchiveOffset));
303// GNU long file names end with a "/\n". 310Twine(StringOffset) +
"not terminated");
317if (
Name.starts_with(
"#1/")) {
319if (
Name.substr(3).rtrim(
' ').getAsInteger(10, NameLength)) {
326returnmalformedError(
"long name length characters after the #1/ are " 327"not all decimal numbers: '" +
328 Buf +
"' for archive member header at offset " +
329Twine(ArchiveOffset));
335" extends past the end of the member or archive " 336"for archive member header at offset " +
337Twine(ArchiveOffset));
344// It is not a long name so trim the blanks at the end of the name. 346returnName.rtrim(
' ');
348// It's a simple name. 349returnName.drop_back(1);
371return *SizeOrErr +
alignTo(*NameLenOrErr, 2);
440// If Size is odd, add 1 to make it even. 463 : Parent(Parent),
Data(
Data), StartOfFile(StartOfFile) {
481// If we are pointed to real data, Start is not a nullptr, then there must be 482// a non-null Err pointer available to report malformed data on. Only in 483// the case sentinel value is being constructed is Err is permitted to be a 485assert(Err &&
"Err can't be nullptr if Start is not a nullptr");
489// If there was an error in the construction of the Header 490// then just return with the error now set. 512// Setup StartOfFile and PaddingBytes. 513 StartOfFile = Header->getSizeOf();
514// Don't include attached name. 523// The actual start of the file is after the name and any necessary 524// even-alignment padding. 525 StartOfFile += ((
Name.size() + 1) >> 1) << 1;
526 }
elseif (
Name.starts_with(
"#1/")) {
531 *Err =
malformedError(
"long name length characters after the #1/ are " 532"not all decimal numbers: '" +
534"' for archive member header at offset " +
544return Header->getSize();
545returnData.size() - StartOfFile;
549return Header->getSize();
552Expected<bool> Archive::Child::isThinMember()
const{
return Header->isThin(); }
564return std::string(
Name);
567 Parent->getMemoryBufferRef().getBufferIdentifier());
569return std::string(FullName);
580returnSize.takeError();
586const std::string &FullName = *FullNameOrErr;
588if (std::error_code EC = Buf.
getError())
590 Parent->ThinBuffers.push_back(std::move(*Buf));
591return Parent->ThinBuffers.back()->getBuffer();
599constchar *NextLoc = *NextLocOrErr;
601// Check to see if this is at the end of the archive. 602if (NextLoc ==
nullptr)
603returnChild(
nullptr,
nullptr,
nullptr);
605// Check to see if this is past the end of the archive. 606if (NextLoc > Parent->Data.getBufferEnd()) {
607 std::string Msg(
"offset to next archive member past the end of the archive " 619Child Ret(Parent, NextLoc, &Err);
621return std::move(Err);
626constchar *a = Parent->Data.getBuffer().data();
627constchar *c =
Data.data();
638 Header->getName(Header->getSizeOf() + RawSize);
664return std::move(*BinaryOrErr);
665return BinaryOrErr.takeError();
670 std::unique_ptr<Archive> Ret;
674 Ret = std::make_unique<BigArchive>(Source, Err);
676 Ret = std::make_unique<Archive>(Source, Err);
679return std::move(Err);
680return std::move(Ret);
683std::unique_ptr<AbstractArchiveMemberHeader>
688return std::make_unique<ArchiveMemberHeader>(
this, RawHeaderPtr,
Size, Err);
689return std::make_unique<BigArchiveMemberHeader>(
this, RawHeaderPtr,
Size,
704 FirstRegularData =
C.Data;
705 FirstRegularStartOfFile =
C.StartOfFile;
712// Check for sufficient magic. 722 Err = make_error<GenericBinaryError>(
"file too small to be an archive",
727// Make sure Format is initialized before any call to 728// ArchiveMemberHeader::getName() is made. This could be a valid empty 729// archive which is the same in all formats. So claiming it to be gnu to is 730// fine if not totally correct before we look for a string table or table of 734// Get the special members. 740// See if this is a valid empty archive and if so return. 747auto Increment = [&]() {
762// Below is the pattern that is used to figure out the archive format 764// First member : / (may exist, if it exists, points to the symbol table ) 765// Second member : // (may exist, if it exists, points to the string table) 766// Note : The string table is used if the filename exceeds 15 characters 768// First member : __.SYMDEF or "__.SYMDEF SORTED" (the symbol table) 769// There is no string table, if the filename exceeds 15 characters or has a 770// embedded space, the filename has #1/<size>, The size represents the size 771// of the filename that needs to be read after the archive header 772// COFF archive format 774// Second member : / (provides a directory of symbols) 775// Third member : // (may exist, if it exists, contains the string table) 776// Note: Microsoft PE/COFF Spec 8.3 says that the third member is present 777// even if the string table is empty. However, lib.exe does not in fact 778// seem to create the third member if there's no member whose filename 779// exceeds 15 characters. So the third member is optional. 781if (
Name ==
"__.SYMDEF" ||
Name ==
"__.SYMDEF_64") {
782if (
Name ==
"__.SYMDEF")
784else// Name == "__.SYMDEF_64" 786// We know that the symbol table is not an external file, but we still must 787// check any Expected<> return value. 802if (
Name.starts_with(
"#1/")) {
804// We know this is BSD, so getName will work since there is no string table. 811if (
Name ==
"__.SYMDEF SORTED" ||
Name ==
"__.SYMDEF") {
812// We know that the symbol table is not an external file, but we still 813// must check any Expected<> return value. 822 }
elseif (
Name ==
"__.SYMDEF_64 SORTED" ||
Name ==
"__.SYMDEF_64") {
824// We know that the symbol table is not an external file, but we still 825// must check any Expected<> return value. 839// MIPS 64-bit ELF archives use a special format of a symbol table. 840// This format is marked by `ar_name` field equals to "/SYM64/". 841// For detailed description see page 96 in the following document: 842// http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf 844bool has64SymTable =
false;
846// We know that the symbol table is not an external file, but we still 847// must check any Expected<> return value. 873// The string table is never an external member, but we still 874// must check any Expected<> return value. 901// We know that the symbol table is not an external file, but we still 902// must check any Expected<> return value. 919 NameOrErr =
C->getRawName();
927// The string table is never an external member, but we still 928// must check any Expected<> return value. 944 NameOrErr =
C->getRawName();
952if (
Name ==
"/<ECSYMBOLS>/") {
953// ARM64EC-aware libraries contain an additional special member with 954// an EC symbol map after the string table. Its format is similar to a 955// regular symbol map, except it doesn't contain member offsets. Its indexes 956// refer to member offsets from the regular symbol table instead. 987bool SkipInternal)
const{
993Child(
this, FirstRegularData, FirstRegularStartOfFile), Err);
1007// Symbols use SymbolCount..SymbolCount+getNumberOfECSymbols() for EC symbol 1010return SymbolCount <= SymbolIndex &&
1016return Parent->ECSymbolTable.
begin() + StringIndex;
1017return Parent->getSymbolTable().begin() + StringIndex;
1021constchar *Buf = Parent->getSymbolTable().begin();
1022constchar *Offsets = Buf;
1029if (Parent->kind() ==
K_GNU) {
1033 }
elseif (Parent->kind() ==
K_BSD) {
1034// The SymbolIndex is an index into the ranlib structs that start at 1035// Offsets (the first uint32_t is the number of bytes of the ranlib 1036// structs). The ranlib structs are a pair of uint32_t's the first 1037// being a string table offset and the second being the offset into 1038// the archive of the member that defines the symbol. Which is what 1042// The SymbolIndex is an index into the ranlib_64 structs that start at 1043// Offsets (the first uint64_t is the number of bytes of the ranlib_64 1044// structs). The ranlib_64 structs are a pair of uint64_t's the first 1045// being a string table offset and the second being the offset into 1046// the archive of the member that defines the symbol. Which is what 1052 Buf += MemberCount * 4 + 4;
1056if (SymbolIndex < SymbolCount) {
1057// Skip SymbolCount to get to the indices table. 1058constchar *Indices = Buf + 4;
1060// Get the index of the offset in the file member offset table for this 1062 OffsetIndex =
read16le(Indices + SymbolIndex * 2);
1063 }
elseif (isECSymbol()) {
1064// Skip SymbolCount to get to the indices table. 1065constchar *Indices = Parent->ECSymbolTable.begin() + 4;
1067// Get the index of the offset in the file member offset table for this 1069 OffsetIndex =
read16le(Indices + (SymbolIndex - SymbolCount) * 2);
1073// Subtract 1 since OffsetIndex is 1 based. 1076if (OffsetIndex >= MemberCount)
1082constchar *Loc = Parent->getData().begin() +
Offset;
1084ChildC(Parent, Loc, &Err);
1086return std::move(Err);
1092if (Parent->kind() ==
K_BSD) {
1093// t.StringIndex is an offset from the start of the __.SYMDEF or 1094// "__.SYMDEF SORTED" member into the string table for the ranlib 1095// struct indexed by t.SymbolIndex . To change t.StringIndex to the 1096// offset in the string table for t.SymbolIndex+1 we subtract the 1097// its offset from the start of the string table for t.SymbolIndex 1098// and add the offset of the string table for t.SymbolIndex+1. 1100// The __.SYMDEF or "__.SYMDEF SORTED" member starts with a uint32_t 1101// which is the number of bytes of ranlib structs that follow. The ranlib 1102// structs are a pair of uint32_t's the first being a string table offset 1103// and the second being the offset into the archive of the member that 1104// define the symbol. After that the next uint32_t is the byte count of 1105// the string table followed by the string table. 1106constchar *Buf = Parent->getSymbolTable().begin();
1109// If t.SymbolIndex + 1 will be past the count of symbols (the RanlibCount) 1110// don't change the t.StringIndex as we don't want to reference a ranlib 1112if (t.SymbolIndex + 1 < RanlibCount) {
1113constchar *Ranlibs = Buf + 4;
1116 CurRanStrx =
read32le(Ranlibs + t.SymbolIndex * 8);
1117 NextRanStrx =
read32le(Ranlibs + (t.SymbolIndex + 1) * 8);
1118 t.StringIndex -= CurRanStrx;
1119 t.StringIndex += NextRanStrx;
1122// Go to one past next null. 1123 t.StringIndex = Parent->ECSymbolTable.find(
'\0', t.StringIndex) + 1;
1125// Go to one past next null. 1126 t.StringIndex = Parent->getSymbolTable().find(
'\0', t.StringIndex) + 1;
1145// The __.SYMDEF or "__.SYMDEF SORTED" member starts with a uint32_t 1146// which is the number of bytes of ranlib structs that follow. The ranlib 1147// structs are a pair of uint32_t's the first being a string table offset 1148// and the second being the offset into the archive of the member that 1149// define the symbol. After that the next uint32_t is the byte count of 1150// the string table followed by the string table. 1153constchar *ranlibs = buf + 4;
1157// Skip the byte count of the string table. 1161// The __.SYMDEF_64 or "__.SYMDEF_64 SORTED" member starts with a uint64_t 1162// which is the number of bytes of ranlib_64 structs that follow. The 1163// ranlib_64 structs are a pair of uint64_t's the first being a string 1164// table offset and the second being the offset into the archive of the 1165// member that define the symbol. After that the next uint64_t is the byte 1166// count of the string table followed by the string table. 1169constchar *ranlibs = buf + 8;
1173// Skip the byte count of the string table. 1182 buf += 4 + (member_count * 4);
// Skip offsets. 1184 buf += 4 + (symbol_count * 2);
// Skip indices. 1197// Validate EC symbol table. 1216for (
uint32_t i = 0; i < Count; ++i) {
1220if (Index > MemberCount)
1222" is larger than member count " +
1227returnmalformedError(
"malformed EC symbol names: not null-terminated");
1253 buf += 4 + (member_count * 4);
// Skip offsets. 1267for (; bs != es; ++bs) {
1269if (SymName ==
name) {
1271returnChild(*MemberOrErr);
1273return MemberOrErr.takeError();
1279// Returns true if archive file contains no member file. 1288constchar *&GlobalSymtabLoc,
1291uint64_t GlobalSymtabContentOffset =
1293if (GlobalSymtabContentOffset > BufferSize)
1295Twine(BitMessage) +
" global symbol table header at offset 0x" +
1298" goes past the end of file");
1306 RawOffset +
"\" is not a number");
1308if (GlobalSymtabContentOffset +
Size > BufferSize)
1310Twine(BitMessage) +
" global symbol table content at offset 0x" +
1327// In a big archive, a global symbol table contains the following information: 1328// - The number of symbols. 1329// - The array of offsets into the archive file. The length is eight 1330// times the number of symbols. 1331// - The name-string table. The size is: 1332// Size-(8*(the number of symbols + 1)). 1338unsigned SymOffsetsSize = 8 * (SymNum + 1);
1353 Err =
malformedError(
"malformed AIX big archive: incomplete fixed length " 1354"header, the archive is only" +
1355Twine(BufferSize) +
" byte(s)");
1361// TODO: Out-of-line. 1362 Err =
malformedError(
"malformed AIX big archive: first member offset \"" +
1363 RawOffset +
"\" is not a number");
1367// TODO: Out-of-line. 1368 Err =
malformedError(
"malformed AIX big archive: last member offset \"" +
1369 RawOffset +
"\" is not a number");
1375"offset of 32-bit members \"" +
1376 RawOffset +
"\" is not a number");
1384"offset of 64-bit members\"" +
1385 RawOffset +
"\" is not a number");
1389constchar *GlobSymtab32Loc =
nullptr;
1390constchar *GlobSymtab64Loc =
nullptr;
1395if (GlobSymtab32Offset) {
1398 GlobSymtab32Loc, GlobSymtab32Size,
"32-bit");
1405if (GlobSymtab64Offset) {
1408 GlobSymtab64Loc, GlobSymtab64Size,
"64-bit");
1417if (GlobSymtab32Offset)
1419if (GlobSymtab64Offset)
1422if (SymtabInfos.
size() == 1) {
1425 }
elseif (SymtabInfos.
size() == 2) {
1426// In order to let the Archive::Symbol::getNext() work for both 32-bit and 1427// 64-bit global symbol tables, we need to merge them into a single table. 1429uint64_t SymNum = SymtabInfos[0].SymNum + SymtabInfos[1].SymNum;
1431// Merge symbol offset. 1432 Out << SymtabInfos[0].SymbolOffsetTable;
1433 Out << SymtabInfos[1].SymbolOffsetTable;
1434// Merge string table. 1435 Out << SymtabInfos[0].StringTable;
1436 Out << SymtabInfos[1].StringTable;
1438// The size of the symbol offset to the member file is 8 bytes. 1440 SymtabInfos[0].StringTable.
size() +
1441 SymtabInfos[1].StringTable.
size());
#define offsetof(TYPE, MEMBER)
Provides ErrorOr<T> smart pointer.
static void appendGlobalSymbolTableInfo(SmallVector< GlobalSymtabInfo > &SymtabInfos, const char *GlobalSymtabLoc, uint64_t Size)
static Error getGlobalSymtabLocAndSize(const MemoryBufferRef &Data, uint64_t GlobalSymtabOffset, const char *&GlobalSymtabLoc, uint64_t &Size, const char *BitMessage)
static Error malformedError(Twine Msg)
StringRef getFieldRawString(const T(&Field)[N])
Expected< uint64_t > getArchiveMemberOctField(Twine FieldName, const StringRef RawField, const Archive *Parent, const AbstractArchiveMemberHeader *MemHeader)
Expected< uint64_t > getArchiveMemberDecField(Twine FieldName, const StringRef RawField, const Archive *Parent, const AbstractArchiveMemberHeader *MemHeader)
static Error createMemberHeaderParseError(const AbstractArchiveMemberHeader *ArMemHeader, const char *RawHeaderPtr, uint64_t Size)
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
static unsigned getSize(unsigned Kind)
Helper for Errors used as out-parameters.
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
const char * getBufferStart() const
StringRef getBuffer() const
const char * getBufferEnd() const
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
StringRef rtrim(char Char) const
Return string with consecutive Char characters starting from the right removed.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
static constexpr size_t npos
A table of densely packed, null-terminated strings indexed by offset.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::string str() const
Return the twine contents as a std::string.
static Twine utohexstr(const uint64_t &Val)
LLVM Value Representation.
A wrapper class for fallible iterators.
static fallible_iterator end(Underlying I)
Construct a fallible iterator that can be used as an end-of-range value.
static fallible_iterator itr(Underlying I, Error &Err)
Construct a fallible iterator that cannot be used as an end-of-range value.
virtual StringRef getRawGID() const =0
virtual StringRef getRawUID() const =0
Expected< unsigned > getUID() const
Expected< sys::fs::perms > getAccessMode() const
Expected< unsigned > getGID() const
virtual uint64_t getOffset() const =0
Expected< sys::TimePoint< std::chrono::seconds > > getLastModified() const
virtual StringRef getRawAccessMode() const =0
virtual StringRef getRawLastModified() const =0
virtual Expected< StringRef > getName(uint64_t Size) const =0
Get the name looking up long names.
ArchiveMemberHeader(const Archive *Parent, const char *RawHeaderPtr, uint64_t Size, Error *Err)
Expected< StringRef > getName(uint64_t Size) const override
Get the name looking up long names.
Expected< StringRef > getRawName() const override
Get the name without looking up long names.
Expected< bool > isThin() const override
Expected< uint64_t > getSize() const override
Expected< const char * > getNextChildLoc() const override
Get next file member location.
Expected< StringRef > getBuffer() const
Expected< Child > getNext() const
Expected< std::string > getFullName() const
uint64_t getChildOffset() const
Expected< uint64_t > getRawSize() const
Expected< StringRef > getName() const
Expected< uint64_t > getSize() const
Expected< StringRef > getRawName() const
Expected< std::unique_ptr< Binary > > getAsBinary(LLVMContext *Context=nullptr) const
Expected< MemoryBufferRef > getMemoryBufferRef() const
Child(const Archive *Parent, const char *Start, Error *Err)
Expected< Child > getMember() const
StringRef getName() const
std::unique_ptr< AbstractArchiveMemberHeader > createArchiveMemberHeader(const char *RawHeaderPtr, uint64_t Size, Error *Err) const
symbol_iterator symbol_begin() const
virtual uint64_t getFirstChildOffset() const
StringRef getStringTable() const
uint32_t getNumberOfSymbols() const
uint32_t getNumberOfECSymbols() const
void setFirstRegular(const Child &C)
uint64_t getArchiveMagicLen() const
StringRef getSymbolTable() const
symbol_iterator symbol_end() const
static object::Archive::Kind getDefaultKind()
virtual bool isEmpty() const
child_iterator child_end() const
bool hasSymbolTable() const
Archive(MemoryBufferRef Source, Error &Err)
static object::Archive::Kind getDefaultKindForTriple(const Triple &T)
Expected< iterator_range< symbol_iterator > > ec_symbols() const
Expected< std::optional< Child > > findSym(StringRef name) const
child_iterator child_begin(Error &Err, bool SkipInternal=true) const
static Expected< std::unique_ptr< Archive > > create(MemoryBufferRef Source)
Expected< uint64_t > getSize() const override
Expected< StringRef > getRawName() const override
Get the name without looking up long names.
Expected< const char * > getNextChildLoc() const override
Get next file member location.
Expected< StringRef > getName(uint64_t Size) const override
Get the name looking up long names.
Expected< uint64_t > getRawNameSize() const
Expected< uint64_t > getNextOffset() const
BigArchiveMemberHeader(Archive const *Parent, const char *RawHeaderPtr, uint64_t Size, Error *Err)
bool Has32BitGlobalSymtab
std::string MergedGlobalSymtabBuf
bool Has64BitGlobalSymtab
const FixLenHdr * ArFixLenHdr
uint64_t FirstChildOffset
BigArchive(MemoryBufferRef Source, Error &Err)
StringRef getData() const
MemoryBufferRef getMemoryBufferRef() const
StringRef getRawLastModified() const override
StringRef getRawUID() const override
uint64_t getSizeOf() const override
uint64_t getOffset() const override
StringRef getRawAccessMode() const override
StringRef getRawGID() const override
UnixArMemHdrType const * ArMemHdr
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
Output Str, turning '\', '\t', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an esca...
A raw_ostream that writes to an std::string.
@ C
The default llvm calling convention, compatible with C.
constexpr size_t NameSize
const char ArchiveMagic[]
const char ThinArchiveMagic[]
const char BigArchiveMagic[]
Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr, bool InitContent=true)
Create a Binary from Source, autodetecting the file type.
uint64_t read64le(const void *P)
uint16_t read16le(const void *P)
uint64_t read64be(const void *P)
uint32_t read32be(const void *P)
uint32_t read32le(const void *P)
StringRef parent_path(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get parent path.
bool is_absolute(const Twine &path, Style style=Style::native)
Is path absolute?
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
TimePoint< std::chrono::seconds > toTimePoint(std::time_t T)
Convert a std::time_t to a TimePoint.
std::string getDefaultTargetTriple()
getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produ...
This is an optimization pass for GlobalISel generic memory operations.
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Error write(MCStreamer &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
void consumeError(Error Err)
Consume a Error without doing anything.
StringRef SymbolOffsetTable
char FirstChildOffset[20]
Offset to first archive member.
char LastChildOffset[20]
Offset to last archive member.
char GlobSym64Offset[20]
Offset global symbol table for 64-bit objects.
char GlobSymOffset[20]
Offset to global symbol table.
char Size[10]
Size of data, not including header or padding.