Skip to content

Commit 5e6dca8

Browse files
nickdesaulnierssuryasaimadhu
authored andcommitted
x86/entry: Emit a symbol for register restoring thunk
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 (Clang's integrated assembler). Josh notes: With the LLVM assembler not generating section symbols, objtool has no way to reference this code when it generates ORC unwinder entries, because this code is outside of any ELF function. The limitation now being imposed by objtool is that all code must be contained in an ELF symbol. And .L symbols don't create such symbols. So basically, you can use an .L symbol *inside* a function or a code segment, you just can't use the .L symbol to contain the code using a SYM_*_START/END annotation pair. Fangrui notes that this optimization is helpful for reducing image size when compiling with -ffunction-sections and -fdata-sections. I have observed on the order of tens of thousands of symbols for the kernel images built with those flags. A patch has been authored against GNU binutils to match this behavior of not generating unused section symbols ([1]), so this will also become a problem for users of GNU binutils once they upgrade to 2.36. Omit the .L prefix on a label so that the assembler will 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 or GNU binutils 2.36+. [ bp: Massage commit message. ] Reported-by: Arnd Bergmann <[email protected]> Suggested-by: Josh Poimboeuf <[email protected]> Suggested-by: Borislav Petkov <[email protected]> Suggested-by: Mark Brown <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Link: ClangBuiltLinux#1209 Link: https://reviews.llvm.org/D93783 Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1408485ce69f844dcd7ded093a8 [1]
1 parent 7c53f6b commit 5e6dca8

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

Documentation/asm-annotations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ Instruction Macros
100100
~~~~~~~~~~~~~~~~~~
101101
This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above.
102102

103+
``objtool`` requires that all code must be contained in an ELF symbol. Symbol
104+
names that have a ``.L`` prefix do not emit symbol table entries. ``.L``
105+
prefixed symbols can be used within a code region, but should be avoided for
106+
denoting a range of code via ``SYM_*_START/END`` annotations.
107+
103108
* ``SYM_FUNC_START`` and ``SYM_FUNC_START_LOCAL`` are supposed to be **the
104109
most frequent markings**. They are used for functions with standard calling
105110
conventions -- global and local. Like in C, they both align the functions to

arch/x86/entry/thunk_64.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SYM_FUNC_START_NOALIGN(\name)
3131
.endif
3232

3333
call \func
34-
jmp .L_restore
34+
jmp __thunk_restore
3535
SYM_FUNC_END(\name)
3636
_ASM_NOKPROBE(\name)
3737
.endm
@@ -44,7 +44,7 @@ SYM_FUNC_END(\name)
4444
#endif
4545

4646
#ifdef CONFIG_PREEMPTION
47-
SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
47+
SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
4848
popq %r11
4949
popq %r10
5050
popq %r9
@@ -56,6 +56,6 @@ SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
5656
popq %rdi
5757
popq %rbp
5858
ret
59-
_ASM_NOKPROBE(.L_restore)
60-
SYM_CODE_END(.L_restore)
59+
_ASM_NOKPROBE(__thunk_restore)
60+
SYM_CODE_END(__thunk_restore)
6161
#endif

include/linux/linkage.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@
178178
* Objtool generates debug info for both FUNC & CODE, but needs special
179179
* annotations for each CODE's start (to describe the actual stack frame).
180180
*
181+
* Objtool requires that all code must be contained in an ELF symbol. Symbol
182+
* names that have a .L prefix do not emit symbol table entries. .L
183+
* prefixed symbols can be used within a code region, but should be avoided for
184+
* denoting a range of code via ``SYM_*_START/END`` annotations.
185+
*
181186
* ALIAS -- does not generate debug info -- the aliased function will
182187
*/
183188

0 commit comments

Comments
 (0)