mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 19:29:37 +00:00
Allow to define symbols in the linker config
git-svn-id: svn://svn.cc65.org/cc65/trunk@620 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
1eff067ff9
commit
1923199dad
@ -619,20 +619,20 @@ static void ParseSegments (void)
|
|||||||
{
|
{
|
||||||
static const IdentTok Attributes [] = {
|
static const IdentTok Attributes [] = {
|
||||||
{ "LOAD", CFGTOK_LOAD },
|
{ "LOAD", CFGTOK_LOAD },
|
||||||
{ "RUN", CFGTOK_RUN },
|
{ "RUN", CFGTOK_RUN },
|
||||||
{ "TYPE", CFGTOK_TYPE },
|
{ "TYPE", CFGTOK_TYPE },
|
||||||
{ "ALIGN", CFGTOK_ALIGN },
|
{ "ALIGN", CFGTOK_ALIGN },
|
||||||
{ "DEFINE", CFGTOK_DEFINE },
|
{ "DEFINE", CFGTOK_DEFINE },
|
||||||
{ "OFFSET", CFGTOK_OFFSET },
|
{ "OFFSET", CFGTOK_OFFSET },
|
||||||
{ "START", CFGTOK_START },
|
{ "START", CFGTOK_START },
|
||||||
};
|
};
|
||||||
static const IdentTok Types [] = {
|
static const IdentTok Types [] = {
|
||||||
{ "RO", CFGTOK_RO },
|
{ "RO", CFGTOK_RO },
|
||||||
{ "RW", CFGTOK_RW },
|
{ "RW", CFGTOK_RW },
|
||||||
{ "BSS", CFGTOK_BSS },
|
{ "BSS", CFGTOK_BSS },
|
||||||
{ "ZP", CFGTOK_ZP },
|
{ "ZP", CFGTOK_ZP },
|
||||||
{ "WP", CFGTOK_WPROT },
|
{ "WP", CFGTOK_WPROT },
|
||||||
{ "WPROT", CFGTOK_WPROT },
|
{ "WPROT", CFGTOK_WPROT },
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned Count;
|
unsigned Count;
|
||||||
@ -1138,6 +1138,36 @@ static void ParseFeatures (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void ParseSymbols (void)
|
||||||
|
/* Parse a symbols section */
|
||||||
|
{
|
||||||
|
while (CfgTok == CFGTOK_IDENT) {
|
||||||
|
|
||||||
|
long Val;
|
||||||
|
|
||||||
|
/* Remember the name */
|
||||||
|
char Name [sizeof (CfgSVal)];
|
||||||
|
strcpy (Name, CfgSVal);
|
||||||
|
CfgNextTok ();
|
||||||
|
|
||||||
|
/* Allow an optional assignment */
|
||||||
|
CfgOptionalAssign ();
|
||||||
|
|
||||||
|
/* Make sure the next token is an integer, read and skip it */
|
||||||
|
CfgAssureInt ();
|
||||||
|
Val = CfgIVal;
|
||||||
|
CfgNextTok ();
|
||||||
|
|
||||||
|
/* Generate an export with the given value */
|
||||||
|
CreateConstExport (Name, Val);
|
||||||
|
|
||||||
|
/* Skip the semicolon */
|
||||||
|
CfgConsumeSemi ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ParseConfig (void)
|
static void ParseConfig (void)
|
||||||
/* Parse the config file */
|
/* Parse the config file */
|
||||||
{
|
{
|
||||||
@ -1147,6 +1177,7 @@ static void ParseConfig (void)
|
|||||||
{ "SEGMENTS", CFGTOK_SEGMENTS },
|
{ "SEGMENTS", CFGTOK_SEGMENTS },
|
||||||
{ "FORMATS", CFGTOK_FORMATS },
|
{ "FORMATS", CFGTOK_FORMATS },
|
||||||
{ "FEATURES", CFGTOK_FEATURES },
|
{ "FEATURES", CFGTOK_FEATURES },
|
||||||
|
{ "SYMBOLS", CFGTOK_SYMBOLS },
|
||||||
};
|
};
|
||||||
cfgtok_t BlockTok;
|
cfgtok_t BlockTok;
|
||||||
|
|
||||||
@ -1183,6 +1214,10 @@ static void ParseConfig (void)
|
|||||||
ParseFeatures ();
|
ParseFeatures ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CFGTOK_SYMBOLS:
|
||||||
|
ParseSymbols ();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FAIL ("Unexpected block token");
|
FAIL ("Unexpected block token");
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ typedef enum {
|
|||||||
CFGTOK_SEGMENTS,
|
CFGTOK_SEGMENTS,
|
||||||
CFGTOK_FORMATS,
|
CFGTOK_FORMATS,
|
||||||
CFGTOK_FEATURES,
|
CFGTOK_FEATURES,
|
||||||
|
CFGTOK_SYMBOLS,
|
||||||
|
|
||||||
CFGTOK_START,
|
CFGTOK_START,
|
||||||
CFGTOK_SIZE,
|
CFGTOK_SIZE,
|
||||||
|
@ -230,7 +230,7 @@ Section* ReadSection (FILE* F, ObjData* O)
|
|||||||
Type = Read8 (F);
|
Type = Read8 (F);
|
||||||
|
|
||||||
/* Print some data */
|
/* Print some data */
|
||||||
Print (stdout, 1, "Module `%s': Found segment `%s', size = %lu, align = %u, type = %u\n",
|
Print (stdout, 2, "Module `%s': Found segment `%s', size = %lu, align = %u, type = %u\n",
|
||||||
GetObjFileName (O), Name, Size, Align, Type);
|
GetObjFileName (O), Name, Size, Align, Type);
|
||||||
|
|
||||||
/* Get the segment for this section */
|
/* Get the segment for this section */
|
||||||
|
Loading…
Reference in New Issue
Block a user