🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Matthew L. Martin Fri, 22 Nov 1996 00:00
gcc-2.7.2{,.1} m68k-elf problem
#6180
Author: Matthew L. Martin
Date: Fri, 22 Nov 1996 00:00
179 lines
5571 bytes
I have reduced this to what I think is the minimum needed to reproduce:

The gcc used is 2.7.2 with no local modifications, targeted for
m68k-unknown-linux, hosted on a sparc running sunos-4.1.4.

I first noticed this on gcc-2.7.2.1, I then backed down to 2.7.2, but it
appears to be a m68k-elf bug.

> cat config.status
#!/bin/sh
# GCC was configured as follows:
./../gcc-2.7.2/configure --target=m68k-linux -prefix=/home/mxm --local-prefix=/u1/ns/exl/tools --with-gnu-as --exec-prefix=/u1/ns/exl/tools
echo host=sparc-sun-sunos4.1.4 target=m68k-unknown-linux
build=sparc-sun-sunos4.1.4

It was compiled with gcc-2.7.2, configured as:

#!/bin/sh
# GCC was configured as follows:
./../gcc-2.7.2/configure --with-gnu-as --prefix=/u1/ns/exl/tools echo host=sparc-sun-sunos4.1.4 target=sparc-sun-sunos4.1.4
build=sparc-sun-sunos4.1.4


When I feed this source code:

>cat inconf.c

/*
 * External declarations
 */
extern int    zero();

extern unsigned int tnets;

void  *ALP(unsigned  int  size);
extern  inline void *alp(unsigned  int  size)
{
  return((void  *)(
    {
    register  unsigned  short  __SCOPS ;
    register  unsigned  long  __RETURN asm("%d0");
    asm volatile ("move %%SR, %0; move #0x2700, %%SR" : "=md" (__SCOPS));
    ;
    ALP ( size );
    asm volatile  ("move %0, %%SR": : "md" ((unsigned  short)(__SCOPS)));
    ;
    __RETURN;
    })
  );
}

struct inia {
  int a;
  int b;
};

void doaddrs()
{
  struct inia **iniatlst;
  iniatlst = (struct inia **) alp(tnets * sizeof(struct inia **));
  zero(iniatlst, tnets * sizeof(struct inia **));
}
>


into the cross compiler, thusly:


>./xgcc -B./ -O2 -S -v -I/u1/ns/exl -DMC68000 -m68020 -fconserve-space
-mnobitfield -Wall -Wno-format inconf.c
Reading specs from ./specs
gcc version 2.7.2
 ./cpp -lang-c -v -I/u1/ns/exl -isystem ./include -undef -D__GNUC__=2
-D__GNUC_MINOR__=7 -D__ELF__ -Dunix -Dmc68000 -Dmc68020 -Dlinux
-D__ELF__ -D__unix__ -D__mc68000__ -D__mc68020__ -D__linux__ -D__unix
-D__mc68000 -D__mc68020 -D__linux -Asystem(unix) -Asystem(posix)
-Acpu(m68k) -Amachine(m68k) -D__OPTIMIZE__ -Wall -Wno-format
-D__HAVE_68881__ -DMC68000 inconf.c /usr/tmp/cca04073.i
GNU CPP version 2.7.2 (68k Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /u1/ns/exl
 ./include
 /u1/ns/exl/tools/lib/gcc-lib/m68k-linux/2.7.2/include
 /u1/ns/exl/tools/lib/gcc-lib/m68k-linux/2.7.2/sys-include
 /u1/ns/exl/tools/m68k-linux/include
End of search list.
 ./cc1 /usr/tmp/cca04073.i -quiet -dumpbase inconf.c -m68020
-mnobitfield -O2 -Wall -Wno-format -version -fconserve-space -o inconf.s
GNU C version 2.7.2 (68k Linux/ELF) compiled by GNU C version 2.7.2.

The resulting assembly code is surprising:

>cat inconf.s

        .file   "inconf.c"
        .version        "01.01"
gcc2_compiled.:
.text
        .align  2
.globl doaddrs
        .type    doaddrs,@function
doaddrs:
        link.w %a6,#0
        move.l %d2,-(%sp)
        move.l tnets,%d0
        asl.l #2,%d0
#APP
        move %SR, %d2; move #0x2700, %SR
#NO_APP
        move.l %d0,-(%sp)
        jbsr ALP
        addq.w #4,%sp
#APP
        move %d2, %SR
#NO_APP
        move.l tnets,%d0
        asl.l #2,%d0
        move.l %d0,-(%sp)   #<-- it seems to believe that d0 has two 
        move.l %d0,-(%sp)   #<-- different values at the same time
        jbsr zero
        move.l -4(%a6),%d2
        unlk %a6
        rts
.Lfe1:
        .size    doaddrs,.Lfe1-doaddrs
        .ident  "GCC: (GNU) 2.7.2"
>

However, when I feed the same source to gcc-2.7.2 configured as:

#!/bin/sh
# GCC was configured as follows:
./../gcc-2.7.2/configure --target=m68k-coff -prefix=/home/mxm --local-prefix=/u1/ns/exl/tools --with-gnu-as --exec-prefix=/u1/ns/exl/tools
echo host=sparc-sun-sunos4.1.4 target=m68k-unknown-coff
build=sparc-sun-sunos4.1.4

with the same command line as above, the assembler output is unsurprising:

        .file   "inconf.c"
gcc2_compiled.:
__gnu_compiled_c:
.text
        .even
.globl doaddrs
doaddrs:
        link.w %a6,#0
        move.l %d2,-(%sp)
        move.l tnets,%d0
        asl.l #2,%d0
#APP
        move %SR, %d2; move #0x2700, %SR
#NO_APP
        move.l %d0,-(%sp)
        jsr ALP
        addq.w #4,%sp
#APP
        move %d2, %SR
#NO_APP
        move.l tnets,%d1     #<-- use a different register for a new
        asl.l #2,%d1         #<-- value when the old one is still live
        move.l %d1,-(%sp)    #<-- thus pushing the correct args
        move.l %d0,-(%sp)
        jsr zero
        move.l -4(%a6),%d2
        unlk %a6
        rts


This is keeping us from using elf, which we would like to do for
debugging information.

Thanks for your attention.

mxm  Matthew L. Martin                       mxm@proteon.com
------------------------------------------------------------
I'm a contractor. If you want an opinion, I'll sell you one.
Which one do you want?
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads