forked from qemu/qemu
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It came out that BFD architectures in `qemu/dis/bfd.h` folder is 9 years older, than architectures in the `bap-frames/libtrace`, and the latter is 14 years older than the latest BFD release. In fact, the BFD architectures are not stable, and numbers for them are allocated at each configuration and depends on the configuration options. The choice to rely on them was a bad decision. The better approach would be to use our own wired format for arches, specified in protobuf or something like this. But so far, we're relying on piqi, that doesn't have (a) normal enums with fixed values, (b) normal extension mechanism. So we will still rely on the old way of specifying architectures. Now we will use architectures from `frames/libtrace/` library, to ensure, that everyone has the same constants. To reduce confusion with BFD we've moved all definitions to the `frames` namespace (i.e., `s/bfd_/frames_`). This PR also fixes numerous issues with the build system: 1. protobuf now is built as a part of `all` target, no need to do `make -C protobuf` 2. protobuf will generate `librotoframes` library, instead of libtrace that nameclashed with at least two libraries: trace library from the qemu itself and libtrace from the bap-frames 3. configure script will properly expand paths 4. protobuf target will now depend on the `piqi` file in the frames library and if the latter is changed, the library will be regenerated and recompiled, as well as all dependencies.
- Loading branch information
Showing
11 changed files
with
59 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,3 +117,6 @@ cscope.* | |
tags | ||
TAGS | ||
*~ | ||
/protobuf/frame.piqi.pb-c.c | ||
/protobuf/frame.piqi.pb-c.h | ||
/protobuf/frame.piqi.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,19 +9,19 @@ project. | |
|
||
# Installing released binaries | ||
|
||
If you don't want to mess with the source and building, then you can just | ||
dowload a tarball with prebuilt binaries. Look at the latest release and | ||
If you don't want to mess with the source and building, then you can just | ||
dowload a tarball with prebuilt binaries. Look at the latest release and | ||
it might happen, that we have built binaries for your linux distribution, | ||
if it is not the case, then create an issue, and we will build it for you. | ||
|
||
Let's pretend, that you're using Ubuntu Trusty, and install it. First | ||
Let's pretend, that you're using Ubuntu Trusty, and install it. First | ||
download it with your favorite downloader: | ||
|
||
``` | ||
wget https://github.com/BinaryAnalysisPlatform/qemu/releases/download/v2.0.0-tracewrap-alpha/qemu-tracewrap-ubuntu-14.04.4-LTS.tgz | ||
``` | ||
|
||
Install it in the specified prefix with a command like `tar -C <prefix> -xf qemu-tracewrap-ubuntu-14.04.4-LTS.tgz`, e.g., | ||
Install it in the specified prefix with a command like `tar -C <prefix> -xf qemu-tracewrap-ubuntu-14.04.4-LTS.tgz`, e.g., | ||
to install in your home directory: | ||
``` | ||
tar -C $HOME -xf qemu-tracewrap-ubuntu-14.04.4-LTS.tgz | ||
|
@@ -62,42 +62,36 @@ $ opam install piqi | |
|
||
## Building | ||
|
||
Download [bap-traces](https://github.com/BinaryAnalysisPlatform/bap-traces) with | ||
Download [bap-frames](https://github.com/BinaryAnalysisPlatform/bap-frames) with | ||
following command | ||
|
||
```bash | ||
$ git clone https://github.com/BinaryAnalysisPlatform/bap-traces.git | ||
$ git clone https://github.com/BinaryAnalysisPlatform/bap-frames.git | ||
``` | ||
|
||
Download qemu tracer with following command | ||
|
||
```bash | ||
$ git clone [email protected]:BinaryAnalysisPlatform/qemu.git -b tracewrap | ||
$ git clone [email protected]:BinaryAnalysisPlatform/qemu.git | ||
``` | ||
|
||
Change folder to qemu and build tracer with command | ||
Change folder to qemu and build tracer: | ||
```bash | ||
$ ./configure --prefix=$HOME --with-tracewrap=`realpath ../bap-frames` \ | ||
--extra-ldflags=-Lprotobuf --target-list="arm-linux-user i386-linux-user \ | ||
x86_64-linux-user mips-linux-user" | ||
$ make -C protobuf | ||
$ cd qemu | ||
$ ./configure --prefix=$HOME --with-tracewrap=../bap-frames --target-list="`echo {arm,i386,x86_64,mips}-linux-user`" | ||
$ make | ||
$ make install | ||
``` | ||
|
||
# Usage | ||
|
||
To run executable `exec` and to save the trace data to `exec.trace`, use | ||
To run executable `exec` compiled for `arch`, use `qemu-arch exec` command, e.g., | ||
`qemu-x86_64 /bin/ls`. It will dump the trace into `ls.frames` file. You can configure | ||
the filename with `-tracefile` option, e.g., `qemu-arm -tracefile arm.ls.frames ls` | ||
|
||
```bash | ||
$ qemu-arm -tracefile exec.trace exec # trace ARM target executable | ||
$ qemu-i386 -tracefile exec.trace exec # trace X86 target executable | ||
$ qemu-x86_64 -tracefile exec.trace exec # trace X86-64 target executable | ||
$ qemu-mips -tracefile exec.trace exec # trace MIPS target executable | ||
``` | ||
|
||
Hints: use option -L to set the elf interpreter prefix to 'path'. Use | ||
[fetchlibs.sh](https://raw.githubusercontent.com/BinaryAnalysisPlatform/bap-traces/master/test/fetchlibs.sh) | ||
[fetchlibs.sh](https://raw.githubusercontent.com/BinaryAnalysisPlatform/bap-frames/master/test/fetchlibs.sh) | ||
to download arm and x86 libraries. | ||
|
||
# Notes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
#include "frame_arch.h" | ||
|
||
const uint64_t frame_arch = frame_arch_arm; | ||
const uint64_t frame_mach = frame_mach_arm_unknown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#pragma once | ||
|
||
#include "disas/bfd.h" | ||
#include "frame_arch.h" | ||
|
||
const uint64_t bfd_arch = bfd_arch_i386; | ||
const uint64_t bfd_machine = bfd_mach_i386_i386; | ||
const uint64_t frame_arch = frame_arch_i386; | ||
const uint64_t frame_mach = frame_mach_i386_i386; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#pragma once | ||
|
||
#include "disas/bfd.h" | ||
#include "frame_arch.h" | ||
|
||
const uint64_t bfd_arch = bfd_arch_mips; | ||
const uint64_t bfd_machine = 32 ; /* bfd_mach_mipsisa32 */ | ||
/* our bfd.h is so outdated, that it doesn't include it.*/ | ||
const uint64_t frame_arch = frame_arch_mips; | ||
const uint64_t frame_mach = frame_mach_mipsisa32 ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#pragma once | ||
|
||
#include "disas/bfd.h" | ||
#include "frame_arch.h" | ||
|
||
const uint64_t bfd_arch = bfd_arch_i386; | ||
const uint64_t bfd_machine = bfd_mach_x86_64; | ||
const uint64_t frame_arch = frame_arch_i386; | ||
const uint64_t frame_mach = frame_mach_x86_64; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters