Commit 495b338d authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[cleanup] Replace ZoneList with ZoneChunkList in ELF class

R=petermarshall@chromium.org

Bug: v8:7754
Change-Id: I70e433cda81629496aef0b5b2c8b379787765c31
Reviewed-on: https://chromium-review.googlesource.com/1144932
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54586}
parent 23cb219f
...@@ -604,9 +604,9 @@ class MachO BASE_EMBEDDED { ...@@ -604,9 +604,9 @@ class MachO BASE_EMBEDDED {
#if defined(__ELF) #if defined(__ELF)
class ELF BASE_EMBEDDED { class ELF BASE_EMBEDDED {
public: public:
explicit ELF(Zone* zone) : zone_(zone), sections_(6, zone) { explicit ELF(Zone* zone) : sections_(zone) {
sections_.Add(new(zone) ELFSection("", ELFSection::TYPE_NULL, 0), zone); sections_.push_back(new (zone) ELFSection("", ELFSection::TYPE_NULL, 0));
sections_.Add(new(zone) ELFStringTable(".shstrtab"), zone); sections_.push_back(new (zone) ELFStringTable(".shstrtab"));
} }
void Write(Writer* w) { void Write(Writer* w) {
...@@ -615,14 +615,12 @@ class ELF BASE_EMBEDDED { ...@@ -615,14 +615,12 @@ class ELF BASE_EMBEDDED {
WriteSections(w); WriteSections(w);
} }
ELFSection* SectionAt(uint32_t index) { ELFSection* SectionAt(uint32_t index) { return sections_.at(index); }
return sections_[index];
}
uint32_t AddSection(ELFSection* section) { size_t AddSection(ELFSection* section) {
sections_.Add(section, zone_); sections_.push_back(section);
section->set_index(sections_.length() - 1); section->set_index(sections_.size() - 1);
return sections_.length() - 1; return sections_.size() - 1;
} }
private: private:
...@@ -705,7 +703,7 @@ class ELF BASE_EMBEDDED { ...@@ -705,7 +703,7 @@ class ELF BASE_EMBEDDED {
header->pht_entry_size = 0; header->pht_entry_size = 0;
header->pht_entry_num = 0; header->pht_entry_num = 0;
header->sht_entry_size = sizeof(ELFSection::Header); header->sht_entry_size = sizeof(ELFSection::Header);
header->sht_entry_num = sections_.length(); header->sht_entry_num = sections_.size();
header->sht_strtab_index = 1; header->sht_strtab_index = 1;
} }
...@@ -714,15 +712,16 @@ class ELF BASE_EMBEDDED { ...@@ -714,15 +712,16 @@ class ELF BASE_EMBEDDED {
DCHECK(w->position() == sizeof(ELFHeader)); DCHECK(w->position() == sizeof(ELFHeader));
Writer::Slot<ELFSection::Header> headers = Writer::Slot<ELFSection::Header> headers =
w->CreateSlotsHere<ELFSection::Header>(sections_.length()); w->CreateSlotsHere<ELFSection::Header>(
static_cast<uint32_t>(sections_.size()));
// String table for section table is the first section. // String table for section table is the first section.
ELFStringTable* strtab = static_cast<ELFStringTable*>(SectionAt(1)); ELFStringTable* strtab = static_cast<ELFStringTable*>(SectionAt(1));
strtab->AttachWriter(w); strtab->AttachWriter(w);
for (int i = 0, length = sections_.length(); uint32_t index = 0;
i < length; for (ELFSection* section : sections_) {
i++) { section->PopulateHeader(headers.at(index), strtab);
sections_[i]->PopulateHeader(headers.at(i), strtab); index++;
} }
strtab->DetachWriter(); strtab->DetachWriter();
} }
...@@ -735,15 +734,14 @@ class ELF BASE_EMBEDDED { ...@@ -735,15 +734,14 @@ class ELF BASE_EMBEDDED {
Writer::Slot<ELFSection::Header> headers = Writer::Slot<ELFSection::Header> headers =
w->SlotAt<ELFSection::Header>(sizeof(ELFHeader)); w->SlotAt<ELFSection::Header>(sizeof(ELFHeader));
for (int i = 0, length = sections_.length(); uint32_t index = 0;
i < length; for (ELFSection* section : sections_) {
i++) { section->WriteBody(headers.at(index), w);
sections_[i]->WriteBody(headers.at(i), w); index++;
} }
} }
Zone* zone_; ZoneChunkList<ELFSection*> sections_;
ZoneList<ELFSection*> sections_;
}; };
...@@ -1041,10 +1039,8 @@ class CodeDescription BASE_EMBEDDED { ...@@ -1041,10 +1039,8 @@ class CodeDescription BASE_EMBEDDED {
}; };
#if defined(__ELF) #if defined(__ELF)
static void CreateSymbolsTable(CodeDescription* desc, static void CreateSymbolsTable(CodeDescription* desc, Zone* zone, ELF* elf,
Zone* zone, size_t text_section_index) {
ELF* elf,
int text_section_index) {
ELFSymbolTable* symtab = new(zone) ELFSymbolTable(".symtab", zone); ELFSymbolTable* symtab = new(zone) ELFSymbolTable(".symtab", zone);
ELFStringTable* strtab = new(zone) ELFStringTable(".strtab"); ELFStringTable* strtab = new(zone) ELFStringTable(".strtab");
...@@ -1921,15 +1917,9 @@ static JITCodeEntry* CreateELFObject(CodeDescription* desc, Isolate* isolate) { ...@@ -1921,15 +1917,9 @@ static JITCodeEntry* CreateELFObject(CodeDescription* desc, Isolate* isolate) {
ELF elf(&zone); ELF elf(&zone);
Writer w(&elf); Writer w(&elf);
int text_section_index = elf.AddSection( size_t text_section_index = elf.AddSection(new (&zone) FullHeaderELFSection(
new(&zone) FullHeaderELFSection( ".text", ELFSection::TYPE_NOBITS, kCodeAlignment, desc->CodeStart(), 0,
".text", desc->CodeSize(), ELFSection::FLAG_ALLOC | ELFSection::FLAG_EXEC));
ELFSection::TYPE_NOBITS,
kCodeAlignment,
desc->CodeStart(),
0,
desc->CodeSize(),
ELFSection::FLAG_ALLOC | ELFSection::FLAG_EXEC));
CreateSymbolsTable(desc, &zone, &elf, text_section_index); CreateSymbolsTable(desc, &zone, &elf, text_section_index);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment