[DynInst_API:] Dyninst binary rewriting and ldd/gdb problem


Date: Wed, 20 Aug 2014 14:36:49 -0400
From: Mohamed Elsabagh <melsabag@xxxxxxx>
Subject: [DynInst_API:] Dyninst binary rewriting and ldd/gdb problem
Hello everyone,Â

I am having a problem with binaries rewritten by Dyninst. Both ldd and gdb cannot handle the rewritten binaries. Specifically, ldd says that the binaries are not dynamically linked, and gcc does not correctly disassemble them (some bad instructions and garbled backtraces). This happens whether there was any instrumentation done on the mutatees or not. The patched binaries execute properly, regardless of the discrepancies though.Â

Follows is a minimal working example that reproduces the problem at my end. Any help with this is highly appreciated.

Thanks,
Mo

Mutatee: hello.c
------------------------
#include <stdio.h>

int main(void) {
 printf("Hello, World!");
 return 0;
}

compile with:
$ gcc -g -o hello hello.c


Mutator: patcher.cpp
------------------------------
#include "BPatch.h"
#include "BPatch_binaryEdit.h"

int main() {
 BPatch bpatch;

 BPatch_addressSpace *app = bpatch.openBinary("hello");
 BPatch_image *appImage = app->getImage();

 BPatch_binaryEdit *appBin = dynamic_cast<BPatch_binaryEdit *>(app);
 appBin->writeFile("hello.patched");

 return 0;
}

compile with:Â
g++ -I/usr/include/dyninst -o patcher patcher.cpp -ldyninstAPI

My environment specs:
----------------------------------
libdyninst-dev 8.1.2-1 amd64
gcc 4.8.2-21
ldd 2.18-5
gdb 7.6.2-1.1
Debian Jessie 2.6.32-042 stable x86_64.



[← Prev in Thread] Current Thread [Next in Thread→]