From 5a467ddc98b209ef0531b10fe76441d40d4979ae Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Sun, 20 Oct 2024 10:57:50 +0200 Subject: [PATCH] Move sort_syms to avoid linker error compiling with tcc and linking with gcc gives error: tcc -c a.c gcc a.o usr/bin/ld: a.o: .symtab local symbol at index 0 (>= sh_info of 0) /usr/bin/ld: a.o: error adding symbols: bad value collect2: error: ld returned 1 exit status Solved by moving call to sort_syms. --- tccelf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tccelf.c b/tccelf.c index 76057275..609a07ab 100644 --- a/tccelf.c +++ b/tccelf.c @@ -2527,6 +2527,8 @@ 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; @@ -2614,8 +2616,6 @@ static int tcc_output_elf(TCCState *s1, FILE *f, int phnum, ElfW(Phdr) *phdr) offset += fwrite(sh, 1, sizeof(ElfW(Shdr)), f); } - sort_syms(s1, s1->symtab); - /* output sections */ for(i = 1; i < s1->nb_sections; i++) { s = s1->sections[i];