mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-18 13:34:04 +00:00
Fix fetching the symbol table of a thin archive.
We were trying to read it as an external file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242926 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1d5c214e84
commit
9db135a5f1
@ -62,6 +62,8 @@ public:
|
||||
return reinterpret_cast<const ArchiveMemberHeader *>(Data.data());
|
||||
}
|
||||
|
||||
bool isThinMember() const;
|
||||
|
||||
public:
|
||||
Child(const Archive *Parent, const char *Start);
|
||||
|
||||
|
@ -87,17 +87,17 @@ Archive::Child::Child(const Archive *Parent, const char *Start)
|
||||
if (!Start)
|
||||
return;
|
||||
|
||||
const ArchiveMemberHeader *Header =
|
||||
reinterpret_cast<const ArchiveMemberHeader *>(Start);
|
||||
uint64_t Size = sizeof(ArchiveMemberHeader);
|
||||
if (!Parent->IsThin || Header->getName() == "/" || Header->getName() == "//")
|
||||
Size += Header->getSize();
|
||||
Data = StringRef(Start, Size);
|
||||
if (!isThinMember()) {
|
||||
Size += getRawSize();
|
||||
Data = StringRef(Start, Size);
|
||||
}
|
||||
|
||||
// Setup StartOfFile and PaddingBytes.
|
||||
StartOfFile = sizeof(ArchiveMemberHeader);
|
||||
// Don't include attached name.
|
||||
StringRef Name = Header->getName();
|
||||
StringRef Name = getRawName();
|
||||
if (Name.startswith("#1/")) {
|
||||
uint64_t NameSize;
|
||||
if (Name.substr(3).rtrim(" ").getAsInteger(10, NameSize))
|
||||
@ -116,8 +116,13 @@ uint64_t Archive::Child::getRawSize() const {
|
||||
return getHeader()->getSize();
|
||||
}
|
||||
|
||||
bool Archive::Child::isThinMember() const {
|
||||
StringRef Name = getHeader()->getName();
|
||||
return Parent->IsThin && Name != "/" && Name != "//";
|
||||
}
|
||||
|
||||
ErrorOr<StringRef> Archive::Child::getBuffer() const {
|
||||
if (!Parent->IsThin)
|
||||
if (!isThinMember())
|
||||
return StringRef(Data.data() + StartOfFile, getSize());
|
||||
ErrorOr<StringRef> Name = getName();
|
||||
if (std::error_code EC = Name.getError())
|
||||
|
@ -8,6 +8,17 @@ CHECK-NEXT: foo in trivial-object-test2.elf-x86-64
|
||||
CHECK-NEXT: main in trivial-object-test2.elf-x86-64
|
||||
CHECK-NOT: bar
|
||||
|
||||
|
||||
RUN: rm -f %t.a
|
||||
RUN: llvm-ar rcT %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
|
||||
RUN: llvm-nm -M %t.a | FileCheck --check-prefix=THIN %s
|
||||
|
||||
THIN: Archive map
|
||||
THIN-NEXT: main in {{.*}}/Inputs/trivial-object-test.elf-x86-64
|
||||
THIN-NEXT: foo in {{.*}}/Inputs/trivial-object-test2.elf-x86-64
|
||||
THIN-NEXT: main in {{.*}}/Inputs/trivial-object-test2.elf-x86-64
|
||||
|
||||
|
||||
CHECK: trivial-object-test.elf-x86-64:
|
||||
CHECK-NEXT: U SomeOtherFunction
|
||||
CHECK-NEXT: 0000000000000000 T main
|
||||
|
Loading…
x
Reference in New Issue
Block a user