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: MC68000 cross compiler


Kim Jørgensen wrote: 
> I'm trying to build a cross compiler on a Red Hat 6.1 (i686) system for a
> custom MC68000 board (with a custom kernel). I didn't know what target to
> compile for, so I chose m68k-coff. Can anybody tell me what coff means?
> 
> I'm using: Binutils-2.9.1, Gcc-2.95.2 and Newlib-1.8.2. I compiled and
> installed the cross compiler using one-tree-1.6.sh and build-cross.sh
> described in the CrossGCC FAQ.
> 
> I didn't have any problems compiling or installing the cross compiler, but I
> can't link compiled c programs. I tried to compile and link this simple test
> program:
> 
> int main()
> {
>     unsigned int x, y;
> 
>     for(x=1; x<10; x++) y = 100 / x;
> 
>     return 0;
> }
> 
> First I did a "m68k-coff-gcc -c -mc68000 test.c".
> Then I did a "m68k-coff-ld test.o", I got these error messages:
> 
> test.o(.text+0x6):test.c: undefined reference to `__main'
> test.o(.text+0x24):test.c: undefined reference to `__udivsi3'
> 
> When I tried to compile the test program for the 68020 I didn't get the last
> error message (`__udivsi3'). Do I have to do anything special when making a
> cross compiler for the 68000?
> 
> Hope you can help me out here!
> Kim Jorgensen

COFF (Common Object File Format) was originally defined by Bell Labs as
part of the evolution of Unix.  It has become a very common format for
object files and several variations have evolved for diferent systems.

For some targets, if GCC sees the function called "main", it will emit a
call to __main which is intended to set up the C++ runtime stuff.  If
you really need to make your main entry point "main", then just add a
dummy __main() which just returns.  In our case, we generate standalone
C and assembler code for embedded systems, and don't use the function
name "main".

Your other problem is that the compiler is calling a math support
package routine for a divide.  If the code gets too large to emit inline
for some math operations, the compiler will call a math support routine
to perform the operation.  These are usually found in libgcc1.  Since
you invoked the linker directly (instead of inplicitely through gcc),
you should have referenced libgcc1 (or some other lib containing the gcc
math routines).  When compiling for the 020, the instruction set has a
few more instructions and the compiler did not have to call a support
routine.

Hope this helps,
Art

------
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]