diff --git a/mach/m68020/ce/EM_table b/mach/m68020/ce/EM_table index e5d8c74e8..099cbe3a9 100644 --- a/mach/m68020/ce/EM_table +++ b/mach/m68020/ce/EM_table @@ -881,3 +881,5 @@ C_prolog ==> . C_jump ==> "bra $1". C_locals ==> "link a6, #-$1". + +C_db_sline ==> "jsr (___u_LiB)". diff --git a/mach/vax4/ce/EM_table b/mach/vax4/ce/EM_table index 1c2194cfa..d7972b133 100644 --- a/mach/vax4/ce/EM_table +++ b/mach/vax4/ce/EM_table @@ -777,3 +777,5 @@ C_locals $1 == 4 ==> "clrq -(sp)". $1 == 8 ==> "clrq -(sp)". default ==> "subl2 ~$1, sp". + +C_db_sline ==> "calls ~0, ___u_LiB". diff --git a/util/ceg/EM_parser/common/C_instr2.c b/util/ceg/EM_parser/common/C_instr2.c index bd85a5401..19281bd49 100644 --- a/util/ceg/EM_parser/common/C_instr2.c +++ b/util/ceg/EM_parser/common/C_instr2.c @@ -145,7 +145,7 @@ t_C_info C_info[] = { { "str", 0, 0, 0}} }, *C_instr_info; -#define N_INSTR 269 +#define N_INSTR 270 struct { char *name; int class, segment;} EM_instr[ N_INSTR ] = { @@ -220,6 +220,7 @@ struct { char *name; int class, segment;} { "C_cuf", NO_ARGS, SEGTXT}, { "C_cui", NO_ARGS, SEGTXT}, { "C_cuu", NO_ARGS, SEGTXT}, + { "C_db_sline", NO_ARGS, SEGTXT}, { "C_dch", NO_ARGS, SEGTXT}, { "C_dec", NO_ARGS, SEGTXT}, { "C_dee", EXTERNAL, SEGTXT}, diff --git a/util/ceg/ce_back/as_back/.distr b/util/ceg/ce_back/as_back/.distr index 65edd256c..fbc0bdb4e 100644 --- a/util/ceg/ce_back/as_back/.distr +++ b/util/ceg/ce_back/as_back/.distr @@ -27,3 +27,4 @@ symboldef.c text1.c text2.c text4.c +dbsym.c diff --git a/util/ceg/ce_back/as_back/dbsym.c b/util/ceg/ce_back/as_back/dbsym.c new file mode 100644 index 000000000..c18448de8 --- /dev/null +++ b/util/ceg/ce_back/as_back/dbsym.c @@ -0,0 +1,26 @@ +#include "header.h" + +#ifndef OWN_SYMB +B_symbstr(s, len, type, add, val, added) +char *s, *val; +arith added; +{ + if (! s) s = ""; + fprint(codefile, ".symb \"%s\", %s+%ld, 0x%x, %d\n", s, val, (long) added, type, add); +} + +B_symbcst(s, len, type, add, val) +char *s; +arith val; +{ + if (! s) s = ""; + fprint(codefile, ".symb \"%s\", %ld, 0x%x, %d\n", s, val, type, add); +} + +B_symd(s, len, type, add) +char *s; +{ + if (! s) s = ""; + fprint(codefile, ".symd \"%s\", 0x%x, %d\n", s, type, add); +} +#endif diff --git a/util/ceg/ce_back/as_back/proto.make b/util/ceg/ce_back/as_back/proto.make index 265b0c034..31b4ce71a 100644 --- a/util/ceg/ce_back/as_back/proto.make +++ b/util/ceg/ce_back/as_back/proto.make @@ -17,7 +17,7 @@ all: bottom.$(SUF) con1.$(SUF) con2.$(SUF) con4.$(SUF) end_back.$(SUF) \ reloc2.$(SUF) reloc4.$(SUF) bss.$(SUF) rom1.$(SUF) rom2.$(SUF) \ rom4.$(SUF) set_global.$(SUF) set_local.$(SUF) switchseg.$(SUF) \ symboldef.$(SUF) do_open.$(SUF) do_close.$(SUF) text1.$(SUF) \ - text2.$(SUF) text4.$(SUF) + text2.$(SUF) text4.$(SUF) dbsym.$(SUF) bottom.$(SUF) : $(SRC_DIR)/mach.h back.h header.h $(SOURCE)/bottom.c $(CC) $(CFLAGS) -c $(SOURCE)/bottom.c @@ -93,3 +93,6 @@ switchseg.$(SUF) : header.h back.h $(SRC_DIR)/mach.h $(SOURCE)/switchseg.c symboldef.$(SUF) : header.h back.h $(SRC_DIR)/mach.h $(SOURCE)/symboldef.c $(CC) $(CFLAGS) -c $(SOURCE)/symboldef.c + +dbsym.$(SUF) : header.h back.h $(SRC_DIR)/mach.h $(SOURCE)/dbsym.c + $(CC) $(CFLAGS) -c $(SOURCE)/dbsym.c diff --git a/util/ceg/ce_back/obj_back/.distr b/util/ceg/ce_back/obj_back/.distr index 4d503dcc9..cd700c6ed 100644 --- a/util/ceg/ce_back/obj_back/.distr +++ b/util/ceg/ce_back/obj_back/.distr @@ -33,3 +33,4 @@ symtable.c text2.c text4.c common.c +dbsym.c diff --git a/util/ceg/ce_back/obj_back/extnd.c b/util/ceg/ce_back/obj_back/extnd.c index 221fb086f..2fda33b83 100644 --- a/util/ceg/ce_back/obj_back/extnd.c +++ b/util/ceg/ce_back/obj_back/extnd.c @@ -77,9 +77,9 @@ char *s; char *extnd_dlb( g) -arith g; +label g; { - string_lengte = mysprint( DLB_FMT, (arith)g); + string_lengte = mysprint( DLB_FMT, (long)g); index_symbol_table = find_sym( string, STORE_STRING); return( symbol_table[ index_symbol_table].on_foff + string_area); } @@ -88,7 +88,7 @@ arith g; char *extnd_ilb( l, prcno) arith l; { - string_lengte = mysprint( ILB_FMT, prcno, (arith) l); + string_lengte = mysprint( ILB_FMT, prcno, (long) l); index_symbol_table = find_sym( string, STORE_STRING); return( symbol_table[ index_symbol_table].on_foff + string_area); } diff --git a/util/ceg/ce_back/obj_back/header.h b/util/ceg/ce_back/obj_back/header.h index a63379409..f48ca3f23 100644 --- a/util/ceg/ce_back/obj_back/header.h +++ b/util/ceg/ce_back/obj_back/header.h @@ -3,5 +3,6 @@ #define SYMBOL_DEFINITION 1 #define REFERENCE 2 #define STORE_STRING 3 +#define FORCE_DEF 4 #define conv_seg( s) ( ( s == SEGROM) ? SEGCON : s) diff --git a/util/ceg/ce_back/obj_back/output.c b/util/ceg/ce_back/obj_back/output.c index 57a581000..0bf5947ba 100644 --- a/util/ceg/ce_back/obj_back/output.c +++ b/util/ceg/ce_back/obj_back/output.c @@ -17,7 +17,7 @@ output_back() { struct outhead header; struct outsect sect; - long ntext = text - text_area, + long ntext = text - text_area, ndata = data - data_area, nchar; @@ -94,12 +94,13 @@ reduce_name_table() * After that, the string table is reduced. */ -#define S_NEEDED 0x8000 -#define removable(nm) (!(nm.on_type & S_NEEDED) && *(nm.on_foff+string_area) == GENLAB) +#define S_NEEDED S_MOD +#define removable(nm) (!(nm->on_type & (S_NEEDED|S_STB)) && *(nm->on_foff+string_area) == GENLAB) register int *diff_index = (int *) Malloc((unsigned)(nname + 1) * sizeof(int)); register struct outrelo *rp = reloc_info; + register struct outname *np; register int i; char *new_str; register char *p, *q; @@ -113,22 +114,31 @@ reduce_name_table() rp++; } - for (i = 0; i < nname; i++) { + for (i = 0, np = symbol_table; i < nname; i++, np++) { diff_index[i] = diff_index[i-1]; - if (removable(symbol_table[i])) { + if (removable(np)) { diff_index[i]++; } + if ((np->on_type & S_TYP) == S_CRS) { + struct outname *n = &symbol_table[(int) np->on_valu]; + if (! (n->on_type & S_COM)) { + np->on_type &= ~S_TYP; + np->on_type |= (n->on_type & S_TYP); + np->on_valu = n->on_valu; + } + } } rp = reloc_info; for (i = 0; i < nrelo; i++) { + symbol_table[rp->or_nami].on_type &= ~S_NEEDED; rp->or_nami -= diff_index[rp->or_nami]; rp++; } - for (i = 0; i < nname; i++) { - register struct outname *np = &symbol_table[i]; - - np->on_type &= ~S_NEEDED; + for (i = 0, np = symbol_table; i < nname; i++, np++) { + if ((np->on_type & S_TYP) == S_CRS) { + np->on_valu -= diff_index[(int) np->on_valu]; + } if (diff_index[i] && diff_index[i] == diff_index[i-1]) { symbol_table[i - diff_index[i]] = *np; } @@ -138,14 +148,20 @@ reduce_name_table() free((char *)(diff_index-1)); new_str = q = Malloc((unsigned)(string - string_area)); - for (i = 0; i < nname; i++) { - p = symbol_table[i].on_foff + string_area; - symbol_table[i].on_foff = q - new_str; + for (i = 0, np = symbol_table; i < nname; i++, np++) { + p = np->on_foff + string_area; + np->on_foff = q - new_str; while (*q++ = *p) p++; } free(string_area); string_area = new_str; string = q; + for (i = 0, np = symbol_table; i < nname; i++, np++) { + if ((np->on_type & S_TYP) == S_CRS) { + /* replace by reference to string */ + np->on_valu = symbol_table[(int) np->on_valu].on_foff; + } + } } wr_fatal() @@ -159,11 +175,14 @@ static convert_outname( header) struct outhead *header; { - int i; + int i; + register struct outname *np; + register long l = OFF_CHAR(*header); - for ( i=0; i < nname; i++) { - symbol_table[ i].on_foff += OFF_CHAR( *header); - } + for (i = 0, np = symbol_table; i < nname; i++, np++) { + np->on_foff += l; + if ((np->on_type & S_TYP) == S_CRS) { + np->on_valu += l; + } + } } - - diff --git a/util/ceg/ce_back/obj_back/proto.make b/util/ceg/ce_back/obj_back/proto.make index 393987488..4f004c23a 100644 --- a/util/ceg/ce_back/obj_back/proto.make +++ b/util/ceg/ce_back/obj_back/proto.make @@ -17,7 +17,8 @@ all: data.$(SUF) con2.$(SUF) con4.$(SUF) relocation.$(SUF) end_back.$(SUF) \ reloc1.$(SUF) reloc2.$(SUF) reloc4.$(SUF) rom2.$(SUF) rom4.$(SUF) \ set_global.$(SUF) set_local.$(SUF) switchseg.$(SUF) symboldef.$(SUF) \ text2.$(SUF) text4.$(SUF) do_open.$(SUF) do_close.$(SUF) memory.$(SUF) \ - label.$(SUF) misc.$(SUF) extnd.$(SUF) symtable.$(SUF) common.$(SUF) + label.$(SUF) misc.$(SUF) extnd.$(SUF) symtable.$(SUF) common.$(SUF) \ + dbsym.$(SUF) data.$(SUF) : data.h back.h header.h $(SOURCE)/data.c $(CC) $(CFLAGS) -c $(SOURCE)/data.c @@ -106,3 +107,5 @@ label.$(SUF) : data.h back.h $(SRC_DIR)/mach.h $(SOURCE)/label.c common.$(SUF) : data.h back.h $(SRC_DIR)/mach.h $(SOURCE)/common.c $(CC) $(CFLAGS) -c $(SOURCE)/common.c +dbsym.$(SUF) : data.h back.h $(SRC_DIR)/mach.h $(SOURCE)/dbsym.c + $(CC) $(CFLAGS) -c $(SOURCE)/dbsym.c diff --git a/util/ceg/ce_back/obj_back/symtable.c b/util/ceg/ce_back/obj_back/symtable.c index db324a96e..8733392e3 100644 --- a/util/ceg/ce_back/obj_back/symtable.c +++ b/util/ceg/ce_back/obj_back/symtable.c @@ -45,7 +45,8 @@ int isdef; register struct Hashitem *ip; register int h; - if ( index_symbol_table != -1 ) { + if (isdef != FORCE_DEF) { + if ( index_symbol_table != -1 ) { s = symbol_table + index_symbol_table; if ( sym == s->on_foff + string_area) { if ( (s->on_valu == -2) && ( isdef == REFERENCE)) { @@ -54,10 +55,10 @@ int isdef; } return( index_symbol_table); } - } + } - h = Hash(sym); - for ( ip = Hashtab[h] + Hashitems ; ip != Hashitems; + h = Hash(sym); + for ( ip = Hashtab[h] + Hashitems ; ip != Hashitems; ip = (ip->hs_next) + Hashitems) { register char *p = sym, *q; @@ -70,26 +71,30 @@ int isdef; } return ip->hs_nami; } + } } if ( nname >= size_symbol) mem_symbol_hash(); s = symbol_table + nname; - ip = Hashitems + nname + 1; /* skip the first entry */ - if (isdef == REFERENCE) { + if (isdef != FORCE_DEF) { + ip = Hashitems + nname + 1; /* skip the first entry */ + + if (isdef == REFERENCE) { s->on_type = S_EXT; s->on_valu = -1; - } - if (isdef == STORE_STRING) { + } + if (isdef == STORE_STRING) { s->on_type = S_UND; s->on_valu = -2; - } + } - ip->hs_nami = nname; - ip->hs_next = Hashtab[h]; - Hashtab[h] = ip - Hashitems; + ip->hs_nami = nname; + ip->hs_next = Hashtab[h]; + Hashtab[h] = ip - Hashitems; + } if ( sym == string) string += string_lengte; diff --git a/util/ceg/ce_back/proto.make b/util/ceg/ce_back/proto.make index 54423a3fd..25ff80c4f 100644 --- a/util/ceg/ce_back/proto.make +++ b/util/ceg/ce_back/proto.make @@ -11,14 +11,14 @@ ASLIST = back.h bottom.c bss.c con1.c con2.c con4.c \ do_close.c do_open.c end_back.c gen1.c gen2.c gen4.c header.h \ init_back.c reloc1.c reloc2.c reloc4.c rom1.c rom2.c rom4.c \ set_global.c set_local.c switchseg.c symboldef.c text1.c \ - text2.c text4.c + text2.c text4.c dbsym.c OBJLIST = back.h con2.c con4.c data.c data.h do_close.c do_open.c \ end_back.c extnd.c gen1.c gen2.c gen4.c hash.h header.h \ init_back.c label.c memory.c misc.c output.c \ reloc1.c reloc2.c reloc4.c relocation.c rom2.c rom4.c \ set_global.c set_local.c switchseg.c symboldef.c symtable.c \ - text2.c text4.c common.c + text2.c text4.c common.c dbsym.c all: diff --git a/util/ceg/defaults/message/C_cst.c b/util/ceg/defaults/message/C_cst.c index ca7682e3a..0118528b8 100644 --- a/util/ceg/defaults/message/C_cst.c +++ b/util/ceg/defaults/message/C_cst.c @@ -1,7 +1,26 @@ #define CODE_EXPANDER #include +#include +#include + +extern int __db_mes, __db_cst, __db_len, __db_type, __db_add; +extern char *__db_str; C_cst( l) arith l; { + if (__db_mes) { + if (! __db_cst) __db_type = l; + else if (__db_cst == 1) { + if (__db_mes == ms_std) { + if (__db_type == N_SLINE) { + C_db_sline(); + } + B_symd(__db_str, __db_len, __db_type, (int) l); + } + else __db_add = l; + } + else B_symbcst(__db_str, __db_len, __db_type, __db_add, l); + __db_cst++; + } } diff --git a/util/ceg/defaults/message/C_dlb.c b/util/ceg/defaults/message/C_dlb.c index 49746d87c..a6da60a99 100644 --- a/util/ceg/defaults/message/C_dlb.c +++ b/util/ceg/defaults/message/C_dlb.c @@ -1,8 +1,15 @@ #define CODE_EXPANDER #include +#include "back.h" + +extern int __db_mes, __db_len, __db_type, __db_add; +extern char *__db_str; C_dlb( l, val) label l; -char *val; +arith val; { + if (__db_mes) { + B_symbstr(__db_str, __db_len, __db_type, __db_add, extnd_dlb(l), val); + } } diff --git a/util/ceg/defaults/message/C_dnam.c b/util/ceg/defaults/message/C_dnam.c index c673ad6d6..5a9cac4d8 100644 --- a/util/ceg/defaults/message/C_dnam.c +++ b/util/ceg/defaults/message/C_dnam.c @@ -1,8 +1,15 @@ #define CODE_EXPANDER #include +#include "back.h" + +extern int __db_mes, __db_len, __db_type, __db_add; +extern char *__db_str; C_dnam( str, val) char *str; arith val; { + if (__db_mes) { + B_symbstr(__db_str, __db_len, __db_type, __db_add, extnd_dnam(str), val); + } } diff --git a/util/ceg/defaults/message/C_ilb.c b/util/ceg/defaults/message/C_ilb.c index 8d431ae39..091feb6f8 100644 --- a/util/ceg/defaults/message/C_ilb.c +++ b/util/ceg/defaults/message/C_ilb.c @@ -1,7 +1,16 @@ #define CODE_EXPANDER #include +#include "back.h" + +extern int __db_mes, __db_len, __db_type, __db_add; +extern char *__db_str; + +extern int B_procno; C_ilb( l) label l; { + if (__db_mes) { + B_symbstr(__db_str, __db_len, __db_type, __db_add, extnd_ilb(l, B_procno), (arith) 0); + } } diff --git a/util/ceg/defaults/message/C_mes_begin.c b/util/ceg/defaults/message/C_mes_begin.c index 773391b89..dedcbf85a 100644 --- a/util/ceg/defaults/message/C_mes_begin.c +++ b/util/ceg/defaults/message/C_mes_begin.c @@ -1,7 +1,16 @@ #define CODE_EXPANDER #include +#include + +int __db_mes; +char *__db_str = 0; +int __db_len = 0; +int __db_cst = 0; +int __db_type; +int __db_add; C_mes_begin( ms) int ms; { + __db_mes = (ms == ms_stb || ms == ms_std) ? ms : 0; } diff --git a/util/ceg/defaults/message/C_mes_end.c b/util/ceg/defaults/message/C_mes_end.c index 542124a44..cf303b732 100644 --- a/util/ceg/defaults/message/C_mes_end.c +++ b/util/ceg/defaults/message/C_mes_end.c @@ -1,6 +1,15 @@ #define CODE_EXPANDER #include +extern int __db_mes; +extern int __db_cst; +extern char *__db_str; + C_mes_end() { + if (__db_mes) { + __db_mes = 0; + __db_cst = 0; + __db_str = 0; + } } diff --git a/util/ceg/defaults/message/C_pnam.c b/util/ceg/defaults/message/C_pnam.c index af5b853be..117f3c2cb 100644 --- a/util/ceg/defaults/message/C_pnam.c +++ b/util/ceg/defaults/message/C_pnam.c @@ -1,7 +1,14 @@ #define CODE_EXPANDER #include +#include "back.h" + +extern int __db_mes, __db_len, __db_type, __db_add; +extern char *__db_str; C_pnam( str) char *str; { + if (__db_mes) { + B_symbstr(__db_str, __db_len, __db_type, __db_add, extnd_name(str), (arith) 0); + } } diff --git a/util/ceg/defaults/message/C_scon.c b/util/ceg/defaults/message/C_scon.c index 6d89bcd98..612cc4736 100644 --- a/util/ceg/defaults/message/C_scon.c +++ b/util/ceg/defaults/message/C_scon.c @@ -1,8 +1,16 @@ #define CODE_EXPANDER #include +extern int __db_mes; +extern char *__db_str; +extern int __db_len; + C_scon( str, siz) char *str; arith siz; { + if (__db_mes) { + __db_str = str; + __db_len = siz; + } } diff --git a/util/ceg/defaults/not_impl/not_impl_table b/util/ceg/defaults/not_impl/not_impl_table index d4923754d..7c0c9c483 100644 --- a/util/ceg/defaults/not_impl/not_impl_table +++ b/util/ceg/defaults/not_impl/not_impl_table @@ -268,3 +268,4 @@ C_bss_fcon ==> not_implemented( "C_bss_fcon"). C_hol_fcon ==> not_implemented( "C_hol_fcon"). C_con_fcon ==> not_implemented( "C_con_fcon"). C_exc ==> not_implemented( "C_exc"). +C_db_sline ==> .