mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-26 18:20:39 +00:00
Object: Add Archive::getNumberOfSymbols().
Add a function that returns number of symbols in archive headers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238213 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -207,6 +207,7 @@ public:
|
|||||||
|
|
||||||
bool hasSymbolTable() const;
|
bool hasSymbolTable() const;
|
||||||
child_iterator getSymbolTableChild() const { return SymbolTable; }
|
child_iterator getSymbolTableChild() const { return SymbolTable; }
|
||||||
|
uint32_t getNumberOfSymbols() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
child_iterator SymbolTable;
|
child_iterator SymbolTable;
|
||||||
|
|||||||
@@ -487,22 +487,21 @@ Archive::symbol_iterator Archive::symbol_begin() const {
|
|||||||
Archive::symbol_iterator Archive::symbol_end() const {
|
Archive::symbol_iterator Archive::symbol_end() const {
|
||||||
if (!hasSymbolTable())
|
if (!hasSymbolTable())
|
||||||
return symbol_iterator(Symbol(this, 0, 0));
|
return symbol_iterator(Symbol(this, 0, 0));
|
||||||
|
return symbol_iterator(Symbol(this, getNumberOfSymbols(), 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Archive::getNumberOfSymbols() const {
|
||||||
const char *buf = SymbolTable->getBuffer().begin();
|
const char *buf = SymbolTable->getBuffer().begin();
|
||||||
uint32_t symbol_count = 0;
|
if (kind() == K_GNU)
|
||||||
if (kind() == K_GNU) {
|
return read32be(buf);
|
||||||
symbol_count = read32be(buf);
|
if (kind() == K_MIPS64)
|
||||||
} else if (kind() == K_MIPS64) {
|
return read64be(buf);
|
||||||
symbol_count = read64be(buf);
|
if (kind() == K_BSD)
|
||||||
} else if (kind() == K_BSD) {
|
return read32le(buf) / 8;
|
||||||
symbol_count = read32le(buf) / 8;
|
|
||||||
} else {
|
|
||||||
uint32_t member_count = 0;
|
uint32_t member_count = 0;
|
||||||
member_count = read32le(buf);
|
member_count = read32le(buf);
|
||||||
buf += 4 + (member_count * 4); // Skip offsets.
|
buf += 4 + (member_count * 4); // Skip offsets.
|
||||||
symbol_count = read32le(buf);
|
return read32le(buf);
|
||||||
}
|
|
||||||
return symbol_iterator(Symbol(this, symbol_count, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Archive::child_iterator Archive::findSym(StringRef name) const {
|
Archive::child_iterator Archive::findSym(StringRef name) const {
|
||||||
|
|||||||
Reference in New Issue
Block a user