From: Tavis Ormandy <taviso@sdf.lonestar.org>
To: gdb@sourceware.org
Subject: reformatting user command argument
Date: Thu, 11 May 2006 14:14:00 -0000 [thread overview]
Message-ID: <20060511124156.GB23650@sdf.lonestar.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1736 bytes --]
Hello, I've written a macro to assemble instructions directly to memory
using the nasm assembler to make patching binaries using `set write`
easier, it works great, but as a final touch I'd like to be able to tell
the assembler the address where the code will be inserted.
This works fine if I call my macro as `assemble 0x12345`, or `assemble
$pc` but if I use `assemble _start` i cant convert that to an address. I
thought `set $arg0 = (unsigned) $arg0` might work, but no such luck.
For example, this will work:
$ gdb --write -q testcase
(gdb) assemble 0x80489a4
Instructions will be written to 0x80489a4.
Type instructions, one per line.
End with a line saying just "end".
>jmp $+18
>msg: db "This is a test.",0xa
>mov eax, 4
>mov ebx, 1
>mov ecx, msg
>mov edx, 16
>int 0x80
>xor eax, eax
>xor ebx, ebx
>inc eax
>int 0x80
>end
(gdb) q
$ ./testcase
This is a test.
(I could have used call/pop but this is just an example)
But this wont, as the assembler doesnt know what main is:
$ gdb --write -q testcase
(gdb) assemble main
Instructions will be written to 0x80489a4.
Type instructions, one per line.
End with a line saying just "end".
>msg: db "foobar"
>mov eax, msg
>end
error: symbol `main' not defined before use
error: No or invalid offset specified in ORG directive.
My macro is here <http://dev.gentoo.org/~taviso/assemble.txt>
Am I out of luck? I could just document that the user should enter `org
ADDR` (the pseudo-op nasm uses for this), but I'd rather automate it if
possible.
Thanks for any advice.
--
-------------------------------------
taviso@sdf.lonestar.org | finger me for my pgp key.
-------------------------------------------------------
[-- Attachment #2: Type: application/pgp-signature, Size: 238 bytes --]
next reply other threads:[~2006-05-11 12:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-11 14:14 Tavis Ormandy [this message]
2006-05-11 14:47 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060511124156.GB23650@sdf.lonestar.org \
--to=taviso@sdf.lonestar.org \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox