|
From: ljp on 10 Apr 2008 13:34 Hi everyone, I have a bizarre question about x86 disassembly... I want to disassemble a Linux x86 executable into assembler source that can then be re-assembled into the original binary. Is this total madness? I control the original compilation (using gcc), so the binary does contain debugging information -- with this information, is objdump (or any other tool?) going to be able to disassemble the binary correctly without guessing about instruction boundaries? The reason I'm considering this is that I need a single assembly file representing the program /after/ linking. Alternately, does anyone know of a way to "link" assembly files, e.g., if the normal order of things is: foo.s -> ASSEMBLER -> foo.o bar.s -> ASSEMBLER -> bar.o foo.o, bar.o -> LINKER -> foobar.exe then I want to get foobar.s such that foo.s, bar.s -> ??? -> foobar.s foobar.s -> ASSEMBLER -> foobar.exe Many thanks
From: Evenbit on 10 Apr 2008 14:37 On Apr 10, 1:34 pm, ljp <lonnie.princeho...(a)gmail.com> wrote: > Hi everyone, I have a bizarre question about x86 disassembly... > > I want to disassemble a Linux x86 executable into assembler source > that can then be re-assembled into the original binary. > > Is this total madness? I control the original compilation (using > gcc), so the binary does contain debugging information -- with this > information, is objdump (or any other tool?) going to be able to > disassemble the binary correctly without guessing about instruction > boundaries? > > The reason I'm considering this is that I need a single assembly file > representing the program /after/ linking. > > Alternately, does anyone know of a way to "link" assembly files, e.g., > if the normal order of things is: > > foo.s -> ASSEMBLER -> foo.o > bar.s -> ASSEMBLER -> bar.o > foo.o, bar.o -> LINKER -> foobar.exe > > then I want to get foobar.s such that > > foo.s, bar.s -> ??? -> foobar.s > foobar.s -> ASSEMBLER -> foobar.exe > > Many thanks This is easy. Just type: $ cat foo.s bar.s > foobar.s ....and then type: $ vi foobar.s ....to change anything that would choke the assembler. Nathan.
From: tin.cans.and.string on 10 Apr 2008 14:59 -----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 On Apr 10, 11:34 am, ljp <lonnie.princeho...(a)gmail.com> wrote: > I want to disassemble a Linux x86 executable into assembler source > that can then be re-assembled into the original binary. I believe the Interactive Disassembler is capable of doing this. > The reason I'm considering this is that I need a single assembly file > representing the program /after/ linking. If you can talk about it, I'd be interested in hearing why. > Alternately, does anyone know of a way to "link" assembly files, e.g., > if the normal order of things is: > > foo.s -> ASSEMBLER -> foo.o > bar.s -> ASSEMBLER -> bar.o > foo.o, bar.o -> LINKER -> foobar.exe > > then I want to get foobar.s such that > > foo.s, bar.s -> ??? -> foobar.s > foobar.s -> ASSEMBLER -> foobar.exe Why not use an INCLUDE directive in foo.s targetting bar.s? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (GNU/Linux) iEYEAREDAAYFAkf+Y0kACgkQyLm4ydrABvcbYQCeM9ImkBEJkmlfg3miros+pRYl ubkAn1O+n9ydjoIR6prmYAOsbepF7kBk =Cw/6 -----END PGP SIGNATURE-----
From: ljp on 10 Apr 2008 17:17 > > I believe the Interactive Disassembler is capable of doing this. > Thanks, I'll check it out. > > The reason I'm considering this is that I need a single assembly file > > representing the program /after/ linking. > > If you can talk about it, I'd be interested in hearing why. It's for an exercise in software fault isolation. I run a rewriter on the assembly code to enforce certain security properties, and part of that involves transforming the .text section so that (a) instructions are aligned on 16-byte boundaries, and (b) the .text section is aligned to an address that is a power of 2, and is padded so its length is also a power of 2. I'm using assembler directives to achieve these alignment goals, but I believe this demands all of the code I'm rewriting be in the same file. (I'm looking into alternatives, but nothing definitive has surfaced) The obvious thing to do is to rewrite the C source code to be in one file, but that is not feasible for my current application. (if you're interested, this is based on the approach described here: http://people.csail.mit.edu/smcc/projects/pittsfield/)
From: ljp on 10 Apr 2008 17:25 > This is easy. Just type: > > $ cat foo.s bar.s > foobar.s > > ...and then type: > > $ vi foobar.s > > ...to change anything that would choke the assembler. It may come to that, but I was looking for something slightly more automatic. For one, there are a lot of duplicate labels that are going to choke the assembler.
|
Next
|
Last
Pages: 1 2 Prev: Crypto++ (Cryptopp) 5.5.2 Tiger implementation maybe too long. Next: Crusher Freeze Parallel |