public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/26908]  New: -g3 (-ggdb3) emits broken calls to asm-defined functions
@ 2006-03-28 18:29 ed at catmur dot co dot uk
  2006-03-28 18:31 ` [Bug debug/26908] " ed at catmur dot co dot uk
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ed at catmur dot co dot uk @ 2006-03-28 18:29 UTC (permalink / raw)
  To: gcc-bugs

foo.c:
asm (
".globl bar\n\t"
"bar:\n\t"
"movl $5, %eax\n\t"
"ret"
);
main() {
        return bar();
}

$ gcc -g2 foo.c; ./a.out; echo $?
5
$ gcc foo.c -g3; ./a.out; echo $?
Segmentation fault
139

Disassembly of the a.out compiled with -g3 gives:

(gdb) disass main
Dump of assembler code for function main:
0x08048364 <main+0>:    push   %ebp
0x08048365 <main+1>:    mov    %esp,%ebp
0x08048367 <main+3>:    sub    $0x8,%esp
0x0804836a <main+6>:    and    $0xfffffff0,%esp
0x0804836d <main+9>:    mov    $0x0,%eax
0x08048372 <main+14>:   add    $0xf,%eax
0x08048375 <main+17>:   add    $0xf,%eax
0x08048378 <main+20>:   shr    $0x4,%eax
0x0804837b <main+23>:   shl    $0x4,%eax
0x0804837e <main+26>:   sub    %eax,%esp
0x08048380 <main+28>:   call   0x4852
0x08048385 <main+33>:   leave
0x08048386 <main+34>:   ret
End of assembler dump.

Note the call to an invalid location; it is this that causes the segfault.

Seen in the wild in tetex-3.0 (uses asm functions in metafont).

Workaround: don't use -g3.

I will attach gcc -g3 -S foo.c output.


-- 
           Summary: -g3 (-ggdb3) emits broken calls to asm-defined functions
           Product: gcc
           Version: 3.4.6
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ed at catmur dot co dot uk
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26908


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-12-29 12:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-28 18:29 [Bug debug/26908] New: -g3 (-ggdb3) emits broken calls to asm-defined functions ed at catmur dot co dot uk
2006-03-28 18:31 ` [Bug debug/26908] " ed at catmur dot co dot uk
2006-03-28 18:45 ` pinskia at gcc dot gnu dot org
2006-03-28 19:15 ` ed at catmur dot co dot uk
2008-11-21  1:29 ` pinskia at gcc dot gnu dot org
2008-11-21  2:17 ` zuogang at huawei dot com
2008-12-28  2:36 ` pinskia at gcc dot gnu dot org
2008-12-29 12:29 ` bonzini at gnu dot org
2008-12-29 12:31 ` bonzini at gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).