From patchwork Wed Oct 19 11:40:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 78229 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp201284qge; Wed, 19 Oct 2016 04:42:44 -0700 (PDT) X-Received: by 10.99.116.76 with SMTP id e12mr8761488pgn.20.1476877364550; Wed, 19 Oct 2016 04:42:44 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id f4si7360429pfc.185.2016.10.19.04.42.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Oct 2016 04:42:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bwpFd-00061W-ST; Wed, 19 Oct 2016 11:41:41 +0000 Received: from mail-qk0-x22d.google.com ([2607:f8b0:400d:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bwpFC-0005OS-M9 for linux-arm-kernel@lists.infradead.org; Wed, 19 Oct 2016 11:41:17 +0000 Received: by mail-qk0-x22d.google.com with SMTP id n189so29412963qke.0 for ; Wed, 19 Oct 2016 04:40:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WN/QO0iov11fG01xdeN0fsX7SUvaqO31iKjcKvWXLPM=; b=B7J+9pBVr525KfxM+5Y+P6W5mc65jkPRtJdoFjKnPHafCqAr3zgimo4+F+Fa8N2npk pImB5C+DUEOqYFifO214tVf58bf+6wmZDu1M4OLDqDA5fhNj+ImtPrwRCfWn5BDelxrU +roRXiQl1L1CGDDq6Y/jWP0D6jFCez+sY4rOw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WN/QO0iov11fG01xdeN0fsX7SUvaqO31iKjcKvWXLPM=; b=nBeRD/44YQpHeodkODv2lg4D/nGmpbzirwaftRshOuVNThY6hQk2OxkrMyysZtz2JS RZhR+WaoiyZFPPmext6t2ZzJuKAM5GxgCDWc42PJWm1PD5Om9to+yogUmi0ekP9hOFYo q8oBFKWxKMaZVNC+99/BtWU7B8374ByXnUyoV46V0Hp+lPS04eRkNH1FAEp3KDyrhLnL xq2Sk5+GcRl/jYmYU5CmmAjYh8Rna94KyEWNxiGlotKlgQvWwDLDi/iGVi7wwUlBiw9E Lo5mmHImO2JHViPI0yUL8ycy4fC42tPZ6zYJwNMbWiZZUvl90R7nPOk+RStiMnqA18QW AqOg== X-Gm-Message-State: AA6/9RlZnL77VEgPNLqF9vKso8+bwWBDahUcePXTazjblEq0P82BR4svQEjjrDcbb7EUsTeQ X-Received: by 10.194.77.237 with SMTP id v13mr4152310wjw.220.1476877253274; Wed, 19 Oct 2016 04:40:53 -0700 (PDT) Received: from localhost.localdomain ([196.72.78.235]) by smtp.gmail.com with ESMTPSA id w1sm17804820wje.36.2016.10.19.04.40.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Oct 2016 04:40:52 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 2/2] efi: arm64: add vmlinux debug link to the Image binary Date: Wed, 19 Oct 2016 12:40:32 +0100 Message-Id: <1476877232-24308-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476877232-24308-1-git-send-email-ard.biesheuvel@linaro.org> References: <1476877232-24308-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161019_044114_992202_CA87A0A6 X-CRM114-Status: GOOD ( 13.49 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400d:c09:0:0:0:22d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, matt@codeblueprint.co.uk, Ard Biesheuvel , leif.lindholm@linaro.org, eugene@hp.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org When building with debugging symbols, take the absolute path to the vmlinux binary and add it to the special PE/COFF debug table entry. This allows a debug EFI build to find the vmlinux binary, which is very helpful in debugging, given that the offset where the Image is first loaded by EFI is highly unpredictable. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/Makefile | 4 +++ arch/arm64/kernel/head.S | 34 +++++++++++++++++++- arch/arm64/kernel/image.h | 3 ++ 3 files changed, 40 insertions(+), 1 deletion(-) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 7d66bbaafc0c..1def85599fdb 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -55,3 +55,7 @@ obj-y += $(arm64-obj-y) vdso/ probes/ obj-m += $(arm64-obj-m) head-y := head.o extra-y += $(head-y) vmlinux.lds + +ifneq ($(CONFIG_DEBUG_INFO),) +AFLAGS_head.o += -DVMLINUX_PATH="\"$(shell readlink -f $(objtree)/vmlinux)\"" +endif diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 427f6d3f084c..2f3fbd966de7 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -149,7 +149,7 @@ extra_header_fields: .quad 0 // SizeOfHeapReserve .quad 0 // SizeOfHeapCommit .long 0 // LoaderFlags - .long 0x6 // NumberOfRvaAndSizes + .long (section_table - .) / 8 // NumberOfRvaAndSizes .quad 0 // ExportTable .quad 0 // ImportTable @@ -158,6 +158,11 @@ extra_header_fields: .quad 0 // CertificationTable .quad 0 // BaseRelocationTable +#ifdef CONFIG_DEBUG_INFO + .long efi_debug_table - _head // DebugTable + .long efi_debug_table_size +#endif + // Section table section_table: @@ -206,6 +211,33 @@ section_table: efi_header_end: #endif +#ifdef CONFIG_DEBUG_INFO + __INITDATA + +efi_debug_table: + // EFI_IMAGE_DEBUG_DIRECTORY_ENTRY + .long 0 // Characteristics + .long 0 // TimeDateStamp + .short 0 // MajorVersion + .short 0 // MinorVersion + .long 2 // Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW + .long efi_debug_entry_size // SizeOfData + .long efi_debug_entry_offset // RVA + .long efi_debug_entry_offset // FileOffset + +ENTRY(efi_debug_entry) + // EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY + .long 0x3031424E // Signature + .long 0 // Unknown + .long 0 // Unknown2 + .long 0 // Unknown3 + + .asciz VMLINUX_PATH + + .set efi_debug_entry_size, . - efi_debug_entry + .set efi_debug_table_size, . - efi_debug_table +#endif + __INIT /* diff --git a/arch/arm64/kernel/image.h b/arch/arm64/kernel/image.h index c7fcb232fe47..ad5406f011c2 100644 --- a/arch/arm64/kernel/image.h +++ b/arch/arm64/kernel/image.h @@ -116,6 +116,9 @@ __efistub__end = KALLSYMS_HIDE(_end); __efistub__edata = KALLSYMS_HIDE(_edata); __efistub_screen_info = KALLSYMS_HIDE(screen_info); +#ifdef CONFIG_DEBUG_INFO +efi_debug_entry_offset = efi_debug_entry - _text; +#endif #endif #endif /* __ASM_IMAGE_H */