codeview: don't walk the file list for every line
[nasm.git] / output / codeview.c
blob16b50e609673d582764c758fcd0d34ebc8cb439d
1 /* ----------------------------------------------------------------------- *
3 * Copyright 1996-2016 The NASM Authors - All Rights Reserved
4 * See the file AUTHORS included with the NASM distribution for
5 * the specific copyright holders.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following
9 * conditions are met:
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * ----------------------------------------------------------------------- */
35 * codeview.c Codeview Debug Format support for COFF
38 #include "version.h"
39 #include "compiler.h"
41 #include <stdio.h>
42 #include <stddef.h>
43 #include <stdlib.h>
45 #include "nasm.h"
46 #include "nasmlib.h"
47 #include "preproc.h"
48 #include "saa.h"
49 #include "hashtbl.h"
50 #include "output/outlib.h"
51 #include "output/pecoff.h"
52 #include "md5.h"
54 static void cv8_init(void);
55 static void cv8_linenum(const char *filename, int32_t linenumber,
56 int32_t segto);
57 static void cv8_deflabel(char *name, int32_t segment, int64_t offset,
58 int is_global, char *special);
59 static void cv8_typevalue(int32_t type);
60 static void cv8_output(int type, void *param);
61 static void cv8_cleanup(void);
63 struct dfmt df_cv8 = {
64 "Codeview 8", /* .fullname */
65 "cv8", /* .shortname */
66 cv8_init, /* .init */
67 cv8_linenum, /* .linenum */
68 cv8_deflabel, /* .debug_deflabel */
69 null_debug_directive, /* .debug_directive */
70 cv8_typevalue, /* .debug_typevalue */
71 cv8_output, /* .debug_output */
72 cv8_cleanup, /* .cleanup */
75 /*******************************************************************************
76 * dfmt callbacks
77 ******************************************************************************/
78 struct source_file;
80 struct source_file {
81 const char *filename;
82 char *fullname;
83 uint32_t fullnamelen;
85 struct source_file *next;
87 uint32_t filetbl_off;
88 uint32_t sourcetbl_off;
90 struct SAA *lines;
91 uint32_t num_lines;
93 unsigned char md5sum[MD5_HASHBYTES];
96 struct linepair {
97 uint32_t file_offset;
98 uint32_t linenumber;
101 enum symbol_type {
102 SYMTYPE_CODE,
103 SYMTYPE_PROC,
104 SYMTYPE_LDATA,
105 SYMTYPE_GDATA,
107 SYMTYPE_MAX
110 struct cv8_symbol {
111 enum symbol_type type;
112 char *name;
114 uint32_t secrel;
115 uint16_t section;
116 uint32_t size;
117 uint32_t typeindex;
119 enum symtype {
120 TYPE_UNREGISTERED = 0x0000, /* T_NOTYPE */
121 TYPE_BYTE = 0x0020,
122 TYPE_WORD = 0x0021,
123 TYPE_DWORD= 0x0022,
124 TYPE_QUAD = 0x0023,
126 TYPE_REAL32 = 0x0040,
127 TYPE_REAL64 = 0x0041,
128 TYPE_REAL80 = 0x0042,
129 TYPE_REAL128= 0x0043,
130 TYPE_REAL256= 0x0044,
131 TYPE_REAL512= 0x0045
132 } symtype;
135 struct cv8_state {
136 int symbol_sect;
137 int type_sect;
139 uint32_t text_offset;
141 struct source_file *source_files, **source_files_tail;
142 const char *last_filename;
143 struct source_file *last_source_file;
144 struct hash_table file_hash;
145 unsigned num_files;
146 uint32_t total_filename_len;
149 unsigned total_lines;
151 struct SAA *symbols;
152 struct cv8_symbol *last_sym;
153 unsigned num_syms[SYMTYPE_MAX];
154 unsigned symbol_lengths;
155 unsigned total_syms;
157 char *cwd;
159 struct cv8_state cv8_state;
161 static void cv8_init(void)
163 const uint32_t sect_flags = IMAGE_SCN_MEM_READ |
164 IMAGE_SCN_MEM_DISCARDABLE |
165 IMAGE_SCN_CNT_INITIALIZED_DATA |
166 IMAGE_SCN_ALIGN_1BYTES;
168 cv8_state.symbol_sect = coff_make_section(".debug$S", sect_flags);
169 cv8_state.type_sect = coff_make_section(".debug$T", sect_flags);
171 cv8_state.text_offset = 0;
173 cv8_state.source_files = NULL;
174 cv8_state.source_files_tail = &cv8_state.source_files;
175 hash_init(&cv8_state.file_hash, HASH_MEDIUM);
177 cv8_state.num_files = 0;
178 cv8_state.total_filename_len = 0;
180 cv8_state.total_lines = 0;
182 cv8_state.symbols = saa_init(sizeof(struct cv8_symbol));
183 cv8_state.last_sym = NULL;
185 cv8_state.cwd = nasm_realpath(".");
188 static struct source_file *register_file(const char *filename);
189 static struct coff_Section *find_section(int32_t segto);
191 static void cv8_linenum(const char *filename, int32_t linenumber,
192 int32_t segto)
194 struct coff_Section *s;
195 struct linepair *li;
196 struct source_file *file;
198 file = register_file(filename);
200 s = find_section(segto);
201 if (s == NULL)
202 return;
204 if ((s->flags & IMAGE_SCN_MEM_EXECUTE) == 0)
205 return;
207 li = saa_wstruct(file->lines);
208 li->file_offset = cv8_state.text_offset;
209 li->linenumber = linenumber;
211 file->num_lines++;
212 cv8_state.total_lines++;
215 static void cv8_deflabel(char *name, int32_t segment, int64_t offset,
216 int is_global, char *special)
218 struct cv8_symbol *sym;
219 struct coff_Section *s;
221 (void)special;
223 s = find_section(segment);
224 if (s == NULL)
225 return;
227 sym = saa_wstruct(cv8_state.symbols);
229 if (s->flags & IMAGE_SCN_MEM_EXECUTE)
230 sym->type = is_global ? SYMTYPE_PROC : SYMTYPE_CODE;
231 else
232 sym->type = is_global ? SYMTYPE_GDATA : SYMTYPE_LDATA;
233 cv8_state.num_syms[sym->type]++;
234 cv8_state.total_syms++;
236 sym->section = segment;
237 sym->secrel = offset;
238 sym->symtype = TYPE_UNREGISTERED;
239 sym->size = 0;
240 sym->typeindex = 0;
242 sym->name = nasm_strdup(name);
243 cv8_state.symbol_lengths += strlen(sym->name) + 1;
245 if (cv8_state.last_sym && cv8_state.last_sym->section == segment)
246 cv8_state.last_sym->size = offset - cv8_state.last_sym->secrel;
247 cv8_state.last_sym = sym;
250 static void cv8_typevalue(int32_t type)
252 if (!cv8_state.last_sym)
253 return;
254 if (cv8_state.last_sym->symtype != TYPE_UNREGISTERED)
255 return;
257 switch (TYM_TYPE(type)) {
258 case TY_BYTE:
259 cv8_state.last_sym->symtype = TYPE_BYTE;
260 break;
261 case TY_WORD:
262 cv8_state.last_sym->symtype = TYPE_WORD;
263 break;
264 case TY_DWORD:
265 cv8_state.last_sym->symtype = TYPE_DWORD;
266 break;
267 case TY_QWORD:
268 cv8_state.last_sym->symtype = TYPE_QUAD;
269 break;
270 case TY_FLOAT:
271 cv8_state.last_sym->symtype = TYPE_REAL32;
272 break;
273 case TY_TBYTE:
274 cv8_state.last_sym->symtype = TYPE_REAL80;
275 break;
276 case TY_OWORD:
277 cv8_state.last_sym->symtype = TYPE_REAL128;
278 break;
279 case TY_YWORD:
280 cv8_state.last_sym->symtype = TYPE_REAL256;
281 break;
282 case TY_UNKNOWN:
283 break;
284 case TY_LABEL:
285 break;
289 static void cv8_output(int type, void *param)
291 struct coff_DebugInfo *dinfo = param;
293 (void)type;
295 if (dinfo->section && dinfo->section->name &&
296 !strncmp(dinfo->section->name, ".text", 5))
297 cv8_state.text_offset += dinfo->size;
300 static void build_symbol_table(struct coff_Section *const sect);
301 static void build_type_table(struct coff_Section *const sect);
303 static void cv8_cleanup(void)
305 struct cv8_symbol *sym;
306 struct source_file *file;
308 struct coff_Section *symbol_sect = coff_sects[cv8_state.symbol_sect];
309 struct coff_Section *type_sect = coff_sects[cv8_state.type_sect];
311 build_symbol_table(symbol_sect);
312 build_type_table(type_sect);
314 list_for_each(file, cv8_state.source_files) {
315 nasm_free(file->fullname);
316 saa_free(file->lines);
317 free(file);
319 hash_free(&cv8_state.file_hash);
321 if (cv8_state.cwd != NULL)
322 nasm_free(cv8_state.cwd);
324 saa_rewind(cv8_state.symbols);
325 while ((sym = saa_rstruct(cv8_state.symbols)))
326 nasm_free(sym->name);
327 saa_free(cv8_state.symbols);
330 /*******************************************************************************
331 * implementation
332 ******************************************************************************/
333 static void calc_md5(const char *const filename,
334 unsigned char sum[MD5_HASHBYTES])
336 int success = 0;
337 unsigned char *file_buf;
338 FILE *f;
339 MD5_CTX ctx;
341 f = pp_input_fopen(filename, "rb");
342 if (!f)
343 goto done;
345 file_buf = nasm_zalloc(BUFSIZ);
347 MD5Init(&ctx);
348 while (!feof(f)) {
349 size_t i = fread(file_buf, 1, BUFSIZ, f);
350 if (ferror(f))
351 goto done_0;
352 else if (i == 0)
353 break;
354 MD5Update(&ctx, file_buf, i);
356 MD5Final(sum, &ctx);
358 success = 1;
359 done_0:
360 nasm_free(file_buf);
361 fclose(f);
362 done:
363 if (!success) {
364 nasm_error(ERR_NONFATAL, "unable to hash file %s. "
365 "Debug information may be unavailable.\n",
366 filename);
368 return;
371 static struct source_file *register_file(const char *filename)
373 struct source_file *file;
374 void **filep;
375 char *fullpath;
376 struct hash_insert hi;
379 * The common case is that we are invoked with the same filename
380 * as we were last time. Make this a pointer comparison: this is
381 * safe because the NASM core code allocates each filename once
382 * and never frees it.
384 if (likely(cv8_state.last_filename == filename))
385 return cv8_state.last_source_file;
387 cv8_state.last_filename = filename;
389 filep = hash_find(&cv8_state.file_hash, filename, &hi);
390 if (likely(filep)) {
391 file = *filep;
392 } else {
393 /* New filename encounter */
395 fullpath = nasm_realpath(filename);
397 file = nasm_zalloc(sizeof(*file));
399 file->filename = filename;
400 file->fullname = fullpath;
401 file->fullnamelen = strlen(fullpath);
402 file->lines = saa_init(sizeof(struct linepair));
403 *cv8_state.source_files_tail = file;
404 cv8_state.source_files_tail = &file->next;
405 calc_md5(fullpath, file->md5sum);
407 hash_add(&hi, filename, file);
409 cv8_state.num_files++;
410 cv8_state.total_filename_len += file->fullnamelen + 1;
413 cv8_state.last_source_file = file;
414 return file;
417 static struct coff_Section *find_section(int32_t segto)
419 int i;
421 for (i = 0; i < coff_nsects; i++) {
422 struct coff_Section *sec;
424 sec = coff_sects[i];
425 if (segto == sec->index)
426 return sec;
428 return NULL;
431 static void register_reloc(struct coff_Section *const sect,
432 char *sym, uint32_t addr, uint16_t type)
434 struct coff_Reloc *r;
435 struct coff_Section *sec;
437 r = *sect->tail = nasm_malloc(sizeof(struct coff_Reloc));
438 sect->tail = &r->next;
439 r->next = NULL;
440 sect->nrelocs++;
442 r->address = addr;
443 r->symbase = SECT_SYMBOLS;
444 r->type = type;
446 r->symbol = 0;
447 for (int i = 0; i < coff_nsects; i++) {
448 sec = coff_sects[i];
449 if (!strcmp(sym, sec->name)) {
450 return;
452 r->symbol += 2;
455 saa_rewind(coff_syms);
456 for (uint32_t i = 0; i < coff_nsyms; i++) {
457 struct coff_Symbol *s = saa_rstruct(coff_syms);
458 r->symbol++;
459 if (s->strpos == -1 && !strcmp(sym, s->name)) {
460 return;
461 } else if (s->strpos != -1) {
462 int res;
463 char *symname;
465 symname = nasm_malloc(s->namlen + 1);
466 saa_fread(coff_strs, s->strpos-4, symname, s->namlen);
467 symname[s->namlen] = '\0';
468 res = strcmp(sym, symname);
469 nasm_free(symname);
470 if (!res)
471 return;
474 nasm_panic(0, "codeview: relocation for unregistered symbol: %s", sym);
477 static inline void section_write32(struct coff_Section *sect, uint32_t val)
479 saa_write32(sect->data, val);
480 sect->len += 4;
483 static inline void section_write16(struct coff_Section *sect, uint16_t val)
485 saa_write16(sect->data, val);
486 sect->len += 2;
489 static inline void section_write8(struct coff_Section *sect, uint8_t val)
491 saa_write8(sect->data, val);
492 sect->len++;
495 static inline void section_wbytes(struct coff_Section *sect, const void *buf,
496 size_t len)
498 saa_wbytes(sect->data, buf, len);
499 sect->len += len;
502 static void write_filename_table(struct coff_Section *const sect)
504 uint32_t field_length;
505 uint32_t tbl_off = 1; /* offset starts at 1 to skip NULL entry */
506 struct source_file *file;
508 nasm_assert(cv8_state.source_files != NULL);
509 nasm_assert(cv8_state.num_files > 0);
510 nasm_assert(cv8_state.total_filename_len > 0);
512 field_length = 1 + cv8_state.total_filename_len;
514 section_write32(sect, 0x000000F3);
515 section_write32(sect, field_length);
517 section_write8(sect, 0);
519 list_for_each(file, cv8_state.source_files) {
520 section_wbytes(sect, file->fullname, file->fullnamelen + 1);
521 file->filetbl_off = tbl_off;
522 tbl_off += file->fullnamelen + 1;
526 static void write_sourcefile_table(struct coff_Section *const sect)
528 const uint32_t entry_size = 4 + 2 + MD5_HASHBYTES + 2;
530 uint32_t field_length = 0;
531 uint32_t tbl_off = 0;
532 struct source_file *file;
534 field_length = entry_size * cv8_state.num_files;
536 section_write32(sect, 0x000000F4);
537 section_write32(sect, field_length);
539 list_for_each(file, cv8_state.source_files) {
540 nasm_assert(file->filetbl_off > 0);
541 section_write32(sect, file->filetbl_off);
542 section_write16(sect, 0x0110);
543 section_wbytes(sect, file->md5sum, MD5_HASHBYTES);
544 section_write16(sect, 0);
546 file->sourcetbl_off = tbl_off;
547 tbl_off += entry_size;
551 static void write_linenumber_table(struct coff_Section *const sect)
553 const uint32_t file_field_len = 12;
554 const uint32_t line_field_len = 8;
556 int i;
557 uint32_t field_length = 0;
558 size_t field_base;
559 struct source_file *file;
560 struct coff_Section *s;
562 for (i = 0; i < coff_nsects; i++) {
563 if (!strncmp(coff_sects[i]->name, ".text", 5))
564 break;
567 if (i == coff_nsects)
568 return;
569 s = coff_sects[i];
571 field_length = 12;
572 field_length += (cv8_state.num_files * file_field_len);
573 field_length += (cv8_state.total_lines * line_field_len);
575 section_write32(sect, 0x000000F2);
576 section_write32(sect, field_length);
578 field_base = sect->len;
579 section_write32(sect, 0); /* SECREL, updated by relocation */
580 section_write16(sect, 0); /* SECTION, updated by relocation*/
581 section_write16(sect, 0); /* pad */
582 section_write32(sect, s->len);
584 register_reloc(sect, ".text", field_base,
585 win64 ? IMAGE_REL_AMD64_SECREL : IMAGE_REL_I386_SECREL);
587 register_reloc(sect, ".text", field_base + 4,
588 win64 ? IMAGE_REL_AMD64_SECTION : IMAGE_REL_I386_SECTION);
590 list_for_each(file, cv8_state.source_files) {
591 struct linepair *li;
593 /* source mapping */
594 section_write32(sect, file->sourcetbl_off);
595 section_write32(sect, file->num_lines);
596 section_write32(sect, file_field_len + (file->num_lines * line_field_len));
598 /* the pairs */
599 saa_rewind(file->lines);
600 while ((li = saa_rstruct(file->lines))) {
601 section_write32(sect, li->file_offset);
602 section_write32(sect, li->linenumber |= 0x80000000);
607 static uint16_t write_symbolinfo_obj(struct coff_Section *sect,
608 const char sep)
610 uint16_t obj_len;
612 obj_len = 2 + 4 + strlen(cv8_state.cwd)+ 1 + strlen(coff_outfile) +1;
614 section_write16(sect, obj_len);
615 section_write16(sect, 0x1101);
616 section_write32(sect, 0); /* ASM language */
617 section_wbytes(sect, cv8_state.cwd, strlen(cv8_state.cwd));
618 section_write8(sect, sep);
619 section_wbytes(sect, coff_outfile, strlen(coff_outfile)+1);
621 return obj_len;
624 static uint16_t write_symbolinfo_properties(struct coff_Section *sect,
625 const char *const creator_str)
627 uint16_t creator_len;
629 creator_len = 2 + 4 + 4 + 4 + 4 + strlen(creator_str)+1 + 2;
631 section_write16(sect, creator_len);
632 section_write16(sect, 0x1116);
633 section_write32(sect, 3); /* language */
634 if (win64)
635 section_write32(sect, 0x000000D0);
636 else if (win32)
637 section_write32(sect, 0x00000006);
638 else
639 nasm_assert(!"neither win32 nor win64 are set!");
640 section_write32(sect, 0); /* flags*/
641 section_write32(sect, 8); /* version */
642 section_wbytes(sect, creator_str, strlen(creator_str)+1);
644 * normally there would be key/value pairs here, but they aren't
645 * necessary. They are terminated by 2B
647 section_write16(sect, 0);
649 return creator_len;
652 static uint16_t write_symbolinfo_symbols(struct coff_Section *sect)
654 uint16_t len = 0, field_len;
655 uint32_t field_base;
656 struct cv8_symbol *sym;
658 saa_rewind(cv8_state.symbols);
659 while ((sym = saa_rstruct(cv8_state.symbols))) {
660 switch (sym->type) {
661 case SYMTYPE_LDATA:
662 case SYMTYPE_GDATA:
663 field_len = 12 + strlen(sym->name) + 1;
664 len += field_len - 2;
665 section_write16(sect, field_len);
666 if (sym->type == SYMTYPE_LDATA)
667 section_write16(sect, 0x110C);
668 else
669 section_write16(sect, 0x110D);
670 section_write32(sect, sym->symtype);
672 field_base = sect->len;
673 section_write32(sect, 0); /* SECREL */
674 section_write16(sect, 0); /* SECTION */
675 break;
676 case SYMTYPE_PROC:
677 case SYMTYPE_CODE:
678 field_len = 9 + strlen(sym->name) + 1;
679 len += field_len - 2;
680 section_write16(sect, field_len);
681 section_write16(sect, 0x1105);
683 field_base = sect->len;
684 section_write32(sect, 0); /* SECREL */
685 section_write16(sect, 0); /* SECTION */
686 section_write8(sect, 0); /* FLAG */
687 break;
688 default:
689 nasm_assert(!"unknown symbol type");
692 section_wbytes(sect, sym->name, strlen(sym->name) + 1);
694 register_reloc(sect, sym->name, field_base,
695 win64 ? IMAGE_REL_AMD64_SECREL :
696 IMAGE_REL_I386_SECREL);
697 register_reloc(sect, sym->name, field_base + 4,
698 win64 ? IMAGE_REL_AMD64_SECTION :
699 IMAGE_REL_I386_SECTION);
702 return len;
705 static void write_symbolinfo_table(struct coff_Section *const sect)
707 const char sep = '\\';
708 const char *creator_str = "The Netwide Assembler " NASM_VER;
711 uint16_t obj_length, creator_length, sym_length;
712 uint32_t field_length = 0, out_len;
714 /* signature, language, workingdir / coff_outfile NULL */
715 obj_length = 2 + 4 + strlen(cv8_state.cwd)+ 1 + strlen(coff_outfile) +1;
716 creator_length = 2 + 4 + 4 + 4 + 4 + strlen(creator_str)+1 + 2;
718 sym_length = ( cv8_state.num_syms[SYMTYPE_CODE] * 7) +
719 ( cv8_state.num_syms[SYMTYPE_PROC] * 7) +
720 ( cv8_state.num_syms[SYMTYPE_LDATA] * 10) +
721 ( cv8_state.num_syms[SYMTYPE_GDATA] * 10) +
722 cv8_state.symbol_lengths;
724 field_length = 2 + obj_length +
725 2 + creator_length +
726 (4 * cv8_state.total_syms) + sym_length;
728 section_write32(sect, 0x000000F1);
729 section_write32(sect, field_length);
731 /* for sub fields, length preceeds type */
733 out_len = write_symbolinfo_obj(sect, sep);
734 nasm_assert(out_len == obj_length);
736 out_len = write_symbolinfo_properties(sect, creator_str);
737 nasm_assert(out_len == creator_length);
739 out_len = write_symbolinfo_symbols(sect);
740 nasm_assert(out_len == sym_length);
743 static inline void align4_table(struct coff_Section *const sect)
745 unsigned diff;
746 uint32_t zero = 0;
747 struct SAA *data = sect->data;
749 if (data->wptr % 4 == 0)
750 return;
752 diff = 4 - (data->wptr % 4);
753 if (diff)
754 section_wbytes(sect, &zero, diff);
757 static void build_symbol_table(struct coff_Section *const sect)
759 section_write32(sect, 0x00000004);
761 write_filename_table(sect);
762 align4_table(sect);
763 write_sourcefile_table(sect);
764 align4_table(sect);
765 write_linenumber_table(sect);
766 align4_table(sect);
767 write_symbolinfo_table(sect);
768 align4_table(sect);
771 static void build_type_table(struct coff_Section *const sect)
773 uint16_t field_len;
774 struct cv8_symbol *sym;
776 section_write32(sect, 0x00000004);
778 saa_rewind(cv8_state.symbols);
779 while ((sym = saa_rstruct(cv8_state.symbols))) {
780 if (sym->type != SYMTYPE_PROC)
781 continue;
783 /* proc leaf */
785 field_len = 2 + 4 + 4 + 4 + 2;
786 section_write16(sect, field_len);
787 section_write16(sect, 0x1008); /* PROC type */
789 section_write32(sect, 0x00000003); /* return type */
790 section_write32(sect, 0); /* calling convention (default) */
791 section_write32(sect, sym->typeindex);
792 section_write16(sect, 0); /* # params */
794 /* arglist */
796 field_len = 2 + 4;
797 section_write16(sect, field_len);
798 section_write16(sect, 0x1201); /* ARGLIST */
799 section_write32(sect, 0); /*num params */