Skip to content

Linker Script

The linker script defines how code and data are organized in memory for gint applications. It specifies memory regions, sections, and the layout of the final binary.

The linker script defines five memory regions:

  • Origin: 0x8c052800
  • Size: 337920 bytes (330 KB)
  • Purpose: VRAM backup area, main fixed area to load code
  • Attributes: Read, Write, Execute (rwx)
  • Origin: 0x8cff0000
  • Size: 61184 bytes (64 KB - 0x1100)
  • Purpose: Space after HollyHock loader
  • Attributes: Read, Write, Execute (rwx)

HollyHock itself loads at 0x8cfd0000 (128 KB before the application). This region fits after it.

  • Origin: 0x8cffef00
  • Size: 4352 bytes (0x1100)
  • Purpose: Space for interrupt vectors
  • Attributes: Read, Write, Execute (rwx)
  • Origin: 0xe5200000
  • Size: 4 KB
  • Purpose: Fast on-chip instruction local memory
  • Attributes: Read, Write, Execute (rwx)
  • Origin: 0xe500e000
  • Size: 16 KB
  • Purpose: Fast on-chip data memory for DSP operations
  • Attributes: Read, Write, Execute (rwx)

These sections contain code and read-only data:

Contains machine code for entry functions and compiler constructors/destructors.

.hh3 : {
*(.hh3*)
*(.eram*)
} > eram

Contains executable code including:

  • Entry function (.text.entry)
  • Constructors (.ctors)
  • Destructors (.dtors)
  • Exchange handlers (.gint.exch)
  • TLB handlers (.gint.tlbh)
  • User code (.text, .text.*)
.text : {
*(.text.entry)
_bctors = . ;
KEEP(*(.ctors .ctors.*))
_ectors = . ;
_bdtors = . ;
KEEP(*(.dtors .dtors.*))
_edtors = . ;
*(.gint.exch)
*(.gint.tlbh)
*(.text .text.*)
} > ram

Contains gint’s interrupt handler blocks. These are relocated at startup by the library/drivers.

.gint.blocks ALIGN(4) : ALIGN(4) {
KEEP(*(.gint.blocks));
} > ram

Contains exposed driver interfaces. Required to start and configure drivers even if symbols are not referenced.

.gint.drivers ALIGN(4) : ALIGN(4) {
_gint_drivers = . ;
KEEP(*(SORT_BY_NAME(.gint.drivers.*)));
_gint_drivers_end = . ;
} > ram

Contains read-only data:

  • Resources from fxconv converters
  • Compiler-marked read-only data
.rodata ALIGN(4) : ALIGN(4) SUBALIGN(4) {
*(.rodata.4)
*(.rodata .rodata.*)
} > ram

These sections contain read-write data:

Contains initialized read-write data and mapped code.

.data ALIGN(4) : ALIGN(4) {
_ldata = LOADADDR(.data);
_rdata = . ;
*(.data .data.*)
*(.gint.mapped)
*(.gint.mappedrel)
} > ram

Contains code for on-chip IL memory.

.ilram ALIGN(4) : ALIGN(4) {
_lilram = ABSOLUTE(LOADADDR(.ilram) + ORIGIN(ram));
_rilram = . ;
*(.ilram)
} > ilram

Contains code for on-chip X and Y memory.

.xyram ALIGN(4) : ALIGN(4) {
_lxyram = ABSOLUTE(LOADADDR(.xyram) + ORIGIN(ram));
_rxyram = . ;
*(.xram .yram .xyram)
} > xyram

Contains uninitialized data. Wiped by the loader at startup.

.bss : {
_rbss = . ;
*(.bss .bss.* COMMON)
} > ram

Contains gint’s uninitialized BSS section for large data arrays.

.gint.bss : {
*(.gint.bss)
_euram = . ; /* End of user RAM */
} > ram

These sections are removed from the final binary:

/DISCARD/ : {
*(.gint.rodata.sh3 .gint.data.sh3 .gint.bss.sh3) /* SH3-only data */
*(.jcr) /* Java class registration */
*(.eh_frame_hdr) *(.eh_frame) /* Exception handling tables */
*(.comment) /* Compiler comments */
}

The linker script defines several important symbols:

SymbolDescription
_bromStart of ROM mappings
_sromSize of ROM mappings
_bctors, _ectorsConstructor table bounds
_bdtors, _edtorsDestructor table bounds
_gint_exch_start, _gint_exch_endExchange handler bounds
_gint_tlbh_start, _gint_tlbh_endTLB handler bounds
_gint_drivers, _gint_drivers_endDriver info bounds
_ldata, _rdataData load/runtime addresses
_sdataSize of data sections
_lilram, _rilramILRAM addresses
_silramSize of ILRAM
_lxyram, _rxyramXYRAM addresses
_sxyramSize of XYRAM
_rbssBSS start
_sbssBSS size
_sgbssgint BSS size
_euramEnd of user RAM
_gint_region_vbrVBR region origin

Source file: fxcp_hh3.ld.c