def toBinArray(self): """ @return: a L{BinArray} with the content of the pseudo-section. """ ba = BinArray(self.interpreter) ba.append(0) return ba
def toBinArray(self): ba = BinArray() for d in self.dyntab: ba.extend(d.toBinArray()) null = struct.pack("<Q", DT_NULL) ba.fromstring(null) return ba
def toBinArray(self): if self.readonly: return BaseSection.toBinArray() ba = BinArray() keys = self.by_index.keys() keys.sort() for k in keys: ba.fromstring(self.by_index[k] + "\0") return ba
def fromfile(self, path): f = file(path, "rb") # Load Elf header data = BinArray() data.fromfile(f, Elf64_Ehdr.size) self.header.fromBinArray(data) # This linker only supports relocatable objects if self.header.e_type != ET_REL: raise NotRelocatableObject(path) if self.header.e_ident.ei_class != ELFCLASS64: raise UnsupportedObject(path, "Not %s" % ELFCLASS64) if self.header.e_machine != EM_X86_64: raise UnsupportedObject(path, "Not %s" % EM_X86_64) # Load sections headers f.seek(self.header.e_shoff) for i in range(self.header.e_shnum): data = BinArray() data.fromfile(f, self.header.e_shentsize) h = Elf64_Shdr(i, data) h.owner = self self.shdrs.append(h) # Read sections content for sh in self.shdrs: data = BinArray() if sh.sh_type != SHT_NOBITS: f.seek(sh.sh_offset) data.fromfile(f, sh.sh_size) sh.content = data f.close()
def toBinArray(self): ba = BinArray() for c in self.content: ba.extend(c.toBinArray()) return ba
def toBinArray(self): ba = BinArray() ba.fromstring(struct.pack(self.format, self.d_tag, self.d_val)) return ba
def toBinArray(self): ba = BinArray(self.ei_magic) ba.append(self.ei_class) ba.append(self.ei_data) ba.append(self.ei_version) ba.append(self.ei_osabi) ba.append(self.ei_abiversion) ba.extend(self.ei_pad) return ba
def toBinArray(self): ba = BinArray() for s in self.segments: ba.extend(s.toBinArray()) return ba