nonfunctional.

Per Lundberg plundis@byggdok.se
Mon Apr 10 06:37:00 GMT 2000


-fomit-frame-pointer in combination with __attribute__ ((section
(".text.init"))) seems to generate faulty code for this snippet:

static void __attribute__ ((section (".text.init"))) kernel_entry (void)
{
  multiboot_init ();
  main (((u32 *) arguments_kernel)[0], (char **) arguments_kernel + 1);
  while (1 == 1);
}

The generated code looks like this:

000000a4 <kernel_entry>:
  a4:	83 ec 0c             	sub    $0xc,%esp
  a7:	e8 fc ff ff ff       	call   a8 <kernel_entry+0x4>
  ac:	83 c4 f8             	add    $0xfffffff8,%esp
  af:	68 04 00 00 00       	push   $0x4
  b4:	ff 35 00 00 00 00    	pushl  0x0
  ba:	e8 fc ff ff ff       	call   bb <kernel_entry+0x17>
  bf:	00 eb                	add    %ch,%bl
  c1:	fe                   	.byte 0xfe

I have tried this with both gcc 2.95.1 and 2.95.2, and the bug seems
to be be present in both compilers. Luckily, I found this by the
"Invalid opcode" exception I got when I tried to boot the kernel. If I
replace the while (1 == 1) with a function call, it works just
fine. Also, if I remove -fomit-frame-pointer or let the section be put
with the rest of the code, the bug disappears.

Any clues?


More information about the Gcc-bugs mailing list