Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit ec6cc05

Browse files
committed
Add a herper function. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242100 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent dee03ee commit ec6cc05

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

include/llvm/Object/Archive.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class Archive : public Binary {
207207

208208
bool hasSymbolTable() const;
209209
child_iterator getSymbolTableChild() const { return SymbolTable; }
210+
StringRef getSymbolTable() const { return SymbolTable->getBuffer(); }
210211
uint32_t getNumberOfSymbols() const;
211212

212213
private:

lib/Object/Archive.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,11 @@ Archive::child_iterator Archive::child_end() const {
353353
}
354354

355355
StringRef Archive::Symbol::getName() const {
356-
return Parent->SymbolTable->getBuffer().begin() + StringIndex;
356+
return Parent->getSymbolTable().begin() + StringIndex;
357357
}
358358

359359
ErrorOr<Archive::child_iterator> Archive::Symbol::getMember() const {
360-
const char *Buf = Parent->SymbolTable->getBuffer().begin();
360+
const char *Buf = Parent->getSymbolTable().begin();
361361
const char *Offsets = Buf;
362362
if (Parent->kind() == K_MIPS64)
363363
Offsets += sizeof(uint64_t);
@@ -421,7 +421,7 @@ Archive::Symbol Archive::Symbol::getNext() const {
421421
// and the second being the offset into the archive of the member that
422422
// define the symbol. After that the next uint32_t is the byte count of
423423
// the string table followed by the string table.
424-
const char *Buf = Parent->SymbolTable->getBuffer().begin();
424+
const char *Buf = Parent->getSymbolTable().begin();
425425
uint32_t RanlibCount = 0;
426426
RanlibCount = read32le(Buf) / 8;
427427
// If t.SymbolIndex + 1 will be past the count of symbols (the RanlibCount)
@@ -438,8 +438,7 @@ Archive::Symbol Archive::Symbol::getNext() const {
438438
}
439439
} else {
440440
// Go to one past next null.
441-
t.StringIndex =
442-
Parent->SymbolTable->getBuffer().find('\0', t.StringIndex) + 1;
441+
t.StringIndex = Parent->getSymbolTable().find('\0', t.StringIndex) + 1;
443442
}
444443
++t.SymbolIndex;
445444
return t;
@@ -449,7 +448,7 @@ Archive::symbol_iterator Archive::symbol_begin() const {
449448
if (!hasSymbolTable())
450449
return symbol_iterator(Symbol(this, 0, 0));
451450

452-
const char *buf = SymbolTable->getBuffer().begin();
451+
const char *buf = getSymbolTable().begin();
453452
if (kind() == K_GNU) {
454453
uint32_t symbol_count = 0;
455454
symbol_count = read32be(buf);
@@ -481,7 +480,7 @@ Archive::symbol_iterator Archive::symbol_begin() const {
481480
symbol_count = read32le(buf);
482481
buf += 4 + (symbol_count * 2); // Skip indices.
483482
}
484-
uint32_t string_start_offset = buf - SymbolTable->getBuffer().begin();
483+
uint32_t string_start_offset = buf - getSymbolTable().begin();
485484
return symbol_iterator(Symbol(this, 0, string_start_offset));
486485
}
487486

@@ -492,7 +491,7 @@ Archive::symbol_iterator Archive::symbol_end() const {
492491
}
493492

494493
uint32_t Archive::getNumberOfSymbols() const {
495-
const char *buf = SymbolTable->getBuffer().begin();
494+
const char *buf = getSymbolTable().begin();
496495
if (kind() == K_GNU)
497496
return read32be(buf);
498497
if (kind() == K_MIPS64)

0 commit comments

Comments
 (0)