2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
6 static char rcsid[] = "$Id: output.c,v 3.6 1994/06/24 10:35:02 ceriel Exp $";
13 static generate_section_names();
15 extern struct outhead outhead;
20 * We have counted all relocation structs but we know only now if
21 * these must be emitted.We add all names here,unless the -s(trip)
23 * If this flag is given we don't need the string table either.
27 extern unsigned short NLocals, NGlobals;
28 extern long NLChars, NGChars;
29 extern char *outputname;
31 if (! wr_open(outputname)) {
32 fatal("can't create %s", outputname);
35 generate_section_names();
37 if (!(flagword & (CFLAG|RFLAG)))
38 outhead.oh_nrelo = (unsigned short)0;
39 if (flagword & SFLAG) {
40 outhead.oh_nname = (unsigned short)0;
41 outhead.oh_nchar = (long)0;
43 outhead.oh_nname = NLocals + NGlobals + outhead.oh_nsect;
44 outhead.oh_nchar = NLChars + NGChars;
51 * Generate names for all sections and put them after the global names.
52 * Section names are used for relocation.
55 generate_section_names()
57 register struct outname *name;
58 register int sectindex;
60 extern struct outsect outsect[];
61 extern char *core_alloc();
63 size = (long)outhead.oh_nsect * sizeof(struct outname);
64 name = (struct outname *)core_alloc(ALLOGLOB, size);
65 if (name == (struct outname *)0)
68 for (sectindex = 0; sectindex < outhead.oh_nsect; sectindex++, name++) {
69 name->on_foff = (long)0; /* No string name. */
70 name->on_type = (S_MIN + sectindex) | S_SCT;
71 name->on_desc = (unsigned short)0;
72 name->on_valu = outsect[sectindex].os_base;
77 * If we didn't keep the whole output file in core, most of it has been
78 * written out, and we just finish that.
79 * If we did, we write out our pieces of core.
84 if (!(flagword & SFLAG))