3.3. Using a Custom Start-file

The start-file, crt0.c, contains instructions to initialize the CPU and memory management unit. The default start-file may be suitable for your requirements, but in general we expect you will need to make some changes. You can see the default start code in file /opt/xgc/m1750-coff/src/libc/crt0.c.

Rather than customize the file /opt/xgc/m1750-coff/src/libc/crt0.c, we suggest you look in the examples directory on the CD-ROM where you will find several examples of start files written in assembly language. The file names are crt0*.S. (The suffix .S indicates that the source should be pre-processed before being assembled.)

If you copy one of these into your local directory, then you can use it in preference to the default start file using the compiler option -nostartfiles as follows:

$ m1750-coff-gcc -nostartfiles crt0.S hello.c -o hello
$ m1750-coff-run hello
Hello world

You may also need to customize the linker script file. The default file is /opt/xgc/m1750-coff/lib/ldscripts/coff_m1750.x. You should copy this file to your local directory, and edit it as necessary.

$ cp /opt/xgc/m1750-coff/lib/ldscripts/coff_m1750.x myboard.ld
$ vi myboard.ld

You can then build a program using your custom linker script file as follows:

$ m1750-coff-gcc -T myboard.ld hello.c -o hello