From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id 1555F3858C39 for ; Wed, 3 Aug 2022 17:43:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1555F3858C39 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1oJIOZ-0000L2-VP for gdb@sourceware.org; Wed, 03 Aug 2022 19:42:59 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: gdb@sourceware.org From: Tavis Ormandy Subject: adding custom stabs symbols Date: Wed, 3 Aug 2022 17:42:53 -0000 (UTC) Message-ID: User-Agent: slrn/pre1.0.4-5 (Linux) X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NML_ADSP_CUSTOM_MED, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Aug 2022 17:43:02 -0000 Hello, I tried asking this on the binutils list but thought I would try here too. I have a stripped binary I don't have the source for that I would like to debug in gdb. I know where some functions and globals are, so I thought a clever solution might be writing some .stabs statements in gas, like this: .equ N_FUN, 0x24 .equ N_PSYM, 0xa0 .stabs "example:f-11", N_FUN, 0, 0, 0x8005bba .stabs "foo:p*-8", N_PSYM, 0, 0, 8 .stabs "bar:p-10", N_PSYM, 0, 0, 12 https://sourceware.org/binutils/docs/as/Stab.html I think this describes a function like this at address 0x8005bba: void example(unsigned int *foo, unsigned long bar); That sort of works, if I assemble it (as -gstabs), then add-symbol-file a.out, gdb knows about the address and type. The problem is it won't resolve it in backtraces: (gdb) add-symbol-file a.out (gdb) info address example Symbol "example" is a function at address 0x8005bba. (gdb) pt example type = void (unsigned int *, unsigned long) (gdb) bt .. #1 0x0000000008005bba in ?? () <-- unresolved .. What am I doing wrong? This is still better than nothing, at least I can put breakpoints on the names and print globals, but is there a better way to accomplish what I'm trying to do? Tavis. -- _o) $ lynx lock.cmpxchg8b.com /\\ _o) _o) $ finger taviso@sdf.org _\_V _( ) _( ) @taviso