[LiSA-Users] Cross compiling

Ionut Nicu ioan.nicu at ines.ro
Fri Jan 12 08:49:24 EET 2007


On Thu, 2007-01-11 at 02:54 -0700, Kerry Brown wrote:
> I actually just had to play with the Make file to get it to compile For 
> Big endian Arm....
> 
> 
> Here is the error I get when i try to link swctl
> 
> arm-linux-ld -EB -o swctl swctl.o ../lib/misc.o
> arm-linux-ld: warning: cannot find entry symbol _start; defaulting to 
> 00008074
> swctl.o(.text+0x1c): In function `parse_hw_addr':
> : undefined reference to `calloc'

Hi Kerry,

I'm not sure what changes have you made to the Makefiles, however it
seems like you're not linking against libc (i.e. the linker doesn't get
called with the appropriate flags and libraries).
To form an executable out of swctl.o and misc.o, the linker needs to
resolve some symbols such as _start and calloc (obviously, these are
from libc and are not defined in our object files).
The correct way to make an executable out of these object files is to
call 'gcc -o swctl swctl.o ../lib/misc.o'. This way gcc knows how to
pass the correct arguments to the linker.
Try running 'gcc -v -o swctl swctl.o ../lib/misc.o' to get an insight on
the parameters that gcc passes to the linker. For instance, on my x86
machine the interesting output is:

gcc -v -o swctl swctl.o ../lib/misc.o

 /usr/libexec/gcc/i686-pc-linux-gnu/3.4.6/collect2 --eh-frame-hdr -m
elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o
swctl /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/../../../crt1.o /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/../../../crti.o /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/crtbegin.o -L/usr/lib/gcc/i686-pc-linux-gnu/3.4.6 -L/usr/lib/gcc/i686-pc-linux-gnu/3.4.6 -L/usr/lib/gcc/i686-pc-linux-gnu/3.4.6/../../../../i686-pc-linux-gnu/lib -L/usr/lib/gcc/i686-pc-linux-gnu/3.4.6/../../.. swctl.o ../lib/misc.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/crtend.o /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/../../../crtn.o

You can see here that swctl is linked also from ld-linux.so.2 crti.o and
crtn.o.

I'm not sure why 'make' didn't work right out of the box for you (the
rule that makes swctl is correct: $(CC) $(LDFLAGS) -o swctl
$^ ../lib/misc.o). Here $(CC) must be resolved to your cross compiler
(arm gcc). If that's the problem, try setting CC to your cross compiler
and make should work just fine.

Ionut.



More information about the LiSA-Users mailing list