Skip to content

Instantly share code, notes, and snippets.

View pgoodman's full-sized avatar
🦥

Peter Goodman pgoodman

🦥
View GitHub Profile

VTable Notes on Multiple Inheritance in GCC C++ Compiler v4.0.1

http://www.cse.wustl.edu/~mdeters/seminar/fall2005/mi.html#basics

The Basics: Single Inheritance

As we discussed in class, single inheritance leads to an object layoutwith base class data laid out before derived class data. So if classes A and B are defined as:

@pgoodman
pgoodman / group_functions.py
Last active August 8, 2024 23:56
Group functions by their type
# Copyright 2024, Peter Goodman. All rights reserved.
"""
This program approximately groups functions by their types, and then prints
out the grouped functions.
XREF: https://x.com/eatonphil/status/1821573274582823247
"""
import argparse
@pgoodman
pgoodman / out.txt
Last active October 6, 2020 03:26
Pretty print tables.
+- Grammar ---------------+ +-----------------------------------------------------+
| | | Production | Nullable | FIRST | FOLLOW |
| S -> S S | |-------------------------+----------+-------+--------|
| S -> if E then S else S | | S' -> S $ | False | exit | |
| S -> if E then S | | | | if | |
| S -> exit when E | |-------------------------+----------+-------+--------|
+-------------------------+ | S -> S S | False | exit | $ |
| S -> if E then S else S | | if | exit |
| S -> if E then S | | | if |
| S -> exit when E | | | else |
// Copyright 2020 Peter Goodman, all rights reserved.
#include <cassert>
#include <cstdint>
#include <cstddef>
#include <iostream>
#include <type_traits>
#include <vector>
template<typename IntegralType_, unsigned kNumBits_, unsigned kShift_>
@pgoodman
pgoodman / asan.md
Created July 3, 2020 03:59
Address Sanitizer

On macOS

export CFLAGS="-fsanitize=address -ffunction-sections -fdata-sections -Wl,-dead_strip -Wl,-undefined,dynamic_lookup -Wno-unused-command-line-argument"
export CXXFLAGS="-fsanitize=address -ffunction-sections -fdata-sections -Wl,-dead_strip -Wl,-undefined,dynamic_lookup -Wno-unused-command-line-argument"

On Linux

export CFLAGS="-fsanitize=address -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--allow-multiple-definition"
export CXXFLAGS="-fsanitize=address -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--allow-multiple-definition"
@pgoodman
pgoodman / Terminal
Created March 3, 2020 21:24
Example on how to use Anvill
/path/to/remill-build/tools/anvill/anvill-decompile-json-9.0 --spec /tmp/slice.json --ir_out /dev/stderr
@pgoodman
pgoodman / compile.sh
Created November 5, 2019 18:16
Using ANVILL with AArch64
clang --target=armv8-pc-linux-gnu -m64 -c /tmp/test.c -o /tmp/test.o
@pgoodman
pgoodman / BUILD_REMILL.md
Last active June 30, 2020 14:22
Instructions for building Remill and its dependencies from scratch

Instructions for a full build of Remill and its depedencies.

Clone cxx-common

cd ~/src
git clone [email protected]:trailofbits/cxx-common.git

Repository path

@pgoodman
pgoodman / lifted.bc
Created October 23, 2019 16:35
anvill-decompile-7.0 --spec /tmp/slice.json --ir_out /dev/stdout
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu-elf"
%struct.Memory = type opaque
%struct.State = type { %struct.ArchState, [32 x %union.VectorReg], %struct.ArithFlags, %union.anon, %struct.Segments, %struct.AddressSpace, %struct.GPR, %struct.X87Stack, %struct.MMX, %struct.FPUStatusFlags, %union.anon, %union.FPU, %struct.SegmentCaches }
%struct.ArchState = type { i32, i32, %union.anon }
%union.VectorReg = type { %union.vec512_t }
%union.vec512_t = type { %struct.uint64v8_t }
%struct.uint64v8_t = type { [8 x i64] }
%struct.ArithFlags = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }
@pgoodman
pgoodman / code.S
Last active October 10, 2019 19:24
remill-lift-7.0 --ir_out /dev/stdout --bytes 89F80FB74C241881F9008000000F95C1D3E0C3 --slice_inputs RSP,EDI --slice_outputs EAX
0: 89 f8 mov eax,edi
2: 0f b7 4c 24 18 movzx ecx,WORD PTR [rsp+0x18]
7: 81 f9 00 80 00 00 cmp ecx,0x8000
d: 0f 95 c1 setne cl
10: d3 e0 shl eax,cl
12: c3 ret