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

Side by Side Diff: runtime/vm/elfgen.h

Issue 12018023: Modify vm code base so that it can be built for --arch=simmips. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 | « runtime/vm/cpu_test.cc ('k') | runtime/vm/instructions.h » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_ELFGEN_H_ 5 #ifndef VM_ELFGEN_H_
6 #define VM_ELFGEN_H_ 6 #define VM_ELFGEN_H_
7 7
8 #include "vm/thread.h" 8 #include "vm/thread.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 ASSERT(text_vma_ != 0); // code must have been added 335 ASSERT(text_vma_ != 0); // code must have been added
336 DebugInfo::ByteBuffer* symtab = &section_buf_[kSymtab]; 336 DebugInfo::ByteBuffer* symtab = &section_buf_[kSymtab];
337 const int beg = symtab->size(); 337 const int beg = symtab->size();
338 WriteInt(symtab, AddName(name)); // st_name 338 WriteInt(symtab, AddName(name)); // st_name
339 #if defined(TARGET_ARCH_X64) 339 #if defined(TARGET_ARCH_X64)
340 WriteShort(symtab, (kSTB_LOCAL << 4) + kSTT_FUNC); // st_info + (st_other<<8) 340 WriteShort(symtab, (kSTB_LOCAL << 4) + kSTT_FUNC); // st_info + (st_other<<8)
341 WriteShort(symtab, kText); // st_shndx 341 WriteShort(symtab, kText); // st_shndx
342 #endif 342 #endif
343 WriteWord(symtab, pc); // st_value 343 WriteWord(symtab, pc); // st_value
344 WriteWord(symtab, size); // st_size 344 WriteWord(symtab, size); // st_size
345 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) 345 #if defined(TARGET_ARCH_IA32) || \
Ivan Posva 2013/01/18 23:57:39 Should this be ARCH_IS_32_BIT and ARCH_IS_64_BIT,
regis 2013/01/19 00:17:34 Good point. I'll fix that in a later cl with other
346 defined(TARGET_ARCH_ARM) || \
347 defined(TARGET_ARCH_MIPS)
346 // st_info + (st_other<<8) 348 // st_info + (st_other<<8)
347 WriteShort(symtab, (kSTB_EXPORTED << 4) + kSTT_FUNC); 349 WriteShort(symtab, (kSTB_EXPORTED << 4) + kSTT_FUNC);
348 WriteShort(symtab, kText); // st_shndx 350 WriteShort(symtab, kText); // st_shndx
349 #endif 351 #endif
350 ASSERT(symtab->size() - beg == kSymbolSize); 352 ASSERT(symtab->size() - beg == kSymbolSize);
351 return beg / kSymbolSize; // symbol index in symtab 353 return beg / kSymbolSize; // symbol index in symtab
352 } 354 }
353 355
354 356
355 bool ElfGen::WriteToFile(File* handle) { 357 bool ElfGen::WriteToFile(File* handle) {
(...skipping 20 matching lines...) Expand all
376 378
377 379
378 int ElfGen::AddName(const char* str) { 380 int ElfGen::AddName(const char* str) {
379 return AddString(&section_buf_[kStrtab], str); 381 return AddString(&section_buf_[kStrtab], str);
380 } 382 }
381 383
382 384
383 void ElfGen::AddELFHeader(int shoff) { 385 void ElfGen::AddELFHeader(int shoff) {
384 ASSERT(text_vma_ != 0); // Code must have been added. 386 ASSERT(text_vma_ != 0); // Code must have been added.
385 Write(&header_, kEI_MAG0_MAG3, 4); // EI_MAG0..EI_MAG3 387 Write(&header_, kEI_MAG0_MAG3, 4); // EI_MAG0..EI_MAG3
386 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) 388 #if defined(TARGET_ARCH_IA32) || \
389 defined(TARGET_ARCH_ARM) || \
390 defined(TARGET_ARCH_MIPS)
regis 2013/01/19 00:17:34 ditto
387 WriteByte(&header_, kELFCLASS32); // EI_CLASS 391 WriteByte(&header_, kELFCLASS32); // EI_CLASS
388 #elif defined(TARGET_ARCH_X64) 392 #elif defined(TARGET_ARCH_X64)
389 WriteByte(&header_, kELFCLASS64); // EI_CLASS 393 WriteByte(&header_, kELFCLASS64); // EI_CLASS
390 #endif 394 #endif
391 WriteByte(&header_, kELFDATA2LSB); // EI_DATA 395 WriteByte(&header_, kELFDATA2LSB); // EI_DATA
392 WriteByte(&header_, kEV_CURRENT); // EI_VERSION 396 WriteByte(&header_, kEV_CURRENT); // EI_VERSION
393 WriteByte(&header_, 0); // EI_PAD 397 WriteByte(&header_, 0); // EI_PAD
394 WriteInt(&header_, 0); // EI_PAD 398 WriteInt(&header_, 0); // EI_PAD
395 WriteInt(&header_, 0); // EI_PAD 399 WriteInt(&header_, 0); // EI_PAD
396 WriteShort(&header_, kET_DYN); // e_type, fake a shared object. 400 WriteShort(&header_, kET_DYN); // e_type, fake a shared object.
397 #if defined(TARGET_ARCH_IA32) 401 #if defined(TARGET_ARCH_IA32)
398 WriteShort(&header_, kEM_386); // e_machine 402 WriteShort(&header_, kEM_386); // e_machine
399 #elif defined(TARGET_ARCH_X64) 403 #elif defined(TARGET_ARCH_X64)
400 WriteShort(&header_, kEM_X86_64); // e_machine 404 WriteShort(&header_, kEM_X86_64); // e_machine
401 #elif defined(TARGET_ARCH_ARM) 405 #elif defined(TARGET_ARCH_ARM)
402 WriteShort(&header_, kEM_ARM); // e_machine 406 WriteShort(&header_, kEM_ARM); // e_machine
403 #endif 407 #endif
regis 2013/01/19 00:17:34 I will handle MIPS here as well.
404 WriteInt(&header_, kEV_CURRENT); // e_version 408 WriteInt(&header_, kEV_CURRENT); // e_version
405 WriteWord(&header_, 0); // e_entry: none 409 WriteWord(&header_, 0); // e_entry: none
406 WriteWord(&header_, 0); // e_phoff: no program header table. 410 WriteWord(&header_, 0); // e_phoff: no program header table.
407 WriteWord(&header_, shoff); // e_shoff: section header table offset. 411 WriteWord(&header_, shoff); // e_shoff: section header table offset.
408 WriteInt(&header_, 0); // e_flags: no flags. 412 WriteInt(&header_, 0); // e_flags: no flags.
409 WriteShort(&header_, kELFHeaderSize); // e_ehsize: header size. 413 WriteShort(&header_, kELFHeaderSize); // e_ehsize: header size.
410 WriteShort(&header_, kProgramHeaderEntrySize); // e_phentsize 414 WriteShort(&header_, kProgramHeaderEntrySize); // e_phentsize
411 WriteShort(&header_, 0); // e_phnum: no entries program header table. 415 WriteShort(&header_, 0); // e_phnum: no entries program header table.
412 WriteShort(&header_, kSectionHeaderEntrySize); // e_shentsize 416 WriteShort(&header_, kSectionHeaderEntrySize); // e_shentsize
413 // e_shnum: number of section header entries. 417 // e_shnum: number of section header entries.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 ASSERT(offset == shoff); 493 ASSERT(offset == shoff);
490 offset += (*writer)(handle, sheaders_); 494 offset += (*writer)(handle, sheaders_);
491 ASSERT(offset == shoff + kNumSections * kSectionHeaderEntrySize); 495 ASSERT(offset == shoff + kNumSections * kSectionHeaderEntrySize);
492 496
493 return true; 497 return true;
494 } 498 }
495 499
496 } // namespace dart 500 } // namespace dart
497 501
498 #endif // VM_ELFGEN_H_ 502 #endif // VM_ELFGEN_H_
OLDNEW
« no previous file with comments | « runtime/vm/cpu_test.cc ('k') | runtime/vm/instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698