def getPatches(self, elfFile, symbols, file): s = self.getSymbol(symbols, self.symbol) # Compile a BL assert (s.value % 4) == 0 assert (self.addr % 4) == 0 offset = (s.value - self.addr - 8) / 4 asm = bitstring.pack("intle:24, bin:4, bin:3, bin:1", offset, "0b1110", "0b101", "0b1") return [(elfhelper.vaddr_to_offset(elfFile, self.addr), asm.tobytes())]
def main(argv): parser = argparse.ArgumentParser(description="vaddroffset") parser.add_argument('-o', '--offset', help="offset") parser.add_argument('-v', '--vaddr', help="vaddr") parser.add_argument('file', help="file") args = parser.parse_args(argv[1:]) elff = elffile.open(args.file) if args.offset: print("0x%x" % (elfhelper.offset_to_vaddr(elff, int(args.offset, 0)))) elif args.vaddr: print("0x%x" % (elfhelper.vaddr_to_offset(elff, int(args.vaddr, 0))))
def getPatches(self, elfFile, symbols, file): s = self.getSymbol(symbols, self.symbol) file.seek(s.value) (new_list_size,) = struct.unpack("I", file.read(4)) file.seek(self.addr) (instr,) = struct.unpack("I", file.read(4)) # Compute the new instruction if instr != 0xE287A03C: raise ValueError("Instruction '%d' is not valid" % instr) instr = instr & 0xFFFFFF00 instr = instr + new_list_size data = struct.pack("I", instr) return [(elfhelper.vaddr_to_offset(elfFile, self.addr), data)]
def getPatches(self, elfFile, symbols, file): s = self.getSymbol(symbols, self.symbol) file.seek(s.value) (value,) = struct.unpack("I", file.read(4)) return [(elfhelper.vaddr_to_offset(elfFile, self.addr), struct.pack("i", value))]
def getPatches(self, elfFile, symbols, file): s = self.getSymbol(symbols, self.symbol) return [(elfhelper.vaddr_to_offset(elfFile, self.addr), struct.pack("i", s.value))]