diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-22 02:10:51 +0200 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-22 02:10:51 +0200 |
| commit | 5a0c2910df62b99fee8baec1f4d846217cd9a054 (patch) | |
| tree | 583963809fe49cbb8b498f6621862589601ba53d /src | |
| parent | 958912f9285175ff95bb0070bea603dd8aef8222 (diff) | |
| download | sdcc-gas-5a0c2910df62b99fee8baec1f4d846217cd9a054.tar.gz | |
First working example!
stm8/main.c: 0x8000 must contain the entry point aka "_start" for GNU as.
Some work on supporting debugging symbols with --gas. Not finished yet.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 2 | ||||
| -rw-r--r-- | src/Makefile.dep | 6 | ||||
| -rw-r--r-- | src/Makefile.in | 2 | ||||
| -rw-r--r-- | src/SDCCdwarf2.c | 6 | ||||
| -rw-r--r-- | src/SDCCglue.c | 53 | ||||
| -rw-r--r-- | src/SDCCmain.c | 21 | ||||
| -rw-r--r-- | src/port.h | 4 | ||||
| -rw-r--r-- | src/stm8/gen.c | 9 | ||||
| -rw-r--r-- | src/stm8/main.c | 7 |
9 files changed, 60 insertions, 50 deletions
diff --git a/src/Makefile b/src/Makefile index 8604fee..3cc5b4b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -34,7 +34,7 @@ OBJECTS = SDCCy.o SDCChasht.o SDCCmain.o \ SDCCBBlock.o SDCCloop.o SDCCcse.o SDCCcflow.o SDCCdflow.o \ SDCClrange.o SDCCptropt.o SDCCpeeph.o SDCCglue.o \ SDCCasm.o SDCCmacro.o SDCCutil.o SDCCdebug.o cdbFile.o SDCCdwarf2.o\ - SDCCerr.o SDCCsystem.o SDCCgen.o SDCCgas.o + SDCCerr.o SDCCsystem.o SDCCgen.o SPECIAL = SDCCy.h ifeq ($(USE_ALT_LEX), 1) diff --git a/src/Makefile.dep b/src/Makefile.dep index f5ac324..0c2c201 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -197,12 +197,6 @@ SDCCgen.o: SDCCgen.c common.h SDCCglobl.h SDCCset.h ../sdccconf.h \ SDCCbitv.h SDCCset.h SDCCast.h SDCCdebug.h SDCCutil.h SDCCasm.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 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/Makefile.in b/src/Makefile.in index f1d012a..dff9d62 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -34,7 +34,7 @@ OBJECTS = SDCCy.o SDCChasht.o SDCCmain.o \ SDCCBBlock.o SDCCloop.o SDCCcse.o SDCCcflow.o SDCCdflow.o \ SDCClrange.o SDCCptropt.o SDCCpeeph.o SDCCglue.o \ SDCCasm.o SDCCmacro.o SDCCutil.o SDCCdebug.o cdbFile.o SDCCdwarf2.o\ - SDCCerr.o SDCCsystem.o SDCCgen.o SDCCgas.o + SDCCerr.o SDCCsystem.o SDCCgen.o SPECIAL = SDCCy.h ifeq ($(USE_ALT_LEX), 1) diff --git a/src/SDCCdwarf2.c b/src/SDCCdwarf2.c index a5e8bd8..7322b4b 100644 --- a/src/SDCCdwarf2.c +++ b/src/SDCCdwarf2.c @@ -100,7 +100,11 @@ dwNewDebugSymbol (void) { char debugSym[SDCC_NAME_MAX]; - sprintf (debugSym, "S%s$%s$%d", dwModuleName, currFunc->name, dwDebugSymbol); + if (options.gasOutput) + sprintf (debugSym, "%s_%s_%d$", dwModuleName, currFunc->name, dwDebugSymbol); + else + sprintf (debugSym, "S%s$%s$%d", dwModuleName, currFunc->name, dwDebugSymbol); + dwDebugSymbol++; return Safe_strdup (debugSym); } diff --git a/src/SDCCglue.c b/src/SDCCglue.c index e8ea6b9..1fc3d6d 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -124,19 +124,22 @@ aopLiteral (value *val, int offset) static void emitDebugSym (struct dbuf_s *oBuf, symbol * sym) { - if (sym->level && sym->localof) /* symbol scope is local */ { - dbuf_printf (oBuf, "L%s.%s$", moduleName, sym->localof->name); - } - else if (IS_STATIC (sym->etype)) /* symbol scope is file */ - { - dbuf_printf (oBuf, "F%s$", moduleName); - } - else /* symbol scope is global */ - { - dbuf_printf (oBuf, "G$"); + if (sym->level && sym->localof) /* symbol scope is local */ + { + dbuf_printf (oBuf, "L%s.%s$", moduleName, sym->localof->name); + } + else if (IS_STATIC (sym->etype)) /* symbol scope is file */ + { + dbuf_printf (oBuf, "F%s$", moduleName); + } + else /* symbol scope is global */ + { + dbuf_printf (oBuf, "G$"); + } + + dbuf_printf (oBuf, "%s$%ld_%ld$%d", sym->name, sym->level / LEVEL_UNIT, sym->level % LEVEL_UNIT, sym->block); } - dbuf_printf (oBuf, "%s$%ld_%ld$%d", sym->name, sym->level / LEVEL_UNIT, sym->level % LEVEL_UNIT, sym->block); } /*-----------------------------------------------------------------*/ @@ -151,9 +154,6 @@ emitRegularMap (memmap *map, bool addPublics, bool arFlag) if (!map) return; - if (options.gasOutput && !map->syms) - return; - if (addPublics && !options.gasOutput) { /* PENDING: special case here - should remove */ @@ -380,7 +380,11 @@ emitRegularMap (memmap *map, bool addPublics, bool arFlag) if (options.debug) { emitDebugSym (&map->oBuf, sym); - dbuf_printf (&map->oBuf, "==.\n"); + + if (options.gasOutput) + dbuf_printf (&map->oBuf, ":\n"); + else + dbuf_printf (&map->oBuf, "==.\n"); } if (IS_STATIC (sym->etype) || sym->level) if (options.gasOutput) @@ -2252,11 +2256,15 @@ emitOverlay (struct dbuf_s *aBuf) { werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE, sym->name); } - /* print extra debug info if required. GNU as does not need this. */ - if (options.debug && !options.gasOutput) + /* print extra debug info if required. */ + if (options.debug) { emitDebugSym (aBuf, sym); - dbuf_printf (aBuf, "==.\n"); + + if (options.gasOutput) + dbuf_printf (aBuf, ":\n"); + else + dbuf_printf (aBuf, "==.\n"); } /* allocate space */ @@ -2648,13 +2656,14 @@ glue (void) /* STM8 / PDK14 note: there are no such instructions supported. Also, we don't need this logic as well. */ - if (port->general.glue_up_main && mainf && IFFUNC_HASBODY (mainf->type)) + if (port->general.glue_up_main && mainf && IFFUNC_HASBODY (mainf->type) && !options.gasOutput) { /* 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. - */ + * This area is guaranteed to follow the static area + * by the ugly shucking and jiving about 20 lines ago. + */ tfprintf (asmFile, "\t!area\n", port->mem.post_static_name); + if(TARGET_IS_STM8) fprintf (asmFile, "\tjp\t__sdcc_program_startup\n"); else if(TARGET_PDK_LIKE) diff --git a/src/SDCCmain.c b/src/SDCCmain.c index affd5a1..feb8f5f 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -1592,21 +1592,22 @@ parseCmdLine (int argc, char **argv) } /* if debug option is set then open the cdbFile */ - if (options.debug && fullSrcFileName && !options.gasOutput) + if (options.debug && fullSrcFileName) { - struct dbuf_s adbFile; + struct dbuf_s adbFile; - dbuf_init (&adbFile, PATH_MAX); - dbuf_append_str (&adbFile, dstFileName); - dbuf_append_str (&adbFile, ".adb"); + dbuf_init (&adbFile, PATH_MAX); + dbuf_append_str (&adbFile, dstFileName); + dbuf_append_str (&adbFile, ".adb"); - if (debugFile->openFile (dbuf_c_str (&adbFile))) - debugFile->writeModule (moduleName); - else - werror (E_FILE_OPEN_ERR, dbuf_c_str (&adbFile)); + if (debugFile->openFile (dbuf_c_str (&adbFile))) + debugFile->writeModule (moduleName); + else + werror (E_FILE_OPEN_ERR, dbuf_c_str (&adbFile)); - dbuf_destroy (&adbFile); + dbuf_destroy (&adbFile); } + MSVC_style (options.vc_err_style); return 0; @@ -119,10 +119,6 @@ typedef struct /** return the model string, used as library destination; port->target is used as model string if get_model is NULL */ const char *(*get_model) (void); - /** Pointer to GAS (GNU assembler) glue function. - * If none is available, it means there is no support - * for this port yet. */ - void (*gas_glue)(void); } general; diff --git a/src/stm8/gen.c b/src/stm8/gen.c index ff195d9..80fd74e 100644 --- a/src/stm8/gen.c +++ b/src/stm8/gen.c @@ -2339,7 +2339,12 @@ void stm8_emitDebuggerSymbol (const char *debugSym) { G.debugLine = 1; - emit2 ("", "%s ==.", debugSym); + + if (options.gasOutput) + emit2 ("", "%s:", debugSym); + else + emit2 ("", "%s ==.", debugSym); + G.debugLine = 0; } @@ -3358,6 +3363,8 @@ genFunction (iCode *ic) emit2 (";", " function %s", sym->name); emit2 (";", "-----------------------------------------"); + /* Place each new function into its own section so GNU ld + * can perform dead code elimination via --gc-sections. */ if (options.function_sections && options.gasOutput) { char name[256]; diff --git a/src/stm8/main.c b/src/stm8/main.c index dbef2a8..b935f96 100644 --- a/src/stm8/main.c +++ b/src/stm8/main.c @@ -29,7 +29,6 @@ #include "gen.h" #include "dbuf_string.h" #include "peep.h" -#include "SDCCgas.h" #include "SDCCglobl.h" #define OPTION_MEDIUM_MODEL "--model-medium" @@ -277,7 +276,7 @@ stm8_genInitStartup (FILE *of) else { fprintf(of, - ".global _start\n" + "\t.global _start\n" "_start:\n" "\t; Zeroing .bss\n" "\tldw x, __bss_start\n" @@ -308,7 +307,8 @@ stm8_genIVT(struct dbuf_s * oBuf, symbol ** intTable, int intCount) int i; if (options.gasOutput) - dbuf_tprintf(oBuf, "\tint __interrupt_vect ; reset\n"); + /* Set entry point address. */ + dbuf_tprintf(oBuf, "\tint _start ; reset\n"); else dbuf_tprintf(oBuf, "\tint s_GSINIT ; reset\n"); @@ -441,7 +441,6 @@ PORT stm8_port = MODEL_MEDIUM | MODEL_LARGE, MODEL_MEDIUM, &get_model, /* model string used as library destination */ - gas_glue }, { /* Assembler */ stm8AsmCmd, |
