int ScopeGUI::resize_event(int w, int h) { clear_box(0, 0, w, h); this->w = w; this->h = h; calculate_sizes(w, h); if(waveform) { waveform->reposition_window(wave_x, wave_y, wave_w, wave_h); waveform->clear_box(0, 0, wave_w, wave_h); } if(histogram) { histogram->reposition_window(hist_x, hist_y, hist_w, hist_h); histogram->clear_box(0, 0, hist_w, hist_h); } if(vectorscope) { vectorscope->reposition_window(vector_x, vector_y, vector_w, vector_h); vectorscope->clear_box(0, 0, vector_w, vector_h); } allocate_bitmaps(); clear_points(0); draw_overlays(1, 1, 1); return 1; }
void VWindowCanvas::zoom_resize_window(float percentage) { EDL *edl = gui->vwindow->get_edl(); if(!edl) edl = mwindow->edl; int canvas_w, canvas_h; int new_w, new_h; // Get required canvas size calculate_sizes(edl->get_aspect_ratio(), edl->session->output_w, edl->session->output_h, percentage, canvas_w, canvas_h); // Estimate window size from current borders new_w = canvas_w + (gui->get_w() - mwindow->theme->vcanvas_w); new_h = canvas_h + (gui->get_h() - mwindow->theme->vcanvas_h); mwindow->session->vwindow_w = new_w; mwindow->session->vwindow_h = new_h; mwindow->theme->get_vwindow_sizes(gui); // Estimate again from new borders new_w = canvas_w + (mwindow->session->vwindow_w - mwindow->theme->vcanvas_w); new_h = canvas_h + (mwindow->session->vwindow_h - mwindow->theme->vcanvas_h); gui->resize_window(new_w, new_h); gui->resize_event(new_w, new_h); }
/** Pre-unparsing updates */ bool SgAsmElfSegmentTable::reallocate() { bool reallocated = false; /* Resize based on word size from ELF File Header */ size_t opt_size, nentries; rose_addr_t need = calculate_sizes(NULL, NULL, &opt_size, &nentries); if (need < get_size()) { if (is_mapped()) { ROSE_ASSERT(get_mapped_size()==get_size()); set_mapped_size(need); } set_size(need); reallocated = true; } else if (need > get_size()) { get_file()->shift_extend(this, 0, need-get_size(), SgAsmGenericFile::ADDRSP_ALL, SgAsmGenericFile::ELASTIC_HOLE); reallocated = true; } /* Update data members in the ELF File Header. No need to return true for these changes. */ SgAsmElfFileHeader *fhdr = dynamic_cast<SgAsmElfFileHeader*>(get_header()); fhdr->set_phextrasz(opt_size); fhdr->set_e_phnum(nentries); return reallocated; }
bool SgAsmElfSection::reallocate() { bool reallocated = false; SgAsmElfSectionTableEntry *sechdr = get_section_entry(); SgAsmElfSegmentTableEntry *seghdr = get_segment_entry(); /* Change section size if this section was defined in the ELF Section Table */ if (sechdr!=NULL) { rose_addr_t need = calculate_sizes(NULL, NULL, NULL, NULL); if (need < get_size()) { if (is_mapped()) { ROSE_ASSERT(get_mapped_size()==get_size()); set_mapped_size(need); } set_size(need); reallocated = true; } else if (need > get_size()) { get_file()->shift_extend(this, 0, need-get_size(), SgAsmGenericFile::ADDRSP_ALL, SgAsmGenericFile::ELASTIC_HOLE); reallocated = true; } } /* Update entry in the ELF Section Table and/or ELF Segment Table */ if (sechdr) sechdr->update_from_section(this); if (seghdr) seghdr->update_from_section(this); return reallocated; }
MonoPIFunc mono_arch_create_trampoline (MonoMethodSignature *sig, gboolean string_ctor) { guint8 *p, *code_buffer; size_data sz; DEBUG (printf ("\nPInvoke [start emiting]\n")); calculate_sizes (sig, &sz, string_ctor); p = code_buffer = alloc_code_memory (sz.code_size); p = emit_prolog (p, sig, &sz); p = emit_save_parameters (p, sig, &sz); p = emit_call_and_store_retval (p, sig, &sz, string_ctor); p = emit_epilog (p, sig, &sz); #ifdef NEED_MPROTECT if (mprotect (code_buffer, 1024, PROT_READ | PROT_WRITE | PROT_EXEC)) { g_error ("Cannot mprotect trampoline\n"); } #endif DEBUG (printf ("emited code size: %d\n", p - code_buffer)); DEBUG (printf ("PInvoke [end emiting]\n")); return (MonoPIFunc) code_buffer; }
/** Return sizes for various parts of the table. See doc for SgAsmElfSection::calculate_sizes. */ rose_addr_t SgAsmElfSymbolSection::calculate_sizes(size_t *entsize, size_t *required, size_t *optional, size_t *entcount) const { std::vector<size_t> extra_sizes; for (size_t i=0; i<p_symbols->get_symbols().size(); i++) extra_sizes.push_back(p_symbols->get_symbols()[i]->get_extra().size()); return calculate_sizes(sizeof(SgAsmElfSymbol::Elf32SymbolEntry_disk), sizeof(SgAsmElfSymbol::Elf64SymbolEntry_disk), extra_sizes, entsize, required, optional, entcount); }
bool TaskDijkstra::refresh_task() { set_stages(task.TaskSize()); if (num_stages < 2) return false; active_stage = task.getActiveTaskPointIndex(); calculate_sizes(); return true; }
void RecordMonitorCanvas::zoom_resize_window(float percentage) { int canvas_w, canvas_h; calculate_sizes(mwindow->edl->get_aspect_ratio(), record->default_asset->width, record->default_asset->height, percentage, canvas_w, canvas_h); int new_w, new_h; new_w = canvas_w + (window->get_w() - mwindow->theme->rmonitor_canvas_w); new_h = canvas_h + (window->get_h() - mwindow->theme->rmonitor_canvas_h); window->resize_window(new_w, new_h); window->resize_event(new_w, new_h); }
/** Write the section table section back to disk */ void SgAsmElfSectionTable::unparse(std::ostream &f) const { SgAsmElfFileHeader *fhdr = dynamic_cast<SgAsmElfFileHeader*>(get_header()); ROSE_ASSERT(fhdr!=NULL); ByteOrder sex = fhdr->get_sex(); SgAsmGenericSectionPtrList sections = fhdr->get_sectab_sections(); /* Write the sections first */ for (size_t i=0; i<sections.size(); i++) sections[i]->unparse(f); unparse_holes(f); /* Calculate sizes. The ELF File Header should have been updated in reallocate() prior to unparsing. */ size_t ent_size, struct_size, opt_size, nentries; calculate_sizes(&ent_size, &struct_size, &opt_size, &nentries); ROSE_ASSERT(fhdr->get_shextrasz()==opt_size); ROSE_ASSERT(fhdr->get_e_shnum()==nentries); /* Write the section table entries */ for (size_t i=0; i<sections.size(); ++i) { SgAsmElfSection *section = dynamic_cast<SgAsmElfSection*>(sections[i]); ROSE_ASSERT(section!=NULL); SgAsmElfSectionTableEntry *shdr = section->get_section_entry(); ROSE_ASSERT(shdr!=NULL); ROSE_ASSERT(shdr->get_sh_offset()==section->get_offset());/*section table entry should have been updated in reallocate()*/ int id = section->get_id(); ROSE_ASSERT(id>=0 && (size_t)id<nentries); SgAsmElfSectionTableEntry::Elf32SectionTableEntry_disk disk32; SgAsmElfSectionTableEntry::Elf64SectionTableEntry_disk disk64; void *disk = NULL; if (4==fhdr->get_word_size()) { disk = shdr->encode(sex, &disk32); } else if (8==fhdr->get_word_size()) { disk = shdr->encode(sex, &disk64); } else { ROSE_ASSERT(!"invalid word size"); } /* The disk struct */ rose_addr_t spos = write(f, id*ent_size, struct_size, disk); if (shdr->get_extra().size() > 0) { ROSE_ASSERT(shdr->get_extra().size()<=opt_size); write(f, spos, shdr->get_extra()); } } }
MonoPIFunc mono_arch_create_trampoline (MonoMethodSignature *sig, gboolean string_ctor) { guint32 *p, *code_buffer; guint stack_size, code_size, i; gboolean use_memcpy = FALSE; static GHashTable *cache = NULL; MonoPIFunc res; if (!cache) cache = g_hash_table_new ((GHashFunc)mono_signature_hash, (GCompareFunc)mono_metadata_signature_equal); if ((res = (MonoPIFunc)g_hash_table_lookup(cache, sig))) return res; calculate_sizes (sig, &stack_size, &code_size, string_ctor, &use_memcpy); p = code_buffer = alloc_code_memory (code_size); p = emit_prolog (p, sig, stack_size); p = emit_save_parameters (p, sig, stack_size, use_memcpy); p = emit_call_and_store_retval (p, sig, stack_size, string_ctor); /* we don't return structs here so pass in NULL as signature */ p = emit_epilog (p, NULL, stack_size); g_assert(p <= code_buffer + (code_size / 4)); DEBUG(sparc_disassemble_code (code_buffer, p, sig_to_name(sig, NULL))); /* So here's the deal... * UltraSPARC will flush a whole cache line at a time * BUT, older SPARCs won't. * So, be compatable and flush dwords at a time... */ for (i = 0; i < ((p - code_buffer)/2); i++) flushi((code_buffer + (i*8))); g_hash_table_insert(cache, sig, code_buffer); return (MonoPIFunc)code_buffer; }
/** Write symbol table sections back to disk */ void SgAsmElfSymbolSection::unparse(std::ostream &f) const { SgAsmElfFileHeader *fhdr = get_elf_header(); ROSE_ASSERT(fhdr); ByteOrder sex = fhdr->get_sex(); size_t entry_size, struct_size, extra_size, nentries; calculate_sizes(&entry_size, &struct_size, &extra_size, &nentries); /* Adjust the entry size stored in the ELF Section Table */ get_section_entry()->set_sh_entsize(entry_size); /* Write each entry's required part followed by the optional part */ for (size_t i=0; i<nentries; i++) { SgAsmElfSymbol::Elf32SymbolEntry_disk disk32; SgAsmElfSymbol::Elf64SymbolEntry_disk disk64; void *disk=NULL; SgAsmElfSymbol *entry = p_symbols->get_symbols()[i]; if (4==fhdr->get_word_size()) { disk = entry->encode(sex, &disk32); } else if (8==fhdr->get_word_size()) { disk = entry->encode(sex, &disk64); } else { ROSE_ASSERT(!"unsupported word size"); } rose_addr_t spos = i * entry_size; spos = write(f, spos, struct_size, disk); if (entry->get_extra().size()>0) { ROSE_ASSERT(entry->get_extra().size()<=extra_size); write(f, spos, entry->get_extra()); } } unparse_holes(f); }
/** Initializes this ELF Symbol Section by parsing a file. */ SgAsmElfSymbolSection * SgAsmElfSymbolSection::parse() { SgAsmElfSection::parse(); SgAsmElfFileHeader *fhdr = get_elf_header(); ROSE_ASSERT(fhdr!=NULL); SgAsmElfSectionTableEntry *shdr = get_section_entry(); ROSE_ASSERT(shdr!=NULL); SgAsmElfStringSection *strsec = dynamic_cast<SgAsmElfStringSection*>(get_linked_section()); ROSE_ASSERT(strsec!=NULL); size_t entry_size, struct_size, extra_size, nentries; calculate_sizes(&entry_size, &struct_size, &extra_size, &nentries); ROSE_ASSERT(entry_size==shdr->get_sh_entsize()); /* Parse each entry */ for (size_t i=0; i<nentries; i++) { SgAsmElfSymbol *entry=0; if (4==fhdr->get_word_size()) { entry = new SgAsmElfSymbol(this); /*adds symbol to this symbol table*/ SgAsmElfSymbol::Elf32SymbolEntry_disk disk; read_content_local(i*entry_size, &disk, struct_size); entry->parse(fhdr->get_sex(), &disk); } else if (8==fhdr->get_word_size()) { entry = new SgAsmElfSymbol(this); /*adds symbol to this symbol table*/ SgAsmElfSymbol::Elf64SymbolEntry_disk disk; read_content_local(i*entry_size, &disk, struct_size); entry->parse(fhdr->get_sex(), &disk); } else { throw FormatError("unsupported ELF word size"); } if (extra_size>0) entry->get_extra() = read_content_local_ucl(i*entry_size+struct_size, extra_size); } return this; }
void ScopeGUI::create_panels() { calculate_sizes(get_w(), get_h()); if((use_wave || use_wave_parade)) { if(!waveform) { add_subwindow(waveform = new ScopeWaveform(this, wave_x, wave_y, wave_w, wave_h)); waveform->create_objects(); } else { waveform->reposition_window(wave_x, wave_y, wave_w, wave_h); waveform->clear_box(0, 0, wave_w, wave_h); } } else if(!(use_wave || use_wave_parade) && waveform) { delete waveform; waveform = 0; } if(use_vector) { if(!vectorscope) { add_subwindow(vectorscope = new ScopeVectorscope(this, vector_x, vector_y, vector_w, vector_h)); vectorscope->create_objects(); } else { vectorscope->reposition_window(vector_x, vector_y, vector_w, vector_h); vectorscope->clear_box(0, 0, vector_w, vector_h); } } else if(!use_vector && vectorscope) { delete vectorscope; vectorscope = 0; } if((use_hist || use_hist_parade)) { if(!histogram) { // printf("ScopeGUI::create_panels %d %d %d %d %d\n", __LINE__, hist_x, // hist_y, // hist_w, // hist_h); add_subwindow(histogram = new ScopeHistogram(this, hist_x, hist_y, hist_w, hist_h)); histogram->create_objects(); } else { histogram->reposition_window(hist_x, hist_y, hist_w, hist_h); histogram->clear_box(0, 0, hist_w, hist_h); } } else if(!(use_hist || use_hist_parade)) { delete histogram; histogram = 0; } allocate_bitmaps(); clear_points(0); draw_overlays(1, 1, 0); }
/** Parses an ELF Segment (Program Header) Table and constructs and parses all segments reachable from the table. The section * is extended as necessary based on the number of entries and teh size of each entry. */ SgAsmElfSegmentTable * SgAsmElfSegmentTable::parse() { SgAsmGenericSection::parse(); SgAsmElfFileHeader *fhdr = dynamic_cast<SgAsmElfFileHeader*>(get_header()); ROSE_ASSERT(fhdr!=NULL); ByteOrder sex = fhdr->get_sex(); size_t ent_size, struct_size, opt_size, nentries; calculate_sizes(&ent_size, &struct_size, &opt_size, &nentries); ROSE_ASSERT(opt_size==fhdr->get_phextrasz() && nentries==fhdr->get_e_phnum()); /* If the current size is very small (0 or 1 byte) then we're coming straight from the constructor and the parsing should * also extend this section to hold all the entries. Otherwise the caller must have assigned a specific size for a good * reason and we should leave that alone, reading zeros if the entries extend beyond the defined size. */ if (get_size()<=1 && get_size()<nentries*ent_size) extend(nentries*ent_size - get_size()); rose_addr_t offset=0; /* w.r.t. the beginning of this section */ for (size_t i=0; i<nentries; i++, offset+=ent_size) { /* Read/decode the segment header */ SgAsmElfSegmentTableEntry *shdr = NULL; if (4==fhdr->get_word_size()) { SgAsmElfSegmentTableEntry::Elf32SegmentTableEntry_disk disk; read_content_local(offset, &disk, struct_size); shdr = new SgAsmElfSegmentTableEntry(sex, &disk); } else { SgAsmElfSegmentTableEntry::Elf64SegmentTableEntry_disk disk; read_content_local(offset, &disk, struct_size); shdr = new SgAsmElfSegmentTableEntry(sex, &disk); } shdr->set_index(i); if (opt_size>0) shdr->get_extra() = read_content_local_ucl(offset+struct_size, opt_size); /* Null segments are just unused slots in the table; no real section to create */ if (SgAsmElfSegmentTableEntry::PT_NULL == shdr->get_type()) continue; /* Create SgAsmElfSection objects for each ELF Segment. However, if the ELF Segment Table describes a segment * that's the same offset and size as a section from the Elf Section Table (and the memory mappings are * consistent) then use the preexisting section instead of creating a new one. */ SgAsmElfSection *s = NULL; SgAsmGenericSectionPtrList possible = fhdr->get_file()->get_sections_by_offset(shdr->get_offset(), shdr->get_filesz()); for (size_t j=0; !s && j<possible.size(); j++) { if (possible[j]->get_offset()!=shdr->get_offset() || possible[j]->get_size()!=shdr->get_filesz()) continue; /*different file extent*/ if (possible[j]->is_mapped()) { if (possible[j]->get_mapped_preferred_rva()!=shdr->get_vaddr() || possible[j]->get_mapped_size()!=shdr->get_memsz()) continue; /*different mapped address or size*/ unsigned section_perms = (possible[j]->get_mapped_rperm() ? 0x01 : 0x00) | (possible[j]->get_mapped_wperm() ? 0x02 : 0x00) | (possible[j]->get_mapped_xperm() ? 0x04 : 0x00); unsigned segment_perms = (shdr->get_flags() & SgAsmElfSegmentTableEntry::PF_RPERM ? 0x01 : 0x00) | (shdr->get_flags() & SgAsmElfSegmentTableEntry::PF_WPERM ? 0x02 : 0x00) | (shdr->get_flags() & SgAsmElfSegmentTableEntry::PF_XPERM ? 0x04 : 0x00); if (section_perms != segment_perms) continue; /*different mapped permissions*/ } /* Found a match. Set memory mapping params only. */ s = dynamic_cast<SgAsmElfSection*>(possible[j]); if (!s) continue; /*potential match was not from the ELF Section or Segment table*/ if (s->get_segment_entry()) continue; /*potential match is assigned to some other segment table entry*/ s->init_from_segment_table(shdr, true); /*true=>set memory mapping params only*/ } /* Create a new segment if no matching section was found. */ if (!s) { if (SgAsmElfSegmentTableEntry::PT_NOTE == shdr->get_type()) { s = new SgAsmElfNoteSection(fhdr); } else { s = new SgAsmElfSection(fhdr); } s->init_from_segment_table(shdr); s->parse(); } } return this; }
rose_addr_t SgAsmElfSection::calculate_sizes(size_t *entsize, size_t *required, size_t *optional, size_t *entcount) const { return calculate_sizes(0, 0, std::vector<size_t>(), entsize, required, optional, entcount); }
/** Parses an ELF Section Table and constructs and parses all sections reachable from the table. The section is extended as * necessary based on the number of entries and the size of each entry. */ SgAsmElfSectionTable * SgAsmElfSectionTable::parse() { SgAsmGenericSection::parse(); SgAsmElfFileHeader *fhdr = dynamic_cast<SgAsmElfFileHeader*>(get_header()); ROSE_ASSERT(fhdr!=NULL); ByteOrder sex = fhdr->get_sex(); size_t ent_size, struct_size, opt_size, nentries; calculate_sizes(&ent_size, &struct_size, &opt_size, &nentries); ROSE_ASSERT(opt_size==fhdr->get_shextrasz() && nentries==fhdr->get_e_shnum()); /* If the current size is very small (0 or 1 byte) then we're coming straight from the constructor and the parsing should * also extend this section to hold all the entries. Otherwise the caller must have assigned a specific size for a good * reason and we should leave that alone, reading zeros if the entries extend beyond the defined size. */ if (get_size()<=1 && get_size()<nentries*ent_size) extend(nentries*ent_size - get_size()); /* Read all the section headers. */ std::vector<SgAsmElfSectionTableEntry*> entries; rose_addr_t offset = 0; for (size_t i=0; i<nentries; i++, offset+=ent_size) { SgAsmElfSectionTableEntry *shdr = NULL; if (4 == fhdr->get_word_size()) { SgAsmElfSectionTableEntry::Elf32SectionTableEntry_disk disk; read_content_local(offset, &disk, struct_size); shdr = new SgAsmElfSectionTableEntry(sex, &disk); } else { SgAsmElfSectionTableEntry::Elf64SectionTableEntry_disk disk; read_content_local(offset, &disk, struct_size); shdr = new SgAsmElfSectionTableEntry(sex, &disk); } if (opt_size>0) shdr->get_extra() = read_content_local_ucl(offset+struct_size, opt_size); entries.push_back(shdr); } /* This vector keeps track of which sections have already been parsed. We could get the same information by calling * fhdr->get_section_by_id() and passing the entry number since entry numbers and IDs are one and the same in ELF. However, * this is a bit easier. */ std::vector<SgAsmElfSection*> is_parsed; is_parsed.resize(entries.size(), NULL); /* All sections implicitly depend on the section string table for their names. */ SgAsmElfStringSection *section_name_strings=NULL; if (fhdr->get_e_shstrndx() > 0) { SgAsmElfSectionTableEntry *entry = entries[fhdr->get_e_shstrndx()]; section_name_strings = new SgAsmElfStringSection(fhdr); section_name_strings->init_from_section_table(entry, section_name_strings, fhdr->get_e_shstrndx()); section_name_strings->parse(); is_parsed[fhdr->get_e_shstrndx()] = section_name_strings; } /* Read all the sections. Some sections depend on other sections, so we read them in such an order that all dependencies * are satisfied first. */ while (1) { bool try_again=false; for (size_t i=0; i<entries.size(); i++) { SgAsmElfSectionTableEntry *entry = entries[i]; ROSE_ASSERT(entry->get_sh_link()<entries.size()); /* Some sections might reference another section through the sh_link member. */ bool need_linked = entry->get_sh_link() > 0; ROSE_ASSERT(!need_linked || entry->get_sh_link()<entries.size()); SgAsmElfSection *linked = need_linked ? is_parsed[entry->get_sh_link()] : NULL; /* Relocation sections might have a second linked section stored in sh_info. */ bool need_info_linked = (entry->get_sh_type() == SgAsmElfSectionTableEntry::SHT_REL || entry->get_sh_type() == SgAsmElfSectionTableEntry::SHT_RELA) && entry->get_sh_info() > 0; ROSE_ASSERT(!need_info_linked || entry->get_sh_info()<entries.size()); SgAsmElfSection *info_linked = need_info_linked ? is_parsed[entry->get_sh_info()] : NULL; if (is_parsed[i]) { /* This section has already been parsed. */ } else if ((need_linked && !linked) || (need_info_linked && !info_linked)) { /* Don't parse this section yet because it depends on something that's not parsed yet. */ try_again = true; } else { switch (entry->get_sh_type()) { case SgAsmElfSectionTableEntry::SHT_NULL: /* Null entry. We still create the section just to hold the section header. */ is_parsed[i] = new SgAsmElfSection(fhdr); break; case SgAsmElfSectionTableEntry::SHT_NOBITS: /* These types of sections don't occupy any file space (e.g., BSS) */ is_parsed[i] = new SgAsmElfSection(fhdr); break; case SgAsmElfSectionTableEntry::SHT_DYNAMIC: { SgAsmElfStringSection *strsec = dynamic_cast<SgAsmElfStringSection*>(linked); ROSE_ASSERT(strsec); is_parsed[i] = new SgAsmElfDynamicSection(fhdr, strsec); break; } case SgAsmElfSectionTableEntry::SHT_DYNSYM: { SgAsmElfStringSection *strsec = dynamic_cast<SgAsmElfStringSection*>(linked); ROSE_ASSERT(strsec); SgAsmElfSymbolSection *symsec = new SgAsmElfSymbolSection(fhdr, strsec); symsec->set_is_dynamic(true); is_parsed[i] = symsec; break; } case SgAsmElfSectionTableEntry::SHT_SYMTAB: { SgAsmElfStringSection *strsec = dynamic_cast<SgAsmElfStringSection*>(linked); ROSE_ASSERT(strsec); SgAsmElfSymbolSection *symsec = new SgAsmElfSymbolSection(fhdr, strsec); symsec->set_is_dynamic(false); is_parsed[i] = symsec; break; } case SgAsmElfSectionTableEntry::SHT_STRTAB: is_parsed[i] = new SgAsmElfStringSection(fhdr); break; case SgAsmElfSectionTableEntry::SHT_REL: { SgAsmElfSymbolSection *symbols = dynamic_cast<SgAsmElfSymbolSection*>(linked); SgAsmElfRelocSection *relocsec = new SgAsmElfRelocSection(fhdr, symbols, info_linked); relocsec->set_uses_addend(false); is_parsed[i] = relocsec; break; } case SgAsmElfSectionTableEntry::SHT_RELA: { SgAsmElfSymbolSection *symbols = dynamic_cast<SgAsmElfSymbolSection*>(linked); SgAsmElfRelocSection *relocsec = new SgAsmElfRelocSection(fhdr, symbols, info_linked); relocsec->set_uses_addend(true); is_parsed[i] = relocsec; break; } case SgAsmElfSectionTableEntry::SHT_PROGBITS: { if (!section_name_strings) { fprintf(stderr, "SgAsmElfSectionTable::parse(): no string table for section table\n"); is_parsed[i] = new SgAsmElfSection(fhdr); } else { std::string section_name = section_name_strings->read_content_local_str(entry->get_sh_name()); if (section_name == ".eh_frame") { is_parsed[i] = new SgAsmElfEHFrameSection(fhdr); } else { is_parsed[i] = new SgAsmElfSection(fhdr); } } break; } case SgAsmElfSectionTableEntry::SHT_GNU_versym: { is_parsed[i] = new SgAsmElfSymverSection(fhdr); break; } case SgAsmElfSectionTableEntry::SHT_GNU_verdef: { SgAsmElfStringSection *strsec = dynamic_cast<SgAsmElfStringSection*>(linked); ROSE_ASSERT(strsec); is_parsed[i] = new SgAsmElfSymverDefinedSection(fhdr,strsec); break; } case SgAsmElfSectionTableEntry::SHT_GNU_verneed: { SgAsmElfStringSection *strsec = dynamic_cast<SgAsmElfStringSection*>(linked); ROSE_ASSERT(strsec); is_parsed[i] = new SgAsmElfSymverNeededSection(fhdr,strsec); break; } default: is_parsed[i] = new SgAsmElfSection(fhdr); break; } is_parsed[i]->init_from_section_table(entry, section_name_strings, i); is_parsed[i]->parse(); } } if (!try_again) break; } /* Initialize links between sections */ for (size_t i = 0; i < entries.size(); i++) { SgAsmElfSectionTableEntry *shdr = entries[i]; if (shdr->get_sh_link() > 0) { SgAsmElfSection *source = isSgAsmElfSection(fhdr->get_file()->get_section_by_id(i)); SgAsmElfSection *target = isSgAsmElfSection(fhdr->get_file()->get_section_by_id(shdr->get_sh_link())); assert(source); /* because we created it above */ source->set_linked_section(target); } } /* Finish parsing sections now that we have basic info for all the sections. */ for (size_t i=0; i<is_parsed.size(); i++) is_parsed[i]->finish_parsing(); return this; }