From 5d74cec95c1e4e29924b01ac1cf6e482388f7abe Mon Sep 17 00:00:00 2001 From: johanknol Date: Tue, 25 Dec 2001 13:08:16 +0000 Subject: [PATCH] fixed the 'char *s="hallo";' initialization bug git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1745 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCglue.c | 51 +++++++++++++++++++++++--------------------------- src/SDCCmem.c | 4 ++-- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/SDCCglue.c b/src/SDCCglue.c index e1e8f323..748f6848 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -176,7 +176,6 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) { symbol *newSym=NULL; - /* if extern then add it into the extern list */ if (IS_EXTERN (sym->etype)) { @@ -236,17 +235,17 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) // create a new "XINIT (CODE)" symbol, that will be emitted later newSym=copySymbol (sym); SPEC_OCLS(newSym->etype)=xinit; - sprintf (newSym->name, "_xinit_%s", sym->name); - sprintf (newSym->rname,"_xinit_%s", sym->rname); + sprintf (newSym->name, "__xinit_%s", sym->name); + sprintf (newSym->rname,"__xinit_%s", sym->rname); SPEC_CONST(newSym->etype)=1; - //SPEC_STAT(newSym->etype)=1; - addSym (SymbolTab, newSym, newSym->name, 0, 0, 1); - + SPEC_STAT(newSym->etype)=1; + //addSym (SymbolTab, newSym, newSym->name, 0, 0, 1); + if (!IS_AGGREGATE(sym->type)) { + resolveIvalSym(newSym->ival); + } // add it to the "XINIT (CODE)" segment addSet(&xinit->syms, newSym); - - //fprintf (stderr, "moved %s from xdata to xidata\n", sym->rname); - + sym->ival=NULL; } else { if (IS_AGGREGATE (sym->type)) { ival = initAggregates (sym, sym->ival, NULL); @@ -287,7 +286,7 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) /* if the ival is a symbol assigned to an aggregate, (bug #458099 -> #462479) we don't need it anymore, so delete it from its segment */ - if (sym->ival->type == INIT_NODE && + if (sym->ival && sym->ival->type == INIT_NODE && IS_AST_SYM_VALUE(sym->ival->init.node) && IS_AGGREGATE (sym->type) ) { symIval=AST_SYMBOL(sym->ival->init.node); @@ -310,24 +309,20 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) SPEC_ADDR (sym->etype)); } else { - if (newSym) { - // this has been moved to another segment - } else { - int size = getSize (sym->type); - if (size==0) { - werror(E_UNKNOWN_SIZE,sym->name); - } - /* allocate space */ - if (options.debug) { - fprintf (map->oFile, "==.\n"); - } - if (IS_STATIC (sym->etype)) - tfprintf (map->oFile, "!slabeldef\n", sym->rname); - else - tfprintf (map->oFile, "!labeldef\n", sym->rname); - tfprintf (map->oFile, "\t!ds\n", - (unsigned int) size & 0xffff); - } + int size = getSize (sym->type); + if (size==0) { + werror(E_UNKNOWN_SIZE,sym->name); + } + /* allocate space */ + if (options.debug) { + fprintf (map->oFile, "==.\n"); + } + if (IS_STATIC (sym->etype)) + tfprintf (map->oFile, "!slabeldef\n", sym->rname); + else + tfprintf (map->oFile, "!labeldef\n", sym->rname); + tfprintf (map->oFile, "\t!ds\n", + (unsigned int) size & 0xffff); } } } diff --git a/src/SDCCmem.c b/src/SDCCmem.c index f369a04f..da118602 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -404,12 +404,12 @@ allocGlobal (symbol * sym) if (SPEC_SCLS (sym->etype) == S_XDATA) { - SPEC_OCLS (sym->etype) = xdata; // should we move this to the initialized data segment? if (port->genXINIT && sym->ival && (sym->level==0) && !SPEC_ABSA(sym->etype)) { SPEC_OCLS(sym->etype)=xidata; - addSet(&xidata->syms, sym); + } else { + SPEC_OCLS (sym->etype) = xdata; } allocIntoSeg (sym); return; -- 2.30.2