fix broken static initializers in non-main() modules
authorkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 2 Mar 2000 21:40:19 +0000 (21:40 +0000)
committerkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 2 Mar 2000 21:40:19 +0000 (21:40 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@146 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCglue.c
src/mcs51/main.c
src/port.h
src/z80/main.c

index 40c14485a1813aed82c0e7c1827e76495ebe17e8..877798738991f2adaa3030f1032e5f6114ec255a 100644 (file)
@@ -1011,7 +1011,17 @@ void glue ()
     fprintf (asmFile, "%s", iComments2);
     fprintf (asmFile, "; global & static initialisations\n");
     fprintf (asmFile, "%s", iComments2);
+    
+    /* Everywhere we generate a reference to the static_name area, 
+     * (which is currently only here), we immediately follow it with a 
+     * definition of the post_static_name area. This guarantees that
+     * the post_static_name area will immediately follow the static_name
+     * area.
+     */
     fprintf (asmFile, "\t.area %s\n", port->mem.static_name); /* MOF */
+    fprintf (asmFile, "\t.area %s\n", port->mem.post_static_name);
+    fprintf (asmFile, "\t.area %s\n", port->mem.static_name);
+    
     if (mainf && mainf->fbody) {
        fprintf (asmFile,"__sdcc_gsinit_startup:\n");
        /* if external stack is specified then the
@@ -1046,7 +1056,14 @@ void glue ()
     copyFile (asmFile, statsg->oFile);
 
     if (port->general.glue_up_main && mainf && mainf->fbody)
+    {
+        /* This code is generated in the post-static area.
+         * This area is guaranteed to follow the static area
+         * by the ugly shucking and jiving about 20 lines ago.
+         */
+       fprintf(asmFile, "\t.area %s\n", port->mem.post_static_name);
        fprintf (asmFile,"\tljmp\t__sdcc_program_startup\n");
+    }
        
     /* copy over code */
     fprintf (asmFile, "%s", iComments2);
index 62881b54370a4983e1ac5c7f4f14bf2a5b973f31..e7b3f4121ca9c2cb432e7457936e8092d083803f 100644 (file)
@@ -170,7 +170,8 @@ PORT mcs51_port = {
        "BSEG    (BIT)",
        "RSEG    (DATA)",
        "GSINIT  (CODE)",
-       "OSEG    (OVR,DATA)"
+       "OSEG    (OVR,DATA)",
+       "GSFINAL (CODE)"
     },
     { 
        +1, 1, 4, 1, 1
index b8639fb1fe3298abc80df1c4917830f1aa4c3d47..6582283221860d32bda4e78e92f1fab7493f999f 100644 (file)
@@ -69,6 +69,7 @@ typedef struct {
        const char *reg_name;
        const char *static_name;
        const char *overlay_name;
+       const char *post_static_name;
     } mem;
     
     /* stack related information */
index f19ad5d845f7f2c83fecd2910b87c2c089b1644b..bcc035eb3430e809167f40ce0af718e631a7df82 100644 (file)
@@ -96,7 +96,8 @@ PORT z80_port = {
        "_BSEG",
        "_RSEG",
        "_GSINIT",
-       "_OVERLAY"
+       "_OVERLAY",
+       "_GSFINAL"
     },
     { 
        -1, 0, 0, 8, 0