1 /*****************************************************************************/
5 /* Target configuration file for the ld65 linker */
9 /* (C) 1998-2010, Ullrich von Bassewitz */
10 /* Roemerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
67 /*****************************************************************************/
69 /*****************************************************************************/
73 /* Remember which sections we had encountered */
82 } SectionsEncountered = SE_NONE;
87 static Collection FileList = STATIC_COLLECTION_INITIALIZER;
90 static Collection MemoryAreas = STATIC_COLLECTION_INITIALIZER;
92 /* Memory attributes */
93 #define MA_START 0x0001
94 #define MA_SIZE 0x0002
95 #define MA_TYPE 0x0004
96 #define MA_FILE 0x0008
97 #define MA_DEFINE 0x0010
98 #define MA_FILL 0x0020
99 #define MA_FILLVAL 0x0040
102 static Collection SegDescList = STATIC_COLLECTION_INITIALIZER;
104 /* Segment attributes */
105 #define SA_TYPE 0x0001
106 #define SA_LOAD 0x0002
107 #define SA_RUN 0x0004
108 #define SA_ALIGN 0x0008
109 #define SA_ALIGN_LOAD 0x0010
110 #define SA_DEFINE 0x0020
111 #define SA_OFFSET 0x0040
112 #define SA_START 0x0080
113 #define SA_OPTIONAL 0x0100
115 /* Symbol types used in the CfgSymbol structure */
117 CfgSymExport, /* Not really used in struct CfgSymbol */
118 CfgSymImport, /* Dito */
119 CfgSymWeak, /* Like export but weak */
120 CfgSymO65Export, /* An o65 export */
121 CfgSymO65Import, /* An o65 import */
124 /* Symbol structure. It is used for o65 imports and exports, but also for
125 * symbols from the SYMBOLS sections (symbols defined in the config file or
128 typedef struct CfgSymbol CfgSymbol;
130 CfgSymType Type; /* Type of symbol */
131 LineInfo* LI; /* Config file position */
132 unsigned Name; /* Symbol name */
133 ExprNode* Value; /* Symbol value if any */
134 unsigned AddrSize; /* Address size of symbol */
137 /* Collections with symbols */
138 static Collection CfgSymbols = STATIC_COLLECTION_INITIALIZER;
140 /* Descriptor holding information about the binary formats */
141 static BinDesc* BinFmtDesc = 0;
142 static O65Desc* O65FmtDesc = 0;
146 /*****************************************************************************/
148 /*****************************************************************************/
152 static File* NewFile (unsigned Name);
153 /* Create a new file descriptor and insert it into the list */
157 /*****************************************************************************/
158 /* List management */
159 /*****************************************************************************/
163 static File* FindFile (unsigned Name)
164 /* Find a file with a given name. */
167 for (I = 0; I < CollCount (&FileList); ++I) {
168 File* F = CollAtUnchecked (&FileList, I);
169 if (F->Name == Name) {
178 static File* GetFile (unsigned Name)
179 /* Get a file entry with the given name. Create a new one if needed. */
181 File* F = FindFile (Name);
183 /* Create a new one */
191 static void FileInsert (File* F, MemoryArea* M)
192 /* Insert the memory area into the files list */
195 CollAppend (&F->MemoryAreas, M);
200 static MemoryArea* CfgFindMemory (unsigned Name)
201 /* Find the memory are with the given name. Return NULL if not found */
204 for (I = 0; I < CollCount (&MemoryAreas); ++I) {
205 MemoryArea* M = CollAtUnchecked (&MemoryAreas, I);
206 if (M->Name == Name) {
215 static MemoryArea* CfgGetMemory (unsigned Name)
216 /* Find the memory are with the given name. Print an error on an invalid name */
218 MemoryArea* M = CfgFindMemory (Name);
220 CfgError (&CfgErrorPos, "Invalid memory area `%s'", GetString (Name));
227 static SegDesc* CfgFindSegDesc (unsigned Name)
228 /* Find the segment descriptor with the given name, return NULL if not found. */
231 for (I = 0; I < CollCount (&SegDescList); ++I) {
232 SegDesc* S = CollAtUnchecked (&SegDescList, I);
233 if (S->Name == Name) {
245 static void MemoryInsert (MemoryArea* M, SegDesc* S)
246 /* Insert the segment descriptor into the memory area list */
248 /* Insert the segment into the segment list of the memory area */
249 CollAppend (&M->SegList, S);
254 /*****************************************************************************/
255 /* Constructors/Destructors */
256 /*****************************************************************************/
260 static CfgSymbol* NewCfgSymbol (CfgSymType Type, unsigned Name)
261 /* Create a new CfgSymbol structure with the given type and name. The
262 * current config file position is recorded in the returned struct. The
263 * created struct is inserted into the CfgSymbols collection and returned.
266 /* Allocate memory */
267 CfgSymbol* Sym = xmalloc (sizeof (CfgSymbol));
269 /* Initialize the fields */
271 Sym->LI = GenLineInfo (&CfgErrorPos);
274 Sym->AddrSize = ADDR_SIZE_INVALID;
276 /* Insert the symbol into the collection */
277 CollAppend (&CfgSymbols, Sym);
279 /* Return the initialized struct */
285 static File* NewFile (unsigned Name)
286 /* Create a new file descriptor and insert it into the list */
288 /* Allocate memory */
289 File* F = xmalloc (sizeof (File));
291 /* Initialize the fields */
294 F->Format = BINFMT_DEFAULT;
295 InitCollection (&F->MemoryAreas);
297 /* Insert the struct into the list */
298 CollAppend (&FileList, F);
300 /* ...and return it */
306 static MemoryArea* CreateMemoryArea (const FilePos* Pos, unsigned Name)
307 /* Create a new memory area and insert it into the list */
309 /* Check for duplicate names */
310 MemoryArea* M = CfgFindMemory (Name);
312 CfgError (&CfgErrorPos,
313 "Memory area `%s' defined twice",
317 /* Create a new memory area */
318 M = NewMemoryArea (Pos, Name);
320 /* Insert the struct into the list ... */
321 CollAppend (&MemoryAreas, M);
323 /* ...and return it */
329 static SegDesc* NewSegDesc (unsigned Name)
330 /* Create a segment descriptor and insert it into the list */
333 /* Check for duplicate names */
334 SegDesc* S = CfgFindSegDesc (Name);
336 CfgError (&CfgErrorPos, "Segment `%s' defined twice", GetString (Name));
339 /* Allocate memory */
340 S = xmalloc (sizeof (SegDesc));
342 /* Initialize the fields */
344 S->LI = GenLineInfo (&CfgErrorPos);
350 /* Insert the struct into the list ... */
351 CollAppend (&SegDescList, S);
353 /* ...and return it */
359 static void FreeSegDesc (SegDesc* S)
360 /* Free a segment descriptor */
362 FreeLineInfo (S->LI);
368 /*****************************************************************************/
369 /* Config file parsing */
370 /*****************************************************************************/
374 static void FlagAttr (unsigned* Flags, unsigned Mask, const char* Name)
375 /* Check if the item is already defined. Print an error if so. If not, set
376 * the marker that we have a definition now.
380 CfgError (&CfgErrorPos, "%s is already defined", Name);
387 static void AttrCheck (unsigned Attr, unsigned Mask, const char* Name)
388 /* Check that a mandatory attribute was given */
390 if ((Attr & Mask) == 0) {
391 CfgError (&CfgErrorPos, "%s attribute is missing", Name);
397 static void ParseMemory (void)
398 /* Parse a MEMORY section */
400 static const IdentTok Attributes [] = {
401 { "START", CFGTOK_START },
402 { "SIZE", CFGTOK_SIZE },
403 { "TYPE", CFGTOK_TYPE },
404 { "FILE", CFGTOK_FILE },
405 { "DEFINE", CFGTOK_DEFINE },
406 { "FILL", CFGTOK_FILL },
407 { "FILLVAL", CFGTOK_FILLVAL },
409 static const IdentTok Types [] = {
414 while (CfgTok == CFGTOK_IDENT) {
416 /* Create a new entry on the heap */
417 MemoryArea* M = CreateMemoryArea (&CfgErrorPos, GetStrBufId (&CfgSVal));
419 /* Skip the name and the following colon */
423 /* Read the attributes */
424 while (CfgTok == CFGTOK_IDENT) {
426 /* Map the identifier to a token */
428 CfgSpecialToken (Attributes, ENTRY_COUNT (Attributes), "Attribute");
431 /* An optional assignment follows */
433 CfgOptionalAssign ();
435 /* Check which attribute was given */
439 FlagAttr (&M->Attr, MA_START, "START");
440 M->StartExpr = CfgExpr ();
444 FlagAttr (&M->Attr, MA_SIZE, "SIZE");
445 M->SizeExpr = CfgExpr ();
449 FlagAttr (&M->Attr, MA_TYPE, "TYPE");
450 CfgSpecialToken (Types, ENTRY_COUNT (Types), "Type");
451 if (CfgTok == CFGTOK_RO) {
458 FlagAttr (&M->Attr, MA_FILE, "FILE");
460 /* Get the file entry and insert the memory area */
461 FileInsert (GetFile (GetStrBufId (&CfgSVal)), M);
466 FlagAttr (&M->Attr, MA_DEFINE, "DEFINE");
467 /* Map the token to a boolean */
469 if (CfgTok == CFGTOK_TRUE) {
470 M->Flags |= MF_DEFINE;
476 FlagAttr (&M->Attr, MA_FILL, "FILL");
477 /* Map the token to a boolean */
479 if (CfgTok == CFGTOK_TRUE) {
486 FlagAttr (&M->Attr, MA_FILLVAL, "FILLVAL");
487 M->FillVal = (unsigned char) CfgCheckedConstExpr (0, 0xFF);
491 FAIL ("Unexpected attribute token");
495 /* Skip an optional comma */
499 /* Skip the semicolon */
502 /* Check for mandatory parameters */
503 AttrCheck (M->Attr, MA_START, "START");
504 AttrCheck (M->Attr, MA_SIZE, "SIZE");
506 /* If we don't have a file name for output given, use the default
509 if ((M->Attr & MA_FILE) == 0) {
510 FileInsert (GetFile (GetStringId (OutputName)), M);
515 /* Remember we had this section */
516 SectionsEncountered |= SE_MEMORY;
521 static void ParseFiles (void)
522 /* Parse a FILES section */
524 static const IdentTok Attributes [] = {
525 { "FORMAT", CFGTOK_FORMAT },
527 static const IdentTok Formats [] = {
528 { "O65", CFGTOK_O65 },
529 { "BIN", CFGTOK_BIN },
530 { "BINARY", CFGTOK_BIN },
534 /* The MEMORY section must preceed the FILES section */
535 if ((SectionsEncountered & SE_MEMORY) == 0) {
536 CfgError (&CfgErrorPos, "MEMORY must precede FILES");
539 /* Parse all files */
540 while (CfgTok != CFGTOK_RCURLY) {
544 /* We expect a string value here */
547 /* Search for the file, it must exist */
548 F = FindFile (GetStrBufId (&CfgSVal));
550 CfgError (&CfgErrorPos,
551 "File `%s' not found in MEMORY section",
552 SB_GetConstBuf (&CfgSVal));
555 /* Skip the token and the following colon */
559 /* Read the attributes */
560 while (CfgTok == CFGTOK_IDENT) {
562 /* Map the identifier to a token */
564 CfgSpecialToken (Attributes, ENTRY_COUNT (Attributes), "Attribute");
567 /* An optional assignment follows */
569 CfgOptionalAssign ();
571 /* Check which attribute was given */
575 if (F->Format != BINFMT_DEFAULT) {
576 /* We've set the format already! */
577 CfgError (&CfgErrorPos,
578 "Cannot set a file format twice");
580 /* Read the format token */
581 CfgSpecialToken (Formats, ENTRY_COUNT (Formats), "Format");
585 F->Format = BINFMT_BINARY;
589 F->Format = BINFMT_O65;
593 Error ("Unexpected format token");
598 FAIL ("Unexpected attribute token");
602 /* Skip the attribute value and an optional comma */
607 /* Skip the semicolon */
612 /* Remember we had this section */
613 SectionsEncountered |= SE_FILES;
618 static void ParseSegments (void)
619 /* Parse a SEGMENTS section */
621 static const IdentTok Attributes [] = {
622 { "ALIGN", CFGTOK_ALIGN },
623 { "ALIGN_LOAD", CFGTOK_ALIGN_LOAD },
624 { "DEFINE", CFGTOK_DEFINE },
625 { "LOAD", CFGTOK_LOAD },
626 { "OFFSET", CFGTOK_OFFSET },
627 { "OPTIONAL", CFGTOK_OPTIONAL },
628 { "RUN", CFGTOK_RUN },
629 { "START", CFGTOK_START },
630 { "TYPE", CFGTOK_TYPE },
632 static const IdentTok Types [] = {
635 { "BSS", CFGTOK_BSS },
642 /* The MEMORY section must preceed the SEGMENTS section */
643 if ((SectionsEncountered & SE_MEMORY) == 0) {
644 CfgError (&CfgErrorPos, "MEMORY must precede SEGMENTS");
647 while (CfgTok == CFGTOK_IDENT) {
651 /* Create a new entry on the heap */
652 S = NewSegDesc (GetStrBufId (&CfgSVal));
654 /* Skip the name and the following colon */
658 /* Read the attributes */
659 while (CfgTok == CFGTOK_IDENT) {
661 /* Map the identifier to a token */
663 CfgSpecialToken (Attributes, ENTRY_COUNT (Attributes), "Attribute");
666 /* An optional assignment follows */
668 CfgOptionalAssign ();
670 /* Check which attribute was given */
674 FlagAttr (&S->Attr, SA_ALIGN, "ALIGN");
675 Val = CfgCheckedConstExpr (1, 0x10000);
676 S->Align = BitFind (Val);
677 if ((0x01L << S->Align) != Val) {
678 CfgError (&CfgErrorPos, "Alignment must be a power of 2");
680 S->Flags |= SF_ALIGN;
683 case CFGTOK_ALIGN_LOAD:
684 FlagAttr (&S->Attr, SA_ALIGN_LOAD, "ALIGN_LOAD");
685 Val = CfgCheckedConstExpr (1, 0x10000);
686 S->AlignLoad = BitFind (Val);
687 if ((0x01L << S->AlignLoad) != Val) {
688 CfgError (&CfgErrorPos, "Alignment must be a power of 2");
690 S->Flags |= SF_ALIGN_LOAD;
694 FlagAttr (&S->Attr, SA_DEFINE, "DEFINE");
695 /* Map the token to a boolean */
697 if (CfgTok == CFGTOK_TRUE) {
698 S->Flags |= SF_DEFINE;
704 FlagAttr (&S->Attr, SA_LOAD, "LOAD");
705 S->Load = CfgGetMemory (GetStrBufId (&CfgSVal));
710 FlagAttr (&S->Attr, SA_OFFSET, "OFFSET");
711 S->Addr = CfgCheckedConstExpr (1, 0x1000000);
712 S->Flags |= SF_OFFSET;
715 case CFGTOK_OPTIONAL:
716 FlagAttr (&S->Attr, SA_OPTIONAL, "OPTIONAL");
718 if (CfgTok == CFGTOK_TRUE) {
719 S->Flags |= SF_OPTIONAL;
725 FlagAttr (&S->Attr, SA_RUN, "RUN");
726 S->Run = CfgGetMemory (GetStrBufId (&CfgSVal));
731 FlagAttr (&S->Attr, SA_START, "START");
732 S->Addr = CfgCheckedConstExpr (1, 0x1000000);
733 S->Flags |= SF_START;
737 FlagAttr (&S->Attr, SA_TYPE, "TYPE");
738 CfgSpecialToken (Types, ENTRY_COUNT (Types), "Type");
740 case CFGTOK_RO: S->Flags |= SF_RO; break;
741 case CFGTOK_RW: /* Default */ break;
742 case CFGTOK_BSS: S->Flags |= SF_BSS; break;
743 case CFGTOK_ZP: S->Flags |= (SF_BSS | SF_ZP); break;
744 default: Internal ("Unexpected token: %d", CfgTok);
750 FAIL ("Unexpected attribute token");
754 /* Skip an optional comma */
758 /* Check for mandatory parameters */
759 AttrCheck (S->Attr, SA_LOAD, "LOAD");
761 /* Set defaults for stuff not given */
762 if ((S->Attr & SA_RUN) == 0) {
767 /* An attribute of ALIGN_LOAD doesn't make sense if there are no
768 * separate run and load memory areas.
770 if ((S->Flags & SF_ALIGN_LOAD) != 0 && (S->Load == S->Run)) {
771 CfgWarning (&CfgErrorPos,
772 "ALIGN_LOAD attribute specified, but no separate "
773 "LOAD and RUN memory areas assigned");
774 /* Remove the flag */
775 S->Flags &= ~SF_ALIGN_LOAD;
778 /* If the segment is marked as BSS style, it may not have separate
779 * load and run memory areas, because it's is never written to disk.
781 if ((S->Flags & SF_BSS) != 0 && (S->Load != S->Run)) {
782 CfgWarning (&CfgErrorPos,
783 "Segment with type `bss' has both LOAD and RUN "
784 "memory areas assigned");
787 /* Don't allow read/write data to be put into a readonly area */
788 if ((S->Flags & SF_RO) == 0) {
789 if (S->Run->Flags & MF_RO) {
790 CfgError (&CfgErrorPos,
791 "Cannot put r/w segment `%s' in r/o memory area `%s'",
792 GetString (S->Name), GetString (S->Run->Name));
796 /* Only one of ALIGN, START and OFFSET may be used */
797 Count = ((S->Flags & SF_ALIGN) != 0) +
798 ((S->Flags & SF_OFFSET) != 0) +
799 ((S->Flags & SF_START) != 0);
801 CfgError (&CfgErrorPos,
802 "Only one of ALIGN, START, OFFSET may be used");
805 /* Skip the semicolon */
809 /* Remember we had this section */
810 SectionsEncountered |= SE_SEGMENTS;
815 static void ParseO65 (void)
816 /* Parse the o65 format section */
818 static const IdentTok Attributes [] = {
819 { "EXPORT", CFGTOK_EXPORT },
820 { "IMPORT", CFGTOK_IMPORT },
821 { "TYPE", CFGTOK_TYPE },
824 { "VERSION", CFGTOK_VERSION },
826 static const IdentTok Types [] = {
827 { "SMALL", CFGTOK_SMALL },
828 { "LARGE", CFGTOK_LARGE },
830 static const IdentTok OperatingSystems [] = {
831 { "LUNIX", CFGTOK_LUNIX },
832 { "OSA65", CFGTOK_OSA65 },
833 { "CC65", CFGTOK_CC65 },
834 { "OPENCBM", CFGTOK_OPENCBM },
837 /* Bitmask to remember the attributes we got already */
841 atOSVersion = 0x0002,
848 unsigned AttrFlags = atNone;
850 /* Remember the attributes read */
851 unsigned OS = 0; /* Initialize to keep gcc happy */
852 unsigned Version = 0;
854 /* Read the attributes */
855 while (CfgTok == CFGTOK_IDENT) {
857 /* Map the identifier to a token */
859 CfgSpecialToken (Attributes, ENTRY_COUNT (Attributes), "Attribute");
862 /* An optional assignment follows */
864 CfgOptionalAssign ();
866 /* Check which attribute was given */
870 /* Remember we had this token (maybe more than once) */
871 AttrFlags |= atExport;
872 /* We expect an identifier */
874 /* Remember it as an export for later */
875 NewCfgSymbol (CfgSymO65Export, GetStrBufId (&CfgSVal));
876 /* Eat the identifier token */
881 /* Remember we had this token (maybe more than once) */
882 AttrFlags |= atImport;
883 /* We expect an identifier */
885 /* Remember it as an import for later */
886 NewCfgSymbol (CfgSymO65Import, GetStrBufId (&CfgSVal));
887 /* Eat the identifier token */
892 /* Cannot have this attribute twice */
893 FlagAttr (&AttrFlags, atType, "TYPE");
894 /* Get the type of the executable */
895 CfgSpecialToken (Types, ENTRY_COUNT (Types), "Type");
899 O65SetSmallModel (O65FmtDesc);
903 O65SetLargeModel (O65FmtDesc);
907 CfgError (&CfgErrorPos, "Unexpected type token");
909 /* Eat the attribute token */
914 /* Cannot use this attribute twice */
915 FlagAttr (&AttrFlags, atOS, "OS");
916 /* Get the operating system. It may be specified as name or
917 * as a number in the range 1..255.
919 if (CfgTok == CFGTOK_INTCON) {
920 CfgRangeCheck (O65OS_MIN, O65OS_MAX);
921 OS = (unsigned) CfgIVal;
923 CfgSpecialToken (OperatingSystems, ENTRY_COUNT (OperatingSystems), "OS type");
925 case CFGTOK_LUNIX: OS = O65OS_LUNIX; break;
926 case CFGTOK_OSA65: OS = O65OS_OSA65; break;
927 case CFGTOK_CC65: OS = O65OS_CC65; break;
928 case CFGTOK_OPENCBM: OS = O65OS_OPENCBM; break;
929 default: CfgError (&CfgErrorPos, "Unexpected OS token");
936 /* Cannot have this attribute twice */
937 FlagAttr (&AttrFlags, atID, "ID");
938 /* We're expecting a number in the 0..$FFFF range*/
939 ModuleId = (unsigned) CfgCheckedConstExpr (0, 0xFFFF);
943 /* Cannot have this attribute twice */
944 FlagAttr (&AttrFlags, atVersion, "VERSION");
945 /* We're expecting a number in byte range */
946 Version = (unsigned) CfgCheckedConstExpr (0, 0xFF);
950 FAIL ("Unexpected attribute token");
954 /* Skip an optional comma */
958 /* Check if we have all mandatory attributes */
959 AttrCheck (AttrFlags, atOS, "OS");
961 /* Check for attributes that may not be combined */
962 if (OS == O65OS_CC65) {
963 if ((AttrFlags & (atImport | atExport)) != 0 && ModuleId < 0x8000) {
964 CfgError (&CfgErrorPos,
965 "OS type CC65 may not have imports or exports for ids < $8000");
968 if (AttrFlags & atID) {
969 CfgError (&CfgErrorPos,
970 "Operating system does not support the ID attribute");
974 /* Set the O65 operating system to use */
975 O65SetOS (O65FmtDesc, OS, Version, ModuleId);
980 static void ParseFormats (void)
981 /* Parse a target format section */
983 static const IdentTok Formats [] = {
984 { "O65", CFGTOK_O65 },
985 { "BIN", CFGTOK_BIN },
986 { "BINARY", CFGTOK_BIN },
989 while (CfgTok == CFGTOK_IDENT) {
991 /* Map the identifier to a token */
993 CfgSpecialToken (Formats, ENTRY_COUNT (Formats), "Format");
996 /* Skip the name and the following colon */
1000 /* Parse the format options */
1001 switch (FormatTok) {
1008 /* No attribibutes available */
1012 Error ("Unexpected format token");
1015 /* Skip the semicolon */
1020 /* Remember we had this section */
1021 SectionsEncountered |= SE_FORMATS;
1026 static void ParseConDes (void)
1027 /* Parse the CONDES feature */
1029 static const IdentTok Attributes [] = {
1030 { "SEGMENT", CFGTOK_SEGMENT },
1031 { "LABEL", CFGTOK_LABEL },
1032 { "COUNT", CFGTOK_COUNT },
1033 { "TYPE", CFGTOK_TYPE },
1034 { "ORDER", CFGTOK_ORDER },
1037 static const IdentTok Types [] = {
1038 { "CONSTRUCTOR", CFGTOK_CONSTRUCTOR },
1039 { "DESTRUCTOR", CFGTOK_DESTRUCTOR },
1040 { "INTERRUPTOR", CFGTOK_INTERRUPTOR },
1043 static const IdentTok Orders [] = {
1044 { "DECREASING", CFGTOK_DECREASING },
1045 { "INCREASING", CFGTOK_INCREASING },
1048 /* Attribute values. */
1049 unsigned SegName = INVALID_STRING_ID;
1050 unsigned Label = INVALID_STRING_ID;
1051 unsigned Count = INVALID_STRING_ID;
1052 /* Initialize to avoid gcc warnings: */
1054 ConDesOrder Order = cdIncreasing;
1056 /* Bitmask to remember the attributes we got already */
1065 unsigned AttrFlags = atNone;
1067 /* Parse the attributes */
1070 /* Map the identifier to a token */
1072 CfgSpecialToken (Attributes, ENTRY_COUNT (Attributes), "Attribute");
1075 /* An optional assignment follows */
1077 CfgOptionalAssign ();
1079 /* Check which attribute was given */
1082 case CFGTOK_SEGMENT:
1083 /* Don't allow this twice */
1084 FlagAttr (&AttrFlags, atSegName, "SEGMENT");
1085 /* We expect an identifier */
1087 /* Remember the value for later */
1088 SegName = GetStrBufId (&CfgSVal);
1092 /* Don't allow this twice */
1093 FlagAttr (&AttrFlags, atLabel, "LABEL");
1094 /* We expect an identifier */
1096 /* Remember the value for later */
1097 Label = GetStrBufId (&CfgSVal);
1101 /* Don't allow this twice */
1102 FlagAttr (&AttrFlags, atCount, "COUNT");
1103 /* We expect an identifier */
1105 /* Remember the value for later */
1106 Count = GetStrBufId (&CfgSVal);
1110 /* Don't allow this twice */
1111 FlagAttr (&AttrFlags, atType, "TYPE");
1112 /* The type may be given as id or numerical */
1113 if (CfgTok == CFGTOK_INTCON) {
1114 CfgRangeCheck (CD_TYPE_MIN, CD_TYPE_MAX);
1115 Type = (int) CfgIVal;
1117 CfgSpecialToken (Types, ENTRY_COUNT (Types), "Type");
1119 case CFGTOK_CONSTRUCTOR: Type = CD_TYPE_CON; break;
1120 case CFGTOK_DESTRUCTOR: Type = CD_TYPE_DES; break;
1121 case CFGTOK_INTERRUPTOR: Type = CD_TYPE_INT; break;
1122 default: FAIL ("Unexpected type token");
1128 /* Don't allow this twice */
1129 FlagAttr (&AttrFlags, atOrder, "ORDER");
1130 CfgSpecialToken (Orders, ENTRY_COUNT (Orders), "Order");
1132 case CFGTOK_DECREASING: Order = cdDecreasing; break;
1133 case CFGTOK_INCREASING: Order = cdIncreasing; break;
1134 default: FAIL ("Unexpected order token");
1139 FAIL ("Unexpected attribute token");
1143 /* Skip the attribute value */
1146 /* Semicolon ends the ConDes decl, otherwise accept an optional comma */
1147 if (CfgTok == CFGTOK_SEMI) {
1149 } else if (CfgTok == CFGTOK_COMMA) {
1154 /* Check if we have all mandatory attributes */
1155 AttrCheck (AttrFlags, atSegName, "SEGMENT");
1156 AttrCheck (AttrFlags, atLabel, "LABEL");
1157 AttrCheck (AttrFlags, atType, "TYPE");
1159 /* Check if the condes has already attributes defined */
1160 if (ConDesHasSegName(Type) || ConDesHasLabel(Type)) {
1161 CfgError (&CfgErrorPos,
1162 "CONDES attributes for type %d are already defined",
1166 /* Define the attributes */
1167 ConDesSetSegName (Type, SegName);
1168 ConDesSetLabel (Type, Label);
1169 if (AttrFlags & atCount) {
1170 ConDesSetCountSym (Type, Count);
1172 if (AttrFlags & atOrder) {
1173 ConDesSetOrder (Type, Order);
1179 static void ParseStartAddress (void)
1180 /* Parse the STARTADDRESS feature */
1182 static const IdentTok Attributes [] = {
1183 { "DEFAULT", CFGTOK_DEFAULT },
1187 /* Attribute values. */
1188 unsigned long DefStartAddr = 0;
1190 /* Bitmask to remember the attributes we got already */
1195 unsigned AttrFlags = atNone;
1197 /* Parse the attributes */
1200 /* Map the identifier to a token */
1202 CfgSpecialToken (Attributes, ENTRY_COUNT (Attributes), "Attribute");
1205 /* An optional assignment follows */
1207 CfgOptionalAssign ();
1209 /* Check which attribute was given */
1212 case CFGTOK_DEFAULT:
1213 /* Don't allow this twice */
1214 FlagAttr (&AttrFlags, atDefault, "DEFAULT");
1215 /* We expect a numeric expression */
1216 DefStartAddr = CfgCheckedConstExpr (0, 0xFFFFFF);
1220 FAIL ("Unexpected attribute token");
1224 /* Semicolon ends the ConDes decl, otherwise accept an optional comma */
1225 if (CfgTok == CFGTOK_SEMI) {
1227 } else if (CfgTok == CFGTOK_COMMA) {
1232 /* Check if we have all mandatory attributes */
1233 AttrCheck (AttrFlags, atDefault, "DEFAULT");
1235 /* If no start address was given on the command line, use the one given
1238 if (!HaveStartAddr) {
1239 StartAddr = DefStartAddr;
1245 static void ParseFeatures (void)
1246 /* Parse a features section */
1248 static const IdentTok Features [] = {
1249 { "CONDES", CFGTOK_CONDES },
1250 { "STARTADDRESS", CFGTOK_STARTADDRESS },
1253 while (CfgTok == CFGTOK_IDENT) {
1255 /* Map the identifier to a token */
1256 cfgtok_t FeatureTok;
1257 CfgSpecialToken (Features, ENTRY_COUNT (Features), "Feature");
1258 FeatureTok = CfgTok;
1260 /* Skip the name and the following colon */
1264 /* Parse the format options */
1265 switch (FeatureTok) {
1271 case CFGTOK_STARTADDRESS:
1272 ParseStartAddress ();
1277 FAIL ("Unexpected feature token");
1280 /* Skip the semicolon */
1284 /* Remember we had this section */
1285 SectionsEncountered |= SE_FEATURES;
1290 static void ParseSymbols (void)
1291 /* Parse a symbols section */
1293 static const IdentTok Attributes[] = {
1294 { "ADDRSIZE", CFGTOK_ADDRSIZE },
1295 { "TYPE", CFGTOK_TYPE },
1296 { "VALUE", CFGTOK_VALUE },
1299 static const IdentTok AddrSizes [] = {
1300 { "ABS", CFGTOK_ABS },
1301 { "ABSOLUTE", CFGTOK_ABS },
1302 { "DIRECT", CFGTOK_ZP },
1303 { "DWORD", CFGTOK_LONG },
1304 { "FAR", CFGTOK_FAR },
1305 { "LONG", CFGTOK_LONG },
1306 { "NEAR", CFGTOK_ABS },
1307 { "ZEROPAGE", CFGTOK_ZP },
1308 { "ZP", CFGTOK_ZP },
1311 static const IdentTok Types [] = {
1312 { "EXPORT", CFGTOK_EXPORT },
1313 { "IMPORT", CFGTOK_IMPORT },
1314 { "WEAK", CFGTOK_WEAK },
1317 while (CfgTok == CFGTOK_IDENT) {
1319 /* Bitmask to remember the attributes we got already */
1322 atAddrSize = 0x0001,
1326 unsigned AttrFlags = atNone;
1328 ExprNode* Value = 0;
1329 CfgSymType Type = CfgSymExport;
1330 unsigned char AddrSize = ADDR_SIZE_ABS;
1335 /* Remember the name */
1336 unsigned Name = GetStrBufId (&CfgSVal);
1339 /* New syntax - skip the colon */
1342 /* Parse the attributes */
1345 /* Map the identifier to a token */
1347 CfgSpecialToken (Attributes, ENTRY_COUNT (Attributes), "Attribute");
1350 /* Skip the attribute name */
1353 /* An optional assignment follows */
1354 CfgOptionalAssign ();
1356 /* Check which attribute was given */
1359 case CFGTOK_ADDRSIZE:
1360 /* Don't allow this twice */
1361 FlagAttr (&AttrFlags, atAddrSize, "ADDRSIZE");
1362 /* Map the type to a token */
1363 CfgSpecialToken (AddrSizes, ENTRY_COUNT (AddrSizes), "AddrSize");
1365 case CFGTOK_ABS: AddrSize = ADDR_SIZE_ABS; break;
1366 case CFGTOK_FAR: AddrSize = ADDR_SIZE_FAR; break;
1367 case CFGTOK_LONG: AddrSize = ADDR_SIZE_LONG; break;
1368 case CFGTOK_ZP: AddrSize = ADDR_SIZE_ZP; break;
1370 Internal ("Unexpected token: %d", CfgTok);
1376 /* Don't allow this twice */
1377 FlagAttr (&AttrFlags, atType, "TYPE");
1378 /* Map the type to a token */
1379 CfgSpecialToken (Types, ENTRY_COUNT (Types), "Type");
1381 case CFGTOK_EXPORT: Type = CfgSymExport; break;
1382 case CFGTOK_IMPORT: Type = CfgSymImport; break;
1383 case CFGTOK_WEAK: Type = CfgSymWeak; break;
1385 Internal ("Unexpected token: %d", CfgTok);
1391 /* Don't allow this twice */
1392 FlagAttr (&AttrFlags, atValue, "VALUE");
1393 /* Value is an expression */
1398 FAIL ("Unexpected attribute token");
1402 /* Semicolon ends the decl, otherwise accept an optional comma */
1403 if (CfgTok == CFGTOK_SEMI) {
1405 } else if (CfgTok == CFGTOK_COMMA) {
1410 /* We must have a type */
1411 AttrCheck (AttrFlags, atType, "TYPE");
1413 /* Further actions depend on the type */
1417 /* We must have a value */
1418 AttrCheck (AttrFlags, atType, "TYPE");
1419 /* Create the export */
1420 Exp = CreateExprExport (Name, Value, AddrSize);
1421 CollAppend (&Exp->LineInfos, GenLineInfo (&CfgErrorPos));
1425 /* An import must not have a value */
1426 if (AttrFlags & atValue) {
1427 CfgError (&CfgErrorPos, "Imports must not have a value");
1429 /* Generate the import */
1430 Imp = InsertImport (GenImport (Name, AddrSize));
1431 /* Remember the file position */
1432 CollAppend (&Imp->LineInfos, GenLineInfo (&CfgErrorPos));
1436 /* We must have a value */
1437 AttrCheck (AttrFlags, atType, "TYPE");
1438 /* Remember the symbol for later */
1439 Sym = NewCfgSymbol (CfgSymWeak, Name);
1441 Sym->AddrSize = AddrSize;
1445 Internal ("Unexpected symbol type %d", Type);
1448 /* Skip the semicolon */
1452 /* Remember we had this section */
1453 SectionsEncountered |= SE_SYMBOLS;
1458 static void ParseConfig (void)
1459 /* Parse the config file */
1461 static const IdentTok BlockNames [] = {
1462 { "MEMORY", CFGTOK_MEMORY },
1463 { "FILES", CFGTOK_FILES },
1464 { "SEGMENTS", CFGTOK_SEGMENTS },
1465 { "FORMATS", CFGTOK_FORMATS },
1466 { "FEATURES", CFGTOK_FEATURES },
1467 { "SYMBOLS", CFGTOK_SYMBOLS },
1473 /* Read the block ident */
1474 CfgSpecialToken (BlockNames, ENTRY_COUNT (BlockNames), "Block identifier");
1478 /* Expected a curly brace */
1479 CfgConsume (CFGTOK_LCURLY, "`{' expected");
1481 /* Read the block */
1492 case CFGTOK_SEGMENTS:
1496 case CFGTOK_FORMATS:
1500 case CFGTOK_FEATURES:
1504 case CFGTOK_SYMBOLS:
1509 FAIL ("Unexpected block token");
1513 /* Skip closing brace */
1514 CfgConsume (CFGTOK_RCURLY, "`}' expected");
1516 } while (CfgTok != CFGTOK_EOF);
1522 /* Read the configuration */
1524 /* Create the descriptors for the binary formats */
1525 BinFmtDesc = NewBinDesc ();
1526 O65FmtDesc = NewO65Desc ();
1528 /* If we have a config name given, open the file, otherwise we will read
1533 /* Parse the file */
1536 /* Close the input file */
1542 /*****************************************************************************/
1543 /* Config file processing */
1544 /*****************************************************************************/
1548 static void ProcessSegments (void)
1549 /* Process the SEGMENTS section */
1553 /* Walk over the list of segment descriptors */
1555 while (I < CollCount (&SegDescList)) {
1557 /* Get the next segment descriptor */
1558 SegDesc* S = CollAtUnchecked (&SegDescList, I);
1560 /* Search for the actual segment in the input files. The function may
1561 * return NULL (no such segment), this is checked later.
1563 S->Seg = SegFind (S->Name);
1565 /* If the segment is marked as BSS style, and if the segment exists
1566 * in any of the object file, check that there's no initialized data
1569 if ((S->Flags & SF_BSS) != 0 && S->Seg != 0 && !IsBSSType (S->Seg)) {
1570 CfgWarning (GetSourcePos (S->LI),
1571 "Segment `%s' with type `bss' contains initialized data",
1572 GetString (S->Name));
1575 /* If this segment does exist in any of the object files, insert the
1576 * segment into the load/run memory areas. Otherwise print a warning
1577 * and discard it, because the segment pointer in the descriptor is
1582 /* Insert the segment into the memory area list */
1583 MemoryInsert (S->Run, S);
1584 if (S->Load != S->Run) {
1585 /* We have separate RUN and LOAD areas */
1586 MemoryInsert (S->Load, S);
1589 /* Process the next segment descriptor in the next run */
1594 /* Print a warning if the segment is not optional */
1595 if ((S->Flags & SF_OPTIONAL) == 0) {
1596 CfgWarning (&CfgErrorPos,
1597 "Segment `%s' does not exist",
1598 GetString (S->Name));
1601 /* Discard the descriptor and remove it from the collection */
1603 CollDelete (&SegDescList, I);
1610 static void ProcessSymbols (void)
1611 /* Process the SYMBOLS section */
1615 /* Walk over all symbols */
1617 for (I = 0; I < CollCount (&CfgSymbols); ++I) {
1619 /* Get the next symbol */
1620 CfgSymbol* Sym = CollAtUnchecked (&CfgSymbols, I);
1622 /* Check what it is. */
1623 switch (Sym->Type) {
1625 case CfgSymO65Export:
1626 /* Check if the export symbol is also defined as an import. */
1627 if (O65GetImport (O65FmtDesc, Sym->Name) != 0) {
1629 GetSourcePos (Sym->LI),
1630 "Exported o65 symbol `%s' cannot also be an o65 import",
1631 GetString (Sym->Name)
1635 /* Check if we have this symbol defined already. The entry
1636 * routine will check this also, but we get a more verbose
1637 * error message when checking it here.
1639 if (O65GetExport (O65FmtDesc, Sym->Name) != 0) {
1641 GetSourcePos (Sym->LI),
1642 "Duplicate exported o65 symbol: `%s'",
1643 GetString (Sym->Name)
1647 /* Insert the symbol into the table */
1648 O65SetExport (O65FmtDesc, Sym->Name);
1651 case CfgSymO65Import:
1652 /* Check if the import symbol is also defined as an export. */
1653 if (O65GetExport (O65FmtDesc, Sym->Name) != 0) {
1655 GetSourcePos (Sym->LI),
1656 "Imported o65 symbol `%s' cannot also be an o65 export",
1657 GetString (Sym->Name)
1661 /* Check if we have this symbol defined already. The entry
1662 * routine will check this also, but we get a more verbose
1663 * error message when checking it here.
1665 if (O65GetImport (O65FmtDesc, Sym->Name) != 0) {
1667 GetSourcePos (Sym->LI),
1668 "Duplicate imported o65 symbol: `%s'",
1669 GetString (Sym->Name)
1673 /* Insert the symbol into the table */
1674 O65SetImport (O65FmtDesc, Sym->Name);
1678 /* If the symbol is not defined until now, define it */
1679 if ((E = FindExport (Sym->Name)) == 0 || IsUnresolvedExport (E)) {
1680 /* The symbol is undefined, generate an export */
1681 E = CreateExprExport (Sym->Name, Sym->Value, Sym->AddrSize);
1682 CollAppend (&E->LineInfos, Sym->LI);
1687 Internal ("Unexpected symbol type %d", Sym->Type);
1696 static void CreateRunDefines (SegDesc* S, unsigned long SegAddr)
1697 /* Create the defines for a RUN segment */
1700 StrBuf Buf = STATIC_STRBUF_INITIALIZER;
1702 /* Define the run address of the segment */
1703 SB_Printf (&Buf, "__%s_RUN__", GetString (S->Name));
1704 E = CreateMemoryExport (GetStrBufId (&Buf), S->Run, SegAddr - S->Run->Start);
1705 CollAppend (&E->LineInfos, S->LI);
1707 /* Define the size of the segment */
1708 SB_Printf (&Buf, "__%s_SIZE__", GetString (S->Name));
1709 E = CreateConstExport (GetStrBufId (&Buf), S->Seg->Size);
1710 CollAppend (&E->LineInfos, S->LI);
1712 S->Flags |= SF_RUN_DEF;
1718 static void CreateLoadDefines (SegDesc* S, unsigned long SegAddr)
1719 /* Create the defines for a LOAD segment */
1722 StrBuf Buf = STATIC_STRBUF_INITIALIZER;
1724 /* Define the load address of the segment */
1725 SB_Printf (&Buf, "__%s_LOAD__", GetString (S->Name));
1726 E = CreateMemoryExport (GetStrBufId (&Buf), S->Load, SegAddr - S->Load->Start);
1727 CollAppend (&E->LineInfos, S->LI);
1729 S->Flags |= SF_LOAD_DEF;
1735 unsigned CfgProcess (void)
1736 /* Process the config file after reading in object files and libraries. This
1737 * includes postprocessing of the config file data but also assigning segments
1738 * and defining segment/memory area related symbols. The function will return
1739 * the number of memory area overflows (so zero means anything went ok).
1740 * In case of overflows, a short mapfile can be generated later, to ease the
1741 * task of rearranging segments for the user.
1744 unsigned Overflows = 0;
1747 /* Postprocess symbols. We must do that first, since weak symbols are
1748 * defined here, which may be needed later.
1752 /* Postprocess segments */
1755 /* Walk through each of the memory sections. Add up the sizes and check
1756 * for an overflow of the section. Assign the start addresses of the
1757 * segments while doing this.
1759 for (I = 0; I < CollCount (&MemoryAreas); ++I) {
1764 /* Get the next memory area */
1765 MemoryArea* M = CollAtUnchecked (&MemoryAreas, I);
1767 /* Remember if this is a relocatable memory area */
1768 M->Relocatable = RelocatableBinFmt (M->F->Format);
1770 /* Resolve the start address expression, remember the start address
1771 * and mark the memory area as placed.
1773 if (!IsConstExpr (M->StartExpr)) {
1774 CfgError (GetSourcePos (M->LI),
1775 "Start address of memory area `%s' is not constant",
1776 GetString (M->Name));
1778 Addr = M->Start = GetExprVal (M->StartExpr);
1779 M->Flags |= MF_PLACED;
1781 /* If requested, define the symbol for the start of the memory area.
1782 * Doing it here means that the expression for the size of the area
1783 * may reference this symbol.
1785 if (M->Flags & MF_DEFINE) {
1787 StrBuf Buf = STATIC_STRBUF_INITIALIZER;
1789 /* Define the start of the memory area */
1790 SB_Printf (&Buf, "__%s_START__", GetString (M->Name));
1791 E = CreateMemoryExport (GetStrBufId (&Buf), M, 0);
1792 CollAppend (&E->LineInfos, M->LI);
1797 /* Resolve the size expression */
1798 if (!IsConstExpr (M->SizeExpr)) {
1799 CfgError (GetSourcePos (M->LI),
1800 "Size of memory area `%s' is not constant",
1801 GetString (M->Name));
1803 M->Size = GetExprVal (M->SizeExpr);
1805 /* Walk through the segments in this memory area */
1806 for (J = 0; J < CollCount (&M->SegList); ++J) {
1808 /* Get the segment */
1809 SegDesc* S = CollAtUnchecked (&M->SegList, J);
1811 /* Some actions depend on wether this is the load or run memory
1816 /* This is the run (and maybe load) memory area. Handle
1817 * alignment and explict start address and offset.
1819 if (S->Flags & SF_ALIGN) {
1820 /* Align the address */
1821 unsigned long Val = (0x01UL << S->Align) - 1;
1822 Addr = (Addr + Val) & ~Val;
1823 } else if (S->Flags & (SF_OFFSET | SF_START)) {
1824 /* Give the segment a fixed starting address */
1825 unsigned long NewAddr = S->Addr;
1826 if (S->Flags & SF_OFFSET) {
1827 /* An offset was given, no address, make an address */
1828 NewAddr += M->Start;
1830 if (Addr > NewAddr) {
1831 /* Offset already too large */
1832 if (S->Flags & SF_OFFSET) {
1833 CfgError (GetSourcePos (M->LI),
1834 "Offset too small in `%s', segment `%s'",
1835 GetString (M->Name),
1836 GetString (S->Name));
1838 CfgError (GetSourcePos (M->LI),
1839 "Start address too low in `%s', segment `%s'",
1840 GetString (M->Name),
1841 GetString (S->Name));
1847 /* Set the start address of this segment, set the readonly flag
1848 * in the segment and and remember if the segment is in a
1849 * relocatable file or not.
1852 S->Seg->ReadOnly = (S->Flags & SF_RO) != 0;
1853 S->Seg->Relocatable = M->Relocatable;
1855 /* Remember that this segment is placed */
1858 } else if (S->Load == M) {
1860 /* This is the load memory area, *and* run and load are
1861 * different (because of the "else" above). Handle alignment.
1863 if (S->Flags & SF_ALIGN_LOAD) {
1864 /* Align the address */
1865 unsigned long Val = (0x01UL << S->AlignLoad) - 1;
1866 Addr = (Addr + Val) & ~Val;
1871 /* Increment the fill level of the memory area and check for an
1874 M->FillLevel = Addr + S->Seg->Size - M->Start;
1875 if (M->FillLevel > M->Size && (M->Flags & MF_OVERFLOW) == 0) {
1877 M->Flags |= MF_OVERFLOW;
1878 CfgWarning (GetSourcePos (M->LI),
1879 "Memory area overflow in `%s', segment `%s' (%lu bytes)",
1880 GetString (M->Name), GetString (S->Name),
1881 M->FillLevel - M->Size);
1884 /* If requested, define symbols for the start and size of the
1887 if (S->Flags & SF_DEFINE) {
1888 if (S->Run == M && (S->Flags & SF_RUN_DEF) == 0) {
1889 CreateRunDefines (S, Addr);
1891 if (S->Load == M && (S->Flags & SF_LOAD_DEF) == 0) {
1892 CreateLoadDefines (S, Addr);
1896 /* Calculate the new address */
1897 Addr += S->Seg->Size;
1901 /* If requested, define symbols for start and size of the memory area */
1902 if (M->Flags & MF_DEFINE) {
1904 StrBuf Buf = STATIC_STRBUF_INITIALIZER;
1906 /* Define the size of the memory area */
1907 SB_Printf (&Buf, "__%s_SIZE__", GetString (M->Name));
1908 E = CreateConstExport (GetStrBufId (&Buf), M->Size);
1909 CollAppend (&E->LineInfos, M->LI);
1911 /* Define the fill level of the memory area */
1912 SB_Printf (&Buf, "__%s_LAST__", GetString (M->Name));
1913 E = CreateMemoryExport (GetStrBufId (&Buf), M, M->FillLevel);
1914 CollAppend (&E->LineInfos, M->LI);
1921 /* Return the number of memory area overflows */
1927 void CfgWriteTarget (void)
1928 /* Write the target file(s) */
1932 /* Walk through the files list */
1933 for (I = 0; I < CollCount (&FileList); ++I) {
1935 /* Get this entry */
1936 File* F = CollAtUnchecked (&FileList, I);
1938 /* We don't need to look at files with no memory areas */
1939 if (CollCount (&F->MemoryAreas) > 0) {
1941 /* Is there an output file? */
1942 if (SB_GetLen (GetStrBuf (F->Name)) > 0) {
1944 /* Assign a proper binary format */
1945 if (F->Format == BINFMT_DEFAULT) {
1946 F->Format = DefaultBinFmt;
1949 /* Call the apropriate routine for the binary format */
1950 switch (F->Format) {
1953 BinWriteTarget (BinFmtDesc, F);
1957 O65WriteTarget (O65FmtDesc, F);
1961 Internal ("Invalid binary format: %u", F->Format);
1967 /* No output file. Walk through the list and mark all segments
1968 * loading into these memory areas in this file as dumped.
1971 for (J = 0; J < CollCount (&F->MemoryAreas); ++J) {
1975 /* Get this entry */
1976 MemoryArea* M = CollAtUnchecked (&F->MemoryAreas, J);
1979 Print (stdout, 2, "Skipping `%s'...\n", GetString (M->Name));
1981 /* Walk throught the segments */
1982 for (K = 0; K < CollCount (&M->SegList); ++K) {
1983 SegDesc* S = CollAtUnchecked (&M->SegList, K);
1985 /* Load area - mark the segment as dumped */