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