From: kvigor Date: Thu, 2 Mar 2000 21:40:19 +0000 (+0000) Subject: fix broken static initializers in non-main() modules X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=9ae6ce03852da0469517b41b7ffbbeed00fe3a2b;p=fw%2Fsdcc fix broken static initializers in non-main() modules git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@146 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 40c14485..87779873 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -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); diff --git a/src/mcs51/main.c b/src/mcs51/main.c index 62881b54..e7b3f412 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -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 diff --git a/src/port.h b/src/port.h index b8639fb1..65822832 100644 --- a/src/port.h +++ b/src/port.h @@ -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 */ diff --git a/src/z80/main.c b/src/z80/main.c index f19ad5d8..bcc035eb 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -96,7 +96,8 @@ PORT z80_port = { "_BSEG", "_RSEG", "_GSINIT", - "_OVERLAY" + "_OVERLAY", + "_GSFINAL" }, { -1, 0, 0, 8, 0