Re: [PATCH] x86/boot/compressed: Fix compressed kernel linking with lld

From: Fangrui Song
Date: Mon Feb 24 2020 - 01:06:26 EST


On 2020-02-23, Kees Cook wrote:
On Sat, Feb 22, 2020 at 1:01 PM 'Fangrui Song' via Clang Built Linux
<clang-built-linux@xxxxxxxxxxxxxxxx> wrote:
https://github.com/torvalds/linux/commit/83a092cf95f28696ddc36c8add0cf03ac034897f
added -Wl,--orphan-handling=warn to arch/powerpc/Makefile .
x86 can follow if that is appropriate.

I've been playing with a series to do this, here:

https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=linker/orphans/x86-arm

There's some work to be done still...

Thanks for investigating this! There are a number of compiler options
which can add ad-hoc sections. They may need caution.


I just filed https://sourceware.org/bugzilla/show_bug.cgi?id=25591 "Should /DISCARD/ : { *(.symtab) *(.strtab) } work?"
Let's see what GNU ld will do...

Note that * can be refined to SHF_ALLOC sections
(https://sourceware.org/binutils/docs/ld/Input-Section-Basics.html):

SECTIONS {
.text : { *(.text) }
/* This excludes .strtab / .symtab / .shstrtab */
/* https://reviews.llvm.org/D72756 implemented INPUT_SECTION_FLAGS. Not included in LLVM release/10.* */
/DISCARD/ : { INPUT_SECTION_FLAGS(SHF_ALLOC) *(*) }
}


Just realized that this was reported as https://bugs.llvm.org/show_bug.cgi?id=44452
Looks like we will probably close it as wontfix.