A tool for automatic synthesis of DWARF.
Go to file
Théophile Bastian c74ec873eb Synth: tolerate undef rbp merge on leaf blocks 2019-07-07 19:04:47 +02:00
DwarfSynth Synth: tolerate undef rbp merge on leaf blocks 2019-07-07 19:04:47 +02:00
csmith Chk_gen_eh_frame: exit with 1 upon failure 2019-07-07 11:50:50 +02:00
curiosities Add uncommitted tests and curiosities 2019-04-05 16:39:21 +02:00
gzip/performance_eval Add performance analysis code + gzip eval 2019-06-11 22:15:32 +02:00
libdwarfw@322e118261 Add libdwarfw as submodule 2018-12-07 17:16:18 +01:00
test Add uncommitted tests and curiosities 2019-04-05 16:39:21 +02:00
tools Add performance analysis code + gzip eval 2019-06-11 22:15:32 +02:00
.gitignore Add synthesize_dwarf.sh 2019-03-18 14:27:24 +01:00
.gitmodules Add libdwarfw as submodule 2018-12-07 17:16:18 +01:00
.merlin Generate CFA tracking with RIP 2018-10-23 19:22:19 +02:00
DwarfSynth.mlpack initial commit of ocaml->c wrappers. as bap linking is already complicated, two independent binaries communicate via a tmp.marshall file for now. 2018-12-30 10:10:51 -08:00
LICENSE Initial commit 2018-10-12 18:45:04 +02:00
Makefile Add `make tarball` 2019-05-28 21:40:05 +02:00
README.md README: dependencies instructions 2019-05-28 21:16:40 +02:00
_tags initial commit of ocaml->c wrappers. as bap linking is already complicated, two independent binaries communicate via a tmp.marshall file for now. 2018-12-30 10:10:51 -08:00
dwarfsynth.ml Add performance analysis code + gzip eval 2019-06-11 22:15:32 +02:00
synthesize_dwarf.sh Add performance analysis code + gzip eval 2019-06-11 22:15:32 +02:00

README.md

dwarf-synthesis

A tool for automatic synthesis of DWARF.

The purpose of this tool is to take any given binary program or library, examine its assembly code and, based solely on that, generate the corresponding .eh_frame DWARF data.

Dependencies

This tool relies on

  • BAP version 1.6 as of today, which is available through OPAM;
  • objcopy, often packaged as binutils
  • libelf
  • libdwarf
  • libdwarfw, packaged as submodule

Installing dependencies

You should be able to easily install objcopy (binutils), libelf, libdwarf and opam via your package manager. Once opam is set up, you should be able to simply opam install bap. We recommand that you use a fresh opam switch in case you already have installed packages with opam.

Compiling

Simply run make to compile all the necessary tools, including compiling and installing the BAP plugin dwarfsynth.

Running with a wrapper script

To generate an .eh_frame section for some binary foo.bin and write the output as foo.eh.bin, you can run

./synthesize_dwarf foo.bin foo.eh.bin

You can also omit the second parameter to simply overwrite foo.bin.

Running by hand

If you want, for some reason, to run by hand the multiple components, you can follow this procedure (by using more appropriate file names, and, possibly, a temporary directory -- see mktemp -d).

Running the BAP plugin

bap prog_to_analyze.bin -p dwarfsynth --dwarfsynth-output tmp.marshal

Running ml_dwarf_write

You can get a help text with ./ml_dwarf_write.bin. Otherwise, you can run

./ml_dwarf_write.bin tmp.marshal prog_to_analyze.bin eh_frame_section`

Stitching the section into a binary

objcopy --add-section .eh_frame=eh_frame_section prog_to_analyze.bin prog_to_analyze.eh.bin

Commonly used commands

List a binary sections

objdump -h blah.bin

Strip a binary of its eh_frame

objcopy --remove-section '.eh_frame' --remove-section '.eh_frame_hdr' blah.bin