Re: [PATCH v3] x86/entry: emit a symbol for register restoring thunk

From: Josh Poimboeuf
Date: Mon Jan 11 2021 - 17:13:43 EST


On Mon, Jan 11, 2021 at 12:38:06PM -0800, Nick Desaulniers wrote:
> Arnd found a randconfig that produces the warning:
>
> arch/x86/entry/thunk_64.o: warning: objtool: missing symbol for insn at
> offset 0x3e
>
> when building with LLVM_IAS=1 (use Clang's integrated assembler). Josh
> notes:
>
> With the LLVM assembler stripping the .text section symbol, objtool
> has no way to reference this code when it generates ORC unwinder
> entries, because this code is outside of any ELF function.
>
> Fangrui notes that this optimization is helpful for reducing images size

"image"

> when compiling with -ffunction-sections and -fdata-sections. I have
> observerd on the order of tens of thousands of symbols for the kernel

"observed"

> images built with those flags. A patch has been authored against GNU
> binutils to match this behavior, with a new flag
> --generate-unused-section-symbols=[yes|no].
>
> We can omit the .L prefix on a label to emit an entry into the symbol
> table for the label, with STB_LOCAL binding. This enables objtool to
> generate proper unwind info here with LLVM_IAS=1.
>
> Cc: Fangrui Song <maskray@xxxxxxxxxx>
> Link: https://github.com/ClangBuiltLinux/linux/issues/1209
> Link: https://reviews.llvm.org/D93783
> Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html
> Link: https://sourceware.org/pipermail/binutils/2020-December/114671.html
> Reported-by: Arnd Bergmann <arnd@xxxxxxxx>
> Suggested-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> Signed-off-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
> ---
> Changes v2 -> v3:
> * rework to use STB_LOCAL rather than STB_GLOBAL by dropping .L prefix,
> as per Josh.
> * rename oneline to drop STB_GLOBAL in commit message.
> * add link to GAS docs on .L prefix.
> * drop Josh's ack since patch changed.

Acked-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>

--
Josh