diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-21 00:22:00 +0200 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-21 00:22:00 +0200 |
| commit | 3fcc2d265f1521c2dcae0734de355962cc6cd7a0 (patch) | |
| tree | 9f914b554fa9af110fda60e6a3962fe9e3a40423 /src | |
| parent | a2a263dd383d76e4ee0ed62f393376ef2ae49171 (diff) | |
More work on GNU as generation
On _gas_mapping, label definitions do not allow "::". ":" must be
used instead.
gasOutput is now part of "options".
Unneeded sections, such as HOME/GSINIT/etc., are no longer declared
and/or defined. GNU as just does not need them.
Startup function name must equal "_start" for GNU ld.
The value of some macros, such as CODE_NAME or DATA_NAME, must change
according to options.gasOutput, as "CODE" or "DATA" (among many others)
are not understood by GNU as.
STM8 port now selects GNU as format on --gas switch enabled.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 8 | ||||
| -rw-r--r-- | src/Makefile.dep | 6 | ||||
| -rw-r--r-- | src/SDCCasm.c | 11 | ||||
| -rw-r--r-- | src/SDCCdwarf2.c | 2 | ||||
| -rw-r--r-- | src/SDCCgas.c | 16 | ||||
| -rw-r--r-- | src/SDCCglobl.h | 4 | ||||
| -rw-r--r-- | src/SDCCglue.c | 137 | ||||
| -rw-r--r-- | src/SDCCmain.c | 39 | ||||
| -rw-r--r-- | src/SDCCmem.c | 12 | ||||
| -rw-r--r-- | src/SDCCmem.h | 12 | ||||
| -rw-r--r-- | src/pdk/main.c | 12 | ||||
| -rw-r--r-- | src/port.h | 4 | ||||
| -rw-r--r-- | src/stm8/main.c | 20 |
13 files changed, 179 insertions, 104 deletions
diff --git a/src/Makefile b/src/Makefile index 692ac7e..8604fee 100644 --- a/src/Makefile +++ b/src/Makefile @@ -15,12 +15,12 @@ PORTS = $(shell cat ../ports.build) ALLPORTS = $(shell cat ../ports.all) PORT_LIBS = $(PORTS:%=%/port.a) -LIBS = -lm +LIBS = -lm -CFLAGS = -pipe -ggdb -g -O2 -Wall -Wno-parentheses -CXXFLAGS = -pipe -ggdb -g -O2 -Wall -Wno-parentheses +CFLAGS = -pipe -ggdb -g -Og -Wall -Wno-parentheses +CXXFLAGS = -pipe -ggdb -g -Og -Wall -Wno-parentheses CPPFLAGS += -I$(srcdir) -LDFLAGS = +LDFLAGS = ifdef SDCC_SUB_VERSION CFLAGS += -DSDCC_SUB_VERSION_STR=\"$(SDCC_SUB_VERSION)\" diff --git a/src/Makefile.dep b/src/Makefile.dep index f67fbcf..f5ac324 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -198,7 +198,11 @@ SDCCgen.o: SDCCgen.c common.h SDCCglobl.h SDCCset.h ../sdccconf.h \ SDCCsystem.h port.h SDCCargs.h ../support/util/newalloc.h \ ../support/util/dbuf_string.h ../support/util/dbuf.h SDCCgas.o: SDCCgas.c SDCCgas.h SDCCglobl.h SDCCset.h ../sdccconf.h \ - SDCCerr.h ../support/util/newalloc.h + SDCCerr.h SDCCmem.h ../support/util/dbuf.h SDCCsymt.h SDCChasht.h \ + SDCCval.h SDCCicode.h SDCCbitv.h SDCCast.h port.h SDCCargs.h SDCCpeeph.h \ + SDCCgen.h SDCCicode.h SDCCbitv.h SDCCset.h SDCCast.h \ + ../support/util/newalloc.h ../support/util/dbuf_string.h \ + ../support/util/dbuf.h SDCClex.o: SDCClex.c common.h SDCCglobl.h SDCCset.h ../sdccconf.h \ SDCCerr.h SDCCmem.h ../support/util/dbuf.h SDCCsymt.h SDCChasht.h \ SDCCval.h SDCCast.h SDCCy.h SDCCbitv.h SDCCicode.h SDCClabel.h \ diff --git a/src/SDCCasm.c b/src/SDCCasm.c index 27f7cd1..05551bd 100644 --- a/src/SDCCasm.c +++ b/src/SDCCasm.c @@ -401,7 +401,7 @@ err_no_line: } static const ASM_MAPPING _gas_mapping[] = { - {"labeldef", "%s::"}, + {"labeldef", "%s:"}, {"slabeldef", "%s:"}, {"tlabeldef", "%05d$:"}, {"tlabel", "%05d$"}, @@ -409,11 +409,12 @@ static const ASM_MAPPING _gas_mapping[] = { {"zero", "#0x00"}, {"one", "#0x01"}, {"area", ".section %s"}, - {"areacode", ".section .text"}, - {"areadata", ".section .bss"}, + {"areacode", ".section %s"}, + {"areadata", ".section %s"}, {"areahome", ".section %s"}, {"ascii", ".ascii \"%s\""}, - {"ds", ".comm %d"}, + {"comm", ".comm %s, %d, %d"}, + {"local", ".local %s"}, {"db", ".byte"}, {"dbs", ".byte %s"}, {"dw", ".word"}, @@ -433,7 +434,7 @@ static const ASM_MAPPING _gas_mapping[] = { "; Function %s\n" "; ---------------------------------"}, {"functionlabeldef", "%s:"}, - {"globalfunctionlabeldef", "%s::"}, + {"globalfunctionlabeldef", "%s:"}, {"los", "(%s & 0xFF)"}, {"his", "(%s >> 8)"}, {"hihis", "(%s >> 16)"}, diff --git a/src/SDCCdwarf2.c b/src/SDCCdwarf2.c index 8041641..a5e8bd8 100644 --- a/src/SDCCdwarf2.c +++ b/src/SDCCdwarf2.c @@ -1805,8 +1805,6 @@ dwWriteLineNumbers (void) lp->begin_sequence = 1; while (lp) { - fprintf(dwarf2FilePtr, ";sdccrm - label [\"%s\"], line %d\n", lp->label, lp->line); - dwWriteLineNumber (lp); if (lp->end_sequence && lp->next) lp->next->begin_sequence = 1; diff --git a/src/SDCCgas.c b/src/SDCCgas.c index b626ee3..8055b99 100644 --- a/src/SDCCgas.c +++ b/src/SDCCgas.c @@ -45,7 +45,7 @@ void gas_glue(void) int clean_dst = 0; const char *dst = fullDstFileName; - if (!gasOutput) + if (!options.gasOutput) { werror(W_ILLEGAL_OPT_COMBINATION, __FILE__, __FUNCTION__, "this function must only be called if GAS" @@ -183,13 +183,21 @@ static void emit_rodata(FILE *const f) printf("%s.%s\n", name, field->name); - if (SPEC_LONG(ft)) + if (IS_LONG(ft)) { - fprintf(f, "\t.long %d\n", ft->select.s.const_val.v_long); + fprintf(f, "\t.long %d\n", SPEC_CVAL(ft).v_long); + } + else if (IS_INT(ft)) + { + fprintf(f, "\t.word %d\n", SPEC_CVAL(ft).v_uint); } else if (SPEC_SHORT(ft)) { - fprintf(f, "\t.hword %d\n", ft->select.s.const_val.v_int); + fprintf(f, "\t.hword %d\n", SPEC_CVAL(ft).v_int); + } + else if (IS_CHAR(ft) || IS_BOOL(ft)) + { + fprintf(f, "\t.byte %d\n", SPEC_CVAL(ft).v_char); } } } diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index b2abbf2..89e33de 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -260,7 +260,7 @@ struct options int cc_only; /* compile only flag */ int intlong_rent; /* integer & long support routines reentrant */ int float_rent; /* floating point routines are reentrant */ - int out_fmt; /* 0 = undefined, 'i' = intel Hex format, 's' = motorola S19 format, 'E' = elf format, 'e' = true ELF format, 'Z' = gb format */ + int out_fmt; /* 0 = undefined, 'i' = intel Hex format, 's' = motorola S19 format, 'E' = elf format, 'Z' = gb format */ int cyclomatic; /* print cyclomatic information */ int noOverlay; /* don't overlay local variables & parameters */ int xram_movc; /* use movc instead of movx to read xram (mcs51) */ @@ -328,6 +328,7 @@ struct options int max_allocs_per_node; /* Maximum number of allocations / combinations considered at each node in the tree-decomposition based algorithms */ bool noOptsdccInAsm; /* Do not emit .optsdcc in asm */ bool oldralloc; /* Use old register allocator */ + int gasOutput; /* Output assembly in GNU as format */ }; /* forward definition for variables accessed globally */ @@ -362,7 +363,6 @@ extern struct optimize optimize; extern struct options options; extern unsigned maxInterrupts; extern int ignoreTypedefType; -extern int gasOutput; /* Visible from SDCCmain.c */ extern set *preArgvSet; diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 8251c43..77a56ce 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -33,6 +33,11 @@ symbol *interrupts[INTNO_MAX + 1]; +static void emit_ds_comm( struct dbuf_s *oBuf, + const char *name, + unsigned int size, + unsigned int alignment); + void printIval (symbol *, sym_link *, initList *, struct dbuf_s *, bool check); set *publics = NULL; /* public variables */ set *externs = NULL; /* Variables that are declared as extern */ @@ -146,6 +151,9 @@ emitRegularMap (memmap *map, bool addPublics, bool arFlag) if (!map) return; + if (options.gasOutput && !map->syms) + return; + if (addPublics) { /* PENDING: special case here - should remove */ @@ -154,7 +162,8 @@ emitRegularMap (memmap *map, bool addPublics, bool arFlag) else if (!strcmp (map->sname, DATA_NAME)) { dbuf_tprintf (&map->oBuf, "\t!areadata\n", map->sname); - if (options.data_seg && strcmp (DATA_NAME, options.data_seg)) + if (options.data_seg && strcmp (DATA_NAME, options.data_seg) && !options.gasOutput) + /* GNU as only needs .bss. */ dbuf_tprintf (&map->oBuf, "\t!area\n", options.data_seg); } else if (!strcmp (map->sname, HOME_NAME)) @@ -366,10 +375,17 @@ emitRegularMap (memmap *map, bool addPublics, bool arFlag) dbuf_printf (&map->oBuf, "==.\n"); } if (IS_STATIC (sym->etype) || sym->level) - dbuf_tprintf (&map->oBuf, "!slabeldef\n", sym->rname); + if (options.gasOutput) + dbuf_tprintf (&map->oBuf, "\t!local\n", sym->rname); + else + dbuf_tprintf (&map->oBuf, "!slabeldef\n", sym->rname); else - dbuf_tprintf (&map->oBuf, "!labeldef\n", sym->rname); - dbuf_tprintf (&map->oBuf, "\t!ds\n", (unsigned int) size & 0xffff); + if (options.gasOutput) + dbuf_tprintf (&map->oBuf, "!global\n", sym->rname); + else + dbuf_tprintf (&map->oBuf, "!labeldef\n", sym->rname); + + emit_ds_comm(&map->oBuf, sym->rname, size & 0xffff, 1/* TBD */); } sym->ival = NULL; @@ -518,7 +534,7 @@ initValPointer (ast *expr) while (t->left != NULL && t->opval.op != '[') t = t->left; - return valForStructElem (t, expr->right); + return valForStructElem (t, expr->right); } return NULL; @@ -854,7 +870,7 @@ printIvalType (symbol * sym, sym_link * type, initList * ilist, struct dbuf_s *o { if (!!(val = initPointer (ilist, type, 0))) { - int i, size = getSize (type), le = port->little_endian, top = (options.model == MODEL_FLAT24) ? 3 : 2;; + int i, size = getSize (type), le = port->little_endian, top = (options.model == MODEL_FLAT24) ? 3 : 2;; dbuf_printf (oBuf, "\t.byte "); for (i = (le ? 0 : size - 1); le ? (i < size) : (i > -1); i += (le ? 1 : -1)) { @@ -867,7 +883,7 @@ printIvalType (symbol * sym, sym_link * type, initList * ilist, struct dbuf_s *o if (val->name && strlen (val->name) > 0) dbuf_printf (oBuf, "(%s >> %d)", val->name, i * 8); else - dbuf_printf (oBuf, "#0x00"); + dbuf_printf (oBuf, "#0x00"); else dbuf_printf (oBuf, "#0x00"); if (i == (le ? (size - 1) : 0)) @@ -1983,8 +1999,12 @@ emitStaticSeg (memmap *map, struct dbuf_s *oBuf) } else { - dbuf_printf (oBuf, "%s:\n", sym->rname); - dbuf_tprintf (oBuf, "\t!ds\n", (unsigned int) size & 0xffff); + if (options.gasOutput) + dbuf_tprintf(oBuf, "\t!local\n", sym->rname); + else + dbuf_printf (oBuf, "%s:\n", sym->rname); + + emit_ds_comm(oBuf, sym->rname, size & 0xffff, 1/* TBD */); } } } @@ -2108,12 +2128,12 @@ createInterruptVect (struct dbuf_s *vBuf) } } -char *iComments1 = { +const char *iComments1 = { ";--------------------------------------------------------\n" "; File Created by SDCC : free open source ANSI-C Compiler\n" }; -char *iComments2 = { +const char *iComments2 = { ";--------------------------------------------------------\n" }; @@ -2177,7 +2197,7 @@ emitOverlay (struct dbuf_s *aBuf) if (elementsInSet (ovrset)) { /* output the area information */ - dbuf_printf (aBuf, "\t.area\t%s\n", port->mem.overlay_name); /* MOF */ + dbuf_printf (aBuf, "\t!area\t%s\n", port->mem.overlay_name); /* MOF */ } for (sym = setFirstItem (ovrset); sym; sym = setNextItem (ovrset)) @@ -2224,16 +2244,21 @@ emitOverlay (struct dbuf_s *aBuf) { werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE, sym->name); } - /* print extra debug info if required */ - if (options.debug) + /* print extra debug info if required. GNU as does not need this. */ + if (options.debug && !options.gasOutput) { emitDebugSym (aBuf, sym); dbuf_printf (aBuf, "==.\n"); } /* allocate space */ - dbuf_tprintf (aBuf, "!slabeldef\n", sym->rname); - dbuf_tprintf (aBuf, "\t!ds\n", (unsigned int) getSize (sym->type) & 0xffff); + if (options.gasOutput) + /* .bss variables do not need a label definition on GNU as. */ + dbuf_tprintf(aBuf, "\t!local\n", sym->rname); + else + dbuf_tprintf (aBuf, "!slabeldef\n", sym->rname); + + emit_ds_comm(aBuf, sym->rname, getSize (sym->type) & 0xffff, 1/* TBD */); } } } @@ -2458,10 +2483,31 @@ glue (void) /* create the stack segment MOF */ if (mainf && IFFUNC_HASBODY (mainf->type)) { + const char *const start_stack = "__start__stack"; + const unsigned int size = 1; + fprintf (asmFile, "%s", iComments2); fprintf (asmFile, "; Stack segment in internal ram \n"); fprintf (asmFile, "%s", iComments2); - fprintf (asmFile, "\t.area\tSSEG\n" "__start__stack:\n\t.ds\t1\n\n"); + + if (options.gasOutput) + { + char section_name[100]; + + snprintf( section_name, sizeof section_name / sizeof *section_name, + ".%s", start_stack); + /* Set alloc/write flags. */ + tfprintf(asmFile, "\t!area , \"aw\", @progbits\n", section_name); + tfprintf(asmFile, "\t!local\n", start_stack); + tfprintf(asmFile, "\t!comm\n\n", start_stack, size, 1); + } + else + { + tfprintf(asmFile, "\t!area\n", "SSEG"); + tfprintf(asmFile, "\t!labeldef\n", start_stack); + tfprintf(asmFile, "\t!ds\n\n", size); + tfprintf(asmFile, "\t!area\n" "__start__stack:\n", "SSEG"); + } } /* create the idata segment */ @@ -2539,8 +2585,9 @@ glue (void) dbuf_write_and_destroy (&xidata->oBuf, asmFile); } - /* If the port wants to generate any extra areas, let it do so. */ - if (port->extraAreas.genExtraAreaDeclaration) + /* If the port wants to generate any extra areas, let it do so. + * This is not needed for GNU as, though. */ + if (port->extraAreas.genExtraAreaDeclaration && !options.gasOutput) { port->extraAreas.genExtraAreaDeclaration (asmFile, mainf && IFFUNC_HASBODY (mainf->type)); } @@ -2559,16 +2606,24 @@ glue (void) 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. - */ - tfprintf (asmFile, "\t!area\n", port->mem.home_name); - tfprintf (asmFile, "\t!area\n", port->mem.static_name); /* MOF */ - tfprintf (asmFile, "\t!area\n", port->mem.post_static_name); - tfprintf (asmFile, "\t!area\n", port->mem.static_name); + if (!options.gasOutput) + { + /* 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. + */ + tfprintf (asmFile, "\t!area\n", port->mem.home_name); + tfprintf (asmFile, "\t!area\n", port->mem.static_name); /* MOF */ + tfprintf (asmFile, "\t!area\n", port->mem.post_static_name); + tfprintf (asmFile, "\t!area\n", port->mem.static_name); + } + + if (options.gasOutput) + { + tfprintf (asmFile, "\t!areacode\n", CODE_NAME); + } if (mainf && IFFUNC_HASBODY (mainf->type)) { @@ -2600,19 +2655,22 @@ glue (void) fprintf (asmFile, "\t%cjmp\t__sdcc_program_startup\n", options.acall_ajmp ? 'a' : 'l'); } - fprintf (asmFile, "%s" "; Home\n" "%s", iComments2, iComments2); - tfprintf (asmFile, "\t!areahome\n", HOME_NAME); - dbuf_write_and_destroy (&home->oBuf, asmFile); + if (!options.gasOutput) + { + fprintf (asmFile, "%s" "; Home\n" "%s", iComments2, iComments2); + tfprintf (asmFile, "\t!areahome\n", HOME_NAME); + dbuf_write_and_destroy (&home->oBuf, asmFile); + } if (mainf && IFFUNC_HASBODY (mainf->type)) { /* STM8 note: there is no need to call main(). - Instead of that, it's address is specified in the + Instead of that, its address is specified in the interrupts table and always equals to 0x8080. */ /* entry point @ start of HOME */ - fprintf (asmFile, "__sdcc_program_startup:\n"); + tfprintf (asmFile, "!labeldef\n", "__sdcc_program_startup"); /* put in jump or call to main */ if(TARGET_IS_STM8) @@ -2623,6 +2681,7 @@ glue (void) fprintf (asmFile, "\t%cjmp\t_main\n", options.acall_ajmp ? 'a' : 'l'); /* needed? */ fprintf (asmFile, ";\treturn from main will return to caller\n"); } + /* copy over code */ fprintf (asmFile, "%s", iComments2); fprintf (asmFile, "; code\n"); @@ -2672,3 +2731,13 @@ isTargetKeyword (const char *s) return 0; } +static void emit_ds_comm( struct dbuf_s *const oBuf, + const char *const name, + const unsigned int size, + const unsigned int alignment) +{ + if (options.gasOutput) + dbuf_tprintf(oBuf, "\t!comm\n", name, size, alignment); + else + dbuf_tprintf(oBuf, "\t!ds\n", size); +} diff --git a/src/SDCCmain.c b/src/SDCCmain.c index b20ef66..d83195a 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -65,7 +65,6 @@ struct optimize optimize; struct options options; int preProcOnly = 0; int noAssemble = 0; -int gasOutput; set *preArgvSet = NULL; /* pre-processor arguments */ set *asmOptionsSet = NULL; /* set of assembler options */ set *linkOptionsSet = NULL; /* set of linker options */ @@ -174,7 +173,7 @@ static const OPTION optionsTable[] = { {'M', NULL, NULL, "Preprocessor option"}, {'W', NULL, NULL, "Pass through options to the pre-processor (p), assembler (a) or linker (l)"}, {'S', NULL, &noAssemble, "Compile only; do not assemble or link"}, - {0 , "--gas", &gasOutput, "Compile only in GAS (GNU Assembler) format. Incompatible with other assembly or compilation options."}, + {0 , "--gas", &options.gasOutput, "Compile in GAS (GNU Assembler) format."}, {'c', "--compile-only", &options.cc_only, "Compile and assemble, but do not link"}, {'E', "--preprocessonly", &preProcOnly, "Preprocess only, do not compile"}, {0, "--c1mode", &options.c1mode, "Act in c1 mode. The standard input is preprocessed code, the output is assembly code."}, @@ -1490,12 +1489,6 @@ parseCmdLine (int argc, char **argv) } } - if (gasOutput && noAssemble) - { - /* Incompatible assembly output formats. */ - werror(W_ILLEGAL_OPT_COMBINATION); - } - /* some sanity checks in c1 mode */ if (options.c1mode) { @@ -1518,7 +1511,7 @@ parseCmdLine (int argc, char **argv) deleteSet (&relFilesSet); deleteSet (&libFilesSet); - if (options.cc_only || noAssemble || preProcOnly || gasOutput) + if (options.cc_only || noAssemble || preProcOnly || options.gasOutput) { werror (W_ILLEGAL_OPT_COMBINATION); } @@ -1598,7 +1591,7 @@ parseCmdLine (int argc, char **argv) } /* if debug option is set then open the cdbFile */ - if (options.debug && fullSrcFileName) + if (options.debug && fullSrcFileName && !options.gasOutput) { struct dbuf_s adbFile; @@ -2608,6 +2601,8 @@ main (int argc, char **argv, char **envp) port->init (); setDefaultOptions (); + + parseCmdLine (argc, argv); #ifdef JAMIN_DS390 if (ds390_jammed) { @@ -2616,8 +2611,6 @@ main (int argc, char **argv, char **envp) } #endif - parseCmdLine (argc, argv); - if (options.verbose && NULL != port->processor) printf ("Processor: %s\n", port->processor); @@ -2648,7 +2641,8 @@ main (int argc, char **argv, char **envp) initMem (); /* finalize target specific options */ - port->finaliseOptions (); + if (port->finaliseOptions) + port->finaliseOptions(); /* finalize common options */ finalizeOptions (); @@ -2675,18 +2669,8 @@ main (int argc, char **argv, char **envp) if (fatalError) exit (EXIT_FAILURE); - if (gasOutput) - { - if (port->general.gas_glue) - port->general.gas_glue(); - else - { - werror(W_ILLEGAL_OPT_COMBINATION, __FILE__, __LINE__, "selected target does not support GNU assembler output"); - exit (1); - } - } - else if (port->general.do_glue != NULL) - (*port->general.do_glue) (); + if (port->general.do_glue) + port->general.do_glue(); else { /* this shouldn't happen */ @@ -2698,7 +2682,7 @@ main (int argc, char **argv, char **envp) if (fatalError) exit (EXIT_FAILURE); - if (!options.c1mode && !noAssemble) + if (!options.c1mode && !noAssemble && !options.gasOutput) { if (options.verbose) printf ("sdcc: Calling assembler...\n"); @@ -2710,7 +2694,7 @@ main (int argc, char **argv, char **envp) if (options.debug && debugFile) debugFile->closeFile (); - if (!options.cc_only && !fatalError && !noAssemble && !options.c1mode && (fullSrcFileName || peekSet (relFilesSet) != NULL)) + if (!options.cc_only && !fatalError && !noAssemble && !options.gasOutput && !options.c1mode && (fullSrcFileName || peekSet (relFilesSet) != NULL)) { if (options.verbose) printf ("sdcc: Calling linker...\n"); @@ -2723,4 +2707,3 @@ main (int argc, char **argv, char **envp) return 0; } - diff --git a/src/SDCCmem.c b/src/SDCCmem.c index 550ee38..c1d8721 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -145,7 +145,7 @@ initMem () DEBUG-NAME - 'C' POINTER-TYPE - CPOINTER */ - code = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME, 'C', CPOINTER); + code = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, DATA_NAME, 'C', CPOINTER); /* home segment ; SFRSPACE - NO @@ -223,13 +223,13 @@ initMem () if (OVERLAY_NAME) overlay = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME, 'E', POINTER); - /* Xternal paged segment ; + /* Xternal paged segment ; SFRSPACE - NO FAR-SPACE - NO PAGED - YES DIRECT-ACCESS - NO BIT-ACCESS - NO - CODE-ACCESS - NO + CODE-ACCESS - NO DEBUG-NAME - 'P' POINTER-TYPE - PPOINTER */ @@ -664,7 +664,7 @@ allocParms (value *val, bool smallc) } else /* use internal stack */ { - + SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = istack; if ((port->stack.direction > 0) != smallc) { @@ -1048,7 +1048,7 @@ clearStackOffsets (void) sym = setNextItem (istack->syms)) { const int size = getSize (sym->type); - + /* nothing to do with parameters so continue */ if ((sym->_isparm && !IS_REGPARM (sym->etype))) continue; @@ -1093,7 +1093,7 @@ redoStackOffsets (void) /* Remove them all, and let btree_alloc() below put them back in more efficiently. */ currFunc->stack -= size; SPEC_STAK (currFunc->etype) -= size; - + if(IS_AGGREGATE (sym->type) || sym->allocreq) btree_add_symbol (sym); } diff --git a/src/SDCCmem.h b/src/SDCCmem.h index ddfea0b..8e1bc56 100644 --- a/src/SDCCmem.h +++ b/src/SDCCmem.h @@ -48,10 +48,10 @@ extern FILE *junkFile; /* memory map prefixes MOF added the DATA,CODE,XDATA,BIT */ #define XSTACK_NAME port->mem.xstack_name #define ISTACK_NAME port->mem.istack_name -#define CODE_NAME port->mem.code_name -#define DATA_NAME port->mem.data_name -#define INITIALIZED_NAME port->mem.initialized_name -#define INITIALIZER_NAME port->mem.initializer_name +#define CODE_NAME (options.gasOutput ? ".text" : port->mem.code_name) +#define DATA_NAME (options.gasOutput ? ".bss" : port->mem.data_name) +#define INITIALIZED_NAME (options.gasOutput ? ".data" : port->mem.data_name) +#define INITIALIZER_NAME (options.gasOutput ? ".data.rodata" : port->mem.data_name) #define IDATA_NAME port->mem.idata_name #define PDATA_NAME port->mem.pdata_name #define XDATA_NAME port->mem.xdata_name @@ -60,9 +60,9 @@ extern FILE *junkFile; #define BIT_NAME port->mem.bit_name #define REG_NAME port->mem.reg_name #define STATIC_NAME port->mem.static_name -#define HOME_NAME port->mem.home_name +#define HOME_NAME (options.gasOutput ? ".text.interrupt_vector" : port->mem.home_name) #define OVERLAY_NAME port->mem.overlay_name -#define CONST_NAME port->mem.const_name +#define CONST_NAME (options.gasOutput ? ".rodata" : port->mem.const_name) #define CABS_NAME port->mem.cabs_name #define XABS_NAME port->mem.xabs_name #define IABS_NAME port->mem.iabs_name diff --git a/src/pdk/main.c b/src/pdk/main.c index 21b1fc2..d28f2d4 100644 --- a/src/pdk/main.c +++ b/src/pdk/main.c @@ -68,8 +68,8 @@ pdk_genAssemblerEnd (FILE *of) int pdk_genIVT(struct dbuf_s *oBuf, symbol **intTable, int intCount) { - dbuf_tprintf (oBuf, "\t.area\tHEADER (ABS)\n"); - dbuf_tprintf (oBuf, "\t.org\t 0x0020\n"); + dbuf_tprintf (oBuf, "\t!area\tHEADER (ABS)\n"); + dbuf_tprintf (oBuf, "\t!org\t 0x0020\n"); if (interrupts[0]) dbuf_tprintf (oBuf, "\tgoto\t%s\n", interrupts[0]->rname); else @@ -85,7 +85,7 @@ pdk_genInitStartup (FILE *of) fprintf (of, "\t.org 0x00\n"); fprintf (of, "p::\n"); fprintf (of, "\t.ds 2\n"); - + fprintf (of, "\t.area\tHEADER (ABS)\n"); // In the header we have 16 bytes. First should be nop. fprintf (of, "\t.org 0x0000\n"); @@ -316,7 +316,7 @@ PORT pdk13_port = 0, 2, 1, /* sp points to next free stack location */ - }, + }, { -1, false }, /* no int x int -> long multiplication support routine. */ { 0, { @@ -482,7 +482,7 @@ PORT pdk14_port = 0, 2, 1, /* sp points to next free stack location */ - }, + }, { -1, false }, /* no int x int -> long multiplication support routine. */ { 0, { @@ -648,7 +648,7 @@ PORT pdk15_port = 0, 2, 1, /* sp points to next free stack location */ - }, + }, { -1, false }, /* no int x int -> long multiplication support routine. */ { 0, { @@ -217,8 +217,8 @@ typedef struct * due to ugly implementation in gbz80 target; * this should be fixed in src/z80/main.c (borutr) */ - const char *code_name; - const char *data_name; + const char *const code_name; + const char *const data_name; const char *const idata_name; const char *const pdata_name; const char *const xdata_name; diff --git a/src/stm8/main.c b/src/stm8/main.c index 49731a0..c183137 100644 --- a/src/stm8/main.c +++ b/src/stm8/main.c @@ -30,6 +30,7 @@ #include "dbuf_string.h" #include "peep.h" #include "SDCCgas.h" +#include "SDCCglobl.h" #define OPTION_MEDIUM_MODEL "--model-medium" #define OPTION_LARGE_MODEL "--model-large" @@ -154,7 +155,6 @@ stm8_genAssemblerEnd (FILE *of) static void stm8_init (void) { - asm_addTree (&asm_asxxxx_mapping); } @@ -187,6 +187,8 @@ stm8_parseOptions (int *pargc, char **argv, int *i) static void stm8_finaliseOptions (void) { + asm_addTree (options.gasOutput ? &asm_gas_mapping : &asm_asxxxx_mapping); + port->mem.default_local_map = data; port->mem.default_globl_map = data; @@ -238,7 +240,11 @@ stm8_genExtraArea (FILE *of, bool hasMain) static void stm8_genInitStartup (FILE *of) { - fprintf (of, "__sdcc_gs_init_startup:\n"); + const char *const startup = options.gasOutput ? + "_start" + : "__sdcc_gs_init_startup"; + + tfprintf (of, "!labeldef\n", startup); if (options.stack_loc >= 0) { @@ -247,7 +253,7 @@ stm8_genInitStartup (FILE *of) } /* Init static & global variables */ - fprintf (of, "__sdcc_init_data:\n"); + tfprintf (of, "!labeldef\n", "__sdcc_init_data"); fprintf (of, "; stm8_genXINIT() start\n"); /* Zeroing memory (required by standard for static & global variables) */ @@ -277,7 +283,13 @@ int stm8_genIVT(struct dbuf_s * oBuf, symbol ** intTable, int intCount) { int i; - dbuf_tprintf (oBuf, "\tint s_GSINIT ; reset\n"); + + if (options.gasOutput) + { + dbuf_tprintf(oBuf, "!area , \"ax\", @progbits\n", ".text.__interrupt"); + } + + dbuf_tprintf(oBuf, "\tint s_GSINIT ; reset\n"); if(intCount > STM8_INTERRUPTS_COUNT) { |
