Re: [uClinux-dev] Building m68k-elf

From: Andrew Kohlsmith (akohlsmith@benshaw.com)
Date: Fri Jan 19 2001 - 21:05:40 EST


> Older version of uC-libc were hardwired for m68k-pic-coff-gcc.  The
> current version has this set in just one place, the Config file.

Thanks for the tip; I grabbed the latest uClibc from CVS and compiled it
with a minimum of fuss.

My test program:
---------------------------------------------
int main(int argc, char **argv)
{
 int i, j;

 j = 0;

 for (i=0; i<10; i++)
     j=j+1;

 return 0;
}
---------------------------------------------

My compile results:
# gcc -lc -o test test.c
/tmp/ccYm6Wg0.o: In function `main':
/tmp/ccYm6Wg0.o(.text+0x6): undefined reference to `__main'
collect2: ld returned 1 exit status

I'm so close now I can taste it...  I'm using Greg's crt0.S supplied from
this list and I don't see a __main there.  However in a few other crt0.S
files I've perused I see __main pointing to an rts just after __exit cleans
up...  However they're encased in "#ifdef NO_LIBGCC".

... soooooo....
---------------------------------------------
--- crt0.S Thu Jan 18 13:55:13 2001
+++ mycrt0.S Fri Jan 19 20:55:16 2001
@@ -1,4 +1,5 @@
  .global __start
+        .global __main

  .bss
  .global environ
@@ -25,6 +26,9 @@
  move.l %sp@+,%d1
  moveq #1,%d0 /* SYS_exit */
  trap #0
+
+__main:
+ rts

  .section .ctors,"aw"
  .align 4
---------------------------------------------

A "# m68k-elf-as ..." later the thing compiles!

root@wanderer:/opt/uClinux# m68k-elf-gcc -lc -o test test.c
root@wanderer:/opt/uClinux# ls -l test
-rwxr-xr-x   1 root     root        19232 Jan 19 21:02 test*
root@wanderer:/opt/uClinux# file test
test: ELF 32-bit MSB executable, Motorola 68000, version 1, statically
linked, not stripped
root@wanderer:/opt/uClinux# m68k-elf-strip test
root@wanderer:/opt/uClinux# ls -l test
-rwxr-xr-x   1 root     root        17984 Jan 19 21:02 test*

So now that's an 18k dummy program.  I know I can flatten that pretty small
but I'm wondering if the uClinux gurus can tell me if I've done anything
terribly wrong here...  Examining the compiler output, I browse what seems
to be the assembly to the program (I'm a little rusty on my 68k assembler
but it looks right) and I feel a little giddy, I have to admit.  :-)

Did I finally do it?

Regards,
Andrew

This message resent by the uclinux-dev@uclinux.org list server http://www.uClinux.org/


This archive was generated by hypermail 2.1.4 : Thu Sep 19 2002 - 13:19:26 EDT