This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Problem with the stack on m68k



Thanks Peter and Scott for your responses.  So that
takes care of the calling procedure.  But I am still
get bus errors and an strange exception that I don't
recognize:

F-Line 
Vector = B      True A7 = FFCF0 True SR = 2700

PC   =$00033ACC   SR   =$00002700   USP  =$00001B00   
SSP  =$000FFCF8   
D0   =$FFFFFFFF   D1   =$00000007   D2   =$000409B1   D3   =$00000008   
D4   =$00000008   D5   =$00000009   D6   =$00000001   D7   =$0003646E   

A0   =$000FFF1A   A1   =$000FFF18   A2   =$000409B3   A3   =$000FFF30   
A4   =$000FFF60   A5   =$00000008   A6   =$000FFD04   A7   =$000

The monitor on the board is derived from the now old FBug68 v. 1.1 (circa
1990).  The errors seem to linked to values in the variable 
space of the function (main in this case), for example the sequence
would be

87 0162 206E FFFC 		move.l -4(%a6),%a0
88 0166 2D50 FFE8 		move.l (%a0),-24(%a6)

the bus error would occur with the second instruction.

I wondering if the way I am linking the libraries in is incorrect.
The way I am trying to do it, is have it use the gizmo.ld linker
script in the current directory as well as the crt0.o in the
current directory.  I tried to use gcc to do everything like
this :

CFLAGS = -mc68000 -msoft-float -malign-int -Wall -DDEBUG 
CC = m68k-coff-gcc
AR = m68k-coff-ar

LIBS = 


testcram.s19 : testcram.o crt0.o rotate.o
        ${CC} ${CFLAGS} testcram.o rotate.o -nodefaultlibs -nostartfiles
-Wl,-Tgizmo.ld -Wl,-M -Wl,-otestcram.s19

But the executable it generated would not run.

This is what my current makefile looks like:

CFLAGS = -m68000 -mno-align-int -Wall -Wa,-alh,-L -fstack-check

CC = m68k-coff-gcc
AR = m68k-coff-ar

LIBS = -lgizmo -lgcc -lc 

testcram.s19 : testcram.o crt0.o
	m68k-coff-ld testcram.o -L/usr/local/m68k-coff/lib/m68000
-L/usr/local/lib/gcc-lib/m68k-coff/2.95.2/m68000 -M -Tgizmo.ld
-otestcram.s19

and my linker script looks like

STARTUP(crt0.o)
OUTPUT_ARCH(m68k)
OUTPUT_FORMAT(srec)

SEARCH_DIR(.)
GROUP(-lgizmo -lc -lgcc)
__DYNAMIC  =  1;

/*
 * Setup the memory map of the M68332BCC Business Card Computer.
 * stack grows down from high memory.
 *
 * The memory map look like this:
 * +--------------------+ <- low memory
 * | .text              |
 * |        _etext      |
 * |        ctor list   | the ctor and dtor lists are for
 * |        dtor list   | C++ support
 * +--------------------+
 * | .data              | initialized data goes here
 * |        _edata      |
 * +--------------------+
 * | .bss               |
 * |        __bss_start | start of bss, cleared by crt0
 * |        _end        | start of heap, used by sbrk()
 * +--------------------+
 * .                    .
 * .                    .
 * .                    .
 * |        __stack     | top of stack
 * +--------------------+
 */
MEMORY
{
  ram (rwx) : ORIGIN = 0x30000, LENGTH = 1M - 0x30000
}

/*
 * allocate the stack to be at the top of memory, since the stack
 * grows down
 */

PROVIDE (__stack = 1M);

/*
 * Initalize some symbols to be zero so we can reference them in the
 * crt0 without core dumping. These functions are all optional, but
 * we do this so we can have our crt0 always use them if they exist. 
 * This is so BSPs work better when using the crt0 installed with gcc.
 * We have to initalize them twice, so we cover a.out (which prepends
 * an underscore) and coff object file formats.
 */
PROVIDE (hardware_init_hook = 0);
PROVIDE (_hardware_init_hook = 0);
PROVIDE (software_init_hook = 0);
PROVIDE (_software_init_hook = 0);
/*
 * stick everything in ram (of course)
 */
SECTIONS
{
  .text :
  {
    *(.text)
    . = ALIGN(0x4);
     __CTOR_LIST__ = .;
    ___CTOR_LIST__ = .;
    LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
    *(.ctors)
    LONG(0)
    __CTOR_END__ = .;
    __DTOR_LIST__ = .;
   ___DTOR_LIST__ = .;
    LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
    *(.dtors)
     LONG(0)
    __DTOR_END__ = .;
    *(.rodata)
    *(.gcc_except_table) 

    __INIT_SECTION__ = . ;
    LONG (0x4e560000)	/* linkw %fp,#0 */
    *(.init)
    SHORT (0x4e5e)	/* unlk %fp */
    SHORT (0x4e75)	/* rts */

    __FINI_SECTION__ = . ;
    LONG (0x4e560000)	/* linkw %fp,#0 */
    *(.fini)
    SHORT (0x4e5e)	/* unlk %fp */
    SHORT (0x4e75)	/* rts */

    _etext = .;
    *(.lit)
  } > ram

  .data :
  {
    *(.shdata)
    *(.data)
    _edata = .;
  } > ram

  .bss :
  {
    . = ALIGN(0x4);
    __bss_start = . ;
    *(.shbss)
    *(.bss)
    *(COMMON)
    _end =  ALIGN (0x8);
    __end = _end;
  } > ram

  .stab 0 (NOLOAD) :
  {
    *(.stab)
  }

  .stabstr 0 (NOLOAD) :
  {
    *(.stabstr)
  }
}


Noah Aklilu
aklilu@nyquist.ee.ualberta.ca
http://www.ee.ualberta.ca/~aklilu/
"Integrity is something you do when no one is looking"





------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]