OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 | 622 |
623 Zone* zone_; | 623 Zone* zone_; |
624 ZoneList<MachOSection*> sections_; | 624 ZoneList<MachOSection*> sections_; |
625 }; | 625 }; |
626 #endif // defined(__MACH_O) | 626 #endif // defined(__MACH_O) |
627 | 627 |
628 | 628 |
629 #if defined(__ELF) | 629 #if defined(__ELF) |
630 class ELF BASE_EMBEDDED { | 630 class ELF BASE_EMBEDDED { |
631 public: | 631 public: |
632 explicit ELF(Zone* zone) : sections_(6, zone) { | 632 explicit ELF(Zone* zone) : zone_(zone), sections_(6, zone) { |
633 sections_.Add(new(zone) ELFSection("", ELFSection::TYPE_NULL, 0), zone); | 633 sections_.Add(new(zone) ELFSection("", ELFSection::TYPE_NULL, 0), zone); |
634 sections_.Add(new(zone) ELFStringTable(".shstrtab"), zone); | 634 sections_.Add(new(zone) ELFStringTable(".shstrtab"), zone); |
635 } | 635 } |
636 | 636 |
637 void Write(Writer* w) { | 637 void Write(Writer* w) { |
638 WriteHeader(w); | 638 WriteHeader(w); |
639 WriteSectionTable(w); | 639 WriteSectionTable(w); |
640 WriteSections(w); | 640 WriteSections(w); |
641 } | 641 } |
642 | 642 |
643 ELFSection* SectionAt(uint32_t index) { | 643 ELFSection* SectionAt(uint32_t index) { |
644 return sections_[index]; | 644 return sections_[index]; |
645 } | 645 } |
646 | 646 |
647 uint32_t AddSection(ELFSection* section, Zone* zone) { | 647 uint32_t AddSection(ELFSection* section) { |
648 sections_.Add(section, zone); | 648 sections_.Add(section, zone_); |
649 section->set_index(sections_.length() - 1); | 649 section->set_index(sections_.length() - 1); |
650 return sections_.length() - 1; | 650 return sections_.length() - 1; |
651 } | 651 } |
652 | 652 |
653 private: | 653 private: |
654 struct ELFHeader { | 654 struct ELFHeader { |
655 uint8_t ident[16]; | 655 uint8_t ident[16]; |
656 uint16_t type; | 656 uint16_t type; |
657 uint16_t machine; | 657 uint16_t machine; |
658 uint32_t version; | 658 uint32_t version; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 Writer::Slot<ELFSection::Header> headers = | 736 Writer::Slot<ELFSection::Header> headers = |
737 w->SlotAt<ELFSection::Header>(sizeof(ELFHeader)); | 737 w->SlotAt<ELFSection::Header>(sizeof(ELFHeader)); |
738 | 738 |
739 for (int i = 0, length = sections_.length(); | 739 for (int i = 0, length = sections_.length(); |
740 i < length; | 740 i < length; |
741 i++) { | 741 i++) { |
742 sections_[i]->WriteBody(headers.at(i), w); | 742 sections_[i]->WriteBody(headers.at(i), w); |
743 } | 743 } |
744 } | 744 } |
745 | 745 |
| 746 Zone* zone_; |
746 ZoneList<ELFSection*> sections_; | 747 ZoneList<ELFSection*> sections_; |
747 }; | 748 }; |
748 | 749 |
749 | 750 |
750 class ELFSymbol BASE_EMBEDDED { | 751 class ELFSymbol BASE_EMBEDDED { |
751 public: | 752 public: |
752 enum Type { | 753 enum Type { |
753 TYPE_NOTYPE = 0, | 754 TYPE_NOTYPE = 0, |
754 TYPE_OBJECT = 1, | 755 TYPE_OBJECT = 1, |
755 TYPE_FUNC = 2, | 756 TYPE_FUNC = 2, |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 | 1020 |
1020 #if defined(__ELF) | 1021 #if defined(__ELF) |
1021 static void CreateSymbolsTable(CodeDescription* desc, | 1022 static void CreateSymbolsTable(CodeDescription* desc, |
1022 Zone* zone, | 1023 Zone* zone, |
1023 ELF* elf, | 1024 ELF* elf, |
1024 int text_section_index) { | 1025 int text_section_index) { |
1025 ELFSymbolTable* symtab = new(zone) ELFSymbolTable(".symtab", zone); | 1026 ELFSymbolTable* symtab = new(zone) ELFSymbolTable(".symtab", zone); |
1026 ELFStringTable* strtab = new(zone) ELFStringTable(".strtab"); | 1027 ELFStringTable* strtab = new(zone) ELFStringTable(".strtab"); |
1027 | 1028 |
1028 // Symbol table should be followed by the linked string table. | 1029 // Symbol table should be followed by the linked string table. |
1029 elf->AddSection(symtab, zone); | 1030 elf->AddSection(symtab); |
1030 elf->AddSection(strtab, zone); | 1031 elf->AddSection(strtab); |
1031 | 1032 |
1032 symtab->Add(ELFSymbol("V8 Code", | 1033 symtab->Add(ELFSymbol("V8 Code", |
1033 0, | 1034 0, |
1034 0, | 1035 0, |
1035 ELFSymbol::BIND_LOCAL, | 1036 ELFSymbol::BIND_LOCAL, |
1036 ELFSymbol::TYPE_FILE, | 1037 ELFSymbol::TYPE_FILE, |
1037 ELFSection::INDEX_ABSOLUTE), | 1038 ELFSection::INDEX_ABSOLUTE), |
1038 zone); | 1039 zone); |
1039 | 1040 |
1040 symtab->Add(ELFSymbol(desc->name(), | 1041 symtab->Add(ELFSymbol(desc->name(), |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 Writer w(&elf); | 1935 Writer w(&elf); |
1935 | 1936 |
1936 int text_section_index = elf.AddSection( | 1937 int text_section_index = elf.AddSection( |
1937 new(&zone) FullHeaderELFSection( | 1938 new(&zone) FullHeaderELFSection( |
1938 ".text", | 1939 ".text", |
1939 ELFSection::TYPE_NOBITS, | 1940 ELFSection::TYPE_NOBITS, |
1940 kCodeAlignment, | 1941 kCodeAlignment, |
1941 desc->CodeStart(), | 1942 desc->CodeStart(), |
1942 0, | 1943 0, |
1943 desc->CodeSize(), | 1944 desc->CodeSize(), |
1944 ELFSection::FLAG_ALLOC | ELFSection::FLAG_EXEC), | 1945 ELFSection::FLAG_ALLOC | ELFSection::FLAG_EXEC)); |
1945 &zone); | |
1946 | 1946 |
1947 CreateSymbolsTable(desc, &zone, &elf, text_section_index); | 1947 CreateSymbolsTable(desc, &zone, &elf, text_section_index); |
1948 | 1948 |
1949 CreateDWARFSections(desc, &zone, &elf); | 1949 CreateDWARFSections(desc, &zone, &elf); |
1950 | 1950 |
1951 elf.Write(&w); | 1951 elf.Write(&w); |
1952 #endif | 1952 #endif |
1953 | 1953 |
1954 return CreateCodeEntry(w.buffer(), w.position()); | 1954 return CreateCodeEntry(w.buffer(), w.position()); |
1955 } | 1955 } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2170 ScopedLock lock(mutex.Pointer()); | 2170 ScopedLock lock(mutex.Pointer()); |
2171 ASSERT(!IsLineInfoTagged(line_info)); | 2171 ASSERT(!IsLineInfoTagged(line_info)); |
2172 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); | 2172 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); |
2173 ASSERT(e->value == NULL); | 2173 ASSERT(e->value == NULL); |
2174 e->value = TagLineInfo(line_info); | 2174 e->value = TagLineInfo(line_info); |
2175 } | 2175 } |
2176 | 2176 |
2177 | 2177 |
2178 } } // namespace v8::internal | 2178 } } // namespace v8::internal |
2179 #endif | 2179 #endif |
OLD | NEW |