]> git.sur5r.net Git - cc65/commitdiff
Fixed a bug: If all output data was discarded (by using file = "" in the
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 9 Jan 2005 13:16:51 +0000 (13:16 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 9 Jan 2005 13:16:51 +0000 (13:16 +0000)
linker config), CheckExports was never called, which in turn meant that
the list of all exports was never built. This caused a crash later when
the linker tried to generate a map file. The solution is to separate the
creation of the exports list and the check for unresolved imports.

git-svn-id: svn://svn.cc65.org/cc65/trunk@3360 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ld65/bin.c
src/ld65/exports.c
src/ld65/exports.h
src/ld65/main.c
src/ld65/o65.c

index 9ba09f673021e58c091d1b3b33419561506453bd..680011127a1d820b44bfb41f2674d7dfb74e3505 100644 (file)
@@ -262,7 +262,7 @@ void BinWriteTarget (BinDesc* D, struct File* F)
      * if we get an unresolved symbol.
      */
     D->Undef = 0;              /* Reset the counter */
-    CheckExports (BinUnresolved, D);
+    CheckUnresolvedImports (BinUnresolved, D);
     if (D->Undef > 0) {
        /* We had unresolved symbols, cannot create output file */
                Error ("%u unresolved external(s) found - cannot create output file", D->Undef);
index 87caa5e56c28c4ca11a4f69eca31929da3d6cf7d..0cdcb3bc06dc42a25d1185dc32fe8c9e759cbd77 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2003 Ullrich von Bassewitz                                       */
+/* (C) 1998-2005 Ullrich von Bassewitz                                       */
 /*               Römerstraße 52                                              */
 /*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
@@ -576,7 +576,7 @@ static void CheckSymType (const Export* E)
                Warning ("Address size mismatch for `%s': Symbol is `%s'"
                          ", but imported from %s, %s(%lu) as `%s'",
                         GetString (E->Name),
-                         ExpAddrSize,             
+                         ExpAddrSize,
                          ImpObjName,
                          GetSourceFileName (Imp->Obj, Imp->Pos.Name),
                         Imp->Pos.Line,
@@ -669,9 +669,9 @@ static void CreateExportPool (void)
 
 
 
-void CheckExports (ExpCheckFunc F, void* Data)
-/* Check if there are any unresolved symbols. On unresolved symbols, F is
- * called (see the comments on ExpCheckFunc in the data section).
+void CheckExports (void)
+/* Setup the list of all exports and check for export/import symbol type
+ * mismatches.
  */
 {
     /* Create an export pool */
@@ -679,8 +679,16 @@ void CheckExports (ExpCheckFunc F, void* Data)
 
     /* Check for symbol type mismatches */
     CheckSymTypes ();
+}
+
 
-    /* Check for unresolved externals (check here for special bin formats) */
+
+void CheckUnresolvedImports (ExpCheckFunc F, void* Data)
+/* Check if there are any unresolved imports. On unresolved imports, F is
+ * called (see the comments on ExpCheckFunc in the data section).
+ */
+{
+    /* Check for unresolved externals */
     if (ImpOpen != 0) {
                /* Print all open imports */
        PrintUnresolved (F, Data);
index bfdca3c1f8fcbd60f0104e86aec1fa613e6baa2b..6247691d0ddffda0216205302daebeff3d5104d3 100644 (file)
@@ -158,8 +158,13 @@ int IsConstExport (const Export* E);
 long GetExportVal (const Export* E);
 /* Get the value of this export */
 
-void CheckExports (ExpCheckFunc F, void* Data);
-/* Check if there are any unresolved symbols. On unresolved symbols, F is
+void CheckExports (void);
+/* Setup the list of all exports and check for export/import symbol type
+ * mismatches.
+ */
+
+void CheckUnresolvedImports (ExpCheckFunc F, void* Data);
+/* Check if there are any unresolved imports. On unresolved imports, F is
  * called (see the comments on ExpCheckFunc in the data section).
  */
 
@@ -189,7 +194,7 @@ void CircularRefError (const Export* E);
 /* End of exports.h */
 
 #endif
-                                    
+
 
 
 
index c5f4aec17cb24a12b2948c87e4db29c5acc0f249..a424d37f1342d864a9e3b779f9f313da3d00f2d0 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                          */
 /*                                                                          */
 /*                                                                          */
-/* (C) 1998-2003 Ullrich von Bassewitz                                       */
+/* (C) 1998-2005 Ullrich von Bassewitz                                       */
 /*               Römerstrasse 52                                             */
 /*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
@@ -512,6 +512,9 @@ int main (int argc, char* argv [])
     /* Check module assertions */
     CheckAssertions ();
 
+    /* Check for import/export mismatches */
+    CheckExports ();
+
     /* Create the output file */
     CfgWriteTarget ();
 
index efc7856bc151bf6bada953246244513df99f55a4..c6c90b428aa516e677ae22c0763991ace88199b9 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1999-2003 Ullrich von Bassewitz                                       */
+/* (C) 1999-2005 Ullrich von Bassewitz                                       */
 /*               Römerstraße 52                                              */
 /*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
@@ -1356,7 +1356,7 @@ void O65WriteTarget (O65Desc* D, File* F)
      * if we get an unresolved symbol.
      */
     D->Undef = 0;              /* Reset the counter */
-    CheckExports (O65Unresolved, D);
+    CheckUnresolvedImports (O65Unresolved, D);
     if (D->Undef > 0) {
        /* We had unresolved symbols, cannot create output file */
                Error ("%u unresolved external(s) found - cannot create output file", D->Undef);