Specifications

16
A Minimal PowerPCª Boot Sequence for
Executing Compiled C Program
s
Sample Boot Sequence
*(.dynamic);
_final_data_end = .;
}
/* Now save off the start of the data in the image */
_img_data_start = LOADADDR(.data);
The _Þnal_data_start and _Þnal_data_end symbols indicate the post-relocation start and end addresses of
the data section. In addition, the symbol _img_data_start holds the start address of the data section in the
ROM image. This information will be used during the relocation of the data.
The linker script treats the bss section much like the data section. The only difference is that it is not
necessary to know the location of the bss section in the ROM image. The relocation program only needs to
know how big the bss is so it can zero out an appropriate section of memory in RAM for uninitialized data.
For the sample boot program, the bss section is located directly after the data section, and the symbols
_bss_start and _bss_end are used to determine the length of the bss section:
.bss (ADDR(.data) + SIZEOF(.data)) :
{
_bss_start = .;
*(.sbss)
*(.scommon)
*(.dynbss)
*(.bss)
*(COMMON);
_bss_end = .;
}
In some cases, it is possible that the address range located at 0xFFF0_0000 is writeable. In this instance, the
user may not wish to relocate the sections from the load address. The easiest way to do this is to specify
equivalent relocation and load addresses for the text section. The sample boot program checks for this before
performing a copy. Because all other section addresses are based on the location of the text, this is the only
change needed in order to leave the entire image in ROM space. This change is accomplished by deÞning
identical IMAGE_TEXT_START and TEXT_START variables in the makeÞle.
Finally, some users may wish to relocate only those sections (data and bss) that are modiÞed during program
execution. The easiest way to do this is to specify an absolute relocation address for the data section, and
allow the bss to be located immediately following the data. The locations of the sections in the compiled
image remains the same. To accomplish this, deÞne IMAGE_TEXT_START and TEXT_START to be
identical in the makeÞle. Then deÞne a DATA_START that speciÞes the desired location of the data section
during execution. Using this method, the data section will still follow the text section in the load image but
it is moved to DATA_START before the user program begins execution. The text section remains at its load
location, reducing the time required for the copy.
The linking phase of the build for the ppcinit program produces a .elf Þle organized as speciÞed in ld.script.
In addition, the -fnobuiltin option has been speciÞed to prevent linking with standard libraries. This .elf Þle
can be loaded and executed. For environments that do not have elf loading capability, the executable may
be translated into Motorola S-Record format using the GNU objcopy utility, specifying the output Þle
format as S-record as follows:
go.srec: go.elf
$(PREFIX)/bin/$(TARGET)Ðobjcopy -O srec go.elf go.srec
This S-record may be loaded into ROM and executed.