diff --git a/tccelf.c b/tccelf.c index 609a07ab..2387ba67 100644 --- a/tccelf.c +++ b/tccelf.c @@ -2527,8 +2527,6 @@ static int tcc_output_elf(TCCState *s1, FILE *f, int phnum, ElfW(Phdr) *phdr) ElfW(Ehdr) ehdr; ElfW(Shdr) shdr, *sh; - sort_syms(s1, s1->symtab); - file_type = s1->output_type; shnum = s1->nb_sections; @@ -2578,6 +2576,8 @@ static int tcc_output_elf(TCCState *s1, FILE *f, int phnum, ElfW(Phdr) *phdr) return -1; } + sort_syms(s1, s1->symtab); + ehdr.e_machine = EM_TCC_TARGET; ehdr.e_version = EV_CURRENT; ehdr.e_shoff = (sizeof(ElfW(Ehdr)) + phnum * sizeof(ElfW(Phdr)) + 3) & -4;