tccelf.c: Reset sym after call to build_got.
The call to build_got can cause symtab_section->data to be reallocated (build_got -> add_elf_sym -> put_elf_sym -> section_ptr_add -> section_realloc -> tcc_realloc). This is not obvious on a cursory inspection, but fortunately Valgrind spotted it immediately. Are there other, similar bugs that Valgrind did not detect?
This commit is contained in:
parent
743684fe39
commit
f0b7566181
1 changed files with 3 additions and 1 deletions
4
tccelf.c
4
tccelf.c
|
@ -1446,8 +1446,10 @@ ST_FUNC void build_got_entries(TCCState *s1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s1->got)
|
if (!s1->got) {
|
||||||
build_got(s1);
|
build_got(s1);
|
||||||
|
sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
|
||||||
|
}
|
||||||
if (type == R_X86_64_GOT32 || type == R_X86_64_GOTPCREL ||
|
if (type == R_X86_64_GOT32 || type == R_X86_64_GOTPCREL ||
|
||||||
type == R_X86_64_PLT32) {
|
type == R_X86_64_PLT32) {
|
||||||
unsigned long ofs;
|
unsigned long ofs;
|
||||||
|
|
Loading…
Add table
Reference in a new issue