From 1923199dadd9d267d59080e2dd5ef4cfd4ec1643 Mon Sep 17 00:00:00 2001 From: cuz Date: Sat, 10 Mar 2001 14:10:38 +0000 Subject: [PATCH] Allow to define symbols in the linker config git-svn-id: svn://svn.cc65.org/cc65/trunk@620 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ld65/config.c | 53 +++++++++++++++++++++++++++++++++++++-------- src/ld65/scanner.h | 1 + src/ld65/segments.c | 2 +- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/ld65/config.c b/src/ld65/config.c index 902db00a8..f0673ff02 100644 --- a/src/ld65/config.c +++ b/src/ld65/config.c @@ -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"); diff --git a/src/ld65/scanner.h b/src/ld65/scanner.h index 399efa414..e5eb5c722 100644 --- a/src/ld65/scanner.h +++ b/src/ld65/scanner.h @@ -65,6 +65,7 @@ typedef enum { CFGTOK_SEGMENTS, CFGTOK_FORMATS, CFGTOK_FEATURES, + CFGTOK_SYMBOLS, CFGTOK_START, CFGTOK_SIZE, diff --git a/src/ld65/segments.c b/src/ld65/segments.c index 3e49facb7..684521dcd 100644 --- a/src/ld65/segments.c +++ b/src/ld65/segments.c @@ -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 */ -- 2.39.5