From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32533 invoked by alias); 11 May 2006 12:46:59 -0000 Received: (qmail 32525 invoked by uid 22791); 11 May 2006 12:46:58 -0000 X-Spam-Check-By: sourceware.org Received: from mx.freeshell.ORG (HELO sdf.lonestar.org) (192.94.73.18) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 11 May 2006 12:46:53 +0000 Received: from sdf.lonestar.org (IDENT:taviso@otaku.freeshell.org [192.94.73.2]) by sdf.lonestar.org (8.13.5.20060308/8.12.10) with ESMTP id k4BCfh8D017373 for ; Thu, 11 May 2006 12:41:44 GMT Received: from localhost (localhost [[UNIX: localhost]]) by sdf.lonestar.org (8.13.5.20060308/8.12.8/Submit) id k4BCfhEB012274 for gdb@sourceware.org; Thu, 11 May 2006 12:41:43 GMT Date: Thu, 11 May 2006 14:14:00 -0000 From: Tavis Ormandy To: gdb@sourceware.org Subject: reformatting user command argument Message-ID: <20060511124156.GB23650@sdf.lonestar.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="YZ5djTAD1cGYuMQK" Content-Disposition: inline User-Agent: Mutt/1.5.11 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00137.txt.bz2 --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1683 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 =3D (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=20 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 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. --=20 ------------------------------------- taviso@sdf.lonestar.org | finger me for my pgp key. ------------------------------------------------------- --YZ5djTAD1cGYuMQK Content-Type: application/pgp-signature Content-Disposition: inline Content-length: 238 -----BEGIN PGP SIGNATURE----- Version: 2.6.3ia Comment: finger me for my pgp key iQBVAwUBRGMxFNommWwmkP1xAQHdIwIAvDXK+cjb8I8BfwzlembipMhw0WlPgsLD RxExmr4pzMkrAqR694mup8Gub3A+R36+04fqdIPoQPN6P84oukcy+g== =Pg6L -----END PGP SIGNATURE----- --YZ5djTAD1cGYuMQK--