[RFC PATCH 11/17] efi: libstub: Ignore relocations for .discard sections

From: Julien Thierry
Date: Wed Jan 20 2021 - 13:52:03 EST


EFI stub cannot have absolute relocations in sections affecting the
execution flow. However, for sections that get discarded at link time,
it doesn't really matter if they have absolute relocations.

Ignore the relocation associated with such sections.

Signed-off-by: Julien Thierry <jthierry@xxxxxxxxxx>
---
drivers/firmware/efi/libstub/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 8a94388e38b3..70e9c7f45d30 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -133,7 +133,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE
#
quiet_cmd_stubcopy = STUBCPY $@
cmd_stubcopy = \
- $(STRIP) --strip-debug -o $@ $<; \
+ $(STRIP) --strip-debug --remove-relocations=".discard.*" -o $@ $<; \
if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); then \
echo "$@: absolute symbol references not allowed in the EFI stub" >&2; \
/bin/false; \
--
2.25.4