Building hello.c with uClibc and m68k-none-elf
richard at codesourcery.com
Sat Nov 4 08:54:56 UTC 2006
Your question isn't relevant to the thread you replied to, so I've
changed the subject line and taken Mike off cc:.
Rick Garcia <rick at liveoaklogic.com> writes:
> Richard Sandiford wrote:
>> Richard Sandiford <richard at codesourcery.com> writes:
>>> However, retesting on m68k showed up a problem that had appeared in
>>> uClibc since the last time I tried. [...]
>> How about this patch? I'd like to get the bug fixed before the upcoming
>> release. As things stand, uClibc trunk is basically unusable on m68k systems.
> I've got a quick question about the status of m68knommu on uClibc -
> here's my situation :
> I've been working on getting busybox up on a m68knommu system. As an
> aside, I tried building "hello, world" to test alongside bb, and I can't
> believe how much trouble it's giving me. I'm cross-compiling against
> uClibc-0.9.28 built for m68knommu. I'm not going to go through every
> iteration/commandline I've tried, but this output is typical of what I'm
> seeing :
> > m68k-none-elf-gcc -c -g \
> > -I/home/Rick/usr/m68k-linux-uclibc/usr/include \
> > hello.c -o hello.o
> > m68k-none-elf-gcc \
> > hello.o \
> > -static -nostdinc -nostdlib -Wl,-elf2flt \
> > -L/home/Rick/usr/m68k-linux-uclibc/usr/lib \
> > -o hello
> > warning: cannot find entry symbol _start; defaulting to 00000000
> > hello.o: In function `main':
> > /home/Rick/src/m68k/hello/hello.c:4: undefined reference to `printf'
> > collect2: ld returned 1 exit status
> > make: *** [hello] Error 1
Yeah, this won't work with any target library I know. If you pass -nostdlib,
no crt files will be linked in, and no C library will be linked in.
You either have to pass them explicitly or remove the -nostdlib option.
> If I specifically point to the uClibc's libc.a and crt0.o on the
> command line, then it gives me a whole bevy of other unfound files and
> symbols. (stddef.h, stdarg.h, ect.)
I don't follow. Why would adding libc.a and crt0.o lead to warnings
about missing include files? Could you copy the message you get?
> If I leave off the -nostdlib, then it attempts to build against newlib
> (which was used to build the compiler) instead of uClibc.
Right. More below.
> Is this a symptom of the breakage you're referring to? I've been able
> to get busybox compiling & running against this same uClibc without the
> kind of trouble that it's giving me for hello.c.
No, this is completely different from the breakage I'm referring to.
The bug I'm talking about is heap corruption at runtime.
You shouldn't really try to use an m68k-none-elf toolchain to build
uClibc apps. If you're using uClinux rather than full linux, build an
m68k-uclinux toolchain instead. You can make life easier for yourself
by configuring with "--with-sysroot=...". You then shouldn't need any
extra options at all; a simple:
m68k-uclinux-gcc hello.c -o hello
More information about the uClibc