aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2017-01-31 08:21:42 -0500
committerIngo Molnar <mingo@kernel.org>2017-02-01 02:45:47 -0500
commit696204faa6e8a318320ebb49d9fa69bc8275644d (patch)
tree3468f0ef98987886ee63fc0a445fabb0d7ea2e9f
parent22c091d02a5422d2825a4fb1af71e5a62f9e4d0f (diff)
efi/libstub: Preserve .debug sections after absolute relocation check
The build commands for the ARM and arm64 EFI stubs strip the .debug sections and other sections that may legally contain absolute relocations, in order to inspect the remaining sections for the presence of such relocations. This leaves us without debugging symbols in the stub for no good reason, considering that these sections are omitted from the kernel binary anyway, and that these relocations are thus only consumed by users of the ELF binary, such as debuggers. So move to 'strip' for performing the relocation check, and if it succeeds, invoke objcopy as before, but leaving the .debug sections in place. Note that these sections may refer to ksymtab/kcrctab contents, so leave those in place as well. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Matt Fleming <matt@codeblueprint.co.uk> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/1485868902-20401-11-git-send-email-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--drivers/firmware/efi/libstub/Makefile24
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index d564d25df8ab..33e0e2f1a730 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -11,7 +11,7 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -O2 \
11 -mno-mmx -mno-sse 11 -mno-mmx -mno-sse
12 12
13cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) 13cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS))
14cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) -g0 \ 14cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \
15 -fno-builtin -fpic -mno-single-pic-base 15 -fno-builtin -fpic -mno-single-pic-base
16 16
17cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt 17cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt
@@ -60,7 +60,7 @@ CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
60extra-$(CONFIG_EFI_ARMSTUB) := $(lib-y) 60extra-$(CONFIG_EFI_ARMSTUB) := $(lib-y)
61lib-$(CONFIG_EFI_ARMSTUB) := $(patsubst %.o,%.stub.o,$(lib-y)) 61lib-$(CONFIG_EFI_ARMSTUB) := $(patsubst %.o,%.stub.o,$(lib-y))
62 62
63STUBCOPY_FLAGS-y := -R .debug* -R *ksymtab* -R *kcrctab* 63STUBCOPY_RM-y := -R *ksymtab* -R *kcrctab*
64STUBCOPY_FLAGS-$(CONFIG_ARM64) += --prefix-alloc-sections=.init \ 64STUBCOPY_FLAGS-$(CONFIG_ARM64) += --prefix-alloc-sections=.init \
65 --prefix-symbols=__efistub_ 65 --prefix-symbols=__efistub_
66STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS 66STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS
@@ -68,17 +68,25 @@ STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS
68$(obj)/%.stub.o: $(obj)/%.o FORCE 68$(obj)/%.stub.o: $(obj)/%.o FORCE
69 $(call if_changed,stubcopy) 69 $(call if_changed,stubcopy)
70 70
71#
72# Strip debug sections and some other sections that may legally contain
73# absolute relocations, so that we can inspect the remaining sections for
74# such relocations. If none are found, regenerate the output object, but
75# this time, use objcopy and leave all sections in place.
76#
71quiet_cmd_stubcopy = STUBCPY $@ 77quiet_cmd_stubcopy = STUBCPY $@
72 cmd_stubcopy = if $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@; then \ 78 cmd_stubcopy = if $(STRIP) --strip-debug $(STUBCOPY_RM-y) -o $@ $<; \
73 $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y) \ 79 then if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); \
74 && (echo >&2 "$@: absolute symbol references not allowed in the EFI stub"; \ 80 then (echo >&2 "$@: absolute symbol references not allowed in the EFI stub"; \
75 rm -f $@; /bin/false); else /bin/false; fi 81 rm -f $@; /bin/false); \
82 else $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@; fi \
83 else /bin/false; fi
76 84
77# 85#
78# ARM discards the .data section because it disallows r/w data in the 86# ARM discards the .data section because it disallows r/w data in the
79# decompressor. So move our .data to .data.efistub, which is preserved 87# decompressor. So move our .data to .data.efistub, which is preserved
80# explicitly by the decompressor linker script. 88# explicitly by the decompressor linker script.
81# 89#
82STUBCOPY_FLAGS-$(CONFIG_ARM) += --rename-section .data=.data.efistub \ 90STUBCOPY_FLAGS-$(CONFIG_ARM) += --rename-section .data=.data.efistub
83 -R ___ksymtab+sort -R ___kcrctab+sort 91STUBCOPY_RM-$(CONFIG_ARM) += -R ___ksymtab+sort -R ___kcrctab+sort
84STUBCOPY_RELOC-$(CONFIG_ARM) := R_ARM_ABS 92STUBCOPY_RELOC-$(CONFIG_ARM) := R_ARM_ABS