I'll try to track my progress a little bit here for people to follow. I'm not going to make any guarantees, but I plan to do this for fun. I work full time at a real job and am working on finishing my masters degree, so I'm usually pretty busy.
today i started to understand how ld-tigcc is constructed and added in a -flash-app switch, but I have a lot of learning to do.... I feel rusty but comfortable... haven't written any serious amount of C code in probably 4+ years! The actual structure of a FLASH application is very simple and documented well by TI. I've also noticed that there are many ROM calls that TI has documented well which tigcc/gcc4ti don't have documented. tiams.h that comes with flash studio is helpful as are the pdf files on TI's website.
Layout of a FLASH application:
1) Flash header (TI-Graph Link)
2) Certificate header
3) Application Header (type FLASH_APP_HEADER defined below)
4a) Relocation Map
4b) Application code
4c) Initial data table
// *** Constants ***
#define FLASH_APP_MAGIC 0x167B533D
#define FLASH_APP_APPHDR_LOCALIZER 0x0001
// *** File Mapping Definitions ***
typedef struct ATTRIBUTE_PACKED
TI4 magic; //FLASH_APP_MAGIC
char name[[ 8 ]]; //Internal Name of the FLASH app. Must be unique from all other FLASH apps installed on the calculator.
I1 zeros; //Reserved - initialize to zeros
TI2 flags; //Bit field FLASH_APP_APPHDR_LOCALIZER or zero.
TI4 dataLen; //Amount of static RAM to allocate for the FLASH APP. Contains static initialized (.data) and uninitialized (.bss) RAM sections
TI4 codeOffset; //Byte offset to code is a header-relative pointer to the beginning of the application code image
TI4 initDataOffset; //.data section is initialized by copying the data from this table
TI4 initDataLen; //length of initial data table
TI4 optlen; //optional header can follow this structure of optlen length. Never used by TI. Currently not used by ld-tigcc.