22 using namespace object;
24 static const char *
const Magic =
"!<arch>\n";
26 void Archive::anchor() { }
30 if (
Name[0] ==
'/' ||
Name[0] ==
'#')
38 assert(end <=
sizeof(
Name) && end > 0);
60 .getAsInteger(10, Seconds))
104 size_t SpaceToSkip =
Data.size();
109 const char *NextLoc =
Data.data() + SpaceToSkip;
112 if (NextLoc >= Parent->Data->getBufferEnd())
113 return Child(Parent, NULL);
115 return Child(Parent, NextLoc);
121 if (name[0] ==
'/') {
122 if (name.
size() == 1) {
126 if (name.
size() == 2 && name[1] ==
'/') {
135 const char *addr = Parent->StringTable->Data.begin()
139 if (Parent->StringTable == Parent->end_children()
140 || addr < (Parent->StringTable->Data.begin()
142 || addr > (Parent->StringTable->Data.begin()
144 + Parent->StringTable->getSize()))
148 if (Parent->kind() ==
K_GNU) {
164 if (name[name.
size() - 1] ==
'/')
172 bool FullPath)
const {
178 getBuffer(), FullPath ? (
Twine(Parent->getFileName()) +
"(" + Name +
")")
236 if (Name ==
"__.SYMDEF") {
251 if (Name ==
"__.SYMDEF SORTED") {
279 if (Name[0] !=
'/') {
325 return Child(
this, NULL);
334 const char *Buf = Parent->SymbolTable->getBuffer().begin();
335 const char *Offsets = Buf + 4;
337 if (Parent->kind() ==
K_GNU) {
340 }
else if (Parent->kind() ==
K_BSD) {
351 if (SymbolIndex >= SymbolCount)
359 uint16_t OffsetIndex =
365 if (OffsetIndex >= MemberCount)
372 const char *Loc = Parent->getData().begin() + Offset;
373 Result =
Child(Parent, Loc);
382 Parent->SymbolTable->getBuffer().find(
'\0', t.StringIndex) + 1;
393 uint32_t symbol_count = 0;
395 buf +=
sizeof(uint32_t) + (symbol_count * (
sizeof(uint32_t)));
399 uint32_t member_count = 0;
400 uint32_t symbol_count = 0;
402 buf += 4 + (member_count * 4);
404 buf += 4 + (symbol_count * 2);
406 uint32_t string_start_offset = buf - SymbolTable->
getBuffer().
begin();
415 uint32_t symbol_count = 0;
421 uint32_t member_count = 0;
423 buf += 4 + (member_count * 4);
427 Symbol(
this, symbol_count, 0));
436 for (; bs != es; ++bs) {
439 if (symname == name) {
static MemoryBuffer * getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
child_iterator end_children() const
const_iterator end(StringRef path)
Get end iterator over path.
size_t size() const
size - Get the string size.
const char * getBufferStart() const
size_t find(char C, size_t From=0) const
StringRef substr(size_t Start, size_t N=npos) const
StringRef rtrim(StringRef Chars=" \t\n\v\f\r") const
error_code getName(StringRef &Result) const
#define llvm_unreachable(msg)
error_code getMember(child_iterator &Result) const
error_code getName(StringRef &Result) const
This file implements a class to represent arbitrary precision integral constant values and operations...
child_iterator begin_children(bool SkipInternal=true) const
bool hasSymbolTable() const
error_code createBinary(MemoryBuffer *Source, OwningPtr< Binary > &Result)
Create a Binary from Source, autodetecting the file type.
symbol_iterator begin_symbols() const
content_iterator< SymbolRef > symbol_iterator
error_code getAsBinary(OwningPtr< Binary > &Result) const
error_code getMemoryBuffer(OwningPtr< MemoryBuffer > &Result, bool FullPath=false) const
Child(const Archive *Parent, const char *Start)
enable_if_c< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
child_iterator findSym(StringRef name) const
static const char *const Magic
StringRef getBuffer() const
bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Archive(MemoryBuffer *source, error_code &ec)
void fromEpochTime(SecondsType seconds)
Convert seconds form PosixTime to TimeValue.
size_t strlen(const char *s);
size_t getBufferSize() const
StringRef getRawName() const
std::string getName(ID id, ArrayRef< Type * > Tys=None)
symbol_iterator end_symbols() const
static error_code success()
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
Provides an abstraction for a fixed point in time.
void swap(OwningPtr &RHS)