public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/21196] New: -O2 optimizer bug?
@ 2005-04-24 20:02 jbglaw at lug-owl dot de
  2005-04-24 20:05 ` [Bug c/21196] " jbglaw at lug-owl dot de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jbglaw at lug-owl dot de @ 2005-04-24 20:02 UTC (permalink / raw)
  To: gcc-bugs

Hi!

While working on a vax-linux cross-compiler, I noticed that my vax-linux kernel
won't boot. I tracked this down to a function that re-calculates addresses (VM
addresses to physical addresses for things that run before VM is switched on).
I've then ran the C file through the preprocessor and put it through my host
compiler (gcc-3.3.x on PeeCee). Same result even there.

Testcase:

void *
s0vmaddr_to_load_addr(void *vaddr)
{
        extern char _rtext;
        return (char *)vaddr - (0x80000000) - 0x00100000 + (unsigned int) &_rtext;
}

jbglaw@d2:~/vax-linux/kernel-2.5$ gcc -c testcase.c
jbglaw@d2:~/vax-linux/kernel-2.5$ objdump -d testcase.o

testcase.o:     file format elf32-i386

Disassembly of section .text:

00000000 <s0vmaddr_to_load_addr>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   b8 00 00 00 00          mov    $0x0,%eax
   8:   05 00 00 f0 7f          add    $0x7ff00000,%eax
   d:   03 45 08                add    0x8(%ebp),%eax
  10:   5d                      pop    %ebp
  11:   c3                      ret    

As you see, four bytes were reserved to be put in by the linker. However, it
seems this is missing in case of a -O2 build:

jbglaw@d2:~/vax-linux/kernel-2.5$ gcc -c -O2 testcase.c
jbglaw@d2:~/vax-linux/kernel-2.5$ objdump -d testcase.o

testcase.o:     file format elf32-i386

Disassembly of section .text:

00000000 <s0vmaddr_to_load_addr>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   8b 45 08                mov    0x8(%ebp),%eax
   6:   5d                      pop    %ebp
   7:   05 00 00 f0 7f          add    $0x7ff00000,%eax
   c:   c3                      ret    

...or am I wrong here?

Thanks!
Jan-Benedict Glaw <jbglaw@lug-owl.de>

-- 
           Summary: -O2 optimizer bug?
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jbglaw at lug-owl dot de
                CC: gcc-bugs at gcc dot gnu dot org
 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=21196


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

* [Bug c/21196] -O2 optimizer bug?
  2005-04-24 20:02 [Bug c/21196] New: -O2 optimizer bug? jbglaw at lug-owl dot de
@ 2005-04-24 20:05 ` jbglaw at lug-owl dot de
  2005-04-24 20:30 ` [Bug rtl-optimization/21196] " pinskia at gcc dot gnu dot org
  2005-04-24 20:32 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: jbglaw at lug-owl dot de @ 2005-04-24 20:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jbglaw at lug-owl dot de  2005-04-24 20:05 -------
Hi!

Here's how I configured it:

/home/jbglaw/vax-linux/scm/build-20050424-193631-i686-linux/src/gcc/configure
--disable-multilib --with-newlib --disable-nls --enable-threads=no
--disable-threads --enable-symvers=gnu --enable-__cxa_atexit --disable-shared
--target=i686-linux
--prefix=/home/jbglaw/vax-linux/scm/build-20050424-193631-i686-linux/install/usr
--enable-languages=c --disable-werror

Thanks,
Jan-Benedict Glaw <jbglaw@lug-owl.de>


-- 


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


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

* [Bug rtl-optimization/21196] -O2 optimizer bug?
  2005-04-24 20:02 [Bug c/21196] New: -O2 optimizer bug? jbglaw at lug-owl dot de
  2005-04-24 20:05 ` [Bug c/21196] " jbglaw at lug-owl dot de
@ 2005-04-24 20:30 ` pinskia at gcc dot gnu dot org
  2005-04-24 20:32 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-24 20:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-24 20:30 -------
        pushl   %ebp
        movl    %esp, %ebp
        movl    8(%ebp), %eax
        popl    %ebp
        addl    $_rtext+2146435072, %eax

This is not a bug, see above: you are missing that relocates can happen in more places than where zero 
happens so that is the bug at all.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |rtl-optimization
            Version|4.1.0                       |3.3


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


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

* [Bug rtl-optimization/21196] -O2 optimizer bug?
  2005-04-24 20:02 [Bug c/21196] New: -O2 optimizer bug? jbglaw at lug-owl dot de
  2005-04-24 20:05 ` [Bug c/21196] " jbglaw at lug-owl dot de
  2005-04-24 20:30 ` [Bug rtl-optimization/21196] " pinskia at gcc dot gnu dot org
@ 2005-04-24 20:32 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-24 20:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-24 20:32 -------
So closing this as invalid.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2005-04-24 20:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-24 20:02 [Bug c/21196] New: -O2 optimizer bug? jbglaw at lug-owl dot de
2005-04-24 20:05 ` [Bug c/21196] " jbglaw at lug-owl dot de
2005-04-24 20:30 ` [Bug rtl-optimization/21196] " pinskia at gcc dot gnu dot org
2005-04-24 20:32 ` pinskia at gcc dot 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).