Hello.
Michael Matz <[email protected]> wrote:
|On Tue, 8 Nov 2016, Steffen Nurpmeso wrote:
...
|> cc': corrupted double-linked list: 0x000000000065c0f0 ***
|
|Something in tcc is probably overwriting random memory which happens to be
|meta info malloc is using for its own implementation leading to the
|ovserved abort (which basically is a consistency check on that internal
|data). valgrind often helps in identifying the real cause, so do:
The attached diff fixes the issue for me.
Ciao!
--steffen
diff --git a/tccelf.c b/tccelf.c
index 9ed2484..52db06a 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -128,9 +128,11 @@ ST_FUNC void tccelf_delete(TCCState *s1)
ST_FUNC Section *new_section(TCCState *s1, const char *name, int sh_type, int sh_flags)
{
Section *sec;
+ size_t len;
- sec = tcc_mallocz(sizeof(Section) + strlen(name));
- strcpy(sec->name, name);
+ len = strlen(name) +1;
+ sec = tcc_mallocz(sizeof(Section) + len);
+ memcpy(sec->name, name, len);
sec->sh_type = sh_type;
sec->sh_flags = sh_flags;
switch(sh_type) {
@@ -695,8 +697,9 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s)
#endif
for_each_elem(sr, 0, rel, ElfW_Rel) {
- ptr = s->data + rel->r_offset;
+ section_ptr_add(s, 8);
+ ptr = s->data + rel->r_offset;
sym_index = ELFW(R_SYM)(rel->r_info);
sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
val = sym->st_value;
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel