Per code review:\

* Make sure we write out the foreign symbol table if we read one \
* Make the padding calculation more efficiently and avoid Solaris warnings


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17883 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2004-11-16 06:47:19 +00:00
parent 1f465809cd
commit 4a980d1813
2 changed files with 40 additions and 30 deletions

View File

@ -16,8 +16,6 @@
using namespace llvm;
namespace {
/// Read a variable-bit-rate encoded unsigned integer
inline unsigned readInteger(const char*&At, const char*End) {
unsigned Shift = 0;
@ -32,8 +30,6 @@ inline unsigned readInteger(const char*&At, const char*End) {
return Result;
}
}
// Completely parse the Archive's symbol table and populate symTab member var.
void
Archive::parseSymbolTable(const void* data, unsigned size) {
@ -226,34 +222,43 @@ Archive::loadArchive() {
// check if this is the foreign symbol table
if (mbr->isForeignSymbolTable()) {
// We don't do anything with this but delete it
// We just save this but don't do anything special
// with it. It doesn't count as the "first file".
foreignST = mbr;
At += mbr->getSize();
delete mbr;
if ((int(At) & 1) == 1)
if ((mbr->getSize() & 1) == 1)
At++;
} else if (mbr->isStringTable()) {
// Simply suck the entire string table into a string
// variable. This will be used to get the names of the
// members that use the "/ddd" format for their names
// (SVR4 style long names).
strtab.assign(At,mbr->getSize());
At += mbr->getSize();
if ((int(At) & 1) == 1)
if ((mbr->getSize() & 1) == 1)
At++;
delete mbr;
} else if (mbr->isLLVMSymbolTable()) {
// This is the LLVM symbol table for the archive. If we've seen it
// already, its an error. Otherwise, parse the symbol table and move on.
if (seenSymbolTable)
throw std::string("invalid archive: multiple symbol tables");
parseSymbolTable(mbr->getData(),mbr->getSize());
seenSymbolTable = true;
At += mbr->getSize();
if ((int(At) & 1) == 1)
if ((mbr->getSize() & 1) == 1)
At++;
delete mbr;
delete mbr; // We don't need this member in the list of members.
} else {
// This is just a regular file. If its the first one, save its offset.
// Otherwise just push it on the list and move on to the next file.
if (!foundFirstFile) {
firstFileOffset = Save - base;
foundFirstFile = true;
}
members.push_back(mbr);
At += mbr->getSize();
if ((int(At) & 1) == 1)
if ((mbr->getSize() & 1) == 1)
At++;
}
}
@ -309,7 +314,7 @@ Archive::loadSymbolTable() {
if (mbr->isForeignSymbolTable()) {
// Skip the foreign symbol table, we don't do anything with it
At += mbr->getSize();
if (mbr->getSize() % 2 != 0)
if ((mbr->getSize() & 1) == 1)
At++;
delete mbr;
@ -322,7 +327,7 @@ Archive::loadSymbolTable() {
// Process the string table entry
strtab.assign((const char*)mbr->getData(),mbr->getSize());
At += mbr->getSize();
if (mbr->getSize() % 2 != 0)
if ((mbr->getSize() & 1) == 1)
At++;
delete mbr;
// Get the next one
@ -334,7 +339,7 @@ Archive::loadSymbolTable() {
if (mbr->isLLVMSymbolTable()) {
parseSymbolTable(mbr->getData(),mbr->getSize());
FirstFile = At + mbr->getSize();
if (mbr->getSize() % 2 != 0)
if ((mbr->getSize() & 1) == 1)
FirstFile++;
} else {
// There's no symbol table in the file. We have to rebuild it from scratch
@ -442,7 +447,7 @@ Archive::findModulesDefiningSymbols(const std::set<std::string>& symbols,
// Go to the next file location
At += mbr->getSize();
if (mbr->getSize() % 2 != 0)
if ((mbr->getSize() & 1) == 1)
At++;
}
}

View File

@ -16,8 +16,6 @@
using namespace llvm;
namespace {
/// Read a variable-bit-rate encoded unsigned integer
inline unsigned readInteger(const char*&At, const char*End) {
unsigned Shift = 0;
@ -32,8 +30,6 @@ inline unsigned readInteger(const char*&At, const char*End) {
return Result;
}
}
// Completely parse the Archive's symbol table and populate symTab member var.
void
Archive::parseSymbolTable(const void* data, unsigned size) {
@ -226,34 +222,43 @@ Archive::loadArchive() {
// check if this is the foreign symbol table
if (mbr->isForeignSymbolTable()) {
// We don't do anything with this but delete it
// We just save this but don't do anything special
// with it. It doesn't count as the "first file".
foreignST = mbr;
At += mbr->getSize();
delete mbr;
if ((int(At) & 1) == 1)
if ((mbr->getSize() & 1) == 1)
At++;
} else if (mbr->isStringTable()) {
// Simply suck the entire string table into a string
// variable. This will be used to get the names of the
// members that use the "/ddd" format for their names
// (SVR4 style long names).
strtab.assign(At,mbr->getSize());
At += mbr->getSize();
if ((int(At) & 1) == 1)
if ((mbr->getSize() & 1) == 1)
At++;
delete mbr;
} else if (mbr->isLLVMSymbolTable()) {
// This is the LLVM symbol table for the archive. If we've seen it
// already, its an error. Otherwise, parse the symbol table and move on.
if (seenSymbolTable)
throw std::string("invalid archive: multiple symbol tables");
parseSymbolTable(mbr->getData(),mbr->getSize());
seenSymbolTable = true;
At += mbr->getSize();
if ((int(At) & 1) == 1)
if ((mbr->getSize() & 1) == 1)
At++;
delete mbr;
delete mbr; // We don't need this member in the list of members.
} else {
// This is just a regular file. If its the first one, save its offset.
// Otherwise just push it on the list and move on to the next file.
if (!foundFirstFile) {
firstFileOffset = Save - base;
foundFirstFile = true;
}
members.push_back(mbr);
At += mbr->getSize();
if ((int(At) & 1) == 1)
if ((mbr->getSize() & 1) == 1)
At++;
}
}
@ -309,7 +314,7 @@ Archive::loadSymbolTable() {
if (mbr->isForeignSymbolTable()) {
// Skip the foreign symbol table, we don't do anything with it
At += mbr->getSize();
if (mbr->getSize() % 2 != 0)
if ((mbr->getSize() & 1) == 1)
At++;
delete mbr;
@ -322,7 +327,7 @@ Archive::loadSymbolTable() {
// Process the string table entry
strtab.assign((const char*)mbr->getData(),mbr->getSize());
At += mbr->getSize();
if (mbr->getSize() % 2 != 0)
if ((mbr->getSize() & 1) == 1)
At++;
delete mbr;
// Get the next one
@ -334,7 +339,7 @@ Archive::loadSymbolTable() {
if (mbr->isLLVMSymbolTable()) {
parseSymbolTable(mbr->getData(),mbr->getSize());
FirstFile = At + mbr->getSize();
if (mbr->getSize() % 2 != 0)
if ((mbr->getSize() & 1) == 1)
FirstFile++;
} else {
// There's no symbol table in the file. We have to rebuild it from scratch
@ -442,7 +447,7 @@ Archive::findModulesDefiningSymbols(const std::set<std::string>& symbols,
// Go to the next file location
At += mbr->getSize();
if (mbr->getSize() % 2 != 0)
if ((mbr->getSize() & 1) == 1)
At++;
}
}