From: <fbk...@us...> - 2003-12-12 06:18:11
|
Update of /cvsroot/nasm/nasm/output In directory sc8-pr-cvs1:/tmp/cvs-serv22025/nasm/output Modified Files: outrdf2.c Log Message: Update rdoff Index: outrdf2.c =================================================================== RCS file: /cvsroot/nasm/nasm/output/outrdf2.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- outrdf2.c 25 Sep 2003 11:43:29 -0000 1.6 +++ outrdf2.c 12 Dec 2003 06:18:07 -0000 1.7 @@ -70,6 +70,7 @@ struct ImportRec { byte type; /* must be 2, or 7 for FAR import */ byte reclen; /* equals 3+label length */ + byte flags; /* SYM_* flags (see below) */ int16 segment; /* segment number allocated to the label for reloc * records - label is assumed to be at offset zero * in this segment, so linker must fix up with offset @@ -109,9 +110,10 @@ }; /* Flags for ExportRec */ -#define SYM_DATA 0x01 -#define SYM_FUNCTION 0x02 -#define SYM_GLOBAL 0x04 +#define SYM_DATA 1 +#define SYM_FUNCTION 2 +#define SYM_GLOBAL 4 +#define SYM_IMPORT 8 #define COUNT_SEGTYPES 9 @@ -124,7 +126,7 @@ 0, 1, 1, 2, 3, 4, 5, 6, 7 }; -/* code for managing buffers needed to seperate code and data into individual +/* code for managing buffers needed to separate code and data into individual * sections until they are ready to be written to the file. * We'd better hope that it all fits in memory else we're buggered... */ @@ -332,6 +334,7 @@ saa_wbytes(header,&r->type,1); saa_wbytes(header,&r->reclen,1); + saa_wbytes(header,&r->flags,1); b = buf; WRITESHORT(b,r->segment); saa_wbytes(header,buf,2); saa_wbytes(header,r->label,strlen(r->label) + 1); @@ -389,7 +392,7 @@ struct CommonRec ci; static int farsym = 0; static int i; - byte export_flags = 0; + byte symflags = 0; if (is_global == 2) { /* Common variable */ @@ -425,7 +428,11 @@ if (!nasm_strnicmp(special, "export", 6)) { special += 6; - export_flags |= SYM_GLOBAL; + symflags |= SYM_GLOBAL; + } + else if (!nasm_strnicmp(special, "import", 6)) { + special += 6; + symflags |= SYM_IMPORT; } if (*special) { @@ -438,11 +445,11 @@ } else if (!nasm_stricmp(special, "proc") || !nasm_stricmp(special, "function")) { - export_flags |= SYM_FUNCTION; + symflags |= SYM_FUNCTION; } else if (!nasm_stricmp(special, "data") || !nasm_stricmp(special, "object")) { - export_flags |= SYM_DATA; + symflags |= SYM_DATA; } else error(ERR_NONFATAL, "unrecognised symbol type `%s'", special); @@ -458,18 +465,20 @@ if (segments[i].segnumber == segment>>1) break; } if (i >= nsegments) { /* EXTERN declaration */ - if (farsym) - ri.type = RDFREC_FARIMPORT; - else - ri.type = RDFREC_IMPORT; + ri.type = farsym ? RDFREC_FARIMPORT : RDFREC_IMPORT; + if (symflags & SYM_GLOBAL) + error(ERR_NONFATAL, "symbol type conflict - EXTERN cannot be EXPORT"); + ri.flags = symflags; ri.segment = segment; strncpy(ri.label,name,32); ri.label[32] = 0; - ri.reclen = 3 + strlen(ri.label); + ri.reclen = 4 + strlen(ri.label); write_import_rec(&ri); } else if (is_global) { r.type = RDFREC_GLOBAL; - r.flags = export_flags; + if (symflags & SYM_IMPORT) + error(ERR_NONFATAL, "symbol type conflict - GLOBAL cannot be IMPORT"); + r.flags = symflags; r.segment = segment; r.offset = offset; strncpy(r.label,name,32); |