From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21239 invoked by alias); 26 Jan 2009 15:24:47 -0000 Received: (qmail 21231 invoked by uid 22791); 26 Jan 2009 15:24:46 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from wf-out-1314.google.com (HELO wf-out-1314.google.com) (209.85.200.168) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 26 Jan 2009 15:24:42 +0000 Received: by wf-out-1314.google.com with SMTP id 28so5884629wfc.24 for ; Mon, 26 Jan 2009 07:24:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.108.2 with SMTP id g2mr4305386wfc.190.1232983480629; Mon, 26 Jan 2009 07:24:40 -0800 (PST) Date: Mon, 26 Jan 2009 15:24:00 -0000 Message-ID: <74fef6df0901260724p188c5507x2cfa3a4283f6fd41@mail.gmail.com> Subject: baffling assembly-level weirdness From: Mathieu Lacage To: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-01/txt/msg00170.txt.bz2 hi, The following gdb session baffles me completely: %edx is reset to zero by the mov at address 0x0804ad62 instead of being set to the constant 0x804ad62. Of course, this code segfaults at $pc = 0x804ad68 when zero is dereferenced... Version: GNU gdb 6.8 (gdb) disas $pc $pc+10 Dump of assembler code from 0x804ad62 to 0x804ad6c: 0x0804ad62 : mov 0x805e3c0,%edx 0x0804ad68 : mov 0x14(%edx),%eax 0x0804ad6b : cmp 0x18(%edx),%eax End of assembler dump. (gdb) p $pc $3 = (void (*)()) 0x804ad62 (gdb) p $edx $4 = 1 (gdb) ni 0x0804ad68 108 return _IO_putc_unlocked (__c, stdout); (gdb) p $edx $5 = 0 (gdb) disas $pc $pc+10 Dump of assembler code from 0x804ad68 to 0x804ad72: 0x0804ad68 : mov 0x14(%edx),%eax 0x0804ad6b : cmp 0x18(%edx),%eax 0x0804ad6e : jae 0x804adbe 0x0804ad70 : movb $0x20,(%eax) End of assembler dump. (gdb) x/20bx 0x0804ad62 0x804ad62 : 0x8b 0x15 0xc0 0xe3 0x05 0x08 0x8b 0x42 0x804ad6a : 0x14 0x3b 0x42 0x18 0x73 0x4e 0xc6 0x00 0x804ad72 : 0x20 0x83 0xc0 0x01 Anyone would have even a remote idea of what could have gone wrong here ? Mathieu -- Mathieu Lacage