*** empty log message ***
authorkaashoek <none@none>
Wed, 25 Nov 1987 13:54:01 +0000 (13:54 +0000)
committerkaashoek <none@none>
Wed, 25 Nov 1987 13:54:01 +0000 (13:54 +0000)
14 files changed:
util/ceg/ce_back/obj_back/Makefile
util/ceg/ce_back/obj_back/data.c
util/ceg/ce_back/obj_back/end_back.c
util/ceg/ce_back/obj_back/extnd.c
util/ceg/ce_back/obj_back/init_back.c
util/ceg/ce_back/obj_back/label.c
util/ceg/ce_back/obj_back/memory.c
util/ceg/ce_back/obj_back/misc.c
util/ceg/ce_back/obj_back/mysprint.c
util/ceg/ce_back/obj_back/output.c
util/ceg/ce_back/obj_back/reloc1.c
util/ceg/ce_back/obj_back/reloc2.c
util/ceg/ce_back/obj_back/reloc4.c
util/ceg/ce_back/obj_back/relocation.c

index f0d5aa9..d906b05 100644 (file)
@@ -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\
index edca182..76577f3 100644 (file)
@@ -2,6 +2,26 @@
 #include <out.h>
 #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,
index 32ab8a3..8aafca3 100644 (file)
@@ -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();  
 }
 
 
index cf8f3f1..e486a89 100644 (file)
@@ -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;
index 58bd911..e4c213a 100644 (file)
@@ -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));
index 8f5d96c..cacf7af 100644 (file)
@@ -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;
index 36aff06..6f46fa9 100644 (file)
@@ -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;
index bd64634..750cc74 100644 (file)
@@ -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;
index d2d53bf..95fedf7 100644 (file)
@@ -1,6 +1,10 @@
 #include <system.h>
 #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;
index 5a576d3..3310b64 100644 (file)
@@ -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.
  */
 
 {
index 624fc0a..fbf7fb6 100644 (file)
@@ -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
index d2b338d..9f27776 100644 (file)
@@ -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
index 4022e2c..72a27bb 100644 (file)
@@ -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
index cb0e8aa..fdfc9fe 100644 (file)
@@ -2,15 +2,21 @@
 #include <out.h>
 #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);
-       }
-}