History

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.

Emil committed 9 years ago

Commit 3e028af1 parent 3e4b7691 file · +7 −5Browse files

Unified · Split

tccelf.c+7−5
@@ -679,7 +679,8 @@ static void sort_syms(TCCState *s1, Section *s) · 678 unmodified lines
679679 p++;
680680 }
681681 /* 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;
683684
684685 /* then second pass for non local symbols */
685686 p = (ElfW(Sym) *)s->data;
@@ -1985,10 +1986,11 @@ static void tidy_section_headers(TCCState *s1, int *sec_order) · 1299 unmodified lines
19851986 for_each_elem(symtab_section, 1, sym, ElfW(Sym))
19861987 if (sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE)
19871988 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+ }
19921994 for (i = 0; i < s1->nb_sections; i++)
19931995 sec_order[i] = i;
19941996 tcc_free(s1->sections);

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