1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +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:
cuz 2001-03-10 14:10:38 +00:00
parent 1eff067ff9
commit 1923199dad
3 changed files with 46 additions and 10 deletions

View File

@ -619,20 +619,20 @@ static void ParseSegments (void)
{
static const IdentTok Attributes [] = {
{ "LOAD", CFGTOK_LOAD },
{ "RUN", CFGTOK_RUN },
{ "RUN", CFGTOK_RUN },
{ "TYPE", CFGTOK_TYPE },
{ "ALIGN", CFGTOK_ALIGN },
{ "DEFINE", CFGTOK_DEFINE },
{ "OFFSET", CFGTOK_OFFSET },
{ "START", CFGTOK_START },
{ "OFFSET", CFGTOK_OFFSET },
{ "START", CFGTOK_START },
};
static const IdentTok Types [] = {
{ "RO", CFGTOK_RO },
{ "RW", CFGTOK_RW },
{ "BSS", CFGTOK_BSS },
{ "ZP", CFGTOK_ZP },
{ "WP", CFGTOK_WPROT },
{ "WPROT", CFGTOK_WPROT },
{ "RO", CFGTOK_RO },
{ "RW", CFGTOK_RW },
{ "BSS", CFGTOK_BSS },
{ "ZP", CFGTOK_ZP },
{ "WP", CFGTOK_WPROT },
{ "WPROT", CFGTOK_WPROT },
};
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)
/* Parse the config file */
{
@ -1147,6 +1177,7 @@ static void ParseConfig (void)
{ "SEGMENTS", CFGTOK_SEGMENTS },
{ "FORMATS", CFGTOK_FORMATS },
{ "FEATURES", CFGTOK_FEATURES },
{ "SYMBOLS", CFGTOK_SYMBOLS },
};
cfgtok_t BlockTok;
@ -1183,6 +1214,10 @@ static void ParseConfig (void)
ParseFeatures ();
break;
case CFGTOK_SYMBOLS:
ParseSymbols ();
break;
default:
FAIL ("Unexpected block token");

View File

@ -65,6 +65,7 @@ typedef enum {
CFGTOK_SEGMENTS,
CFGTOK_FORMATS,
CFGTOK_FEATURES,
CFGTOK_SYMBOLS,
CFGTOK_START,
CFGTOK_SIZE,

View File

@ -230,7 +230,7 @@ Section* ReadSection (FILE* F, ObjData* O)
Type = Read8 (F);
/* 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);
/* Get the segment for this section */