New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/spi/spidev.o:(__jump_table+0x74): undefined reference to .Ltmp4' #320

Closed
nickdesaulniers opened this Issue Jan 17, 2019 · 11 comments

Comments

Projects
None yet
3 participants
@nickdesaulniers
Copy link
Member

nickdesaulniers commented Jan 17, 2019

Forked from #6

drivers/spi/spidev.o:(__jump_table+0x74): undefined reference to `.Ltmp4'

This one looks like a codegen bug to me (reference to a temporary label that probably got cleaned up). I had spotted one of these in the v1 of the asm goto patches, which ctopper fixed.

Questions:

  • Is this seen because of asm goto patches or not?
  • seems like the base defconfig + CONFIG_SPI_SPIDEV is not enough to retrigger.
  • what combo of configs trigger it?
@nathanchance

This comment has been minimized.

Copy link
Member

nathanchance commented Jan 18, 2019

With https://github.com/nathanchance/linux/commits/no-asm-goto and a build of Clang @ llvm/llvm-project@e50d9cb, I do not see this error.

@nickdesaulniers

This comment has been minimized.

Copy link
Member Author

nickdesaulniers commented Jan 18, 2019

__jump_table is a section. $ objdump -D -r -j __jump_table drivers/spi/spidev.o. Now to find a smaller repro...

@nickdesaulniers

This comment has been minimized.

Copy link
Member Author

nickdesaulniers commented Jan 18, 2019

$ make CC=clang -j46 allyesconfig
$ make CC=clang -j46 drivers/spi/spidev.o
...
drivers/spi/spidev.o: warning: objtool: +0x0: special: can't find new instruction
$ objdump -D -r -j __jump_table drivers/spi/spidev.o
...
                        74: R_X86_64_PC32       .Ltmp4
@nickdesaulniers

This comment has been minimized.

Copy link
Member Author

nickdesaulniers commented Jan 18, 2019

I'm running creduce on the preprocessed input now. Should have a pared down test case soon. Should write a blog post about creduce...

@nickdesaulniers

This comment has been minimized.

Copy link
Member Author

nickdesaulniers commented Jan 18, 2019

creduce spat this out:

a;
b(void);
c() {
  int d;
  if (a)
    d = b();
  else {
    asm goto("1:.pushsection   \"aw\" \n\t.long  ., %l[l_yes] - . "
             "\n\t.popsection \n\t"
             :
             :
             :
             : l_yes);
  l_yes:;
  }
  if (d)
    b();
}

but this doesn't produce relocations to any undefined .Ltmp sections with just -no-integrated-as -c time to start bisecting the flags now.

@nickdesaulniers

This comment has been minimized.

Copy link
Member Author

nickdesaulniers commented Jan 18, 2019

clang -O1 -no-integrated-as -c spidev.c is enough to reproduce.

@gwelymernans

This comment has been minimized.

Copy link

gwelymernans commented Jan 18, 2019

I got an ICE:

clang-8: /usr/local/google/home/morbo/llvm/llvm.src/lib/CodeGen/MachineBasicBlock.cpp:548: void llvm::MachineBasicBlock::updateTerminator(): Assertion `!TBB && "Found more than one non-landing-pad successor!"' failed.
Stack dump:
0.	Program arguments: /sandbox/morbo/llvm/llvm.opt.install/bin/clang-8 -cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -main-file-name intel.c -mrelocation-model static -mthread-model posix -fno-delete-null-pointer-checks -mllvm -warn-stack-size=2048 -mdisable-fp-elim -relaxed-aliasing -fmath-errno -masm-verbose -no-integrated-as -mconstructor-aliases -fuse-init-array -mcode-model kernel -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -target-feature -sse -target-feature -mmx -target-feature -sse2 -target-feature -3dnow -target-feature -avx -target-feature -x87 -target-feature +retpoline-external-thunk -disable-red-zone -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file /usr/local/google/home/morbo/prodkernel-gcc/arch/x86/kernel/cpu/microcode/intel.gcno -nostdsysteminc -nobuiltininc -resource-dir /sandbox/morbo/llvm/llvm.opt.install/lib/clang/9.0.0 -dependency-file arch/x86/kernel/cpu/microcode/.intel.o.d -MT arch/x86/kernel/cpu/microcode/intel.o -sys-header-deps -isystem /sandbox/morbo/llvm/llvm.opt.install/lib/clang/9.0.0/include -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -I ./arch/x86/include -I ./arch/x86/include/generated -I ./include -I ./arch/x86/include/uapi -I ./arch/x86/include/generated/uapi -I ./include/uapi -I ./include/generated/uapi -D __KERNEL__ -D CONFIG_X86_X32_ABI -D CONFIG_AS_CFI=1 -D CONFIG_AS_CFI_SIGNAL_FRAME=1 -D CONFIG_AS_CFI_SECTIONS=1 -D CONFIG_AS_FXSAVEQ=1 -D CONFIG_AS_SSSE3=1 -D CONFIG_AS_AVX=1 -D CONFIG_AS_AVX2=1 -D CONFIG_AS_AVX512=1 -D CONFIG_AS_SHA1_NI=1 -D CONFIG_AS_SHA256_NI=1 -D CC_USING_FENTRY -D KBUILD_BASENAME="intel" -D KBUILD_MODNAME="microcode" -O2 -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -Werror-implicit-function-declaration -Werror=implicit-int -Wno-format-security -Wno-sign-compare -Wno-format-invalid-specifier -Wno-gnu -Wno-address-of-packed-member -Wno-tautological-compare -Wno-unused-const-variable -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Werror=date-time -Werror=incompatible-pointer-types -Wno-initializer-overrides -Wno-unused-value -Wno-format -Wno-sign-compare -Wno-format-zero-length -Wno-uninitialized -std=gnu89 -fno-dwarf-directory-asm -fdebug-compilation-dir /usr/local/google/home/morbo/prodkernel-gcc -ferror-limit 19 -fmessage-length 0 -fsanitize-coverage-type=3 -fsanitize-coverage-trace-cmp -fsanitize-coverage-trace-pc -fsanitize=kernel-address -fsanitize-recover=kernel-address -pg -mfentry -fwrapv -stack-protector 2 -mstack-alignment=8 -fwchar-type=short -fno-signed-wchar -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -vectorize-loops -vectorize-slp -mllvm -asan-mapping-offset=0xdffffc0000000000 -mllvm -asan-globals=1 -mllvm -asan-instrumentation-with-call-threshold=0 -mllvm -asan-stack=1 -mllvm -asan-use-after-scope=1 -o /tmp/intel-a6b9a9.s -x c arch/x86/kernel/cpu/microcode/intel.c 
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'arch/x86/kernel/cpu/microcode/intel.c'.
4.	Running pass 'Branch Probability Basic Block Placement' on function '@generic_load_microcode'
 #0 0x00005640793e158a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x27bf58a)
 #1 0x00005640793df554 llvm::sys::RunSignalHandlers() (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x27bd554)
 #2 0x00005640793df682 SignalHandler(int) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x27bd682)
 #3 0x00007f2ae87420c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
 #4 0x00007f2ae72d3fcf gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
 #5 0x00007f2ae72d53fa abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
 #6 0x00007f2ae72cce37 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
 #7 0x00007f2ae72ccee2 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
 #8 0x0000564078a745e0 llvm::MachineBasicBlock::addLiveIn(unsigned short, llvm::TargetRegisterClass const*) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x1e525e0)
 #9 0x0000564078cdb7b4 (anonymous namespace)::MachineBlockPlacement::buildCFGChains() (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x20b97b4)
#10 0x0000564078cdc493 (anonymous namespace)::MachineBlockPlacement::runOnMachineFunction(llvm::MachineFunction&) (.part.348) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x20ba493)
#11 0x0000564078ab9edf llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x1e97edf)
#12 0x0000564078e4f829 llvm::FPPassManager::runOnFunction(llvm::Function&) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x222d829)
#13 0x0000564078e4f8d9 llvm::FPPassManager::runOnModule(llvm::Module&) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x222d8d9)
#14 0x0000564078e4ebf2 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x222cbf2)
#15 0x00005640795d414c (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x29b214c)
#16 0x00005640795d5af5 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x29b3af5)
#17 0x0000564079f23200 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x3301200)
#18 0x000056407a786719 clang::ParseAST(clang::Sema&, bool, bool) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x3b64719)
#19 0x0000564079f21f20 clang::CodeGenAction::ExecuteAction() (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x32fff20)
#20 0x0000564079a5af1e clang::FrontendAction::Execute() (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x2e38f1e)
#21 0x0000564079a1ca06 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x2dfaa06)
#22 0x0000564079afae45 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0x2ed8e45)
#23 0x0000564077946208 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0xd24208)
#24 0x00005640778a494c main (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0xc8294c)
#25 0x00007f2ae72c12b1 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b1)
#26 0x0000564077941dca _start (/sandbox/morbo/llvm/llvm.opt.install/bin/clang-8+0xd1fdca)
clang-8: error: unable to execute command: Aborted
clang-8: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 9.0.0 (trunk) (llvm/trunk 351520)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/google/home/morbo/llvm/llvm.opt.install/bin
clang-8: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang-8: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-8: note: diagnostic msg: /tmp/intel-a595d8.c
clang-8: note: diagnostic msg: /tmp/intel-a595d8.sh
clang-8: note: diagnostic msg: 

********************
scripts/Makefile.build:276: recipe for target 'arch/x86/kernel/cpu/microcode/intel.o' failed
make[4]: *** [arch/x86/kernel/cpu/microcode/intel.o] Error 254
scripts/Makefile.build:492: recipe for target 'arch/x86/kernel/cpu/microcode' failed
make[3]: *** [arch/x86/kernel/cpu/microcode] Error 2
scripts/Makefile.build:492: recipe for target 'arch/x86/kernel/cpu' failed
make[2]: *** [arch/x86/kernel/cpu] Error 2
scripts/Makefile.build:492: recipe for target 'arch/x86/kernel' failed
make[1]: *** [arch/x86/kernel] Error 2
Makefile:1043: recipe for target 'arch/x86' failed
make: *** [arch/x86] Error 2

intel-a595d8.c.txt
intel-a595d8.sh.txt

@nickdesaulniers

This comment has been minimized.

Copy link
Member Author

nickdesaulniers commented Jan 18, 2019

@gwelymernans that looks like a different issue; please file another bug.

creduce is not deterministic when it runs multithreaded, so here's another reproducer that managed to remove some unrelated assembly:

a() {
  int b;
  c();
  if (c < 2)
    b = d();
  else {
    asm goto("1:.long b - ., %l[l_yes] - . \n\t" : : : : l_yes);
  l_yes:;
  }
  if (b)
    e();
}
@gwelymernans

This comment has been minimized.

Copy link

gwelymernans commented Jan 18, 2019

@nickdesaulniers Doh! I put this in the wrong bug. I pointed it out on Phabricator at least.

@nickdesaulniers

This comment has been minimized.

@nickdesaulniers

This comment has been minimized.

Copy link
Member Author

nickdesaulniers commented Jan 18, 2019

Fixed in https://reviews.llvm.org/D53765 diff 182593.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment