Skip to content

Instantly share code, notes, and snippets.

// Small utility to measure how much time does it take to
// run an arbitrary function.
// Written by Agustin Gianni (agustin.gianni@gmail.com).
// Based on https://ngathanasiou.wordpress.com/2015/04/01/benchmarking-in-c/
//
// $ clang++ measure.cpp -o measure -std=c++11 -Wall && ./measure
// Return value: Boom!
// Elapsed time: 0 ms
#include <ctime>
#include <chrono>
// Author: Agustin Gianni (agustingianni@gmail.com).
// License: BSD variant "if you steal my shit i'll cut you".
#include <iostream>
#include <random>
#include <limits>
#include <cassert>
#include <cstdio>
using namespace std;
#include <stdint.h>
#include <stdio.h>
template<typename T> T get_bits(T value, unsigned msb, unsigned lsb) {
return (value >> lsb) & ((1 << (msb - lsb + 1)) - 1);
}
template<typename T, unsigned N = (sizeof(T) * 8)> int log2(T value) {
unsigned i = 0;
while (i < N && (value >>= 1)) {
class AbstractMemory {
public:
AbstractMemory() = default;
~AbstractMemory() = default;
template <typename T> size_t read(uintptr_t address, T &value) {
return read(address, reinterpret_cast<void *>(&value), sizeof(T));
}
template <typename T> size_t write(uintptr_t address, T value) {
class AbstractMemory {
public:
AbstractMemory() = default;
~AbstractMemory() = default;
template <typename T> size_t read(uintptr_t address, T &value) {
return read(address, reinterpret_cast<void *>(&value), sizeof(T));
}
template <typename T> size_t write(uintptr_t address, T value) {
from z3 import *
input_size = BitVec('input_size', 32)
t1 = BitVecVal(0xAAAAAAAAAAAAAAAB, 128) * ZeroExt(128 - 32, input_size)
t2 = LShR(t1, 64)
t3 = LShR(t2, 3)
t4 = Extract(31, 0, t3)
expr1 = t4
expr2 = UDiv(input_size, 12)
solve(expr1 != expr2)
shared_ptr<ARMInstruction> ARMDecoder::decode_adc_register_t2(uint32_t opcode, Disassembler::ARMInstrSize ins_size, ARMEncoding encoding) {
int S = get_bit(opcode, 20);
int Rn = get_bits(opcode, 19, 16);
int imm3 = get_bits(opcode, 14, 12);
int Rd = get_bits(opcode, 11, 8);
int imm2 = get_bits(opcode, 7, 6);
int type = get_bits(opcode, 5, 4);
int Rm = get_bits(opcode, 3, 0);
int shift_t = 0;
int d = 0;
bool ARMInterpreter::interpret_ldc_ldc2_immediate(ARMContext& ctx, const ARMInstruction& ins)
{
if (ConditionPassed()) {
EncodingSpecificOperations();
if (!Coproc_Accepted(cp, ThisInstr())) {
GenerateCoprocessorException();
}
else {
NullCheckIfThumbEE(n);
/*
* libdisassembly.cpp
*
* Created on: Sep 20, 2015
* Author: anon
*/
#include <memory>
#include <boost/python.hpp>
#include <iostream>
LC_CODE_SEGMENT_SPLIT_INFO
LC_CODE_SIGNATURE
LC_DATA_IN_CODE
LC_DYLD_ENVIRONMENT
LC_DYLD_INFO
LC_DYLD_INFO_ONLY
LC_DYLIB_CODE_SIGN_DRS
LC_DYSYMTAB
LC_ENCRYPTION_INFO
LC_ENCRYPTION_INFO_64