(draft; work in progress)
See also:
- Compilers
- Program analysis:
- Dynamic analysis - instrumentation, translation, sanitizers
AS=nasm | |
ASFLAGS=-f elf64 -g -F dwarf | |
LD=ld | |
LDFLAGS=-dynamic-linker /lib64/ld-linux-x86-64.so.2 -lc -m elf_x86_64 | |
RM=rm -rf | |
SOURCES=$(wildcard *.asm) | |
OBJECTS=$(SOURCES:.asm=.o) | |
TARGET=out | |
%.o: %.asm |
(draft; work in progress)
See also:
I've been working on optimizing the YARA compiler to generate better bytecode for loops. The goal is to skip as much of loops as possible by not iterating further once the loop condition is met. Here's the rule I'm using. Completely contrived and excessive, but it's to show the performance improvement:
wxs@wxs-mbp yara % cat rules/test.yara
rule a {
condition:
for any i in (0..100000000): (i == 1)
}
wxs@wxs-mbp yara %
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;popcnt expl ;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(declare-const V (_ BitVec 64)) | |
(declare-const I1 (_ BitVec 64)) | |
(declare-const I2 (_ BitVec 64)) | |
(assert | |
(not | |
(= |
//===-- max_stack_height.cpp - Static analysis for stack height approximation --------------------------------------==// | |
// | |
// The LLVM Compiler Infrastructure | |
// | |
// This file is distributed under the University of Illinois Open Source | |
// License. See LICENSE.TXT for details. | |
// | |
//===----------------------------------------------------------------------===// | |
// | |
// This implements a function pass to approximate the max stack height of each function. |
import bap | |
import networkx as nx | |
def build_cfg(sub): | |
G = nx.DiGraph() | |
entry = sub.blks[0].id.number | |
G.add_node(entry) | |
for blk in sub.blks: | |
for jmp in blk.jmps: | |
if jmp.constr == 'Goto' and jmp.target.constr == 'Direct': |
#!/usr/bin/env python | |
import os | |
import sys | |
import os.path | |
import site | |
try: | |
import binaryninja | |
print "Binary Ninja API Installed" |
; MacOS X: /usr/local/bin/nasm -f macho64 *.s && ld -macosx_version_min 10.7 *.o | |
; Solaris/FreeBSD/DragonFly: nasm -f elf64 -D UNIX *.s && ld *.o | |
; NetBSD: nasm -f elf64 -D UNIX -D NetBSD *.s && ld *.o | |
; OpenBSD: nasm -f elf64 -D UNIX -D OpenBSD *.s && ld -static *.o | |
; OpenIndiana: nasm -f elf64 -D UNIX *.s && ld -m elf_x86_64 *.o | |
; Linux: nasm -f elf64 *.s && ld *.o | |
%ifdef NetBSD | |
section .note.netbsd.ident | |
dd 7,4,1 |