llvm.org GIT mirror llvm / 9db135a
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 Rafael Espindola 5 years ago
3 changed file(s) with 24 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
6161 return reinterpret_cast(Data.data());
6262 }
6363
64 bool isThinMember() const;
65
6466 public:
6567 Child(const Archive *Parent, const char *Start);
6668
8686 if (!Start)
8787 return;
8888
89 const ArchiveMemberHeader *Header =
90 reinterpret_cast(Start);
9189 uint64_t Size = sizeof(ArchiveMemberHeader);
92 if (!Parent->IsThin || Header->getName() == "/" || Header->getName() == "//")
93 Size += Header->getSize();
9490 Data = StringRef(Start, Size);
91 if (!isThinMember()) {
92 Size += getRawSize();
93 Data = StringRef(Start, Size);
94 }
9595
9696 // Setup StartOfFile and PaddingBytes.
9797 StartOfFile = sizeof(ArchiveMemberHeader);
9898 // Don't include attached name.
99 StringRef Name = Header->getName();
99 StringRef Name = getRawName();
100100 if (Name.startswith("#1/")) {
101101 uint64_t NameSize;
102102 if (Name.substr(3).rtrim(" ").getAsInteger(10, NameSize))
115115 return getHeader()->getSize();
116116 }
117117
118 bool Archive::Child::isThinMember() const {
119 StringRef Name = getHeader()->getName();
120 return Parent->IsThin && Name != "/" && Name != "//";
121 }
122
118123 ErrorOr Archive::Child::getBuffer() const {
119 if (!Parent->IsThin)
124 if (!isThinMember())
120125 return StringRef(Data.data() + StartOfFile, getSize());
121126 ErrorOr Name = getName();
122127 if (std::error_code EC = Name.getError())
66 CHECK-NEXT: foo in trivial-object-test2.elf-x86-64
77 CHECK-NEXT: main in trivial-object-test2.elf-x86-64
88 CHECK-NOT: bar
9
10
11 RUN: rm -f %t.a
12 RUN: llvm-ar rcT %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64
13 RUN: llvm-nm -M %t.a | FileCheck --check-prefix=THIN %s
14
15 THIN: Archive map
16 THIN-NEXT: main in {{.*}}/Inputs/trivial-object-test.elf-x86-64
17 THIN-NEXT: foo in {{.*}}/Inputs/trivial-object-test2.elf-x86-64
18 THIN-NEXT: main in {{.*}}/Inputs/trivial-object-test2.elf-x86-64
19
920
1021 CHECK: trivial-object-test.elf-x86-64:
1122 CHECK-NEXT: U SomeOtherFunction