From patchwork Wed Jan 25 10:39:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 92428 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2145324qgi; Wed, 25 Jan 2017 02:39:38 -0800 (PST) X-Received: by 10.84.128.33 with SMTP id 30mr2573193pla.128.1485340778047; Wed, 25 Jan 2017 02:39:38 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8si22998214pgd.73.2017.01.25.02.39.37; Wed, 25 Jan 2017 02:39:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751864AbdAYKjh (ORCPT + 2 others); Wed, 25 Jan 2017 05:39:37 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:38579 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751672AbdAYKjg (ORCPT ); Wed, 25 Jan 2017 05:39:36 -0500 Received: by mail-wm0-f47.google.com with SMTP id r144so23077822wme.1 for ; Wed, 25 Jan 2017 02:39:36 -0800 (PST) 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=jkXL+S++2mlSxxdTgKfe0kLM16cUFCPcSK+zjXzS7f4=; b=YyNzR0mzeI5kR58moVWQzvk2VYrDPTRecczVfzwh7MqAKnECZfIg7aiwiRffkjhfoh VDcV/tbNcpZCSWk98g9OKp+242uVX31bhTo7Ak36dv+8O2jK+nYwA1nDsQiMKCU1dQUd /VPil5nkE8DbyZWfswNc0FoS2POqlBDQ5SKkU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jkXL+S++2mlSxxdTgKfe0kLM16cUFCPcSK+zjXzS7f4=; b=FVwAEledwQAMlSBsVXcZqcdietCp6syXcWrLZ6uHhkT484fEyVRC0azPgDeIXsmoaE dADWOrTrR+BlsxyIkaroyBQOy1pEO6s0QQ7NSiEvR/9qlmWBBozBTQkgwGoYIOvhbm4i 1SYVcBggKxd81YGu2S4c3UdbO1GsFwSmak1qVSjQu+5fHRtZI30jJ0GtQXt2nI6iF3J7 8lP2/tUTO6+BqIDpdWEhwjlzvZMC3IAo6ENthwvGLY+t+f4rUftdXFbVX5sjbC1JAag3 0KSF23tE9KRTnnZvHo2y9x40zWy1Nvdzk5VZWW0IKH0uHnCSSkj2YllRfswyB33ORfDp wTiw== X-Gm-Message-State: AIkVDXLi6g4f6nQy5DoHEEdHpb/bGO8t++lzEZLaXasULpD0OZq1A/SAV1cZxcgHGNndVffC X-Received: by 10.223.165.76 with SMTP id j12mr32144131wrb.17.1485340775450; Wed, 25 Jan 2017 02:39:35 -0800 (PST) Received: from localhost.localdomain ([160.163.215.165]) by smtp.gmail.com with ESMTPSA id o70sm5674153wrc.20.2017.01.25.02.39.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Jan 2017 02:39:34 -0800 (PST) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, catalin.marinas@arm.com, leif.lindholm@linaro.org, mark.rutland@arm.com, matt@codeblueprint.co.uk Cc: Ard Biesheuvel Subject: [PATCH v2 2/2] arm64: efi: add vmlinux debug link to the Image binary Date: Wed, 25 Jan 2017 10:39:19 +0000 Message-Id: <1485340759-28975-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485340759-28975-1-git-send-email-ard.biesheuvel@linaro.org> References: <1485340759-28975-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.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. These entries are used internally by EDK2 based* debug builds of UEFI to populate the DebugImageInfo table, which can be used by debuggers as well as by the OS itself to retrieve information about all loaded PE/COFF executables. This is highly useful for source level debugging of the UEFI stub. * for AArch64, this probably means all of them Cc: Matt Fleming 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 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 7d66bbaafc0c..6dbc0e5527f5 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 + +ifeq ($(CONFIG_EFI)$(CONFIG_DEBUG_INFO),yy) +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 4b1abac3485a..b462ab1f11ef 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: @@ -204,6 +209,33 @@ section_table: */ .align 12 efi_header_end: + +#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 #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 */