Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Side by Side Diff: lib/Object/Archive.cpp

Issue 9617030: Distinguish between ELF 32/64, little/big endian, in the type system of Binary.h (Closed) Base URL: https://llvm.org/svn/llvm-project/llvm/trunk/
Patch Set: x Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/llvm/Object/ObjectFile.h ('k') | lib/Object/COFFObjectFile.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « include/llvm/Object/ObjectFile.h ('k') | lib/Object/COFFObjectFile.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698