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;