aboutsummaryrefslogtreecommitdiff
path: root/tccelf.c
diff options
context:
space:
mode:
authorEdmund Grimley Evans <Edmund.Grimley.Evans@gmail.com>2015-10-16 20:33:41 +0100
committerEdmund Grimley Evans <Edmund.Grimley.Evans@gmail.com>2015-10-16 20:33:41 +0100
commitf0b7566181d8cf3407a6aaef51703b62b07ce2a6 (patch)
treebbb59e01d0f4dede12b52a81f75a3c3d8cd1cee9 /tccelf.c
parent743684fe39a56cdc0409ad6877afae486242ec2c (diff)
downloadtinycc-f0b7566181d8cf3407a6aaef51703b62b07ce2a6.tar.gz
tinycc-f0b7566181d8cf3407a6aaef51703b62b07ce2a6.tar.bz2
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?
Diffstat (limited to 'tccelf.c')
-rw-r--r--tccelf.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tccelf.c b/tccelf.c
index 1f87946..f9a8ced 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -1446,8 +1446,10 @@ ST_FUNC void build_got_entries(TCCState *s1)
break;
}
- if (!s1->got)
+ if (!s1->got) {
build_got(s1);
+ sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
+ }
if (type == R_X86_64_GOT32 || type == R_X86_64_GOTPCREL ||
type == R_X86_64_PLT32) {
unsigned long ofs;