From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Mon, 12 Oct 2020 20:39:19 +0000 (-0700)
Subject: Merge tag 'core-build-2020-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git... 
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=34eb62d868d729e9a252aa497277081fb652eeed;p=linux.git

Merge tag 'core-build-2020-10-12' of git://git./linux/kernel/git/tip/tip

Pull orphan section checking from Ingo Molnar:
 "Orphan link sections were a long-standing source of obscure bugs,
  because the heuristics that various linkers & compilers use to handle
  them (include these bits into the output image vs discarding them
  silently) are both highly idiosyncratic and also version dependent.

  Instead of this historically problematic mess, this tree by Kees Cook
  (et al) adds build time asserts and build time warnings if there's any
  orphan section in the kernel or if a section is not sized as expected.

  And because we relied on so many silent assumptions in this area, fix
  a metric ton of dependencies and some outright bugs related to this,
  before we can finally enable the checks on the x86, ARM and ARM64
  platforms"

* tag 'core-build-2020-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (36 commits)
  x86/boot/compressed: Warn on orphan section placement
  x86/build: Warn on orphan section placement
  arm/boot: Warn on orphan section placement
  arm/build: Warn on orphan section placement
  arm64/build: Warn on orphan section placement
  x86/boot/compressed: Add missing debugging sections to output
  x86/boot/compressed: Remove, discard, or assert for unwanted sections
  x86/boot/compressed: Reorganize zero-size section asserts
  x86/build: Add asserts for unwanted sections
  x86/build: Enforce an empty .got.plt section
  x86/asm: Avoid generating unused kprobe sections
  arm/boot: Handle all sections explicitly
  arm/build: Assert for unwanted sections
  arm/build: Add missing sections
  arm/build: Explicitly keep .ARM.attributes sections
  arm/build: Refactor linker script headers
  arm64/build: Assert for unwanted sections
  arm64/build: Add missing DWARF sections
  arm64/build: Use common DISCARDS in linker script
  arm64/build: Remove .eh_frame* sections due to unwind tables
  ...
---

34eb62d868d729e9a252aa497277081fb652eeed
diff --cc arch/arm64/kernel/vmlinux.lds.S
index 82801d98a2b70,e8847ca6a945e..5ca957e656ab7
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@@ -96,16 -89,13 +97,13 @@@ SECTION
  	 * matching the same input section name.  There is no documented
  	 * order of matching.
  	 */
+ 	DISCARDS
  	/DISCARD/ : {
- 		EXIT_CALL
- 		*(.discard)
- 		*(.discard.*)
  		*(.interp .dynamic)
  		*(.dynsym .dynstr .hash .gnu.hash)
- 		*(.eh_frame)
  	}
  
 -	. = KIMAGE_VADDR + TEXT_OFFSET;
 +	. = KIMAGE_VADDR;
  
  	.head.text : {
  		_text = .;
diff --cc arch/x86/boot/compressed/Makefile
index ff7894f39e0ea,871cc071c925d..4fb989ef5665a
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@@ -43,8 -43,7 +43,9 @@@ KBUILD_CFLAGS += -Wno-pointer-sig
  KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
  KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
  KBUILD_CFLAGS += -D__DISABLE_EXPORTS
 +# Disable relocation relaxation in case the link is not PIE.
 +KBUILD_CFLAGS += $(call as-option,-Wa$(comma)-mrelax-relocations=no)
+ KBUILD_CFLAGS += -include $(srctree)/include/linux/hidden.h
  
  KBUILD_AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
  GCOV_PROFILE := n
diff --cc drivers/firmware/efi/libstub/Makefile
index 5a80cf6bd6066,0c911e391d755..039a9acab8173
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@@ -64,7 -65,14 +65,13 @@@ lib-$(CONFIG_ARM)		+= arm32-stub.
  lib-$(CONFIG_ARM64)		+= arm64-stub.o
  lib-$(CONFIG_X86)		+= x86-stub.o
  CFLAGS_arm32-stub.o		:= -DTEXT_OFFSET=$(TEXT_OFFSET)
 -CFLAGS_arm64-stub.o		:= -DTEXT_OFFSET=$(TEXT_OFFSET)
  
+ # Even when -mbranch-protection=none is set, Clang will generate a
+ # .note.gnu.property for code-less object files (like lib/ctype.c),
+ # so work around this by explicitly removing the unwanted section.
+ # https://bugs.llvm.org/show_bug.cgi?id=46480
+ STUBCOPY_FLAGS-y		+= --remove-section=.note.gnu.property
+ 
  #
  # For x86, bootloaders like systemd-boot or grub-efi do not zero-initialize the
  # .bss section, so the .bss section of the EFI stub needs to be included in the