Skip to contentSkip to conversation

efi/libstub: avoid linking libstub/lib-ksyms.o into vmlinux

PATCH In review Masahiro Yamada 2 participants 6 messages Mar 5, 2020 EFI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi/libstub: avoid linking libstub/lib-ksyms.o into vmlinux

drivers/firmware/efi/libstub/Makefile is supposed to create a static library, which is not directly linked to vmlinux.

Since commit 7f2084fa55e6 ("[kbuild] handle exports in lib-y objects reliably"), any Makefile using lib-y generates lib-ksyms.o which is linked into vmlinux.

In this case, the following garbage object is linked into vmlinux.

drivers/firmware/efi/libstub/lib-ksyms.o

We do not want to link anything from libstub/ directly to vmlinux, so using subdir-y instead of obj-y is the correct way to descend into this directory.

---

 drivers/firmware/efi/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/Makefile +1 -1
index 554d795270d9..4fd2fa02f549 100644
@@ -19,7 +19,7 @@ obj-$(CONFIG_EFI_VARS_PSTORE)		+= efi-pstore.o
 obj-$(CONFIG_UEFI_CPER)			+= cper.o
 obj-$(CONFIG_EFI_RUNTIME_MAP)		+= runtime-map.o
 obj-$(CONFIG_EFI_RUNTIME_WRAPPERS)	+= runtime-wrappers.o
-obj-$(CONFIG_EFI_STUB)			+= libstub/
+subdir-$(CONFIG_EFI_STUB)		+= libstub
 obj-$(CONFIG_EFI_FAKE_MEMMAP)		+= fake_map.o
 obj-$(CONFIG_EFI_BOOTLOADER_CONTROL)	+= efibc.o
 obj-$(CONFIG_EFI_TEST)			+= test/
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 4 lines · Masahiro Yamada

drivers/firmware/efi/libstub/Makefile is supposed to create a static library, which is not directly linked to vmlinux.

This is not true for arm64. Does that matter?

Quoted 34 lines

Since commit 7f2084fa55e6 ("[kbuild] handle exports in lib-y objects reliably"), any Makefile using lib-y generates lib-ksyms.o which is linked into vmlinux.

In this case, the following garbage object is linked into vmlinux.

drivers/firmware/efi/libstub/lib-ksyms.o

We do not want to link anything from libstub/ directly to vmlinux, so using subdir-y instead of obj-y is the correct way to descend into this directory.

---

 drivers/firmware/efi/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/Makefile +1 -2
index 554d795270d9..4fd2fa02f549 100644
@@ -19,7 +19,7 @@ obj-$(CONFIG_EFI_VARS_PSTORE)         += efi-pstore.o
 obj-$(CONFIG_UEFI_CPER)                        += cper.o
 obj-$(CONFIG_EFI_RUNTIME_MAP)          += runtime-map.o
 obj-$(CONFIG_EFI_RUNTIME_WRAPPERS)     += runtime-wrappers.o
-obj-$(CONFIG_EFI_STUB)                 += libstub/
+subdir-$(CONFIG_EFI_STUB)              += libstub
 obj-$(CONFIG_EFI_FAKE_MEMMAP)          += fake_map.o
 obj-$(CONFIG_EFI_BOOTLOADER_CONTROL)   += efibc.o
 obj-$(CONFIG_EFI_TEST)                 += test/
--

2.17.1

#2 lore raw
Quoted 8 lines · Ard Biesheuvel
Quoted 4 lines · Masahiro Yamada

drivers/firmware/efi/libstub/Makefile is supposed to create a static library, which is not directly linked to vmlinux.

This is not true for arm64. Does that matter?

Yeah, I know. arm64 vmlinux links it
(but in a different manner from normal lib.a )

Shall I rephrase this paragraph as follows?

drivers/firmware/efi/libstub/Makefile is supposed to create a static library, which is not directly linked to vmlinux on ARCH=arm, x86.

This is just a matter of whether linking
unneeded lib-ksyms.o or not.

Quoted 34 lines
Quoted 34 lines

Since commit 7f2084fa55e6 ("[kbuild] handle exports in lib-y objects reliably"), any Makefile using lib-y generates lib-ksyms.o which is linked into vmlinux.

In this case, the following garbage object is linked into vmlinux.

drivers/firmware/efi/libstub/lib-ksyms.o

We do not want to link anything from libstub/ directly to vmlinux, so using subdir-y instead of obj-y is the correct way to descend into this directory.

---

 drivers/firmware/efi/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/Makefile +1 -2
index 554d795270d9..4fd2fa02f549 100644
@@ -19,7 +19,7 @@ obj-$(CONFIG_EFI_VARS_PSTORE)         += efi-pstore.o
 obj-$(CONFIG_UEFI_CPER)                        += cper.o
 obj-$(CONFIG_EFI_RUNTIME_MAP)          += runtime-map.o
 obj-$(CONFIG_EFI_RUNTIME_WRAPPERS)     += runtime-wrappers.o
-obj-$(CONFIG_EFI_STUB)                 += libstub/
+subdir-$(CONFIG_EFI_STUB)              += libstub
 obj-$(CONFIG_EFI_FAKE_MEMMAP)          += fake_map.o
 obj-$(CONFIG_EFI_BOOTLOADER_CONTROL)   += efibc.o
 obj-$(CONFIG_EFI_TEST)                 += test/
--

2.17.1

Signature · 2 lines
Best Regards
Masahiro Yamada
maintainer
#3 lore raw
Quoted 19 lines · Masahiro Yamada
Quoted 8 lines · Ard Biesheuvel
Quoted 4 lines · Masahiro Yamada

drivers/firmware/efi/libstub/Makefile is supposed to create a static library, which is not directly linked to vmlinux.

This is not true for arm64. Does that matter?

Yeah, I know. arm64 vmlinux links it
(but in a different manner from normal lib.a )

Shall I rephrase this paragraph as follows?

Quoted 8 lines

drivers/firmware/efi/libstub/Makefile is supposed to create a static library, which is not directly linked to vmlinux on ARCH=arm, x86.

This is just a matter of whether linking
unneeded lib-ksyms.o or not.

How about

"""
drivers/firmware/efi/libstub/Makefile builds a static library, which is not linked into the main vmlinux target in the ordinary way [arm64], or at all [ARM, x86]
"""

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Since commit 7f2084fa55e6 ("[kbuild] handle exports in lib-y objects reliably"), any Makefile using lib-y generates lib-ksyms.o which is linked into vmlinux.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

In this case, the following garbage object is linked into vmlinux.

drivers/firmware/efi/libstub/lib-ksyms.o

We do not want to link anything from libstub/ directly to vmlinux,

and

"""
We do not want to follow the default linking rules for static libraries built under libstub/
"""

If you agree, no need to resend, I'll fix it up when applying

Quoted 31 lines
Quoted 9 lines
Quoted 9 lines

so using subdir-y instead of obj-y is the correct way to descend into this directory.

---

 drivers/firmware/efi/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 14 lines
drivers/firmware/efi/Makefile +1 -2
index 554d795270d9..4fd2fa02f549 100644
@@ -19,7 +19,7 @@ obj-$(CONFIG_EFI_VARS_PSTORE)         += efi-pstore.o
 obj-$(CONFIG_UEFI_CPER)                        += cper.o
 obj-$(CONFIG_EFI_RUNTIME_MAP)          += runtime-map.o
 obj-$(CONFIG_EFI_RUNTIME_WRAPPERS)     += runtime-wrappers.o
-obj-$(CONFIG_EFI_STUB)                 += libstub/
+subdir-$(CONFIG_EFI_STUB)              += libstub
 obj-$(CONFIG_EFI_FAKE_MEMMAP)          += fake_map.o
 obj-$(CONFIG_EFI_BOOTLOADER_CONTROL)   += efibc.o
 obj-$(CONFIG_EFI_TEST)                 += test/
--
Quoted 2 lines

2.17.1

--
Best Regards
Masahiro Yamada

#4 lore raw

Hi Ard,

Quoted 3 lines · Ard Biesheuvel

If you agree, no need to resend, I'll fix it up when applying

I agree.
Please fix it up.

Thanks.

Signature · 2 lines
Best Regards
Masahiro Yamada
maintainer
#5 lore raw
Quoted 4 lines · Masahiro Yamada

Hi Ard,

Quoted 9 lines
Quoted 3 lines · Ard Biesheuvel

If you agree, no need to resend, I'll fix it up when applying

I agree.
Please fix it up.

Thank you,

Queued in efi/next