--- /dev/null
+# Constants and flags, placed into classes for namespacing\r
+\r
+class SHN_INDICES(object):\r
+ """ Special section indices
+ """\r
+ SHN_UNDEF=0\r
+ SHN_LORESERVE=0xff00\r
+ SHN_LOPROC=0xff00\r
+ SHN_HIPROC=0xff1f\r
+ SHN_ABS=0xfff1\r
+ SHN_COMMON=0xfff2\r
+ SHN_HIRESERVE=0xffff
+\r
+\r
+class SH_FLAGS(object):\r
+ """ Flag values for the sh_flags field of section headers
+ """\r
+ SHF_WRITE=0x1\r
+ SHF_ALLOC=0x2\r
+ SHF_EXECINSTR=0x4\r
+ SHF_MERGE=0x10\r
+ SHF_STRINGS=0x20\r
+ SHF_INFO_LINK=0x40\r
+ SHF_LINK_ORDER=0x80\r
+ SHF_OS_NONCONFORMING=0x100\r
+ SHF_GROUP=0x200\r
+ SHF_TLS=0x400\r
+ SHF_MASKOS=0x0ff00000\r
+ SHF_MASKPROC=0xf0000000\r
+\r
+\r
+class P_FLAGS(object):\r
+ """ Flag values for the p_flags field of program headers
+ """\r
+ PF_X=0x1\r
+ PF_W=0x2\r
+ PF_R=0x4\r
+ PF_MASKOS=0x00FF0000\r
+ PF_MASKPROC=0xFF000000\r
+\r
+++ /dev/null
-# Flag values, placed into classes for namespacing\r
-\r
-class SH_FLAGS(object):\r
- SHF_WRITE=0x1\r
- SHF_ALLOC=0x2\r
- SHF_EXECINSTR=0x4\r
- SHF_MERGE=0x10\r
- SHF_STRINGS=0x20\r
- SHF_INFO_LINK=0x40\r
- SHF_LINK_ORDER=0x80\r
- SHF_OS_NONCONFORMING=0x100\r
- SHF_GROUP=0x200\r
- SHF_TLS=0x400\r
- SHF_MASKOS=0x0ff00000\r
- SHF_MASKPROC=0xf0000000\r
-\r
self.Elf_sxword = SBInt32 if self.elfclass == 32 else SBInt64\r
\r
self._create_ehdr()\r
+ self._create_phdr()\r
self._create_shdr()\r
self._create_sym()\r
\r
self.Elf_half('e_shstrndx'),\r
)\r
\r
+ def _create_phdr(self):\r
+ if self.elfclass == 32:\r
+ self.Elf_Phdr = Struct('Elf_Phdr',\r
+ Enum(self.Elf_word('p_type'), **ENUM_P_TYPE),\r
+ self.Elf_offset('p_offset'),\r
+ self.Elf_addr('p_vaddr'),\r
+ self.Elf_addr('p_paddr'),\r
+ self.Elf_word('p_filesz'),\r
+ self.Elf_word('p_memsz'),\r
+ self.Elf_word('p_flags'),\r
+ self.Elf_word('p_align'),\r
+ )\r
+ else:\r
+ self.Elf_Phdr = Struct('Elf_Phdr',\r
+ Enum(self.Elf_word('p_type'), **ENUM_P_TYPE),\r
+ self.Elf_word('p_flags'),\r
+ self.Elf_offset('p_offset'),\r
+ self.Elf_addr('p_vaddr'),\r
+ self.Elf_addr('p_paddr'),\r
+ self.Elf_word('p_filesz'),\r
+ self.Elf_word('p_memsz'),\r
+ self.Elf_word('p_align'),\r
+ ) \r
+ \r
def _create_shdr(self):
self.Elf_Shdr = Struct('Elf_Shdr',\r
self.Elf_word('sh_name'),\r