efi: arm64: Add vmlinux debug link to the Image binary
PATCH v4 1/1 efi: arm64: Add vmlinux debug link to the Image binary
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.
On implementations of UEFI that choose to implement it, this information is exposed via the EFI debug support table, which is a UEFI configuration table that is accessible both by the firmware at boot time and by the OS at runtime, and lists all PE/COFF images loaded by the system.
The format of the NB10 Codeview entry is based on the definition used by EDK2, which is our primary reference when it comes to the use of PE/COFF in the context of UEFI firmware.
---
v4: add a separate DEBUG_EFI debug option so that this feature is disabled
by default
dropped 1/2 which has been queued already in the EFI tree use ASCII rather than an opaque constant for "NB10" signature
arch/arm64/Kconfig.debug | 8 ++++ arch/arm64/kernel/Makefile | 4 ++ arch/arm64/kernel/head.S | 47 +++++++++++++++++++- 3 files changed, 58 insertions(+), 1 deletion(-)
arch/arm64/Kconfig.debug +8 -0
@@ -95,6 +95,14 @@ config DEBUG_ALIGN_RODATA If in doubt, say N. +config DEBUG_EFI + depends on EFI && DEBUG_INFO + bool "UEFI debugging" + help + Enable this option to include EFI specific debugging features into + the kernel that are only useful when using a debug build of the + UEFI firmware + source "drivers/hwtracing/coresight/Kconfig" endmenu
arch/arm64/kernel/Makefile +4 -0
@@ -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_DEBUG_EFI),y) +AFLAGS_head.o += -DVMLINUX_PATH="\"$(shell readlink -f $(objtree)/vmlinux)\"" +endif
arch/arm64/kernel/head.S +46 -1
65 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 1/1 efi: arm64: Add vmlinux debug link to the Image binary
Hi Ard,
Quoted 34 lines · Ard Biesheuvel
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.
On implementations of UEFI that choose to implement it, this information is exposed via the EFI debug support table, which is a UEFI configuration table that is accessible both by the firmware at boot time and by the OS at runtime, and lists all PE/COFF images loaded by the system.
The format of the NB10 Codeview entry is based on the definition used by EDK2, which is our primary reference when it comes to the use of PE/COFF in the context of UEFI firmware.
Signed-off-by Ard Biesheuvel <[email protected]>---
v4: add a separateDEBUG_EFIdebug option so that this feature is disabled
by default
dropped 1/2 which has been queued already in the EFI tree use ASCII rather than an opaque constant for "NB10" signaturearch/arm64/Kconfig.debug | 8 ++++ arch/arm64/kernel/Makefile | 4 ++ arch/arm64/kernel/head.S | 47 +++++++++++++++++++- 3 files changed, 58 insertions(+), 1 deletion(-)arch/arm64/Kconfig.debug +0
-0@@ -95,6 +95,14 @@ config DEBUG_ALIGN_RODATA
arch/arm64/Kconfig.debug config DEBUG_ALIGN_RODATA · line 105
Quoted 10 lines
arch/arm64/Kconfig.debug +8
-0If in doubt, say N. +config DEBUG_EFI + depends on EFI && DEBUG_INFO + bool "UEFI debugging" + help + Enable this option to include EFI specific debugging features into + the kernel that are only useful when using a debug build of the + UEFI firmware +
I don't much like embedding the absolute host build path in the kernel image, but if that's what the tools expect then so be it.
Quoted 8 lines
arch/arm64/Kconfig.debug +0
-0source "drivers/hwtracing/coresight/Kconfig" endmenuarch/arm64/kernel/Makefile +0
-0
arch/arm64/kernel/Makefile obj-y += $(arm64-obj-y) vdso/ probes/ · line 61
Quoted 7 lines
arch/arm64/kernel/Makefile +4
-0@@ -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_DEBUG_EFI),y) +AFLAGS_head.o += -DVMLINUX_PATH="\"$(shell readlink -f $(objtree)/vmlinux)\"" +endif
Can we use the Make realpath directive instead of calling out to the shell?
Do you want me to merge this via arm64?
Will
PATCH v4 1/1 efi: arm64: Add vmlinux debug link to the Image binary
Quoted 53 lines · Will Deacon
Hi Ard,
Quoted 34 lines · Ard Biesheuvel
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.
On implementations of UEFI that choose to implement it, this information is exposed via the EFI debug support table, which is a UEFI configuration table that is accessible both by the firmware at boot time and by the OS at runtime, and lists all PE/COFF images loaded by the system.
The format of the NB10 Codeview entry is based on the definition used by EDK2, which is our primary reference when it comes to the use of PE/COFF in the context of UEFI firmware.
Signed-off-by Ard Biesheuvel <[email protected]>---
v4: add a separateDEBUG_EFIdebug option so that this feature is disabled
by default
dropped 1/2 which has been queued already in the EFI tree use ASCII rather than an opaque constant for "NB10" signaturearch/arm64/Kconfig.debug | 8 ++++ arch/arm64/kernel/Makefile | 4 ++ arch/arm64/kernel/head.S | 47 +++++++++++++++++++- 3 files changed, 58 insertions(+), 1 deletion(-)arch/arm64/Kconfig.debug +0
-0@@ -95,6 +95,14 @@ config DEBUG_ALIGN_RODATAarch/arm64/Kconfig.debug config DEBUG_ALIGN_RODATA · line 105
Quoted 10 lines
arch/arm64/Kconfig.debug +8
-0If in doubt, say N. +config DEBUG_EFI + depends on EFI && DEBUG_INFO + bool "UEFI debugging" + help + Enable this option to include EFI specific debugging features into + the kernel that are only useful when using a debug build of the + UEFI firmware +I don't much like embedding the absolute host build path in the kernel image, but if that's what the tools expect then so be it.
Quoted 2 lines
arch/arm64/Kconfig.debug +0
-0source "drivers/hwtracing/coresight/Kconfig"
Quoted 16 lines
arch/arm64/kernel/Makefile obj-y += $(arm64-obj-y) vdso/ probes/ · line 61
Quoted 13 lines
arch/arm64/Kconfig.debug +0
-0endmenuarch/arm64/kernel/Makefile +4
-0@@ -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_DEBUG_EFI),y) +AFLAGS_head.o += -DVMLINUX_PATH="\"$(shell readlink -f $(objtree)/vmlinux)\"" +endifCan we use the Make realpath directive instead of calling out to the shell?
Yep. This works as expected:
arch/arm64/kernel/Makefile +1 -1
@@ -57,5 +57,5 @@ head-y := head.o extra-y += $(head-y) vmlinux.lds ifeq ($(CONFIG_DEBUG_EFI),y) -AFLAGS_head.o += -DVMLINUX_PATH="\"$(shell readlink -f $(objtree)/vmlinux)\"" +AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\"" endif
Quoted 2 lines
Do you want me to merge this via arm64?
Yes, please
PATCH v4 1/1 efi: arm64: Add vmlinux debug link to the Image binary
Quoted 86 lines · Ard Biesheuvel
Quoted 53 lines · Will Deacon
Hi Ard,
Quoted 34 lines · Ard Biesheuvel
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.
On implementations of UEFI that choose to implement it, this information is exposed via the EFI debug support table, which is a UEFI configuration table that is accessible both by the firmware at boot time and by the OS at runtime, and lists all PE/COFF images loaded by the system.
The format of the NB10 Codeview entry is based on the definition used by EDK2, which is our primary reference when it comes to the use of PE/COFF in the context of UEFI firmware.
Signed-off-by Ard Biesheuvel <[email protected]>---
v4: add a separateDEBUG_EFIdebug option so that this feature is disabled
by default
dropped 1/2 which has been queued already in the EFI tree use ASCII rather than an opaque constant for "NB10" signaturearch/arm64/Kconfig.debug | 8 ++++ arch/arm64/kernel/Makefile | 4 ++ arch/arm64/kernel/head.S | 47 +++++++++++++++++++- 3 files changed, 58 insertions(+), 1 deletion(-)arch/arm64/Kconfig.debug +0
-0@@ -95,6 +95,14 @@ config DEBUG_ALIGN_RODATAarch/arm64/Kconfig.debug config DEBUG_ALIGN_RODATA · line 105
Quoted 10 lines
arch/arm64/Kconfig.debug +8
-0If in doubt, say N. +config DEBUG_EFI + depends on EFI && DEBUG_INFO + bool "UEFI debugging" + help + Enable this option to include EFI specific debugging features into + the kernel that are only useful when using a debug build of the + UEFI firmware +I don't much like embedding the absolute host build path in the kernel image, but if that's what the tools expect then so be it.
Quoted 2 lines
arch/arm64/Kconfig.debug +0
-0source "drivers/hwtracing/coresight/Kconfig"Quoted 16 lines
arch/arm64/kernel/Makefile obj-y += $(arm64-obj-y) vdso/ probes/ · line 61
Quoted 13 lines
arch/arm64/Kconfig.debug +0
-0endmenuarch/arm64/kernel/Makefile +4
-0@@ -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_DEBUG_EFI),y) +AFLAGS_head.o += -DVMLINUX_PATH="\"$(shell readlink -f $(objtree)/vmlinux)\"" +endifCan we use the Make realpath directive instead of calling out to the shell?
Yep. This works as expected:
arch/arm64/kernel/Makefile +1
-1@@ -57,5 +57,5 @@ head-y := head.o extra-y += $(head-y) vmlinux.lds ifeq ($(CONFIG_DEBUG_EFI),y) -AFLAGS_head.o += -DVMLINUX_PATH="\"$(shell readlink -f $(objtree)/vmlinux)\"" +AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\"" endif
Quoted 4 lines
Quoted 2 lines
Do you want me to merge this via arm64?
Yes, please
Should I respin this?
PATCH v4 1/1 efi: arm64: Add vmlinux debug link to the Image binary
Quoted 16 lines · Ard Biesheuvel
Quoted 15 lines · Ard Biesheuvel
Quoted 1 line · Will Deacon
On Thu, Feb 02, 2017 at 05:33:19PM +0000, Ard Biesheuvel wrote:
arch/arm64/kernel/Makefile +1
-1@@ -57,5 +57,5 @@ head-y := head.o extra-y += $(head-y) vmlinux.lds ifeq ($(CONFIG_DEBUG_EFI),y) -AFLAGS_head.o += -DVMLINUX_PATH="\"$(shell readlink -f $(objtree)/vmlinux)\"" +AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\"" endif
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Do you want me to merge this via arm64?
Yes, please
Should I respin this?
No need, I'll pick it up and make the change. I'll push out before I leave work this evening.
Will
PATCH v4 1/1 efi: arm64: Add vmlinux debug link to the Image binary
Quoted 20 lines · Will Deacon
Quoted 19 lines · Ard Biesheuvel
Quoted 18 lines · Ard Biesheuvel
Quoted 1 line · Will Deacon
On Thu, Feb 02, 2017 at 05:33:19PM +0000, Ard Biesheuvel wrote:
arch/arm64/kernel/Makefile +1
-1@@ -57,5 +57,5 @@ head-y := head.o extra-y += $(head-y) vmlinux.lds ifeq ($(CONFIG_DEBUG_EFI),y) -AFLAGS_head.o += -DVMLINUX_PATH="\"$(shell readlink -f $(objtree)/vmlinux)\"" +AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\"" endifQuoted 4 lines
Do you want me to merge this via arm64?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Yes, please
Should I respin this?
No need, I'll pick it up and make the change. I'll push out before I leave work this evening.
Cheers