diff --git a/tccmacho.c b/tccmacho.c index 6fdf6f54..77e5454e 100644 --- a/tccmacho.c +++ b/tccmacho.c @@ -558,7 +558,7 @@ static void collect_sections(TCCState *s1, struct macho *mo) mo->ep.cmd = LC_MAIN; mo->ep.cmdsize = sizeof(mo->ep); - mo->ep.entryoff = 4096; // XXX + mo->ep.entryoff = 4096; mo->ep.stacksize = 0; add_lc(mo, &mo->ep); @@ -810,6 +810,7 @@ ST_FUNC int macho_output_file(TCCState *s1, const char *filename) Section *s; collect_sections(s1, &mo); relocate_syms(s1, s1->symtab, 0); + mo.ep.entryoff = get_elf_sym_addr(s1, "main", 1) - mo.seg[1]->vmaddr; if (s1->nb_errors) goto do_ret;