CHGame 0.3.0
Libraries for the CHGame handheld
Loading...
Searching...
No Matches
RamFunc.h File Reference

RAMFUNC(name): run a function from SRAM. More...

Go to the source code of this file.

Macros

#define CHGAME_RAMFUNC(name)   __attribute__((section(".gnu.linkonce.r.chg." #name), noinline))
 The library's own SRAM functions (section "chg.<name>").
 
#define CHGAME_APP_RAMFUNC(name)   __attribute__((section(".gnu.linkonce.r.app." #name), noinline))
 A sketch's SRAM functions (section "app.<name>"); RAMFUNC() is this.
 
#define RAMFUNC(name)   CHGAME_APP_RAMFUNC(name)
 Run this function from SRAM.
 

Detailed Description

RAMFUNC(name): run a function from SRAM.

The section name is CHGfx 1.3's trick: the core's link script puts *(.gnu.linkonce.r.*) first in .data (copied to SRAM at boot), ahead of .sdata/.sbss. linkonce merges sections of the same name, so every function needs a name of its own (which also lets the linker drop unused ones one at a time). The library's are "chg.<name>"; CHGfx's are "chgfx.<name>". A sketch's own, RAMFUNC(name), are "app.<name>", so a sketch's function can never merge with one of the library's of the same name (but two of the sketch's must have different names).

The simulator keeps noinline but not the section: Mach-O (macOS) rejects ELF section names.