These macros are included in all of the demos' scripts, and I highly suggest you use them as well as they simplify the script greatly.
BEGIN_SEG(name, addr)Arguments:
name: The name of your segment. Example: code addr: The address of your segment in memory. Example:0x80000400Function
Declares the beginning of a new segment. It also declares symbols for the beginning of your segment in RAM and ROM.
These symbols are named _nameSegmentStart and _nameSegmentRomStart respectively, where name is the name argument.
Make sure to keep this in mind when thinking of a segment name, i.e don't name your segment codesegment because then your symbol will be named _codesegmentSegmentStart.
Simularities to spec format
This is the equivalent of the beginseg command, and the name and address subcommands.
END_SEG(name)Arguments:
name: The name of your segment. Example: code Function
Declares the end of a segment. It also declares symbols for the end of your segment in RAM and ROM.
These symbols are named _nameSegmentEnd and _nameSegmentRomEnd respectively, where name is the name argument.
Simularities to spec format
This is the equivalent of the endseg command.
BEGIN_SEG and END_SEG: BEGIN_SEG(code, 0x80000400)
{
BUILD_DIR/asm/entry.o(.start);
BUILD_DIR/src/main*.o(.text);
*/libultra_rom.a:*.o(.text);
*/libgcc.a:*.o(.text);
/usr/lib/n64/PR/rspboot.o(.text);
/usr/lib/n64/PR/gspF3DEX2.NoN.fifo.o(.text);
/* data */
BUILD_DIR/src/main*.o(.data*);
*/libultra_rom.a:*.o(.data*);
/usr/lib/n64/PR/rspboot.o(.data*);
/usr/lib/n64/PR/gspF3DEX2.NoN.fifo.o(.data*);
/* rodata */
BUILD_DIR/src/main*.o(.*rodata*);
*/libultra_rom.a:*.o(.*rodata*);
*/libgcc.a:*.o(.*rodata*);
}
END_SEG(code)
BEGIN_NOLOAD(name)Arguments:
name: The name of your segment. Example: codeFunction
Declares the beginning of a new NOLOAD segment. A NOLOAD segment is a kind of segment which is not intended to be loaded into RAM on boot. This is intended for storing things that are uninitialized data, like .bss sections of your code, and buffers like your framebuffer or zbuffer.
NOLOAD segments do not support address assignment the same way as a regular segment, so to assign your segment to a specific address, use a . = ADDRESSHERE; statement. This tells ld that the current location in RAM is changing to that address, think like how cd changes directory in the command line.
Simularities to spec format
spec has no equivalent for this.
END_NOLOAD(name)Arguments:
name: The name of your segment. Example: codeFunction
Declares the end of a NOLOAD segment.
Simularities to spec format
spec has no equivalent for this.
BEGIN_NOLOAD and END_NOLOAD: . = 0x80100000; /* Tells LD to go to this address */
BEGIN_NOLOAD(cfb)
{
BUILD_DIR/src/buffers/cfb.o(.bss*);
}
END_NOLOAD(cfb)
Back to Linkerscripts section