llvm.org GIT mirror llvm / 2225825
Simplify the handling of the archive string table. We only need to store a StringRef git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251746 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 4 years ago
2 changed file(s) with 11 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
217217
218218 private:
219219 child_iterator SymbolTable;
220 child_iterator StringTable;
220 StringRef StringTable;
221221 child_iterator FirstRegular;
222222 unsigned Format : 2;
223223 unsigned IsThin : 1;
178178 std::size_t offset;
179179 if (name.substr(1).rtrim(" ").getAsInteger(10, offset))
180180 llvm_unreachable("Long name offset is not an integer");
181 const char *addr = Parent->StringTable->Data.begin()
182 + sizeof(ArchiveMemberHeader)
183 + offset;
181
184182 // Verify it.
185 if (Parent->StringTable == Parent->child_end()
186 || addr < (Parent->StringTable->Data.begin()
187 + sizeof(ArchiveMemberHeader))
188 || addr > (Parent->StringTable->Data.begin()
189 + sizeof(ArchiveMemberHeader)
190 + Parent->StringTable->getSize()))
183 if (offset >= Parent->StringTable.size())
191184 return object_error::parse_failed;
185 const char *addr = Parent->StringTable.begin() + offset;
192186
193187 // GNU long file names end with a "/\n".
194188 if (Parent->kind() == K_GNU || Parent->kind() == K_MIPS64) {
239233
240234 Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
241235 : Binary(Binary::ID_Archive, Source), SymbolTable(child_end()),
242 StringTable(child_end()), FirstRegular(child_end()) {
236 FirstRegular(child_end()) {
243237 StringRef Buffer = Data.getBuffer();
244238 // Check for sufficient magic.
245239 if (Buffer.startswith(ThinMagic)) {
327321
328322 if (Name == "//") {
329323 Format = has64SymTable ? K_MIPS64 : K_GNU;
330 StringTable = i;
324 // The string table is never an external member, so we just assert on the
325 // ErrorOr.
326 StringTable = *i->getBuffer();
331327 ++i;
332328 FirstRegular = i;
333329 ec = std::error_code();
359355 Name = i->getRawName();
360356
361357 if (Name == "//") {
362 StringTable = i;
358 // The string table is never an external member, so we just assert on the
359 // ErrorOr.
360 StringTable = *i->getBuffer();
363361 ++i;
364362 }
365363