The section header should not contain the number of local symbols when the sh_size is null. This makes the header compliant and IDA will not issue any warnings when an executable is disassembled.
Unified · Split
| @@ -679,7 +679,8 @@ static void sort_syms(TCCState *s1, Section *s) · 678 unmodified lines | ||
| 679 | 679 | p++; |
| 680 | 680 | } |
| 681 | 681 | /* save the number of local symbols in section header */ |
| 682 | − s->sh_info = q - new_syms; | |
| 682 | + if( s->sh_size ) /* this 'if' makes IDA happy */ | |
| 683 | + s->sh_info = q - new_syms; | |
| 683 | 684 | |
| 684 | 685 | /* then second pass for non local symbols */ |
| 685 | 686 | p = (ElfW(Sym) *)s->data; |
| @@ -1985,10 +1986,11 @@ static void tidy_section_headers(TCCState *s1, int *sec_order) · 1299 unmodified lines | ||
| 1985 | 1986 | for_each_elem(symtab_section, 1, sym, ElfW(Sym)) |
| 1986 | 1987 | if (sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE) |
| 1987 | 1988 | sym->st_shndx = backmap[sym->st_shndx]; |
| 1988 | − for_each_elem(s1->dynsym, 1, sym, ElfW(Sym)) | |
| 1989 | − if (sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE) | |
| 1990 | − sym->st_shndx = backmap[sym->st_shndx]; | |
| 1991 | − | |
| 1989 | + if( !s1->static_link ) { | |
| 1990 | + for_each_elem(s1->dynsym, 1, sym, ElfW(Sym)) | |
| 1991 | + if (sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE) | |
| 1992 | + sym->st_shndx = backmap[sym->st_shndx]; | |
| 1993 | + } | |
| 1992 | 1994 | for (i = 0; i < s1->nb_sections; i++) |
| 1993 | 1995 | sec_order[i] = i; |
| 1994 | 1996 | tcc_free(s1->sections); |