changeset 324:cdd8835c6c2f

[project @ 2004-10-23 22:52:58 by bellard] update
author bellard
date Sat, 23 Oct 2004 22:52:58 +0000
parents 164e85dc9987
children 0a6b6ad4b159
files tcccoff.c
diffstat 1 files changed, 9 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/tcccoff.c	Sat Oct 23 22:52:42 2004 +0000
+++ b/tcccoff.c	Sat Oct 23 22:52:58 2004 +0000
@@ -73,9 +73,8 @@
     unsigned short dummy4;
 } AUXEF;
 
-int tcc_output_coff(TCCState *s1, const char *OutFile)
+int tcc_output_coff(TCCState *s1, FILE *f)
 {
-    FILE *f;
     Section *tcc_sect;
     SCNHDR *coff_sec;
     int file_pointer;
@@ -84,12 +83,6 @@
     FILHDR file_hdr;		/* FILE HEADER STRUCTURE              */
     Section *stext, *sdata, *sbss;
 
-    f = fopen(OutFile, "wb");
-
-    if (!f) {
-	error("Unable to open output file");
-    }
-
     stext = FindSection(s1, ".text");
     sdata = FindSection(s1, ".data");
     sbss = FindSection(s1, ".bss");
@@ -237,7 +230,7 @@
 			EndAddress[nFuncs] = pc;
 			FuncEntries[nFuncs] =
 			    (file_pointer -
-			     LineNoFilePtr[nFuncs]) / LINESZ;
+			     LineNoFilePtr[nFuncs]) / LINESZ - 1;
 			LastLineNo[nFuncs++] = last_line_num + 1;
 		    } else {
 			// beginning of function
@@ -703,8 +696,6 @@
 	tcc_free(Coff_str_table);
     }
 
-    fclose(f);
-
     return 0;
 }
 
@@ -843,18 +834,13 @@
     return n;			// total number of symbols
 }
 
-
-
-
-
-
 BOOL OutputTheSection(Section * sect)
 {
     const char *s = sect->name;
 
-    if (s == ".text")
+    if (!strcmp(s, ".text"))
 	return true;
-    else if (s == ".data")
+    else if (!strcmp(s, ".data"))
 	return true;
     else
 	return 0;
@@ -862,15 +848,15 @@
 
 short int GetCoffFlags(const char *s)
 {
-    if (s == ".text")
+    if (!strcmp(s, ".text"))
 	return STYP_TEXT | STYP_DATA | STYP_ALIGN | 0x400;
-    else if (s == ".data")
+    else if (!strcmp(s, ".data"))
 	return STYP_DATA;
-    else if (s == ".bss")
+    else if (!strcmp(s, ".bss"))
 	return STYP_BSS;
-    else if (s == ".stack")
+    else if (!strcmp(s, ".stack"))
 	return STYP_BSS | STYP_ALIGN | 0x200;
-    else if (s == ".cinit")
+    else if (!strcmp(s, ".cinit"))
 	return STYP_COPY | STYP_DATA | STYP_ALIGN | 0x200;
     else
 	return 0;