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
2527 ElfW(Ehdr) ehdr;2527 ElfW(Ehdr) ehdr;
2528 ElfW(Shdr) shdr, *sh;2528 ElfW(Shdr) shdr, *sh;
2529 2529
2530 sort_syms(s1, s1->symtab);
2531
2530 file_type = s1->output_type;2532 file_type = s1->output_type;
2531 shnum = s1->nb_sections;2533 shnum = s1->nb_sections;
2532 2534
@@ -2614,8 +2616,6 @@ static int tcc_output_elf(TCCState *s1, FILE *f, int phnum, ElfW(Phdr) *phdr) · 81 unmodified lines
2614 offset += fwrite(sh, 1, sizeof(ElfW(Shdr)), f);2616 offset += fwrite(sh, 1, sizeof(ElfW(Shdr)), f);
2615 }2617 }
2616 2618
2617 sort_syms(s1, s1->symtab);
2618
2619 /* output sections */2619 /* output sections */
2620 for(i = 1; i < s1->nb_sections; i++) {2620 for(i = 1; i < s1->nb_sections; i++) {
2621 s = s1->sections[i];2621 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