mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-10 05:41:40 +00:00
Simplify the handling of the archive string table.
We only need to store a StringRef llvm-svn: 251746
This commit is contained in:
parent
bfd831d3f2
commit
f0f9bc5a37
@ -218,7 +218,7 @@ public:
|
||||
|
||||
private:
|
||||
child_iterator SymbolTable;
|
||||
child_iterator StringTable;
|
||||
StringRef StringTable;
|
||||
child_iterator FirstRegular;
|
||||
unsigned Format : 2;
|
||||
unsigned IsThin : 1;
|
||||
|
@ -179,17 +179,11 @@ ErrorOr<StringRef> Archive::Child::getName() const {
|
||||
std::size_t offset;
|
||||
if (name.substr(1).rtrim(" ").getAsInteger(10, offset))
|
||||
llvm_unreachable("Long name offset is not an integer");
|
||||
const char *addr = Parent->StringTable->Data.begin()
|
||||
+ sizeof(ArchiveMemberHeader)
|
||||
+ offset;
|
||||
|
||||
// Verify it.
|
||||
if (Parent->StringTable == Parent->child_end()
|
||||
|| addr < (Parent->StringTable->Data.begin()
|
||||
+ sizeof(ArchiveMemberHeader))
|
||||
|| addr > (Parent->StringTable->Data.begin()
|
||||
+ sizeof(ArchiveMemberHeader)
|
||||
+ Parent->StringTable->getSize()))
|
||||
if (offset >= Parent->StringTable.size())
|
||||
return object_error::parse_failed;
|
||||
const char *addr = Parent->StringTable.begin() + offset;
|
||||
|
||||
// GNU long file names end with a "/\n".
|
||||
if (Parent->kind() == K_GNU || Parent->kind() == K_MIPS64) {
|
||||
@ -240,7 +234,7 @@ ErrorOr<std::unique_ptr<Archive>> Archive::create(MemoryBufferRef Source) {
|
||||
|
||||
Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
|
||||
: Binary(Binary::ID_Archive, Source), SymbolTable(child_end()),
|
||||
StringTable(child_end()), FirstRegular(child_end()) {
|
||||
FirstRegular(child_end()) {
|
||||
StringRef Buffer = Data.getBuffer();
|
||||
// Check for sufficient magic.
|
||||
if (Buffer.startswith(ThinMagic)) {
|
||||
@ -328,7 +322,9 @@ Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
|
||||
|
||||
if (Name == "//") {
|
||||
Format = has64SymTable ? K_MIPS64 : K_GNU;
|
||||
StringTable = i;
|
||||
// The string table is never an external member, so we just assert on the
|
||||
// ErrorOr.
|
||||
StringTable = *i->getBuffer();
|
||||
++i;
|
||||
FirstRegular = i;
|
||||
ec = std::error_code();
|
||||
@ -360,7 +356,9 @@ Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
|
||||
Name = i->getRawName();
|
||||
|
||||
if (Name == "//") {
|
||||
StringTable = i;
|
||||
// The string table is never an external member, so we just assert on the
|
||||
// ErrorOr.
|
||||
StringTable = *i->getBuffer();
|
||||
++i;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user