From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/2] arm64: efi: add vmlinux debug link to the Image binary
Date: Wed, 25 Jan 2017 10:39:19 +0000 [thread overview]
Message-ID: <1485340759-28975-3-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1485340759-28975-1-git-send-email-ard.biesheuvel@linaro.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 <matt@codeblueprint.co.uk>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
arch/arm64/kernel/Makefile | 4 +++
arch/arm64/kernel/head.S | 34 +++++++++++++++++++-
arch/arm64/kernel/image.h | 3 ++
3 files changed, 40 insertions(+), 1 deletion(-)
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 */
--
2.7.4
next prev parent reply other threads:[~2017-01-25 10:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-25 10:39 [PATCH v2 0/2] efi/arm64: add vmlinux link to PE/COFF debug table Ard Biesheuvel
2017-01-25 10:39 ` [PATCH v2 1/2] efi: libstub: Preserve .debug sections after absolute relocation check Ard Biesheuvel
2017-01-25 10:39 ` Ard Biesheuvel [this message]
2017-01-25 11:45 ` [PATCH v2 2/2] arm64: efi: add vmlinux debug link to the Image binary Ard Biesheuvel
2017-01-25 11:53 ` Mark Rutland
2017-01-25 12:00 ` Ard Biesheuvel
2017-01-26 18:26 ` Mark Rutland
2017-01-26 18:33 ` Ard Biesheuvel
2017-01-26 18:44 ` Mark Rutland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1485340759-28975-3-git-send-email-ard.biesheuvel@linaro.org \
--to=ard.biesheuvel@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).