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 | p++; | 679 | p++; |
| 680 | } | 680 | } |
| 681 | /* save the number of local symbols in section header */ | 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 | /* then second pass for non local symbols */ | 685 | /* then second pass for non local symbols */ |
| 685 | p = (ElfW(Sym) *)s->data; | 686 | p = (ElfW(Sym) *)s->data; |
| @@ -1985,10 +1986,11 @@ static void tidy_section_headers(TCCState *s1, int *sec_order) · 1299 unmodified lines | |||
| 1985 | for_each_elem(symtab_section, 1, sym, ElfW(Sym)) | 1986 | for_each_elem(symtab_section, 1, sym, ElfW(Sym)) |
| 1986 | if (sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE) | 1987 | if (sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE) |
| 1987 | sym->st_shndx = backmap[sym->st_shndx]; | 1988 | sym->st_shndx = backmap[sym->st_shndx]; |
| 1988 | for_each_elem(s1->dynsym, 1, sym, ElfW(Sym)) | 1989 | if( !s1->static_link ) { |
| 1989 | if (sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE) | 1990 | for_each_elem(s1->dynsym, 1, sym, ElfW(Sym)) |
| 1990 | sym->st_shndx = backmap[sym->st_shndx]; | 1991 | if (sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE) |
| 1991 | 1992 | sym->st_shndx = backmap[sym->st_shndx]; | |
| 1993 | } | ||
| 1992 | for (i = 0; i < s1->nb_sections; i++) | 1994 | for (i = 0; i < s1->nb_sections; i++) |
| 1993 | sec_order[i] = i; | 1995 | sec_order[i] = i; |
| 1994 | tcc_free(s1->sections); | 1996 | tcc_free(s1->sections); |