mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-17 06:33:21 +00:00
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:
parent
1f465809cd
commit
4a980d1813
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
/// Read a variable-bit-rate encoded unsigned integer
|
/// Read a variable-bit-rate encoded unsigned integer
|
||||||
inline unsigned readInteger(const char*&At, const char*End) {
|
inline unsigned readInteger(const char*&At, const char*End) {
|
||||||
unsigned Shift = 0;
|
unsigned Shift = 0;
|
||||||
@ -32,8 +30,6 @@ inline unsigned readInteger(const char*&At, const char*End) {
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Completely parse the Archive's symbol table and populate symTab member var.
|
// Completely parse the Archive's symbol table and populate symTab member var.
|
||||||
void
|
void
|
||||||
Archive::parseSymbolTable(const void* data, unsigned size) {
|
Archive::parseSymbolTable(const void* data, unsigned size) {
|
||||||
@ -226,34 +222,43 @@ Archive::loadArchive() {
|
|||||||
|
|
||||||
// check if this is the foreign symbol table
|
// check if this is the foreign symbol table
|
||||||
if (mbr->isForeignSymbolTable()) {
|
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();
|
At += mbr->getSize();
|
||||||
delete mbr;
|
if ((mbr->getSize() & 1) == 1)
|
||||||
if ((int(At) & 1) == 1)
|
|
||||||
At++;
|
At++;
|
||||||
} else if (mbr->isStringTable()) {
|
} 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());
|
strtab.assign(At,mbr->getSize());
|
||||||
At += mbr->getSize();
|
At += mbr->getSize();
|
||||||
if ((int(At) & 1) == 1)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
At++;
|
At++;
|
||||||
delete mbr;
|
delete mbr;
|
||||||
} else if (mbr->isLLVMSymbolTable()) {
|
} 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)
|
if (seenSymbolTable)
|
||||||
throw std::string("invalid archive: multiple symbol tables");
|
throw std::string("invalid archive: multiple symbol tables");
|
||||||
parseSymbolTable(mbr->getData(),mbr->getSize());
|
parseSymbolTable(mbr->getData(),mbr->getSize());
|
||||||
seenSymbolTable = true;
|
seenSymbolTable = true;
|
||||||
At += mbr->getSize();
|
At += mbr->getSize();
|
||||||
if ((int(At) & 1) == 1)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
At++;
|
At++;
|
||||||
delete mbr;
|
delete mbr; // We don't need this member in the list of members.
|
||||||
} else {
|
} 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) {
|
if (!foundFirstFile) {
|
||||||
firstFileOffset = Save - base;
|
firstFileOffset = Save - base;
|
||||||
foundFirstFile = true;
|
foundFirstFile = true;
|
||||||
}
|
}
|
||||||
members.push_back(mbr);
|
members.push_back(mbr);
|
||||||
At += mbr->getSize();
|
At += mbr->getSize();
|
||||||
if ((int(At) & 1) == 1)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
At++;
|
At++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,7 +314,7 @@ Archive::loadSymbolTable() {
|
|||||||
if (mbr->isForeignSymbolTable()) {
|
if (mbr->isForeignSymbolTable()) {
|
||||||
// Skip the foreign symbol table, we don't do anything with it
|
// Skip the foreign symbol table, we don't do anything with it
|
||||||
At += mbr->getSize();
|
At += mbr->getSize();
|
||||||
if (mbr->getSize() % 2 != 0)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
At++;
|
At++;
|
||||||
delete mbr;
|
delete mbr;
|
||||||
|
|
||||||
@ -322,7 +327,7 @@ Archive::loadSymbolTable() {
|
|||||||
// Process the string table entry
|
// Process the string table entry
|
||||||
strtab.assign((const char*)mbr->getData(),mbr->getSize());
|
strtab.assign((const char*)mbr->getData(),mbr->getSize());
|
||||||
At += mbr->getSize();
|
At += mbr->getSize();
|
||||||
if (mbr->getSize() % 2 != 0)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
At++;
|
At++;
|
||||||
delete mbr;
|
delete mbr;
|
||||||
// Get the next one
|
// Get the next one
|
||||||
@ -334,7 +339,7 @@ Archive::loadSymbolTable() {
|
|||||||
if (mbr->isLLVMSymbolTable()) {
|
if (mbr->isLLVMSymbolTable()) {
|
||||||
parseSymbolTable(mbr->getData(),mbr->getSize());
|
parseSymbolTable(mbr->getData(),mbr->getSize());
|
||||||
FirstFile = At + mbr->getSize();
|
FirstFile = At + mbr->getSize();
|
||||||
if (mbr->getSize() % 2 != 0)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
FirstFile++;
|
FirstFile++;
|
||||||
} else {
|
} else {
|
||||||
// There's no symbol table in the file. We have to rebuild it from scratch
|
// 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
|
// Go to the next file location
|
||||||
At += mbr->getSize();
|
At += mbr->getSize();
|
||||||
if (mbr->getSize() % 2 != 0)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
At++;
|
At++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
/// Read a variable-bit-rate encoded unsigned integer
|
/// Read a variable-bit-rate encoded unsigned integer
|
||||||
inline unsigned readInteger(const char*&At, const char*End) {
|
inline unsigned readInteger(const char*&At, const char*End) {
|
||||||
unsigned Shift = 0;
|
unsigned Shift = 0;
|
||||||
@ -32,8 +30,6 @@ inline unsigned readInteger(const char*&At, const char*End) {
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Completely parse the Archive's symbol table and populate symTab member var.
|
// Completely parse the Archive's symbol table and populate symTab member var.
|
||||||
void
|
void
|
||||||
Archive::parseSymbolTable(const void* data, unsigned size) {
|
Archive::parseSymbolTable(const void* data, unsigned size) {
|
||||||
@ -226,34 +222,43 @@ Archive::loadArchive() {
|
|||||||
|
|
||||||
// check if this is the foreign symbol table
|
// check if this is the foreign symbol table
|
||||||
if (mbr->isForeignSymbolTable()) {
|
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();
|
At += mbr->getSize();
|
||||||
delete mbr;
|
if ((mbr->getSize() & 1) == 1)
|
||||||
if ((int(At) & 1) == 1)
|
|
||||||
At++;
|
At++;
|
||||||
} else if (mbr->isStringTable()) {
|
} 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());
|
strtab.assign(At,mbr->getSize());
|
||||||
At += mbr->getSize();
|
At += mbr->getSize();
|
||||||
if ((int(At) & 1) == 1)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
At++;
|
At++;
|
||||||
delete mbr;
|
delete mbr;
|
||||||
} else if (mbr->isLLVMSymbolTable()) {
|
} 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)
|
if (seenSymbolTable)
|
||||||
throw std::string("invalid archive: multiple symbol tables");
|
throw std::string("invalid archive: multiple symbol tables");
|
||||||
parseSymbolTable(mbr->getData(),mbr->getSize());
|
parseSymbolTable(mbr->getData(),mbr->getSize());
|
||||||
seenSymbolTable = true;
|
seenSymbolTable = true;
|
||||||
At += mbr->getSize();
|
At += mbr->getSize();
|
||||||
if ((int(At) & 1) == 1)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
At++;
|
At++;
|
||||||
delete mbr;
|
delete mbr; // We don't need this member in the list of members.
|
||||||
} else {
|
} 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) {
|
if (!foundFirstFile) {
|
||||||
firstFileOffset = Save - base;
|
firstFileOffset = Save - base;
|
||||||
foundFirstFile = true;
|
foundFirstFile = true;
|
||||||
}
|
}
|
||||||
members.push_back(mbr);
|
members.push_back(mbr);
|
||||||
At += mbr->getSize();
|
At += mbr->getSize();
|
||||||
if ((int(At) & 1) == 1)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
At++;
|
At++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,7 +314,7 @@ Archive::loadSymbolTable() {
|
|||||||
if (mbr->isForeignSymbolTable()) {
|
if (mbr->isForeignSymbolTable()) {
|
||||||
// Skip the foreign symbol table, we don't do anything with it
|
// Skip the foreign symbol table, we don't do anything with it
|
||||||
At += mbr->getSize();
|
At += mbr->getSize();
|
||||||
if (mbr->getSize() % 2 != 0)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
At++;
|
At++;
|
||||||
delete mbr;
|
delete mbr;
|
||||||
|
|
||||||
@ -322,7 +327,7 @@ Archive::loadSymbolTable() {
|
|||||||
// Process the string table entry
|
// Process the string table entry
|
||||||
strtab.assign((const char*)mbr->getData(),mbr->getSize());
|
strtab.assign((const char*)mbr->getData(),mbr->getSize());
|
||||||
At += mbr->getSize();
|
At += mbr->getSize();
|
||||||
if (mbr->getSize() % 2 != 0)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
At++;
|
At++;
|
||||||
delete mbr;
|
delete mbr;
|
||||||
// Get the next one
|
// Get the next one
|
||||||
@ -334,7 +339,7 @@ Archive::loadSymbolTable() {
|
|||||||
if (mbr->isLLVMSymbolTable()) {
|
if (mbr->isLLVMSymbolTable()) {
|
||||||
parseSymbolTable(mbr->getData(),mbr->getSize());
|
parseSymbolTable(mbr->getData(),mbr->getSize());
|
||||||
FirstFile = At + mbr->getSize();
|
FirstFile = At + mbr->getSize();
|
||||||
if (mbr->getSize() % 2 != 0)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
FirstFile++;
|
FirstFile++;
|
||||||
} else {
|
} else {
|
||||||
// There's no symbol table in the file. We have to rebuild it from scratch
|
// 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
|
// Go to the next file location
|
||||||
At += mbr->getSize();
|
At += mbr->getSize();
|
||||||
if (mbr->getSize() % 2 != 0)
|
if ((mbr->getSize() & 1) == 1)
|
||||||
At++;
|
At++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user