#include "llvm/Object/Archive.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/Error.h"
#include "llvm/Support/Chrono.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
#include <system_error>
usingnamespacellvm;
usingnamespaceobject;
usingnamespacellvm::support::endian;
void Archive::anchor() { … }
static Error malformedError(Twine Msg) { … }
static Error
createMemberHeaderParseError(const AbstractArchiveMemberHeader *ArMemHeader,
const char *RawHeaderPtr, uint64_t Size) { … }
template <class T, std::size_t N>
StringRef getFieldRawString(const T (&Field)[N]) { … }
template <class T>
StringRef CommonArchiveMemberHeader<T>::getRawAccessMode() const { … }
template <class T>
StringRef CommonArchiveMemberHeader<T>::getRawLastModified() const { … }
template <class T> StringRef CommonArchiveMemberHeader<T>::getRawUID() const { … }
template <class T> StringRef CommonArchiveMemberHeader<T>::getRawGID() const { … }
template <class T> uint64_t CommonArchiveMemberHeader<T>::getOffset() const { … }
template class object::CommonArchiveMemberHeader<UnixArMemHdrType>;
template class object::CommonArchiveMemberHeader<BigArMemHdrType>;
ArchiveMemberHeader::ArchiveMemberHeader(const Archive *Parent,
const char *RawHeaderPtr,
uint64_t Size, Error *Err)
: … { … }
BigArchiveMemberHeader::BigArchiveMemberHeader(const Archive *Parent,
const char *RawHeaderPtr,
uint64_t Size, Error *Err)
: … { … }
Expected<StringRef> ArchiveMemberHeader::getRawName() const { … }
Expected<uint64_t>
getArchiveMemberDecField(Twine FieldName, const StringRef RawField,
const Archive *Parent,
const AbstractArchiveMemberHeader *MemHeader) { … }
Expected<uint64_t>
getArchiveMemberOctField(Twine FieldName, const StringRef RawField,
const Archive *Parent,
const AbstractArchiveMemberHeader *MemHeader) { … }
Expected<StringRef> BigArchiveMemberHeader::getRawName() const { … }
Expected<StringRef> ArchiveMemberHeader::getName(uint64_t Size) const { … }
Expected<StringRef> BigArchiveMemberHeader::getName(uint64_t Size) const { … }
Expected<uint64_t> ArchiveMemberHeader::getSize() const { … }
Expected<uint64_t> BigArchiveMemberHeader::getSize() const { … }
Expected<uint64_t> BigArchiveMemberHeader::getRawNameSize() const { … }
Expected<uint64_t> BigArchiveMemberHeader::getNextOffset() const { … }
Expected<sys::fs::perms> AbstractArchiveMemberHeader::getAccessMode() const { … }
Expected<sys::TimePoint<std::chrono::seconds>>
AbstractArchiveMemberHeader::getLastModified() const { … }
Expected<unsigned> AbstractArchiveMemberHeader::getUID() const { … }
Expected<unsigned> AbstractArchiveMemberHeader::getGID() const { … }
Expected<bool> ArchiveMemberHeader::isThin() const { … }
Expected<const char *> ArchiveMemberHeader::getNextChildLoc() const { … }
Expected<const char *> BigArchiveMemberHeader::getNextChildLoc() const { … }
Archive::Child::Child(const Archive *Parent, StringRef Data,
uint16_t StartOfFile)
: … { … }
Archive::Child::Child(const Archive *Parent, const char *Start, Error *Err)
: … { … }
Expected<uint64_t> Archive::Child::getSize() const { … }
Expected<uint64_t> Archive::Child::getRawSize() const { … }
Expected<bool> Archive::Child::isThinMember() const { … }
Expected<std::string> Archive::Child::getFullName() const { … }
Expected<StringRef> Archive::Child::getBuffer() const { … }
Expected<Archive::Child> Archive::Child::getNext() const { … }
uint64_t Archive::Child::getChildOffset() const { … }
Expected<StringRef> Archive::Child::getName() const { … }
Expected<MemoryBufferRef> Archive::Child::getMemoryBufferRef() const { … }
Expected<std::unique_ptr<Binary>>
Archive::Child::getAsBinary(LLVMContext *Context) const { … }
Expected<std::unique_ptr<Archive>> Archive::create(MemoryBufferRef Source) { … }
std::unique_ptr<AbstractArchiveMemberHeader>
Archive::createArchiveMemberHeader(const char *RawHeaderPtr, uint64_t Size,
Error *Err) const { … }
uint64_t Archive::getArchiveMagicLen() const { … }
void Archive::setFirstRegular(const Child &C) { … }
Archive::Archive(MemoryBufferRef Source, Error &Err)
: … { … }
object::Archive::Kind Archive::getDefaultKindForTriple(Triple &T) { … }
object::Archive::Kind Archive::getDefaultKind() { … }
Archive::child_iterator Archive::child_begin(Error &Err,
bool SkipInternal) const { … }
Archive::child_iterator Archive::child_end() const { … }
bool Archive::Symbol::isECSymbol() const { … }
StringRef Archive::Symbol::getName() const { … }
Expected<Archive::Child> Archive::Symbol::getMember() const { … }
Archive::Symbol Archive::Symbol::getNext() const { … }
Archive::symbol_iterator Archive::symbol_begin() const { … }
Archive::symbol_iterator Archive::symbol_end() const { … }
Expected<iterator_range<Archive::symbol_iterator>> Archive::ec_symbols() const { … }
uint32_t Archive::getNumberOfSymbols() const { … }
uint32_t Archive::getNumberOfECSymbols() const { … }
Expected<std::optional<Archive::Child>> Archive::findSym(StringRef name) const { … }
bool Archive::isEmpty() const { … }
bool Archive::hasSymbolTable() const { … }
static Error getGlobalSymtabLocAndSize(const MemoryBufferRef &Data,
uint64_t GlobalSymtabOffset,
const char *&GlobalSymtabLoc,
uint64_t &Size, const char *BitMessage) { … }
struct GlobalSymtabInfo { … };
static void
appendGlobalSymbolTableInfo(SmallVector<GlobalSymtabInfo> &SymtabInfos,
const char *GlobalSymtabLoc, uint64_t Size) { … }
BigArchive::BigArchive(MemoryBufferRef Source, Error &Err)
: … { … }