From: kaashoek Date: Wed, 25 Nov 1987 13:54:01 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: release-5-5~3707 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=152faf2b36a5a6976e8bb97d84a66d0f9c21a387;p=ack.git *** empty log message *** --- diff --git a/util/ceg/ce_back/obj_back/Makefile b/util/ceg/ce_back/obj_back/Makefile index f0d5aa9ff..d906b05ea 100644 --- a/util/ceg/ce_back/obj_back/Makefile +++ b/util/ceg/ce_back/obj_back/Makefile @@ -7,11 +7,7 @@ IDIRS=-I.\ -I$(EM)/h\ -I$(EM)/modules/h -LIBS=$(EM)/modules/lib/object.a\ - $(EM)/modules/lib/libstring.a\ - $(EM)/modules/lib/libprint.a\ - $(EM)/modules/lib/liballoc.a\ - $(EM)/modules/lib/libsystem.a +LIBS=$(EM)/modules/lib/*.a all : data.o con2.o con4.o relocation.o end_back.o gen1.o gen2.o\ gen4.o init_back.o mysprint.o output.o reloc1.o reloc2.o reloc4.o\ diff --git a/util/ceg/ce_back/obj_back/data.c b/util/ceg/ce_back/obj_back/data.c index edca182de..76577f3d7 100644 --- a/util/ceg/ce_back/obj_back/data.c +++ b/util/ceg/ce_back/obj_back/data.c @@ -2,6 +2,26 @@ #include #include "mach.h" +/* Global datastructures : + * - 'text_area' points to the text segment, 'text' points to first free + * entry in the text segment. + * - 'data_area' points to the data segment, 'data' points to the first free + * entry in the data segmnet. + * - 'string_area' points to the string area, 'string' points to the first free + * entry in the string area. + * - 'reloc_info' points to the relocation table, 'relo' points to the first + * free entry in the relocation table. + * - 'symbol_table' points to the symbol table, 'nname' is the index of the + * first free entry in the symbol_table. If pointers were used it is a pain + * to do a realloc on the symbol table, because all pointers in the + * relocation table to the symbol table have to be updated. + * - The bss segment contains only one vaue, so its enough to count the + * the bytes wanted. + * - The 'size_*' variables count the number of entries in each segment. + * - 'cur_seg' contains the number of the segment to be filled. + * (see "back.h") + */ + char *text_area, *data_area, diff --git a/util/ceg/ce_back/obj_back/end_back.c b/util/ceg/ce_back/obj_back/end_back.c index 32ab8a3f7..8aafca346 100644 --- a/util/ceg/ce_back/obj_back/end_back.c +++ b/util/ceg/ce_back/obj_back/end_back.c @@ -6,18 +6,21 @@ end_back() { - sync(); - define_segments(); + finish_tables(); do_local_relocation(); } -sync() +finish_tables() + +/* Prepare tables for do_local_relocation() and output(). + */ { while ( ( text - text_area) % EM_WSIZE != 0 ) text1( '\0'); while ( ( data - data_area) % EM_WSIZE != 0 ) con1( '\0'); + define_segments(); } diff --git a/util/ceg/ce_back/obj_back/extnd.c b/util/ceg/ce_back/obj_back/extnd.c index cf8f3f14b..e486a89c2 100644 --- a/util/ceg/ce_back/obj_back/extnd.c +++ b/util/ceg/ce_back/obj_back/extnd.c @@ -4,10 +4,10 @@ #include "header.h" #include "mach.h" -/* The extnd_*() make a name unique. The resulting string is directly stored - in the symbol_table (by mysprint()). Later additional fields in the - symbol_table are filled. For these actions the values of the index in - the symbol_table and the length of the string are stored. +/* The extnd_*()s make a name unique. The resulting string is directly stored + * in the symbol_table (by mysprint()). Later additional fields in the + * symbol_table are filled. For these actions the values of the index in + * the symbol_table and the length of the string are stored. */ extern int string_lengte, index_symbol_table; diff --git a/util/ceg/ce_back/obj_back/init_back.c b/util/ceg/ce_back/obj_back/init_back.c index 58bd911e8..e4c213ad0 100644 --- a/util/ceg/ce_back/obj_back/init_back.c +++ b/util/ceg/ce_back/obj_back/init_back.c @@ -5,6 +5,9 @@ char *calloc(); init_back() + +/* Allocate space for the tables and set the default values. + */ { text_area = calloc( MAXTEXT, sizeof( char)); data_area = calloc( MAXDATA, sizeof( char)); diff --git a/util/ceg/ce_back/obj_back/label.c b/util/ceg/ce_back/obj_back/label.c index 8f5d96c20..cacf7afe6 100644 --- a/util/ceg/ce_back/obj_back/label.c +++ b/util/ceg/ce_back/obj_back/label.c @@ -6,6 +6,12 @@ int Label, label_waiting; save_label( lab) char *lab; + +/* It is now not possible to tell where the label belongs to, so store + * the string and remember the returned index to store the missing + * information later on (see dump_label()). Two labels at one address + * is not allowed. + */ { Label = find_sym( lab, SYMBOL_DEFINITION); label_waiting = 1; diff --git a/util/ceg/ce_back/obj_back/memory.c b/util/ceg/ce_back/obj_back/memory.c index 36aff065b..6f46fa990 100644 --- a/util/ceg/ce_back/obj_back/memory.c +++ b/util/ceg/ce_back/obj_back/memory.c @@ -5,6 +5,10 @@ char *realloc(); +/* The routines allocate more space for the segments and update the + * global variables. Each time the space asked for is multiplied with 2. + */ + mem_text() { /* print( "text_area too small %d %d \n", text_area, text); */ @@ -53,11 +57,10 @@ mem_relo() mem_string() { - int i; + int i = string - string_area; /* print( "string_area out of memory %d %d \n", string_area, string);*/ - i = string - string_area; size_string = 2 * size_string; string_area = realloc( string_area, sizeof( char) * size_string); string = string_area + i; diff --git a/util/ceg/ce_back/obj_back/misc.c b/util/ceg/ce_back/obj_back/misc.c index bd6463447..750cc7459 100644 --- a/util/ceg/ce_back/obj_back/misc.c +++ b/util/ceg/ce_back/obj_back/misc.c @@ -3,10 +3,13 @@ #include "back.h" /* The following functions are called from reloc1(), reloc2(), reloc4(), - dump_label(). + * dump_label(). */ align_word() + +/* Do word allignment. + */ { switch ( cur_seg) { case SEGTXT : return; @@ -26,6 +29,9 @@ align_word() long cur_value() + +/* Return the index of the first free entry. + */ { switch( cur_seg) { case SEGTXT: return text - text_area; diff --git a/util/ceg/ce_back/obj_back/mysprint.c b/util/ceg/ce_back/obj_back/mysprint.c index d2d53bf70..95fedf7ff 100644 --- a/util/ceg/ce_back/obj_back/mysprint.c +++ b/util/ceg/ce_back/obj_back/mysprint.c @@ -1,6 +1,10 @@ #include #include "data.h" +/* Mysprint() stores the string directly in the string_arae. This saves + * a copy action. + */ + int mysprint( fmt, args) char *fmt; int args; diff --git a/util/ceg/ce_back/obj_back/output.c b/util/ceg/ce_back/obj_back/output.c index 5a576d3fa..3310b64e3 100644 --- a/util/ceg/ce_back/obj_back/output.c +++ b/util/ceg/ce_back/obj_back/output.c @@ -3,7 +3,8 @@ #include "data.h" output() -/* Notice : entries in the symbol_table are converted. +/* Dump the tables. + * Notice : entries in the symbol_table are converted. */ { diff --git a/util/ceg/ce_back/obj_back/reloc1.c b/util/ceg/ce_back/obj_back/reloc1.c index 624fc0a01..fbf7fb679 100644 --- a/util/ceg/ce_back/obj_back/reloc1.c +++ b/util/ceg/ce_back/obj_back/reloc1.c @@ -4,6 +4,10 @@ #include "back.h" #include "header.h" +/* There are two forms of relocation program counter relative or + * absolute. + */ + reloc1( sym, off, pcrel) char *sym; arith off; @@ -13,7 +17,7 @@ int pcrel; mem_relo(); relo->or_type = RELO1; -#ifdef BYTES_REVERSED /* Nog optimaliseren?? */ +#ifdef BYTES_REVERSED relo->or_type |= RELBR; #endif #ifdef WORDS_REVERSED diff --git a/util/ceg/ce_back/obj_back/reloc2.c b/util/ceg/ce_back/obj_back/reloc2.c index d2b338d4d..9f27776bb 100644 --- a/util/ceg/ce_back/obj_back/reloc2.c +++ b/util/ceg/ce_back/obj_back/reloc2.c @@ -4,6 +4,10 @@ #include "back.h" #include "header.h" +/* There are two forms of relocation program counter relative or + * absolute. + */ + reloc2( sym, off, pcrel) char *sym; arith off; @@ -13,7 +17,7 @@ int pcrel; mem_relo(); relo->or_type = RELO2; -#ifdef BYTES_REVERSED /* Nog optimaliseren?? */ +#ifdef BYTES_REVERSED relo->or_type |= RELBR; #endif #ifdef WORDS_REVERSED diff --git a/util/ceg/ce_back/obj_back/reloc4.c b/util/ceg/ce_back/obj_back/reloc4.c index 4022e2c18..72a27bb2f 100644 --- a/util/ceg/ce_back/obj_back/reloc4.c +++ b/util/ceg/ce_back/obj_back/reloc4.c @@ -5,6 +5,10 @@ #include "back.h" #include "header.h" +/* There are two forms of relocation program counter relative or + * absolute. + */ + reloc4( sym, off, pcrel) char *sym; arith off; @@ -14,7 +18,7 @@ int pcrel; mem_relo(); relo->or_type = RELO4; -#ifdef BYTES_REVERSED /* Nog optimaliseren?? */ +#ifdef BYTES_REVERSED relo->or_type |= RELBR; #endif #ifdef WORDS_REVERSED diff --git a/util/ceg/ce_back/obj_back/relocation.c b/util/ceg/ce_back/obj_back/relocation.c index cb0e8aac9..fdfc9fe6a 100644 --- a/util/ceg/ce_back/obj_back/relocation.c +++ b/util/ceg/ce_back/obj_back/relocation.c @@ -2,15 +2,21 @@ #include #include "back.h" +/* Solve the local references. + */ + #define seg_index( s) ( nname - SEGBSS - 1 + s) long get4(); -long base_adres(); extern short get2(); extern char get1(); do_local_relocation() + +/* Check if this reference is solvable. External references contain + * -1 in 'on_valu'. + */ { register struct outrelo *ptr; register int s; @@ -26,6 +32,10 @@ do_local_relocation() do_relo(np,rp) struct outname *np; struct outrelo *rp; + +/* Solve the reference relative to the start of the segment where the symbol + * is defined. + */ { long oldval,newval; char *sect; @@ -44,7 +54,6 @@ struct outrelo *rp; break; } - /* nu reloceren tov het segment waar het symbool in voorkomt! */ if ( rp->or_type & RELO4) { oldval = get4( sect, rp->or_addr); newval = oldval + np->on_valu; @@ -77,15 +86,3 @@ struct outrelo *rp; */ } - - -long base_adres( seg) -int seg; -{ - switch ( seg) { - case SEGTXT : return( 0); - case SEGCON : return( text-text_area); - case SEGBSS : return( text-text_area + data-data_area); - default : fprint( STDERR, "base_adres() wrong seg %d\n", seg); - } -}