Hello, On 12 Jun 2019, at 21:21, Mike <tankf33...@disroot.org<mailto:tankf33...@disroot.org>> wrote:
I've run "make test" under -fsanitize=address and got the same report for several failed tests: This appears to be caused by an offset into a dynamically allocated block being assigned to sym in build_got_entries at line 1041: sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; And this dynamically allocated block being realloc'ed as a result of calling build_got(s1) at line 1102: build_got(s1); Bearing in mind that we keep using sym at line 1108: attr = put_got_entry(s1, reloc_type, sym->st_size, sym->st_info, sym_index); I have no idea what I am doing, but I applied the following patch and it seems to have fixed the dangling pointer, according to the tool I use (not ASan). diff --git a/tccelf.c b/tccelf.c index e5f6c42..6ddfb9f 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1098,8 +1098,10 @@ ST_FUNC void build_got_entries(TCCState *s1) } else reloc_type = R_GLOB_DAT; - if (!s1->got) + if (!s1->got) { build_got(s1); + sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; //attempt + } if (gotplt_entry == BUILD_GOT_ONLY) continue; Would a developer confirm this is a good idea? Pascal
dangling.patch
Description: dangling.patch
_______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel