]> git.sur5r.net Git - cc65/blob - src/ld65/exports.c
Move the version numbers from the interface of the version module into a new
[cc65] / src / ld65 / exports.c
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 exports.c                                 */
4 /*                                                                           */
5 /*                   Exports handling for the ld65 linker                    */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2009, Ullrich von Bassewitz                                      */
10 /*                Roemerstrasse 52                                           */
11 /*                D-70794 Filderstadt                                        */
12 /* EMail:         uz@cc65.org                                                */
13 /*                                                                           */
14 /*                                                                           */
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.                                    */
18 /*                                                                           */
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:                            */
22 /*                                                                           */
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              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39
40 /* common */
41 #include "addrsize.h"
42 #include "check.h"
43 #include "coll.h"
44 #include "hashstr.h"
45 #include "symdefs.h"
46 #include "xmalloc.h"
47
48 /* ld65 */
49 #include "condes.h"
50 #include "error.h"
51 #include "exports.h"
52 #include "expr.h"
53 #include "fileio.h"
54 #include "global.h"
55 #include "objdata.h"
56 #include "spool.h"
57
58
59
60 /*****************************************************************************/
61 /*                                   Data                                    */
62 /*****************************************************************************/
63
64
65
66 /* Hash table */
67 #define HASHTAB_MASK    0x0FFFU
68 #define HASHTAB_SIZE    (HASHTAB_MASK + 1)
69 static Export*          HashTab[HASHTAB_SIZE];
70
71 /* Import management variables */
72 static unsigned         ImpCount = 0;           /* Import count */
73 static unsigned         ImpOpen  = 0;           /* Count of open imports */
74
75 /* Export management variables */
76 static unsigned         ExpCount = 0;           /* Export count */
77 static Export**         ExpPool  = 0;           /* Exports array */
78
79 /* Defines for the flags in Import */
80 #define IMP_INLIST      0x0001U                 /* Import is in exports list */
81
82 /* Defines for the flags in Export */
83 #define EXP_INLIST      0x0001U                 /* Export is in exports list */
84 #define EXP_USERMARK    0x0002U                 /* User setable flag */
85
86
87
88 /*****************************************************************************/
89 /*                              Import handling                              */
90 /*****************************************************************************/
91
92
93
94 static Export* NewExport (unsigned char Type, unsigned char AddrSize,
95                           unsigned Name, ObjData* Obj);
96 /* Create a new export and initialize it */
97
98
99
100 static Import* NewImport (unsigned char AddrSize, ObjData* Obj)
101 /* Create a new import and initialize it */
102 {
103     /* Allocate memory */
104     Import* I = xmalloc (sizeof (Import));
105
106     /* Initialize the fields */
107     I->Next     = 0;
108     I->Obj      = Obj;
109     InitFilePos (&I->Pos);
110     I->Exp      = 0;
111     I->Name     = INVALID_STRING_ID;
112     I->Flags    = 0;
113     I->AddrSize = AddrSize;
114
115     /* Return the new structure */
116     return I;
117 }
118
119
120
121 void FreeImport (Import* I)
122 /* Free an import. NOTE: This won't remove the import from the exports table,
123  * so it may only be called for unused imports (imports from modules that
124  * aren't referenced).
125  */
126 {
127     /* Safety */
128     PRECONDITION ((I->Flags & IMP_INLIST) == 0);
129
130     /* Free the struct */
131     xfree (I);
132 }
133
134
135
136 Import* ReadImport (FILE* F, ObjData* Obj)
137 /* Read an import from a file and return it */
138 {
139     Import* I;
140
141     /* Read the import address size */
142     unsigned char AddrSize = Read8 (F);
143
144     /* Create a new import */
145     I = NewImport (AddrSize, Obj);
146
147     /* Read the name */
148     I->Name = MakeGlobalStringId (Obj, ReadVar (F));
149
150     /* Read the file position */
151     ReadFilePos (F, &I->Pos);
152
153     /* Check the address size */
154     if (I->AddrSize == ADDR_SIZE_DEFAULT || I->AddrSize > ADDR_SIZE_LONG) {
155         /* Beware: This function may be called in cases where the object file
156          * is not read completely into memory. In this case, the file list is
157          * invalid. Be sure not to access it in this case.
158          */
159         if (ObjHasFiles (I->Obj)) {
160             Error ("Invalid import size in for `%s', imported from %s(%lu): 0x%02X",
161                    GetString (I->Name),
162                    GetSourceFileName (I->Obj, I->Pos.Name),
163                    I->Pos.Line,
164                    I->AddrSize);
165         } else {
166             Error ("Invalid import size in for `%s', imported from %s: 0x%02X",
167                    GetString (I->Name),
168                    GetObjFileName (I->Obj),
169                    I->AddrSize);
170         }
171     }
172
173     /* Return the new import */
174     return I;
175 }
176
177
178
179 Import* GenImport (const char* Name, unsigned char AddrSize)
180 /* Generate a new import with the given name and address size and return it */
181 {
182     /* Create a new import */
183     Import* I = NewImport (AddrSize, 0);
184
185     /* Read the name */
186     I->Name = GetStringId (Name);
187
188     /* Check the address size */
189     if (I->AddrSize == ADDR_SIZE_DEFAULT || I->AddrSize > ADDR_SIZE_LONG) {
190         /* Beware: This function may be called in cases where the object file
191          * is not read completely into memory. In this case, the file list is
192          * invalid. Be sure not to access it in this case.
193          */
194         if (ObjHasFiles (I->Obj)) {
195             Error ("Invalid import size in for `%s', imported from %s(%lu): 0x%02X",
196                    GetString (I->Name),
197                    GetSourceFileName (I->Obj, I->Pos.Name),
198                    I->Pos.Line,
199                    I->AddrSize);
200         } else {
201             Error ("Invalid import size in for `%s', imported from %s: 0x%02X",
202                    GetString (I->Name),
203                    GetObjFileName (I->Obj),
204                    I->AddrSize);
205         }
206     }
207
208     /* Return the new import */
209     return I;
210 }
211
212
213
214 void InsertImport (Import* I)
215 /* Insert an import into the table */
216 {
217     Export* E;
218
219     /* As long as the import is not inserted, V.Name is valid */
220     unsigned Name = I->Name;
221
222     /* Create a hash value for the given name */
223     unsigned Hash = (Name & HASHTAB_MASK);
224
225     /* Search through the list in that slot and print matching duplicates */
226     if (HashTab[Hash] == 0) {
227         /* The slot is empty, we need to insert a dummy export */
228         E = HashTab[Hash] = NewExport (0, ADDR_SIZE_DEFAULT, Name, 0);
229         ++ExpCount;
230     } else {
231         E = HashTab [Hash];
232         while (1) {
233             if (E->Name == Name) {
234                 /* We have an entry, L points to it */
235                 break;
236             }
237             if (E->Next == 0) {
238                 /* End of list an entry not found, insert a dummy */
239                 E->Next = NewExport (0, ADDR_SIZE_DEFAULT, Name, 0);
240                 E = E->Next;            /* Point to dummy */
241                 ++ExpCount;             /* One export more */
242                 break;
243             } else {
244                 E = E->Next;
245             }
246         }
247     }
248
249     /* Ok, E now points to a valid exports entry for the given import. Insert
250      * the import into the imports list and update the counters.
251      */
252     I->Exp     = E;
253     I->Next    = E->ImpList;
254     E->ImpList = I;
255     E->ImpCount++;
256     ++ImpCount;                 /* Total import count */
257     if (E->Expr == 0) {
258         /* This is a dummy export */
259         ++ImpOpen;
260     }
261
262     /* Mark the import so we know it's in the list */
263     I->Flags |= IMP_INLIST;
264 }
265
266
267
268 /*****************************************************************************/
269 /*                                   Code                                    */
270 /*****************************************************************************/
271
272
273
274 static Export* NewExport (unsigned char Type, unsigned char AddrSize,
275                           unsigned Name, ObjData* Obj)
276 /* Create a new export and initialize it */
277 {
278     /* Allocate memory */
279     Export* E = xmalloc (sizeof (Export));
280
281     /* Initialize the fields */
282     E->Name     = Name;
283     E->Next     = 0;
284     E->Flags    = 0;
285     E->Obj      = Obj;
286     E->ImpCount = 0;
287     E->ImpList  = 0;
288     E->Expr     = 0;
289     E->Type     = Type;
290     E->AddrSize = AddrSize;
291     memset (E->ConDes, 0, sizeof (E->ConDes));
292
293     /* Return the new entry */
294     return E;
295 }
296
297
298
299 void FreeExport (Export* E)
300 /* Free an export. NOTE: This won't remove the export from the exports table,
301  * so it may only be called for unused exports (exports from modules that
302  * aren't referenced).
303  */
304 {
305     /* Safety */
306     PRECONDITION ((E->Flags & EXP_INLIST) == 0);
307
308     /* Free the export expression */
309     FreeExpr (E->Expr);
310
311     /* Free the struct */
312     xfree (E);
313 }
314
315
316
317 void InsertExport (Export* E)
318 /* Insert an exported identifier and check if it's already in the list */
319 {
320     Export* L;
321     Export* Last;
322     Import* Imp;
323     unsigned Hash;
324
325     /* Mark the export as inserted */
326     E->Flags |= EXP_INLIST;
327
328     /* Insert the export into any condes tables if needed */
329     if (IS_EXP_CONDES (E->Type)) {
330         ConDesAddExport (E);
331     }
332
333     /* Create a hash value for the given name */
334     Hash = (E->Name & HASHTAB_MASK);
335
336     /* Search through the list in that slot */
337     if (HashTab[Hash] == 0) {
338         /* The slot is empty */
339         HashTab[Hash] = E;
340         ++ExpCount;
341     } else {
342
343         Last = 0;
344         L = HashTab[Hash];
345         do {
346             if (L->Name == E->Name) {
347                 /* This may be an unresolved external */
348                 if (L->Expr == 0) {
349
350                     /* This *is* an unresolved external. Use the actual export
351                      * in E instead of the dummy one in L.
352                      */
353                     E->Next     = L->Next;
354                     E->ImpCount = L->ImpCount;
355                     E->ImpList  = L->ImpList;
356                     if (Last) {
357                         Last->Next = E;
358                     } else {
359                         HashTab[Hash] = E;
360                     }
361                     ImpOpen -= E->ImpCount;     /* Decrease open imports now */
362                     xfree (L);
363                     /* We must run through the import list and change the
364                      * export pointer now.
365                      */
366                     Imp = E->ImpList;
367                     while (Imp) {
368                         Imp->Exp = E;
369                         Imp = Imp->Next;
370                     }
371                 } else {
372                     /* Duplicate entry, ignore it */
373                     Warning ("Duplicate external identifier: `%s'",
374                              GetString (L->Name));
375                 }
376                 return;
377             }
378             Last = L;
379             L = L->Next;
380
381         } while (L);
382
383         /* Insert export at end of queue */
384         Last->Next = E;
385         ++ExpCount;
386     }
387 }
388
389
390
391 Export* ReadExport (FILE* F, ObjData* O)
392 /* Read an export from a file */
393 {
394     unsigned      ConDesCount;
395     Export* E;
396
397     /* Read the type */
398     unsigned char Type = Read8 (F);
399
400     /* Read the address size */
401     unsigned char AddrSize = Read8 (F);
402
403     /* Create a new export without a name */
404     E = NewExport (Type, AddrSize, INVALID_STRING_ID, O);
405
406     /* Read the constructor/destructor decls if we have any */
407     ConDesCount = GET_EXP_CONDES_COUNT (Type);
408     if (ConDesCount > 0) {
409
410         unsigned char ConDes[CD_TYPE_COUNT];
411         unsigned I;
412
413         /* Read the data into temp storage */
414         ReadData (F, ConDes, ConDesCount);
415
416         /* Re-order the data. In the file, each decl is encoded into a byte
417          * which contains the type and the priority. In memory, we will use
418          * an array of types which contain the priority. This array was
419          * cleared by the constructor (NewExport), so we must only set the
420          * fields that contain values.
421          */
422         for (I = 0; I < ConDesCount; ++I) {
423             unsigned ConDesType = CD_GET_TYPE (ConDes[I]);
424             unsigned ConDesPrio = CD_GET_PRIO (ConDes[I]);
425             E->ConDes[ConDesType] = ConDesPrio;
426         }
427     }
428
429     /* Read the name */
430     E->Name = MakeGlobalStringId (O, ReadVar (F));
431
432     /* Read the value */
433     if (IS_EXP_EXPR (Type)) {
434         E->Expr = ReadExpr (F, O);
435     } else {
436         E->Expr = LiteralExpr (Read32 (F), O);
437     }
438
439     /* Last is the file position where the definition was done */
440     ReadFilePos (F, &E->Pos);
441
442     /* Return the new export */
443     return E;
444 }
445
446
447
448 Export* CreateConstExport (unsigned Name, long Value)
449 /* Create an export for a literal date */
450 {
451     /* Create a new export */
452     Export* E = NewExport (EXP_CONST | EXP_EQUATE, ADDR_SIZE_ABS, Name, 0);
453
454     /* Assign the value */
455     E->Expr = LiteralExpr (Value, 0);
456
457     /* Insert the export */
458     InsertExport (E);
459
460     /* Return the new export */
461     return E;
462 }
463
464
465
466 Export* CreateMemoryExport (unsigned Name, Memory* Mem, unsigned long Offs)
467 /* Create an relative export for a memory area offset */
468 {
469     /* Create a new export */
470     Export* E = NewExport (EXP_EXPR | EXP_LABEL, ADDR_SIZE_ABS, Name, 0);
471
472     /* Assign the value */
473     E->Expr = MemoryExpr (Mem, Offs, 0);
474
475     /* Insert the export */
476     InsertExport (E);
477
478     /* Return the new export */
479     return E;
480 }
481
482
483
484 Export* CreateSegmentExport (unsigned Name, Segment* Seg, unsigned long Offs)
485 /* Create a relative export to a segment */
486 {
487     /* Create a new export */
488     Export* E = NewExport (EXP_EXPR | EXP_LABEL, Seg->AddrSize, Name, 0);
489
490     /* Assign the value */
491     E->Expr = SegmentExpr (Seg, Offs, 0);
492
493     /* Insert the export */
494     InsertExport (E);
495
496     /* Return the new export */
497     return E;
498 }
499
500
501
502 Export* CreateSectionExport (unsigned Name, Section* Sec, unsigned long Offs)
503 /* Create a relative export to a section */
504 {
505     /* Create a new export */
506     Export* E = NewExport (EXP_EXPR | EXP_LABEL, Sec->AddrSize, Name, 0);
507
508     /* Assign the value */
509     E->Expr = SectionExpr (Sec, Offs, 0);
510
511     /* Insert the export */
512     InsertExport (E);
513
514     /* Return the new export */
515     return E;
516 }
517
518
519
520 Export* FindExport (unsigned Name)
521 /* Check for an identifier in the list. Return 0 if not found, otherwise
522  * return a pointer to the export.
523  */
524 {
525     /* Get a pointer to the list with the symbols hash value */
526     Export* L = HashTab[Name & HASHTAB_MASK];
527     while (L) {
528         /* Search through the list in that slot */
529         if (L->Name == Name) {
530             /* Entry found */
531             return L;
532         }
533         L = L->Next;
534     }
535
536     /* Not found */
537     return 0;
538 }
539
540
541
542 int IsUnresolved (unsigned Name)
543 /* Check if this symbol is an unresolved export */
544 {
545     /* Find the export */
546     return IsUnresolvedExport (FindExport (Name));
547 }
548
549
550
551 int IsUnresolvedExport (const Export* E)
552 /* Return true if the given export is unresolved */
553 {
554     /* Check if it's unresolved */
555     return E != 0 && E->Expr == 0;
556 }
557
558
559
560 int IsConstExport (const Export* E)
561 /* Return true if the expression associated with this export is const */
562 {
563     if (E->Expr == 0) {
564         /* External symbols cannot be const */
565         return 0;
566     } else {
567         return IsConstExpr (E->Expr);
568     }
569 }
570
571
572
573 long GetExportVal (const Export* E)
574 /* Get the value of this export */
575 {
576     if (E->Expr == 0) {
577         /* OOPS */
578         Internal ("`%s' is an undefined external", GetString (E->Name));
579     }
580     return GetExprVal (E->Expr);
581 }
582
583
584
585 static void CheckSymType (const Export* E)
586 /* Check the types for one export */
587 {
588     /* External with matching imports */
589     Import* Imp = E->ImpList;
590     while (Imp) {
591         if (E->AddrSize != Imp->AddrSize) {
592             /* Export is ZP, import is abs or the other way round */
593             const char* ExpAddrSize = AddrSizeToStr (E->AddrSize);
594             const char* ImpAddrSize = AddrSizeToStr (Imp->AddrSize);
595             const char* ExpObjName  = GetObjFileName (E->Obj);
596             const char* ImpObjName  = GetObjFileName (Imp->Obj);
597             if (E->Obj) {
598                 /* User defined export */
599                 Warning ("Address size mismatch for `%s': Exported from %s, "
600                          "%s(%lu) as `%s', import in %s, %s(%lu) as `%s'",
601                          GetString (E->Name),
602                          ExpObjName,
603                          GetSourceFileName (E->Obj, E->Pos.Name),
604                          E->Pos.Line,
605                          ExpAddrSize,
606                          ImpObjName,
607                          GetSourceFileName (Imp->Obj, Imp->Pos.Name),
608                          Imp->Pos.Line,
609                          ImpAddrSize);
610             } else {
611                 /* Export created by the linker */
612                 Warning ("Address size mismatch for `%s': Symbol is `%s'"
613                          ", but imported from %s, %s(%lu) as `%s'",
614                          GetString (E->Name),
615                          ExpAddrSize,
616                          ImpObjName,
617                          GetSourceFileName (Imp->Obj, Imp->Pos.Name),
618                          Imp->Pos.Line,
619                          ImpAddrSize);
620             }
621         }
622         Imp = Imp->Next;
623     }
624 }
625
626
627
628 static void CheckSymTypes (void)
629 /* Check for symbol tape mismatches */
630 {
631     unsigned I;
632
633     /* Print all open imports */
634     for (I = 0; I < ExpCount; ++I) {
635         const Export* E = ExpPool [I];
636         if (E->Expr != 0 && E->ImpCount > 0) {
637             /* External with matching imports */
638             CheckSymType (E);
639         }
640     }
641 }
642
643
644
645 static void PrintUnresolved (ExpCheckFunc F, void* Data)
646 /* Print a list of unresolved symbols. On unresolved symbols, F is
647  * called (see the comments on ExpCheckFunc in the data section).
648  */
649 {
650     unsigned I;
651
652     /* Print all open imports */
653     for (I = 0; I < ExpCount; ++I) {
654         Export* E = ExpPool [I];
655         if (E->Expr == 0 && E->ImpCount > 0 && F (E->Name, Data) == 0) {
656             /* Unresolved external */
657             Import* Imp = E->ImpList;
658             fprintf (stderr,
659                      "Unresolved external `%s' referenced in:\n",
660                      GetString (E->Name));
661             while (Imp) {
662                 const char* Name = GetSourceFileName (Imp->Obj, Imp->Pos.Name);
663                 fprintf (stderr, "  %s(%lu)\n", Name, Imp->Pos.Line);
664                 Imp = Imp->Next;
665             }
666         }
667     }
668 }
669
670
671
672 static int CmpExpName (const void* K1, const void* K2)
673 /* Compare function for qsort */
674 {
675     return SB_Compare (GetStrBuf ((*(Export**)K1)->Name),
676                        GetStrBuf ((*(Export**)K2)->Name));
677 }
678
679
680
681 static void CreateExportPool (void)
682 /* Create an array with pointer to all exports */
683 {
684     unsigned I, J;
685
686     /* Allocate memory */
687     if (ExpPool) {
688         xfree (ExpPool);
689     }
690     ExpPool = xmalloc (ExpCount * sizeof (Export*));
691
692     /* Walk through the list and insert the exports */
693     for (I = 0, J = 0; I < sizeof (HashTab) / sizeof (HashTab [0]); ++I) {
694         Export* E = HashTab[I];
695         while (E) {
696             CHECK (J < ExpCount);
697             ExpPool[J++] = E;
698             E = E->Next;
699         }
700     }
701
702     /* Sort them by name */
703     qsort (ExpPool, ExpCount, sizeof (Export*), CmpExpName);
704 }
705
706
707
708 void CheckExports (void)
709 /* Setup the list of all exports and check for export/import symbol type
710  * mismatches.
711  */
712 {
713     /* Create an export pool */
714     CreateExportPool ();
715
716     /* Check for symbol type mismatches */
717     CheckSymTypes ();
718 }
719
720
721
722 void CheckUnresolvedImports (ExpCheckFunc F, void* Data)
723 /* Check if there are any unresolved imports. On unresolved imports, F is
724  * called (see the comments on ExpCheckFunc in the data section).
725  */
726 {
727     /* Check for unresolved externals */
728     if (ImpOpen != 0) {
729         /* Print all open imports */
730         PrintUnresolved (F, Data);
731     }
732 }
733
734
735
736 static char GetAddrSizeCode (unsigned char AddrSize)
737 /* Get a one char code for the address size */
738 {
739     switch (AddrSize) {
740         case ADDR_SIZE_ZP:      return 'Z';
741         case ADDR_SIZE_ABS:     return 'A';
742         case ADDR_SIZE_FAR:     return 'F';
743         case ADDR_SIZE_LONG:    return 'L';
744         default:
745             Internal ("Invalid address size: %u", AddrSize);
746             /* NOTREACHED */
747             return '-';
748     }
749 }
750
751
752
753 void PrintExportMap (FILE* F)
754 /* Print an export map to the given file */
755 {
756     unsigned I;
757     unsigned Count;
758
759     /* Print all exports */
760     Count = 0;
761     for (I = 0; I < ExpCount; ++I) {
762         const Export* E = ExpPool [I];
763
764         /* Print unreferenced symbols only if explictly requested */
765         if (VerboseMap || E->ImpCount > 0 || IS_EXP_CONDES (E->Type)) {
766             fprintf (F,
767                      "%-25s %06lX %c%c%c%c   ",
768                      GetString (E->Name),
769                      GetExportVal (E),
770                      E->ImpCount? 'R' : ' ',
771                      IS_EXP_LABEL (E->Type)? 'L' : 'E',
772                      GetAddrSizeCode (E->AddrSize),
773                      IS_EXP_CONDES (E->Type)? 'I' : ' ');
774             if (++Count == 2) {
775                 Count = 0;
776                 fprintf (F, "\n");
777             }
778         }
779     }
780     fprintf (F, "\n");
781 }
782
783
784
785 void PrintImportMap (FILE* F)
786 /* Print an import map to the given file */
787 {
788     unsigned I;
789     const Import* Imp;
790
791     /* Loop over all exports */
792     for (I = 0; I < ExpCount; ++I) {
793
794         /* Get the export */
795         const Export* Exp = ExpPool [I];
796
797         /* Print the symbol only if there are imports, or if a verbose map
798          * file is requested.
799          */
800         if (VerboseMap || Exp->ImpCount > 0) {
801
802             /* Print the export */
803             fprintf (F,
804                      "%s (%s):\n",
805                      GetString (Exp->Name),
806                      GetObjFileName (Exp->Obj));
807
808             /* Print all imports for this symbol */
809             Imp = Exp->ImpList;
810             while (Imp) {
811
812                 /* Print the import */
813                 fprintf (F,
814                          "    %-25s %s(%lu)\n",
815                          GetObjFileName (Imp->Obj),
816                          GetSourceFileName (Imp->Obj, Imp->Pos.Name),
817                          Imp->Pos.Line);
818
819                 /* Next import */
820                 Imp = Imp->Next;
821             }
822         }
823     }
824     fprintf (F, "\n");
825 }
826
827
828
829 void PrintExportLabels (FILE* F)
830 /* Print the exports in a VICE label file */
831 {
832     unsigned I;
833
834     /* Print all exports */
835     for (I = 0; I < ExpCount; ++I) {
836         const Export* E = ExpPool [I];
837         fprintf (F, "al %06lX .%s\n", GetExportVal (E), GetString (E->Name));
838     }
839 }
840
841
842
843 void MarkExport (Export* E)
844 /* Mark the export */
845 {
846     E->Flags |= EXP_USERMARK;
847 }
848
849
850
851 void UnmarkExport (Export* E)
852 /* Remove the mark from the export */
853 {
854     E->Flags &= ~EXP_USERMARK;
855 }
856
857
858
859 int ExportHasMark (Export* E)
860 /* Return true if the export has a mark */
861 {
862     return (E->Flags & EXP_USERMARK) != 0;
863 }
864
865
866
867 void CircularRefError (const Export* E)
868 /* Print an error about a circular reference using to define the given export */
869 {
870     Error ("Circular reference for symbol `%s', %s(%lu)",
871            GetString (E->Name),
872            GetSourceFileName (E->Obj, E->Pos.Name),
873            E->Pos.Line);
874 }
875
876
877
878