/** Construct a new ELF File Header with default values. The new section is placed at file offset zero and the size is * initially one byte (calling parse() will extend it as necessary). Setting the initial size of non-parsed sections to a * positive value works better when adding sections to the end-of-file since the sections will all have different starting * offsets and therefore SgAsmGenericFile::shift_extend will know what order the sections should be in when they are * eventually resized. */ void SgAsmElfFileHeader::ctor() { ROSE_ASSERT(get_file()!=NULL); ROSE_ASSERT(get_size()>0); set_name(new SgAsmBasicString("ELF File Header")); set_synthesized(true); set_purpose(SP_HEADER); /* Magic number */ p_magic.clear(); p_magic.push_back(0x7f); p_magic.push_back('E'); p_magic.push_back('L'); p_magic.push_back('F'); /* Executable Format */ ROSE_ASSERT(p_exec_format!=NULL); p_exec_format->set_family(FAMILY_ELF); p_exec_format->set_purpose(PURPOSE_EXECUTABLE); p_exec_format->set_sex(ByteOrder::ORDER_LSB); p_exec_format->set_word_size(4); p_exec_format->set_version(1); p_exec_format->set_is_current_version(true); p_exec_format->set_abi(ABI_UNSPECIFIED); p_exec_format->set_abi_version(0); p_isa = ISA_IA32_386; p_e_ident_data_encoding = 1; /*LSB*/ p_e_ident_padding = SgUnsignedCharList(9, '\0'); }
/* Constructor */ void SgAsmCoffSymbolTable::ctor() { set_synthesized(true); set_name(new SgAsmBasicString("COFF Symbols")); set_purpose(SP_SYMTAB); p_symbols = new SgAsmCoffSymbolList; p_symbols->set_parent(this); }
/* Constructor */ void SgAsmPESectionTable::ctor() { SgAsmPEFileHeader *fhdr = dynamic_cast<SgAsmPEFileHeader*>(get_header()); ROSE_ASSERT(fhdr!=NULL); fhdr->set_section_table(this); set_synthesized(true); set_name(new SgAsmBasicString("PE Section Table")); set_purpose(SP_HEADER); }
/** Non-parsing constructor for an ELF Segment (Program Header) Table */ void SgAsmElfSegmentTable::ctor() { /* There can be only one ELF Segment Table */ SgAsmElfFileHeader *fhdr = dynamic_cast<SgAsmElfFileHeader*>(get_header()); ROSE_ASSERT(fhdr); ROSE_ASSERT(fhdr->get_segment_table()==NULL); fhdr->set_segment_table(this); set_synthesized(true); /* the segment table isn't part of any explicit section */ set_name(new SgAsmBasicString("ELF Segment Table")); set_purpose(SP_HEADER); fhdr->set_segment_table(this); }
/** Non-parsing constructor for an ELF Section Table */ void SgAsmElfSectionTable::ctor() { /* There can be only one ELF Section Table */ SgAsmElfFileHeader *fhdr = dynamic_cast<SgAsmElfFileHeader*>(get_header()); ROSE_ASSERT(fhdr); ROSE_ASSERT(fhdr->get_section_table()==NULL); set_synthesized(true); /* the section table isn't really a section itself */ set_name(new SgAsmBasicString("ELF Section Table")); set_purpose(SP_HEADER); /* Every section table has a first entry that's all zeros. We don't declare that section here (see parse()) but we do set * the section count in the header in order to reserve that first slot. */ if (fhdr->get_e_shnum()<1) fhdr->set_e_shnum(1); fhdr->set_section_table(this); }
/* Construct a new PE File Header with default values. */ void SgAsmPEFileHeader::ctor() { ROSE_ASSERT(get_file()!=NULL); ROSE_ASSERT(get_size()>0); set_name(new SgAsmBasicString("PE File Header")); set_synthesized(true); set_purpose(SP_HEADER); p_rvasize_pairs = new SgAsmPERVASizePairList(this); /* Magic number */ p_magic.clear(); p_magic.push_back('P'); p_magic.push_back('E'); p_magic.push_back('\0'); p_magic.push_back('\0'); /* Executable Format */ ROSE_ASSERT(p_exec_format!=NULL); p_exec_format->set_family(FAMILY_PE); p_exec_format->set_purpose(PURPOSE_EXECUTABLE); p_exec_format->set_sex(ORDER_LSB); p_exec_format->set_word_size(4); p_exec_format->set_version(0); p_exec_format->set_is_current_version(true); p_exec_format->set_abi(ABI_NT); p_exec_format->set_abi_version(0); /* Default instruction architecture */ p_e_cpu_type = 0x014c; /*i386*/ p_isa = ISA_IA32_386; p_e_time = time(NULL); p_e_nt_hdr_size = sizeof(PE32OptHeader_disk); }
void SgAsmElfSection::ctor() { set_synthesized(false); set_purpose(SP_UNSPECIFIED); }