From: uz Date: Tue, 9 Nov 2010 21:01:27 +0000 (+0000) Subject: Merge CfgProcess and CfgAssignSegments because both do some sort of X-Git-Tag: V2.13.3~613 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a2b7ef2b08726bcae16227154aee968486d1cb35;p=cc65 Merge CfgProcess and CfgAssignSegments because both do some sort of postprocessing. Print a warning if %O was used in the config file and the output file name is changed later using -o. git-svn-id: svn://svn.cc65.org/cc65/trunk@4842 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ld65/config.c b/src/ld65/config.c index 3de6c9a1a..f86aaaaf6 100644 --- a/src/ld65/config.c +++ b/src/ld65/config.c @@ -1683,17 +1683,6 @@ static void ProcessSymbols (void) -void CfgProcess (void) -/* Process the config file after reading in object files and libraries */ -{ - ProcessSymbols (); /* ######## */ - ProcessMemory (); - ProcessSegments (); - ProcessFormats (); -} - - - static void CreateRunDefines (SegDesc* S, unsigned long SegAddr) /* Create the defines for a RUN segment */ { @@ -1722,20 +1711,28 @@ static void CreateLoadDefines (SegDesc* S, unsigned long SegAddr) -unsigned CfgAssignSegments (void) -/* Assign segments, define linker symbols where requested. The function will - * return the number of memory area overflows (so zero means anything went ok). +unsigned CfgProcess (void) +/* Process the config file after reading in object files and libraries. This + * includes postprocessing of the config file data but also assigning segments + * and defining segment/memory area related symbols. The function will return + * the number of memory area overflows (so zero means anything went ok). * In case of overflows, a short mapfile can be generated later, to ease the * task of rearranging segments for the user. */ { unsigned Overflows = 0; + unsigned I; + + /* Do postprocessing of the config file data */ + ProcessSymbols (); /* ######## */ + ProcessMemory (); + ProcessSegments (); + ProcessFormats (); /* Walk through each of the memory sections. Add up the sizes and check * for an overflow of the section. Assign the start addresses of the * segments while doing this. */ - unsigned I; for (I = 0; I < CollCount (&MemoryAreas); ++I) { unsigned J; diff --git a/src/ld65/config.h b/src/ld65/config.h index 4f16e6dab..af752ae8d 100644 --- a/src/ld65/config.h +++ b/src/ld65/config.h @@ -102,12 +102,11 @@ struct SegDesc { void CfgRead (void); /* Read the configuration */ -void CfgProcess (void); -/* Process the config file after reading in object files and libraries */ - -unsigned CfgAssignSegments (void); -/* Assign segments, define linker symbols where requested. The function will - * return the number of memory area overflows (so zero means anything went ok). +unsigned CfgProcess (void); +/* Process the config file after reading in object files and libraries. This + * includes postprocessing of the config file data but also assigning segments + * and defining segment/memory area related symbols. The function will return + * the number of memory area overflows (so zero means anything went ok). * In case of overflows, a short mapfile can be generated later, to ease the * task of rearranging segments for the user. */ diff --git a/src/ld65/global.c b/src/ld65/global.c index 607b7c3ed..94f378dec 100644 --- a/src/ld65/global.c +++ b/src/ld65/global.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2003 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 1998-2010, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -44,6 +44,7 @@ const char* OutputName = "a.out"; /* Name of output file */ +unsigned OutputNameUsed = 0; /* Output name was used by %O */ unsigned ModuleId = 0; /* Id for o65 module */ diff --git a/src/ld65/global.h b/src/ld65/global.h index b3cf45020..9ddec43fb 100644 --- a/src/ld65/global.h +++ b/src/ld65/global.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2003 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 1998-2010, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -45,6 +45,7 @@ extern const char* OutputName; /* Name of output file */ +extern unsigned OutputNameUsed; /* Output name was used by %O */ extern unsigned ModuleId; /* Id for o65 module */ diff --git a/src/ld65/main.c b/src/ld65/main.c index 19356630c..47b43c671 100644 --- a/src/ld65/main.c +++ b/src/ld65/main.c @@ -449,6 +449,21 @@ static void OptObjPath (const char* Opt attribute ((unused)), const char* Arg) +static void OptOutputName (const char* Opt, const char* Arg) +/* Give the name of the output file */ +{ + /* If the name of the output file has been used in the config before + * (by using %O) we're actually changing it later, which - in most cases - + * gives unexpected results, so emit a warning in this case. + */ + if (OutputNameUsed) { + Warning ("Option `%s' should preceede options `-t' or `-C'", Opt); + } + OutputName = Arg; +} + + + static void OptStartAddr (const char* Opt, const char* Arg) /* Set the default start address */ { @@ -574,7 +589,7 @@ int main (int argc, char* argv []) break; case 'o': - OutputName = GetArg (&I, 2); + OptOutputName (Arg, GetArg (&I, 2)); break; case 't': @@ -652,14 +667,11 @@ int main (int argc, char* argv []) /* Create the condes tables if requested */ ConDesCreate (); - /* Process data from the config file */ - CfgProcess (); - - /* Assign start addresses for the segments, define linker symbols. The - * function will return the number of memory area overflows (zero on - * success). + /* Process data from the config file. Assign start addresses for the + * segments, define linker symbols. The function will return the number + * of memory area overflows (zero on success). */ - MemoryAreaOverflows = CfgAssignSegments (); + MemoryAreaOverflows = CfgProcess (); /* Check module assertions */ CheckAssertions (); diff --git a/src/ld65/scanner.c b/src/ld65/scanner.c index b27ec62c5..9809f3aea 100644 --- a/src/ld65/scanner.c +++ b/src/ld65/scanner.c @@ -200,6 +200,7 @@ static void StrVal (void) if (OutputName) { SB_AppendStr (&CfgSVal, OutputName); } + OutputNameUsed = 1; NextChar (); break; @@ -378,6 +379,7 @@ Again: SB_Clear (&CfgSVal); } SB_Terminate (&CfgSVal); + OutputNameUsed = 1; CfgTok = CFGTOK_STRCON; break;