Question

I am trying to extract information like function name and its parameters from elf file, with the goal to perform robustness testing by changing the parameter values for functions, I am working on windows environment and the elf file I want to instrument is for powerPC architecture, I tried using opensource tool DynInst http://www.dyninst.org/ which can be built on MS Visual Studio, but it instruments binaries compiled with cl compiler (exe and dll formats), I have the following questions to pose:

1) Is it possible to use Microsoft Visual studio c++ compiler to produce elf file, so that I can use DynInst to instrument the binary?

2) Is there any other means or tools that can be used to extract and instrument elf files on windows platform?

objdump, readelf, nm etc provide features for extracting elf, but my need is to also instrument them. I dont know how to tailor these utilities to meet my needs, any suggestions would be of great help!

/Thanks

Was it helpful?

Solution

1) Is it possible to use Microsoft Visual studio c++ compiler to produce elf file

Sure: ELF is just a file format. Just like you can write a .zip file on PowerPC/AIX and read it on a SPARC/Solaris and x86/Windows, so you can write an ELF file on any OS.

so that I can use DynInst to instrument the binary?

Whether DynInst will be able to instrument such a file I have no idea.

Is there any other means or tools that can be used to extract and instrument elf files on windows platform?

You can compile the GNU binutils package, which contains readelf. You can use it to extract all kinds of info from the ELF file.

There is also libelf library, which allows you to read and write ELF files. Whether libelf can be built on Windows without too much trouble, I don't know.

OTHER TIPS

It's not possible to use the Visual Studio compiler to directly generate an ELF binary. Windows binaries are PE format, which is incompatible with ELF. It is possible to generate an ELF output a roundabout way, with a lot of work, by compiling to the assembly language, and running a script over the resulting file to convert from PE to ELF, and use an ELF-aware assembler (like gas, yasm, nasm) to assemble the resulting file.

Additionally, you won't be able to execute a PowerPC binary on Windows, because Windows does not support the PowerPC architecture.

If DynaInst simply inserts hooks into the compiling code, then you should use a cross-compiler to compile both the DynaInst library hooks and the binary you wish to instrument.

There are other tools available, that should work on Windows as well, such as gprof, which only relies on having certain functions be available, which are used to instrument function calls.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top