| @@ -73,9 +73,8 @@ typedef struct { · 72 unmodified lines |
| 73 | unsigned short dummy4; | 73 | unsigned short dummy4; |
| 74 | } AUXEF; | 74 | } AUXEF; |
| 75 | | 75 | |
| 76 | int tcc_output_coff(TCCState *s1, const char *OutFile) | 76 | int tcc_output_coff(TCCState *s1, FILE *f) |
| 77 | { | 77 | { |
| 78 | FILE *f; | | |
| 79 | Section *tcc_sect; | 78 | Section *tcc_sect; |
| 80 | SCNHDR *coff_sec; | 79 | SCNHDR *coff_sec; |
| 81 | int file_pointer; | 80 | int file_pointer; |
| @@ -84,12 +83,6 @@ int tcc_output_coff(TCCState *s1, const char *OutFile) · 2 unmodified lines |
| 84 | FILHDR file_hdr; /* FILE HEADER STRUCTURE */ | 83 | FILHDR file_hdr; /* FILE HEADER STRUCTURE */ |
| 85 | Section *stext, *sdata, *sbss; | 84 | Section *stext, *sdata, *sbss; |
| 86 | | 85 | |
| 87 | f = fopen(OutFile, "wb"); | | |
| 88 | | | |
| 89 | if (!f) { | | |
| 90 | error("Unable to open output file"); | | |
| 91 | } | | |
| 92 | | | |
| 93 | stext = FindSection(s1, ".text"); | 86 | stext = FindSection(s1, ".text"); |
| 94 | sdata = FindSection(s1, ".data"); | 87 | sdata = FindSection(s1, ".data"); |
| 95 | sbss = FindSection(s1, ".bss"); | 88 | sbss = FindSection(s1, ".bss"); |
| @@ -237,7 +230,7 @@ int tcc_output_coff(TCCState *s1, const char *OutFile) · 141 unmodified lines |
| 237 | EndAddress[nFuncs] = pc; | 230 | EndAddress[nFuncs] = pc; |
| 238 | FuncEntries[nFuncs] = | 231 | FuncEntries[nFuncs] = |
| 239 | (file_pointer - | 232 | (file_pointer - |
| 240 | LineNoFilePtr[nFuncs]) / LINESZ; | 233 | LineNoFilePtr[nFuncs]) / LINESZ - 1; |
| 241 | LastLineNo[nFuncs++] = last_line_num + 1; | 234 | LastLineNo[nFuncs++] = last_line_num + 1; |
| 242 | } else { | 235 | } else { |
| 243 | // beginning of function | 236 | // beginning of function |
| @@ -703,8 +696,6 @@ int tcc_output_coff(TCCState *s1, const char *OutFile) · 459 unmodified lines |
| 703 | tcc_free(Coff_str_table); | 696 | tcc_free(Coff_str_table); |
| 704 | } | 697 | } |
| 705 | | 698 | |
| 706 | fclose(f); | | |
| 707 | | | |
| 708 | return 0; | 699 | return 0; |
| 709 | } | 700 | } |
| 710 | | 701 | |
| @@ -843,18 +834,13 @@ int FindCoffSymbolIndex(const char *func_name) · 132 unmodified lines |
| 843 | return n; // total number of symbols | 834 | return n; // total number of symbols |
| 844 | } | 835 | } |
| 845 | | 836 | |
| 846 | | | |
| 847 | | | |
| 848 | | | |
| 849 | | | |
| 850 | | | |
| 851 | BOOL OutputTheSection(Section * sect) | 837 | BOOL OutputTheSection(Section * sect) |
| 852 | { | 838 | { |
| 853 | const char *s = sect->name; | 839 | const char *s = sect->name; |
| 854 | | 840 | |
| 855 | if (s == ".text") | 841 | if (!strcmp(s, ".text")) |
| 856 | return true; | 842 | return true; |
| 857 | else if (s == ".data") | 843 | else if (!strcmp(s, ".data")) |
| 858 | return true; | 844 | return true; |
| 859 | else | 845 | else |
| 860 | return 0; | 846 | return 0; |
| @@ -862,15 +848,15 @@ BOOL OutputTheSection(Section * sect) · 1 unmodified line |
| 862 | | 848 | |
| 863 | short int GetCoffFlags(const char *s) | 849 | short int GetCoffFlags(const char *s) |
| 864 | { | 850 | { |
| 865 | if (s == ".text") | 851 | if (!strcmp(s, ".text")) |
| 866 | return STYP_TEXT | STYP_DATA | STYP_ALIGN | 0x400; | 852 | return STYP_TEXT | STYP_DATA | STYP_ALIGN | 0x400; |
| 867 | else if (s == ".data") | 853 | else if (!strcmp(s, ".data")) |
| 868 | return STYP_DATA; | 854 | return STYP_DATA; |
| 869 | else if (s == ".bss") | 855 | else if (!strcmp(s, ".bss")) |
| 870 | return STYP_BSS; | 856 | return STYP_BSS; |
| 871 | else if (s == ".stack") | 857 | else if (!strcmp(s, ".stack")) |
| 872 | return STYP_BSS | STYP_ALIGN | 0x200; | 858 | return STYP_BSS | STYP_ALIGN | 0x200; |
| 873 | else if (s == ".cinit") | 859 | else if (!strcmp(s, ".cinit")) |
| 874 | return STYP_COPY | STYP_DATA | STYP_ALIGN | 0x200; | 860 | return STYP_COPY | STYP_DATA | STYP_ALIGN | 0x200; |
| 875 | else | 861 | else |
| 876 | return 0; | 862 | return 0; |