Re: objtool segfault with ORC unwinder enabled

From: Markus
Date: Wed Jan 03 2018 - 12:26:34 EST


On Wed, Jan 03, 2018 at 17:36:30 CET Josh Poimboeuf wrote:
> On Wed, Jan 03, 2018 at 03:14:55PM +0100, Markus wrote:
> > On Wed, Jan 03, 2018 at 14:59:24 CET Josh Poimboeuf wrote:
> > > On Wed, Jan 03, 2018 at 01:22:07PM +0100, Markus wrote:
> > > > /tools/objtool/objtool orc generate --no-fp "arch/x86/kernel/irq.o"
> > > >
> > > > => segfault.
> > > >
> > > > Changing CFLAGS for objtool to O1 and starting from gdb:
> > > >
> > > > (gdb) r orc generate --no-fp "arch/x86/kernel/irq.o"
> > > > Starting program: tools/objtool/objtool orc generate --no-fp
> > > > "arch/x86/kernel/ irq.o"
> > > >
> > > > Program received signal SIGSEGV, Segmentation fault.
> > > > 0x000055555555e06c in elf_rebuild_rela_section
> > > > (sec=sec@entry=0x7ffff690d010) at elf.c:554
> > > > 554 relas[idx].r_info =
> > > > GELF_R_INFO(rela->sym->idx,
> > > > rela->
> > > >
> > > > >type);
> > > >
> > > > (gdb) bt
> > > > #0 0x000055555555e06c in elf_rebuild_rela_section
> > > > (sec=sec@entry=0x7ffff690d010) at elf.c:554
> > > > #1 0x000055555555d0aa in create_orc_sections
> > > > (file=file@entry=0x7ffffff7d740) at orc_gen.c:210
> > > > #2 0x000055555555c146 in check (_objname=<optimized out>,
> > > > _no_fp=<optimized out>, no_unreachable=<optimized out>,
> > > > orc=orc@entry=true) at check.c:1971 #3 0x000055555555811f in cmd_orc
> > > > (argc=<optimized out>, argv=0x7fffffffd8d8) at builtin-orc.c:54
> > > > #4 0x000055555555f490 in handle_internal_command
> > > > (argv=0x7fffffffd8d0,
> > > > argc=4) at objtool.c:108
> > > > #5 main (argc=4, argv=0x7fffffffd8d0) at objtool.c:131
> > > > (gdb) p rela->sym
> > > > $1 = (struct symbol *) 0x0
> > >
> > > I'm unable to recreate. Can you attach one of the .o files (like the
> > > above irq.o)?
> >
> > Sure, see attached. (From vanilla linux-4.14.11.)
>
> There's something weird with the toolchain. The object file doesn't
> have an ELF section symbol for the .irqentry.text section.
>
> Are there any special KCFLAGS being added? Can you build the object
> with V=1 to show the full gcc command line?

I have not added anything. There is no env variable set like $KCFLAGS or
$CFLAGS. (If that was the question.)

I think you mean this line from output:
gcc -Wp,-MD,arch/x86/kernel/.irq.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-
pc-linux-gnu/6.4.0/include -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 -include ./include/linux/kconfig.h -
D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-
aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-
format-security -std=gnu89 -fno-PIE -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -
mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -
mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -
mcmodel=kernel -funit-at-a-time -DCONFIG_AS_CFI=1 -
DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1
-DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -
DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-
sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -
Wno-frame-address -O2 --param=allow-store-data-races=0 -DCC_HAVE_ASM_GOTO -
Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -
Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -
Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fno-
stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -
Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -
Iarch/x86/kernel/../include/asm/trace -DKBUILD_BASENAME='"irq"' -
DKBUILD_MODNAME='"irq"' -c -o arch/x86/kernel/.tmp_irq.o arch/x86/kernel/irq.c

The next line is the objtool that segfaults.

BR,
Markus