#include #ifdef HAVE_CONFIG_H # include "config.h" #endif /* !HAVE_CONFIG_H */ #include #include #include #include #define COFF_DEFAULT_ENTRYNAME "_start" void dynarray_add(void *ptab, int *nb_ptr, void *data); void dynarray_reset(void *pp, int *n); static TCCSection * coff_new_section(TCCState2 *s1, const char *name, int flags) { TCCSection *sec; sec = tcc_mallocz(sizeof(TCCSection)); sec->state = s1; strncpy(sec->name, name, 8); /* truncate section name */ sec->flags = flags; sec->secnum = s1->nb_sections; dynarray_add(&s1->sections, &s1->nb_sections, sec); return (sec); } static void coff_free_section(TCCSection *s) { if (!s) return; tcc_free(s->data); s->data = NULL; s->data_allocated = s->data_offset = 0; } static void coff_new_symtab(TCCState2 *s1) { TCCSymtab *symtab; symtab = tcc_mallocz(sizeof(TCCSymtab)); } void coff_new(TCCState2 *s1) { dynarray_add(&s1->sections, &s1->nb_sections, NULL); s1->text_section = coff_new_section(s1, ".text", COFF_STYP_TEXT); s1->data_section = coff_new_section(s1, ".data", COFF_STYP_DATA); s1->bss_section = coff_new_section(s1, ".bss", COFF_STYP_BSS); s1->rodata_section = coff_new_section(s1, ".rodata", COFF_STYP_DATA); coff_new_symtab(s1); } void coff_delete(TCCState2 *s1) { int i; for (i = 1; i < s1->nb_sections; i++) { coff_free_section(s1->sections[i]); } dynarray_reset(&s1->sections, &s1->nb_sections); } int tcc_output_coff(TCCState2 *s1, FILE *f) { COFFFileHeader coffhdr; AOutHeader aouthdr; COFFSectionHeader coffsec; const char *entry_name = COFF_DEFAULT_ENTRYNAME; memset(&coffhdr, 0, sizeof(COFFFileHeader)); coffhdr.flags = COFF_F_LITTLE | COFF_F_LNNO; coffhdr.magic = COFF_MAGIC; coffhdr.nscns = s1->nb_sections; if (s1->output_type == /*TCC_OUTPUT_EXE*/666) { coffhdr.flags |= COFF_F_RELFLG | COFF_F_EXEC | COFF_F_LSYMS; coffhdr.nsyms = 0; memset(&aouthdr, 0, sizeof(AOutHeader)); aouthdr.magic = AOUT_ZMAGIC; coffhdr.opthdr = sizeof(AOutHeader); if (s1->entryname != NULL) { entry_name = s1->entryname; } //aouthdr.entry = get_sym_addr(s1, entry_name, 1, 0); if (s1->nb_errors) { return (-1); } } return (0); } int coff_output_object(TCCState2 *s, const char *filename) { return (0); } int coff_output_exe(TCCState2 *s, const char *filename) { return (0); } int coff_load_object(TCCState2 *s, int fd, size_t file_offset) { COFFFileHeader chdr; return (0); }