forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Labels
[BUG] llvmA bug that should be fixed in upstream LLVMA bug that should be fixed in upstream LLVM[FIXED][LLVM] 14This bug was fixed in LLVM 14.xThis bug was fixed in LLVM 14.x[FIXED][LLVM] 15This bug was fixed in LLVM 15.xThis bug was fixed in LLVM 15.x[TOOL] lldThe issue is relevant to LLD linkerThe issue is relevant to LLD linker
Description
Peter Zijlstra reported that attempting to run objtool on the .o part of modules before linking the .o and .mod.o into .ko shows a warning about a .plt section:
warning: objtool: .plt+0x6: indirect jump found in RETPOLINE build
As it turns out, this can be reproduced with an "empty" .o file:
$ echo | clang -fcf-protection=branch -O2 -x c -c -o foo.o -
$ ld.lld -m elf_x86_64 -r -o foo-mod.o foo.o
$ objtool orc generate --module --lto --ibt --ibt-fix-direct --ibt-seal --no-fp --retpoline --uaccess foo-mod.o
foo-mod.o: warning: objtool: .plt+0x6: indirect jump found in RETPOLINE build
$ llvm-objdump -d --section=.plt foo-mod.o
foo-mod.o: file format elf64-x86-64
Disassembly of section .plt:
0000000000000000 <.plt>:
0: ff 35 02 00 00 00 pushq 2(%rip) # 0x8 <.plt+0x8>
6: ff 25 04 00 00 00 jmpq *4(%rip) # 0x10 <.plt+0x10>
c: 0f 1f 40 00 nopl (%rax)
ld.bfd does not exhibit this same behavior:
$ ld -m elf_x86_64 -r -o foo-mod.o foo.o
$ objtool orc generate --module --lto --ibt --ibt-fix-direct --ibt-seal --no-fp --retpoline --uaccess foo-mod.o
$ llvm-objdump -d --section=.plt foo-mod.o
foo-mod.o: file format elf64-x86-64
llvm-objdump: warning: section '.plt' mentioned in a -j/--section option, but not found in any input file
It is not reproducible without -fcf-protection=branch:
$ echo | clang -O2 -x c -c -o foo.o -
$ ld.lld -m elf_x86_64 -r -o foo-mod.o foo.o
$ objtool orc generate --module --lto --ibt --ibt-fix-direct --ibt-seal --no-fp --retpoline --uaccess foo-mod.o
$ llvm-objdump -d --section=.plt foo-mod.o
foo-mod.o: file format elf64-x86-64
llvm-objdump: warning: section '.plt' mentioned in a -j/--section option, but not found in any input file
It does not appear to depend on compiler, I could reproduce this with GCC + ld.lld as well:
$ echo | gcc -fcf-protection=branch -O2 -x c -c -o foo.o -
$ ld.lld -m elf_x86_64 -r -o foo-mod.o foo.o
$ objtool orc generate --module --lto --ibt --ibt-fix-direct --ibt-seal --no-fp --retpoline --uaccess foo-mod.o
foo-mod.o: warning: objtool: .plt+0x6: indirect jump found in RETPOLINE build
$ llvm-objdump -d --section=.plt foo-mod.o
foo-mod.o: file format elf64-x86-64
Disassembly of section .plt:
0000000000000000 <.plt>:
0: ff 35 02 00 00 00 pushq 2(%rip) # 0x8 <.plt+0x8>
6: ff 25 04 00 00 00 jmpq *4(%rip) # 0x10 <.plt+0x10>
c: 0f 1f 40 00 nopl (%rax)
I have uploaded objtool here, based on Peter's x86/wip.ibt branch.
Metadata
Metadata
Assignees
Labels
[BUG] llvmA bug that should be fixed in upstream LLVMA bug that should be fixed in upstream LLVM[FIXED][LLVM] 14This bug was fixed in LLVM 14.xThis bug was fixed in LLVM 14.x[FIXED][LLVM] 15This bug was fixed in LLVM 15.xThis bug was fixed in LLVM 15.x[TOOL] lldThe issue is relevant to LLD linkerThe issue is relevant to LLD linker