mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-06 06:40:07 +08:00
When creating a staticaly linked ELF program should not include
any dyn symbols. The if( !s1->static_link ) prevents tcc from crashing when buiding a program linked to dietlibc. 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.
This commit is contained in:
parent
3e4b7693bf
commit
3e028af453
12
tccelf.c
12
tccelf.c
@ -679,7 +679,8 @@ static void sort_syms(TCCState *s1, Section *s)
|
|||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
/* save the number of local symbols in section header */
|
/* save the number of local symbols in section header */
|
||||||
s->sh_info = q - new_syms;
|
if( s->sh_size ) /* this 'if' makes IDA happy */
|
||||||
|
s->sh_info = q - new_syms;
|
||||||
|
|
||||||
/* then second pass for non local symbols */
|
/* then second pass for non local symbols */
|
||||||
p = (ElfW(Sym) *)s->data;
|
p = (ElfW(Sym) *)s->data;
|
||||||
@ -1985,10 +1986,11 @@ static void tidy_section_headers(TCCState *s1, int *sec_order)
|
|||||||
for_each_elem(symtab_section, 1, sym, ElfW(Sym))
|
for_each_elem(symtab_section, 1, sym, ElfW(Sym))
|
||||||
if (sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE)
|
if (sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE)
|
||||||
sym->st_shndx = backmap[sym->st_shndx];
|
sym->st_shndx = backmap[sym->st_shndx];
|
||||||
for_each_elem(s1->dynsym, 1, sym, ElfW(Sym))
|
if( !s1->static_link ) {
|
||||||
if (sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE)
|
for_each_elem(s1->dynsym, 1, sym, ElfW(Sym))
|
||||||
sym->st_shndx = backmap[sym->st_shndx];
|
if (sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE)
|
||||||
|
sym->st_shndx = backmap[sym->st_shndx];
|
||||||
|
}
|
||||||
for (i = 0; i < s1->nb_sections; i++)
|
for (i = 0; i < s1->nb_sections; i++)
|
||||||
sec_order[i] = i;
|
sec_order[i] = i;
|
||||||
tcc_free(s1->sections);
|
tcc_free(s1->sections);
|
||||||
|
Loading…
Reference in New Issue
Block a user