From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5153 invoked from network); 7 Dec 2020 16:46:21 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 7 Dec 2020 16:46:21 -0000 Received: (qmail 26476 invoked by uid 550); 7 Dec 2020 16:46:16 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 26451 invoked from network); 7 Dec 2020 16:46:15 -0000 Date: Mon, 7 Dec 2020 11:46:01 -0500 From: Rich Felker To: Chen Wang Cc: musl Message-ID: <20201207164601.GH534@brightrain.aerifal.cx> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [QUESTION] how to gdb dynamic linker for musl? On Mon, Dec 07, 2020 at 09:37:45PM +0800, Chen Wang wrote: > Hello, > I confugure and make musl with following: > > CFLAGS=-g CROSS_COMPILE=riscv64-unknown-linux-gnu- ./configure --prefix=/home/u/ws/musl/install --exec-prefix=/home/u/ws/musl/install --syslibdir=/home/u/ws/musl/install > > create the executable with: ./install/bin/musl-gcc -g test.c I can't say conclusively that you can't make this work, but you really don't want to do it this way. musl-gcc is for repurposing the host gcc on a glibc-based system for "trying out" musl and making minimal programs. It doesn't make sense to build a glibc-targeting cross compiler then use musl-gcc to try to repurpose it. Just build a proper musl-targeting cross-compiler. However this probably isn't your problem. > Then I tried to debug: > $ qemu-riscv64 -g 1234 ./a.out > then launch gdb: > $ riscv64-unknown-linux-gnu-gdb a.out > > but after I tried to target remote, gdb oops and tell me: > ``` > gdb) target remote:1234 > Remote debugging using :1234 > warning: Unable to find dynamic linker breakpoint function. > GDB will be unable to debug shared library initializers > and track explicitly loaded dynamic code. > 0x0000004000850ae2 in ?? () > ``` > > I tried to set sysroot but does NOT take effect: > ``` > (gdb) set sysroot /home/u/ws/musl/install/ > warning: Unable to find dynamic linker breakpoint function. > GDB will be unable to debug shared library initializers > and track explicitly loaded dynamic code. > (gdb) set sysroot /home/u/ws/musl/install/lib > warning: Unable to find dynamic linker breakpoint function. > GDB will be unable to debug shared library initializers > and track explicitly loaded dynamic code. > ``` > I checked the a.out > ``` > $ riscv64-unknown-linux-gnu-readelf -l a.out > ...... > INTERP 0x00000000000001c8 0x00000000000101c8 0x00000000000101c8 > 0x000000000000002d 0x000000000000002d R 0x1 > [Requesting program interpreter: /home/u/ws/musl/install/ld-musl-riscv64.so.1] > ...... > ``` > And I can run with qemu directly: $ qemu-riscv64 ./a.out, this > works, but why I can not debug with gdb? Who can help me out? Thanks > in adv. I haven't used gdb remote with qemu so I'm not sure what to expect here in terms of how it finds/loads the binary and dynamic linker (does it do that over the remote interface or via the local fs?). If you can enable more output from qemu or strace one or both of gdb and qemu it might help figure out what's going on. Hopefully someone else who's use gdb this way can offer more useful help. Rich