x86/boot: Discard .discard.unreachable for arch/x86/boot/compressed/vmlinux
authorFangrui Song <maskray@google.com>
Wed, 20 May 2020 18:20:10 +0000 (11:20 -0700)
committerBorislav Petkov <bp@suse.de>
Fri, 22 May 2020 10:42:07 +0000 (12:42 +0200)
commitd6ee6529436a15a0541aff6e1697989ee7dc2c44
tree310a4d693963f6f5a51f6d856b78e4303c65df72
parent675a59b7dec6e03c5fb060f18fc25b2e56be3c7a
x86/boot: Discard .discard.unreachable for arch/x86/boot/compressed/vmlinux

With commit

  ce5e3f909fc0 ("efi/printf: Add 64-bit and 8-bit integer support")

arch/x86/boot/compressed/vmlinux may have an undesired .discard.unreachable
section coming from drivers/firmware/efi/libstub/vsprintf.stub.o. That section
gets generated from unreachable() annotations when CONFIG_STACK_VALIDATION is
enabled.

.discard.unreachable contains an R_X86_64_PC32 relocation which will be
warned about by LLD: a non-SHF_ALLOC section (.discard.unreachable) is
not part of the memory image, thus conceptually the distance between a
non-SHF_ALLOC and a SHF_ALLOC is not a constant which can be resolved at
link time:

  % ld.lld -m elf_x86_64 -T arch/x86/boot/compressed/vmlinux.lds ... -o arch/x86/boot/compressed/vmlinux
  ld.lld: warning: vsprintf.c:(.discard.unreachable+0x0): has non-ABS relocation R_X86_64_PC32 against symbol ''

Reuse the DISCARDS macro which includes .discard.* to drop
.discard.unreachable.

 [ bp: Massage and complete the commit message. ]

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Fangrui Song <maskray@google.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Arvind Sankar <nivedita@alum.mit.edu>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Link: https://lkml.kernel.org/r/20200520182010.242489-1-maskray@google.com
arch/x86/boot/compressed/vmlinux.lds.S