mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for Ard Biesheuvel <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org,
	mingo@kernel.org, tglx@linutronix.de, ard.biesheuvel@linaro.org,
	matt@codeblueprint.co.uk, hpa@zytor.com, peterz@infradead.org
Subject: [tip:efi/core] efi/libstub: Preserve .debug sections after absolute relocation check
Date: Wed, 1 Feb 2017 01:49:13 -0800	[thread overview]
Message-ID: <tip-696204faa6e8a318320ebb49d9fa69bc8275644d@git.kernel.org> (raw)
In-Reply-To: <1485868902-20401-11-git-send-email-ard.biesheuvel@linaro.org>

Commit-ID:  696204faa6e8a318320ebb49d9fa69bc8275644d
Gitweb:     http://git.kernel.org/tip/696204faa6e8a318320ebb49d9fa69bc8275644d
Author:     Ard Biesheuvel <ard.biesheuvel@linaro.org>
AuthorDate: Tue, 31 Jan 2017 13:21:42 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 1 Feb 2017 08:45:47 +0100

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>
---
 drivers/firmware/efi/libstub/Makefile | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index d564d25..33e0e2f 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 \
 				   -mno-mmx -mno-sse
 
 cflags-$(CONFIG_ARM64)		:= $(subst -pg,,$(KBUILD_CFLAGS))
-cflags-$(CONFIG_ARM)		:= $(subst -pg,,$(KBUILD_CFLAGS)) -g0 \
+cflags-$(CONFIG_ARM)		:= $(subst -pg,,$(KBUILD_CFLAGS)) \
 				   -fno-builtin -fpic -mno-single-pic-base
 
 cflags-$(CONFIG_EFI_ARMSTUB)	+= -I$(srctree)/scripts/dtc/libfdt
@@ -60,7 +60,7 @@ CFLAGS_arm64-stub.o 		:= -DTEXT_OFFSET=$(TEXT_OFFSET)
 extra-$(CONFIG_EFI_ARMSTUB)	:= $(lib-y)
 lib-$(CONFIG_EFI_ARMSTUB)	:= $(patsubst %.o,%.stub.o,$(lib-y))
 
-STUBCOPY_FLAGS-y		:= -R .debug* -R *ksymtab* -R *kcrctab*
+STUBCOPY_RM-y			:= -R *ksymtab* -R *kcrctab*
 STUBCOPY_FLAGS-$(CONFIG_ARM64)	+= --prefix-alloc-sections=.init \
 				   --prefix-symbols=__efistub_
 STUBCOPY_RELOC-$(CONFIG_ARM64)	:= R_AARCH64_ABS
@@ -68,17 +68,25 @@ STUBCOPY_RELOC-$(CONFIG_ARM64)	:= R_AARCH64_ABS
 $(obj)/%.stub.o: $(obj)/%.o FORCE
 	$(call if_changed,stubcopy)
 
+#
+# Strip debug sections and some other sections that may legally contain
+# absolute relocations, so that we can inspect the remaining sections for
+# 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 = if $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@; then	\
-		     $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y)	\
-		     && (echo >&2 "$@: absolute symbol references not allowed in the EFI stub"; \
-			 rm -f $@; /bin/false); else /bin/false; fi
+      cmd_stubcopy = if $(STRIP) --strip-debug $(STUBCOPY_RM-y) -o $@ $<; \
+		     then if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); \
+		     then (echo >&2 "$@: absolute symbol references not allowed in the EFI stub"; \
+			   rm -f $@; /bin/false); 			  \
+		     else $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@; fi	  \
+		     else /bin/false; fi
 
 #
 # ARM discards the .data section because it disallows r/w data in the
 # decompressor. So move our .data to .data.efistub, which is preserved
 # explicitly by the decompressor linker script.
 #
-STUBCOPY_FLAGS-$(CONFIG_ARM)	+= --rename-section .data=.data.efistub \
-				   -R ___ksymtab+sort -R ___kcrctab+sort
+STUBCOPY_FLAGS-$(CONFIG_ARM)	+= --rename-section .data=.data.efistub
+STUBCOPY_RM-$(CONFIG_ARM)	+= -R ___ksymtab+sort -R ___kcrctab+sort
 STUBCOPY_RELOC-$(CONFIG_ARM)	:= R_ARM_ABS

      reply	other threads:[~2017-02-01  9:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-31 13:21 [GIT PULL 00/10] EFI updates for v4.11 Ard Biesheuvel
2017-01-31 13:21 ` [PATCH 01/10] efi: Deduplicate efi_file_size() / _read() / _close() Ard Biesheuvel
2017-02-01  9:44   ` [tip:efi/core] " tip-bot for Lukas Wunner
2017-01-31 13:21 ` [PATCH 02/10] x86/efi: Deduplicate efi_char16_printk() Ard Biesheuvel
2017-02-01  9:45   ` [tip:efi/core] " tip-bot for Lukas Wunner
2017-01-31 13:21 ` [PATCH 03/10] efi: Make EFI_MEMORY_ATTRIBUTES_TABLE initialization common across all architectures Ard Biesheuvel
2017-02-01  9:45   ` [tip:efi/core] " tip-bot for Sai Praneeth
2017-01-31 13:21 ` [PATCH 04/10] efi: Introduce EFI_MEM_ATTR bit and set it from memory attributes table Ard Biesheuvel
2017-02-01  9:46   ` [tip:efi/core] efi: Introduce the EFI_MEM_ATTR bit and set it from the " tip-bot for Sai Praneeth
2017-01-31 13:21 ` [PATCH 05/10] x86/efi: Add support for EFI_MEMORY_ATTRIBUTES_TABLE Ard Biesheuvel
2017-02-01  9:46   ` [tip:efi/core] " tip-bot for Sai Praneeth
2017-01-31 13:21 ` [PATCH 06/10] efi/esrt: Fix spelling mistake "doen't" Ard Biesheuvel
2017-02-01  9:47   ` [tip:efi/core] efi/esrt: Fix typo in pr_err() message tip-bot for Colin Ian King
2017-01-31 13:21 ` [PATCH 07/10] efi: Use typed function pointers for runtime services table Ard Biesheuvel
2017-02-01  9:47   ` [tip:efi/core] efi: Use typed function pointers for the " tip-bot for Ard Biesheuvel
2017-01-31 13:21 ` [PATCH 08/10] efi/x86: Move EFI BGRT init code to early init code Ard Biesheuvel
2017-02-01  9:48   ` [tip:efi/core] efi/x86: Move the " tip-bot for Dave Young
2017-05-13 23:18   ` [PATCH 08/10] efi/x86: Move " Sabrina Dubroca
2017-05-15  8:37     ` Dave Young
2017-05-15 11:10       ` Sabrina Dubroca
2017-05-15 13:18         ` Dave Young
2017-05-15 13:44           ` Sabrina Dubroca
2017-01-31 13:21 ` [PATCH 09/10] efi/x86: Add debug code to print cooked memmap Ard Biesheuvel
2017-02-01  9:48   ` [tip:efi/core] " tip-bot for Dave Young
2017-01-31 13:21 ` [PATCH 10/10] efi: libstub: Preserve .debug sections after absolute relocation check Ard Biesheuvel
2017-02-01  9:49   ` tip-bot for Ard Biesheuvel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-696204faa6e8a318320ebb49d9fa69bc8275644d@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=matt@codeblueprint.co.uk \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome