Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7732FC433F5 for ; Wed, 12 Jan 2022 07:43:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 266E2830D9; Wed, 12 Jan 2022 08:43:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=etri.re.kr Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=dooray.com header.i=@dooray.com header.b="xGk+ke2G"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F55F830DE; Wed, 12 Jan 2022 08:43:42 +0100 (CET) Received: from mscreen.etri.re.kr (mscreen.etri.re.kr [129.254.9.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1012081429 for ; Wed, 12 Jan 2022 08:43:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=etri.re.kr Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ckim@etri.re.kr Received: from unknown (HELO send002-relay.gov-dooray.com) (211.180.235.153) by 129.254.9.16 with ESMTP; 12 Jan 2022 16:43:29 +0900 X-Original-SENDERIP: 211.180.235.153 X-Original-MAILFROM: ckim@etri.re.kr X-Original-RCPTTO: u-boot@lists.denx.de Received: from [10.162.225.112] (HELO smtp002-imp.gov-dooray.com) ([10.162.225.112]) by send002-relay.gov-dooray.com with SMTP id af09cc4c61de86a1; Wed, 12 Jan 2022 16:43:29 +0900 DKIM-Signature: a=rsa-sha256; b=xGk+ke2Gf4tAKUomttagjx9+oAOW0AeomB94I2MAKCApJsdEZAh4+fJyrFXtc00ASOQsE5l9G5 K67mRjikYnNSFiyRCk0+dsCZ7PH9tTzxwK+AzhQP3VqoodpMvdkNE3LAZrxq1k6/7VTTSx/06GT+ s+Rdk67dUU+keWWmFTLcF96IoGnCmGkgkkti5c5tNm+PfYAkjzWVG5Zm3+qZWgkc5Gsewh2lKowx xTUcRN3h15hMW6j6fkXkwOP/XyGD7TbV6eso7HTvN1h69sMW9iim2TcXQPSDA0VIZyn97qYrwjQM 5D6l+VyTXECBeYMhvAiRaCxTS4ZQySt0bzmvw1kQ==; c=relaxed/relaxed; s=selector; d=dooray.com; v=1; bh=VF2xKNGTOX1l4WrrW6dX5X0ZaeSuqNY99c5oOkSAuPs=; h=From:To:Subject:Message-ID; Received: from [129.254.132.39] (HELO CHANKIMPC) ([129.254.132.39]) by smtp002-imp.gov-dooray.com with SMTP id f217320c61de86a1; Wed, 12 Jan 2022 16:43:29 +0900 From: "Chan Kim" To: "U-Boot Mailing List" Subject: How to use add-symbol-file in gdb after the program jumped to linux? (both when PC is physical and virtual) Date: Wed, 12 Jan 2022 16:43:27 +0900 Message-ID: <000c01d80788$1653b180$42fb1480$@etri.re.kr> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdgHiBGMIFPl3JAjS9Gj7YCJMRo9bw== Content-Language: ko Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.39 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hello experts, I'm following linux boot-loading using u-boot (using SPL falcon mode, from RAM) on a qemu virtual machine (now linux started in real board too). The code jumped to linux kernel and because I have done `add-symbol-file vmlinux 0x80081000` I can follow the kernel code step by step using gdb connected to the virtual machine. Actually I loaded the kernel image to 0x80080000 but I had to set the address to 0x80081000 to make the source code appear on the gdb correctly according to the PC value(I don't know why this difference of 0x1000 is needed). Later I found the kernel sets up the page table (identity mapping and swap table) and jumps to `__primary_switched` and this is where pure kernel virtual address is used first time for the PC. This is where the call is made at the end of the head.S file. ldr x8, =__primary_switched adrp x0, __PHYS_OFFSET br x8 In the symbol file (vmlinux, an elf file), the symbols before __primary_switched are all mapped at virtual addresses (starting with 0xffffffc0..... high addresses) but the gdb could follow the source even when the PC value was using physical address. (The PC was initially loaded with physical address of the kernel start and PC relative jumps were being used until it jumps to `__primary_switched`, mmu disabled or using identity mapping) So does this mean, in doing `add-symbol-file` only the offset of the symbols from the start of text matters? Another question : I can follow the kernel source with gdb but after __primary_switched, I cannot see the source. The debugger doesn't show the correct source location according to the now kernel virtual PC value. Should I tell the debugger to use correct offset using add-symbol-file again? if so how? I would be happy to hear any comment or advice. Thank you! Chan Kim