[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200415221520.2692512-3-nivedita@alum.mit.edu>
Date: Wed, 15 Apr 2020 18:15:17 -0400
From: Arvind Sankar <nivedita@...m.mit.edu>
To: Ard Biesheuvel <ardb@...nel.org>
Cc: linux-efi@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
x86@...nel.org, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
linux-kernel@...r.kernel.org
Subject: [PATCH 2/5] efi/libstub: Factor out relocation checking
In preparation for using STUBCOPY for x86 as well, which doesn't require
relocation checking, move the checking code into its own variable so it
can be left out for x86.
Signed-off-by: Arvind Sankar <nivedita@...m.mit.edu>
---
drivers/firmware/efi/libstub/Makefile | 30 ++++++++++++++++-----------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 45ffe0822df1..e5e76677f2da 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -80,6 +80,15 @@ STUBCOPY_FLAGS-$(CONFIG_ARM64) += --prefix-alloc-sections=.init \
--prefix-symbols=__efistub_
STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS
+#
+# ARM discards the .data section because it disallows r/w data in the
+# decompressor. So move our .data to .data.efistub and .bss to .bss.efistub,
+# which are preserved explicitly by the decompressor linker script.
+#
+STUBCOPY_FLAGS-$(CONFIG_ARM) += --rename-section .data=.data.efistub \
+ --rename-section .bss=.bss.efistub,load,alloc
+STUBCOPY_RELOC-$(CONFIG_ARM) := R_ARM_ABS
+
$(obj)/%.stub.o: $(obj)/%.o FORCE
$(call if_changed,stubcopy)
@@ -89,20 +98,17 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE
# such relocations. If none are found, regenerate the output object, but
# this time, use objcopy and leave all sections in place.
#
-quiet_cmd_stubcopy = STUBCPY $@
- cmd_stubcopy = \
+
+cmd_stubrelocs_check-y = /bin/true
+
+cmd_stubrelocs_check-$(CONFIG_EFI_ARMSTUB) = \
$(STRIP) --strip-debug -o $@ $<; \
if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); then \
echo "$@: absolute symbol references not allowed in the EFI stub" >&2; \
/bin/false; \
- fi; \
- $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@
+ fi
-#
-# ARM discards the .data section because it disallows r/w data in the
-# decompressor. So move our .data to .data.efistub and .bss to .bss.efistub,
-# which are preserved explicitly by the decompressor linker script.
-#
-STUBCOPY_FLAGS-$(CONFIG_ARM) += --rename-section .data=.data.efistub \
- --rename-section .bss=.bss.efistub,load,alloc
-STUBCOPY_RELOC-$(CONFIG_ARM) := R_ARM_ABS
+quiet_cmd_stubcopy = STUBCPY $@
+ cmd_stubcopy = \
+ $(cmd_stubrelocs_check-y); \
+ $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@
--
2.24.1
Powered by blists - more mailing lists