Download GNAT User's Guide

Transcript
GNAT User’s Guide Supplement for Cross Platforms
issue for that simple program. Also, it is conceivable that the ROM monitor will
set the stack to a usable value before branching to the entry point. However, it
is more likely that you will want to set the stack pointer early in your startup
code, and there may be other registers that must be set. For example, if the
relevant Application Binary Interface (ABI) specifies an addressing mode that
is relative to a designated register, the linker will output a symbol containing
the value that the register must be set to. For example, on MIPS, _gp must be
loaded into register 28. On PowerPC you could set r13 to point to the small data
area (although this is not necessary unless you take advantage of this feature,
and is not relevant here).
Here is the “bare bones” startup assembly code, ‘start.s’:
top_of_stack = 0x200000
.section ".text"
.global _start
_start:
lis 1, __bss_start@ha
la 1, __bss_start@l (1)
lis 2, __end@ha
la 2, __end@l (2)
li 3, 0
bssloop:
cmp 0,0,1,2
bge bssdone
stw 3, 0(1)
addi 1, 1, 4
b
bssloop
bssdone:
addis 1, 0, top_of_stack@h
ori
1, 1, top_of_stack@l
bl
forever:
b
main
forever
And here is the link command:
powerpc-elf-ld -Ttext 0x100000 -o nu start.o nu.o b~nu.o
A single command that would build the application is:
powerpc-elf-gnatmake -g nu -largs -Wl,-Ttext,0x100000,start.o
It is very likely that your setup may work with S-record files. If so, the following objcopy command converts the executable ELF file ‘nu’ to an S-record file
‘nu.sre’ (details are in the binutils documentation):
powerpc-elf-objcopy -S -O srec nu nu.sre
A script written in ld’s script language controls how ld composes the pieces
of a relocatable (‘.o’) file when creating an executable. Up to now, the default
10