EmbeddedRelated.com
Forums

GNUPro Toolkit, crt0, Altera Nios confusion

Started by Nat Chan October 7, 2003
Hi,

I'm trying to build some C code (separate .c files) and link the .o
files together for Nios using the GNUPro tools that came with it. I
keep getting errors that ld can't find crt0.o.

So, I looked around the Nios documentation and couldn't find
anything on crt0. I managed to find some stuff on it in RedHat's
generic GNUPro Toolkit Getting Started Guide about how it is the
main startup file, "its object is linked in first and bootstraps the
rest of your application", and "A crt0 file is available for most
platforms"... The toolkit I have did come with example crt0 files
but only for a29khif, arm, cygwin, d10v, go32, h8300hms, h8500hms,
m88kbug, netware, rtems, sh, sparc64, sysmec, sysnec810, sysnecv850,
sysvi386, sysnecv70, tic80, w65, and z8ksim...but not for nios!

Does anyone know where I can find an example of a Nios crt0.s or
Nios crt0.c file? Or does anyone know how to make SOPC builder
generate such a file? I'm new at this and don't know how to write
one from scratch.

Is there any option besides throwing all the code into 1 file for
compilation?

Thanks,
NCKC



> I'm trying to build some C code (separate .c files) and link the .o
> files together for Nios using the GNUPro tools that came with it. I
> keep getting errors that ld can't find crt0.o.

CRT0 isn't needed to link and execute Nios programs.
During compilation of some Nios programs I can't see crt0
anywhere within the scripts.
BTW: Use nios-build script for compilation and linking (or look inside what
libraries are linked). I think all libraries needed for compilation are
created
during processor build process.

Here is some example line with linker:

# 2003.10.08 17:13:06 (*) nios-elf-gcc -I .. -I ../.. -I ../inc -I
../../inc -I ../../../inc -I ../../../../inc -I ../../../../../inc -W -g
-O2 -mno-zero-extend -m32 g1.c -o g1.c.o -c
In file included from g1.c:8:
pid.h:10: warning: useless keyword or type name in empty declaration
g1.c: In function `czekaj':
g1.c:41: warning: `j' might be used uninitialized in this function

# 2003.10.08 17:13:07 (*) nios-elf-gcc -I .. -I ../.. -I ../inc -I
../../inc -I ../../../inc -I ../../../../inc -I ../../../../../inc -W -g
-O2 -mno-zero-extend -m32 pid.c -o pid.c.o -c
In file included from pid.c:1:
pid.h:10: warning: useless keyword or type name in empty declaration

# 2003.10.08 17:13:07 (*) nios-elf-ld -e _start -u _start -g -T
/cygdrive/c/altera/excalibur/sopc_builder/bin/excalibur.ld ../../lib/obj32/
nios_jumptostart.s.o g1.c.o pid.c.o --start-group -l nios32 -l c -l m -l
gcc --end-group -L/cygdrive/c/altera/excalibur/sopc_builder/bin/nio
s-gnupro/nios-elf/lib/m32 -L/cygdrive/c/altera/excalibur/sopc_builder/bin/ni
os-gnupro/lib/gcc-lib/nios-elf/2.9-nios-010801-20020710/m32 -L..
/lib -L../../lib -L../../../lib -L../../../../lib -L../../../../../lib -L../
inc -L../../inc -L../../../inc -L../../../../inc -L../../../../.
./inc -L. -o pid.out

# 2003.10.08 17:13:08 (*) nios-elf-objcopy -O srec pid.out pid.srec

# 2003.10.08 17:13:08 (*) nios-elf-nm pid.out | sort > pid.nm

# 2003.10.08 17:13:08 (*) nios-elf-objdump -d --source pid.out > pid.objdump
Hope this helps.

Jerry