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

Side by Side Diff: courgette/image_info.cc

Issue 8344037: Start refactoring to reduce executable type knowledge. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix comment. Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « courgette/ensemble_create.cc ('k') | courgette/image_info_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "courgette/image_info.h" 5 #include "courgette/image_info.h"
6 6
7 #include <memory.h> 7 #include <memory.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // header to see if the section contains instructions. 303 // header to see if the section contains instructions.
304 if (memcmp(section->name, ".text", 6) == 0) 304 if (memcmp(section->name, ".text", 6) == 0)
305 has_text_section_ = true; 305 has_text_section_ = true;
306 306
307 uint32 section_end = 307 uint32 section_end =
308 section->file_offset_of_raw_data + section->size_of_raw_data; 308 section->file_offset_of_raw_data + section->size_of_raw_data;
309 if (section_end > file_length_) 309 if (section_end > file_length_)
310 file_length_ = section_end; 310 file_length_ = section_end;
311 } 311 }
312 312
313 if (!is_32bit()) {
314 return Bad("64 bit executables are not yet supported");
315 }
316
317 if (!has_text_section()) {
318 return Bad("Resource-only executables are not yet supported");
319 }
320
313 failure_reason_ = NULL; 321 failure_reason_ = NULL;
314 return true; 322 return true;
315 } 323 }
316 324
317 bool PEInfo::ReadDataDirectory(int index, ImageDataDirectory* directory) { 325 bool PEInfo::ReadDataDirectory(int index, ImageDataDirectory* directory) {
318 if (index < number_of_data_directories_) { 326 if (index < number_of_data_directories_) {
319 size_t offset = index * 8 + offset_of_data_directories_; 327 size_t offset = index * 8 + offset_of_data_directories_;
320 if (offset >= size_of_optional_header_) 328 if (offset >= size_of_optional_header_)
321 return Bad("number of data directories inconsistent"); 329 return Bad("number of data directories inconsistent");
322 const uint8* data_directory = optional_header_ + offset; 330 const uint8* data_directory = optional_header_ + offset;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 410
403 block += size; 411 block += size;
404 } 412 }
405 413
406 std::sort(relocs->begin(), relocs->end()); 414 std::sort(relocs->begin(), relocs->end());
407 415
408 return true; 416 return true;
409 } 417 }
410 418
411 } // namespace courgette 419 } // namespace courgette
OLDNEW
« no previous file with comments | « courgette/ensemble_create.cc ('k') | courgette/image_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698