History

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.

herman ten brugge committed 2 years ago

Commit 5a467dd1 parent 7a6f3fd1 file · +2 −2Browse files

Unified · Split

tccelf.c+2−2
@@ -2527,6 +2527,8 @@ static int tcc_output_elf(TCCState *s1, FILE *f, int phnum, ElfW(Phdr) *phdr) · 2526 unmodified lines
25272527 ElfW(Ehdr) ehdr;
25282528 ElfW(Shdr) shdr, *sh;
25292529
2530+ sort_syms(s1, s1->symtab);
2531+
25302532 file_type = s1->output_type;
25312533 shnum = s1->nb_sections;
25322534
@@ -2614,8 +2616,6 @@ static int tcc_output_elf(TCCState *s1, FILE *f, int phnum, ElfW(Phdr) *phdr) · 81 unmodified lines
26142616 offset += fwrite(sh, 1, sizeof(ElfW(Shdr)), f);
26152617 }
26162618
2617− sort_syms(s1, s1->symtab);
2618−
26192619 /* output sections */
26202620 for(i = 1; i < s1->nb_sections; i++) {
26212621 s = s1->sections[i];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t