[PATCH 5/5] efi/x86: Check for bad relocations
From: Arvind Sankar
Date: Wed Apr 15 2020 - 18:16:16 EST
Add relocation checking for x86 as well to catch non-PC-relative
relocations that require runtime processing, since the EFI stub does not
do any runtime relocation processing.
This will catch, for example, data relocations created by static
initializers of pointers.
Signed-off-by: Arvind Sankar <nivedita@xxxxxxxxxxxx>
---
drivers/firmware/efi/libstub/Makefile | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 0bb2916eb12b..2aff59812a54 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -96,6 +96,8 @@ STUBCOPY_RELOC-$(CONFIG_ARM) := R_ARM_ABS
# .bss section here so it's easy to pick out in the linker script.
#
STUBCOPY_FLAGS-$(CONFIG_X86) += --rename-section .bss=.bss.efistub,load,alloc
+STUBCOPY_RELOC-$(CONFIG_X86_32) := 'R_X86_32_(8|16|32)'
+STUBCOPY_RELOC-$(CONFIG_X86_64) := 'R_X86_64_(8|16|32|32S|64)'
$(obj)/%.stub.o: $(obj)/%.o FORCE
$(call if_changed,stubcopy)
@@ -107,16 +109,14 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE
# this time, use objcopy and leave all sections in place.
#
-cmd_stubrelocs_check-y = /bin/true
-
-cmd_stubrelocs_check-$(CONFIG_EFI_ARMSTUB) = \
+cmd_stubrelocs_check = \
$(STRIP) --strip-debug -o $@ $<; \
- if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); then \
+ if $(OBJDUMP) -r $@ | grep -E $(STUBCOPY_RELOC-y); then \
echo "$@: absolute symbol references not allowed in the EFI stub" >&2; \
/bin/false; \
fi
quiet_cmd_stubcopy = STUBCPY $@
cmd_stubcopy = \
- $(cmd_stubrelocs_check-y); \
+ $(cmd_stubrelocs_check); \
$(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@
--
2.24.1