Bug 211693

Summary: objtool segfault with certain kernel config and binutils-2.36.1
Product: Platform Specific/Hardware Reporter: Xi Ruoyao (xry111)
Component: x86-64Assignee: platform_x86_64 (platform_x86_64)
Status: RESOLVED CODE_FIX    
Severity: normal    
Priority: P1    
Hardware: x86-64   
OS: Linux   
URL: https://lore.kernel.org/lkml/9500f9c881b221af47ab1e58524a66ea0b74fd8c.camel@mengyan1223.wang/
Kernel Version: 5.10.15 Subsystem:
Regression: No Bisected commit-id:
Attachments: .config which triggers the bug

Description Xi Ruoyao 2021-02-11 03:17:27 UTC
Created attachment 295217 [details]
.config which triggers the bug

Hi kernel developers.

Since binutils-2.36.1 is released, we managed to incorporate them into Linux From Scratch (http://www.linuxfromscratch.org/lfs/view/development/).  Unfortunately, some users and editors report that they are getting segfaults from objtool trying to build the kernel.

$ make mrproper
$ gzip -cd ~/config-segfault.gz > .config
$ make arch/x86/kernel/apic/apic.o
(long output ...)
  CC      arch/x86/kernel/apic/apic.o
make[3]: *** [scripts/Makefile.build:279: arch/x86/kernel/apic/apic.o] Segmentation fault (core dumped)
make[3]: *** Deleting file 'arch/x86/kernel/apic/apic.o'
make[2]: *** [scripts/Makefile.build:496: arch/x86/kernel/apic] Error 2
make[1]: *** [scripts/Makefile.build:496: arch/x86/kernel] Error 2
make: *** [Makefile:1801: arch/x86] Error 2

It's reproducible with kernel source code of 5.10.x (at least 5.10.14 and 5.10.15).  It only happens if binutils-2.36 or 2.36.1 is used.  Binutils-2.35.x builds the kernel without any problem.

The stack backtrace is:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000000040c0ae in elf_rebuild_rela_reloc_section (nr=<optimized out>, 
    sec=0x2c6cee0) at elf.c:890
#1  elf_rebuild_reloc_section (elf=<optimized out>, sec=sec@entry=0x2c6cee0)
    at elf.c:911
#2  0x0000000000408b0d in create_static_call_sections (file=0x41f920 <file>)
    at check.c:520
#3  check (file=file@entry=0x41f920 <file>) at check.c:2918
#4  0x000000000040b2d2 in cmd_orc (argc=1, argv=<optimized out>)
    at builtin-orc.c:47
#5  0x00000000004026cb in handle_internal_command (argv=0x7fff961e2e00, argc=6)
    at objtool.c:128
#6  main (argc=6, argv=0x7fff961e2e00) at objtool.c:151

The .config file content triggering the issue is attached.
Comment 1 Xi Ruoyao 2021-02-11 03:19:40 UTC
Some discussion of this issue is at:

http://lists.linuxfromscratch.org/pipermail/lfs-support/2021-February/054087.html
Comment 2 Xi Ruoyao 2021-02-28 03:02:27 UTC
Fixed in 5.10.17, by backporting a patch.