From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by sourceware.org (Postfix) with ESMTPS id 8590C385783A for ; Thu, 29 Oct 2020 15:29:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8590C385783A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maringuu.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=work@maringuu.de Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4CMTrp22C6zQl1t; Thu, 29 Oct 2020 16:29:46 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id WfPotqybdzQA; Thu, 29 Oct 2020 16:29:43 +0100 (CET) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Subject: Re: [Question] Is there a way to specify an offset to the loaded symbols? From: "Marten Ringwelski" To: "Christian Biesinger" , "Marten Ringwelski" Cc: "Reuben Thomas via Gdb" Date: Thu, 29 Oct 2020 16:26:41 +0100 Message-Id: In-Reply-To: X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.67 / 15.00 / 15.00 X-Rspamd-Queue-Id: 474B5EF7 X-Rspamd-UID: b94349 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, URIBL_SBL, URIBL_SBL_A autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Thu, 29 Oct 2020 15:29:49 -0000 On Thu Oct 29, 2020 at 2:29 PM CET, Christian Biesinger wrote: > On Thu, Oct 29, 2020 at 9:23 AM Marten Ringwelski > wrote: > > > > Hello, > > for some reason that is not important here I need to debug a binary tha= t is executed by calling the linker manually. > > In my case I do `/lib/ld-musl-x86_64.so.1 binary`. > > The problem with this is that gdb now obviously thinks that I want to d= ebug `/lib/ld-musl-x86_64.so.1`. This is not the case. > > Loading the symbols from `binary` does not help since the the linker lo= ads the process into memory and the jumps to its main. > > > > In other words I have the symbols for the binary to be debugged but the= binary is loaded into memory with an offset so the symbols are offseted. > > Is there any way to get this working? > > add-symbol-file lets you specify an address but maybe it's easier if > you just use patchelf --set-interpreter to make it use > /lib/ld-musl-x86_64.so.1 Thank you, that was easier than expected!