| OLD | NEW |
| 1 //===- Archive.cpp - ar File Format implementation --------------*- C++ -*-===// | 1 //===- Archive.cpp - ar File Format implementation --------------*- C++ -*-===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This file defines the ArchiveObjectFile class. | 10 // This file defines the ArchiveObjectFile class. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 error_code Archive::Child::getAsBinary(OwningPtr<Binary> &Result) const { | 167 error_code Archive::Child::getAsBinary(OwningPtr<Binary> &Result) const { |
| 168 OwningPtr<Binary> ret; | 168 OwningPtr<Binary> ret; |
| 169 if (error_code ec = | 169 if (error_code ec = |
| 170 createBinary(getBuffer(), ret)) | 170 createBinary(getBuffer(), ret)) |
| 171 return ec; | 171 return ec; |
| 172 Result.swap(ret); | 172 Result.swap(ret); |
| 173 return object_error::success; | 173 return object_error::success; |
| 174 } | 174 } |
| 175 | 175 |
| 176 Archive::Archive(MemoryBuffer *source, error_code &ec) | 176 Archive::Archive(MemoryBuffer *source, error_code &ec) |
| 177 : Binary(Binary::isArchive, source) { | 177 : Binary(Binary::ID_Archive, source) { |
| 178 // Check for sufficient magic. | 178 // Check for sufficient magic. |
| 179 if (!source || source->getBufferSize() | 179 if (!source || source->getBufferSize() |
| 180 < (8 + sizeof(ArchiveMemberHeader) + 2) // Smallest archive. | 180 < (8 + sizeof(ArchiveMemberHeader) + 2) // Smallest archive. |
| 181 || StringRef(source->getBufferStart(), 8) != Magic) { | 181 || StringRef(source->getBufferStart(), 8) != Magic) { |
| 182 ec = object_error::invalid_file_type; | 182 ec = object_error::invalid_file_type; |
| 183 return; | 183 return; |
| 184 } | 184 } |
| 185 | 185 |
| 186 // Get the special members. | 186 // Get the special members. |
| 187 child_iterator i = begin_children(false); | 187 child_iterator i = begin_children(false); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 263 } |
| 264 | 264 |
| 265 Archive::symbol_iterator Archive::end_symbols() const { | 265 Archive::symbol_iterator Archive::end_symbols() const { |
| 266 const char *buf = SymbolTable->getBuffer()->getBufferStart(); | 266 const char *buf = SymbolTable->getBuffer()->getBufferStart(); |
| 267 uint32_t member_count = *reinterpret_cast<const support::ulittle32_t*>(buf); | 267 uint32_t member_count = *reinterpret_cast<const support::ulittle32_t*>(buf); |
| 268 buf += 4 + (member_count * 4); // Skip offsets. | 268 buf += 4 + (member_count * 4); // Skip offsets. |
| 269 uint32_t symbol_count = *reinterpret_cast<const support::ulittle32_t*>(buf); | 269 uint32_t symbol_count = *reinterpret_cast<const support::ulittle32_t*>(buf); |
| 270 return symbol_iterator( | 270 return symbol_iterator( |
| 271 Symbol(this, symbol_count, 0)); | 271 Symbol(this, symbol_count, 0)); |
| 272 } | 272 } |
| OLD | NEW |