Pristine Ack-5.5
[Ack-5.5.git] / util / ceg / ce_back / obj_back / end_back.c
1 #include <out.h>
2 #include "mach.h"
3 #include "back.h"
4 #include "header.h"
5
6 static
7 finish_tables()
8
9 /* Prepare tables for do_local_relocation() and output().
10  */
11 {
12         register struct outname *np = symbol_table;
13         register int i = nname;
14
15         for (; i; i--, np++) {
16                 if ((np->on_type & S_COM) && ! (np->on_type & S_EXT)) {
17                         long sz = np->on_valu;
18
19                         switchseg(SEGBSS);
20                         align_word();
21                         np->on_type &= (~S_COM);
22                         np->on_valu = cur_value();
23                         bss(sz);
24                 }
25         }
26         while ( ( text - text_area) % EM_WSIZE != 0 ) 
27                 text1( '\0');
28         while ( ( data - data_area) % EM_WSIZE != 0 )
29                 con1( '\0');
30         define_segments();  
31 }
32
33 static char *seg_name[] = {
34                 ".text",
35                 ".rom",
36                 ".con",
37                 ".bss"
38         };
39
40 static
41 define_segments()
42 {
43         int i, s;
44
45         for ( s = SEGTXT; s <= SEGBSS; s++) {
46                 i = find_sym( seg_name[s], SYMBOL_DEFINITION);
47                 symbol_table[i].on_type = ( S_MIN + s) | S_SCT;
48         }
49 }
50
51 end_back()
52 {
53         finish_tables();                 
54         do_local_relocation();
55 }