diff options
| author | grischka <grischka> | 2009-04-03 20:52:40 +0200 |
|---|---|---|
| committer | grischka <grischka> | 2009-04-18 15:07:28 +0200 |
| commit | 29c8e1545a490325907e46206fd7156c7bda502b (patch) | |
| tree | 5e896aae98cd14c5a4db026b971e645104c89fd4 | |
| parent | c80f81c19958fa219500a150513f9b2a6ab55c35 (diff) | |
| download | tinycc-29c8e1545a490325907e46206fd7156c7bda502b.tar.gz tinycc-29c8e1545a490325907e46206fd7156c7bda502b.tar.bz2 | |
get rid of "free_section problem" with private sections
| -rw-r--r-- | tcc.c | 27 |
1 files changed, 14 insertions, 13 deletions
@@ -466,6 +466,9 @@ struct TCCState { Section **sections; int nb_sections; /* number of sections, including first dummy section */ + Section **priv_sections; + int nb_priv_sections; /* number of private sections */ + /* got handling */ Section *got; Section *plt; @@ -1294,22 +1297,19 @@ Section *new_section(TCCState *s1, const char *name, int sh_type, int sh_flags) break; } - /* only add section if not private */ - if (!(sh_flags & SHF_PRIVATE)) { + if (sh_flags & SHF_PRIVATE) { + dynarray_add((void ***)&s1->priv_sections, &s1->nb_priv_sections, sec); + } else { sec->sh_num = s1->nb_sections; dynarray_add((void ***)&s1->sections, &s1->nb_sections, sec); } + return sec; } static void free_section(Section *s) { - if (s->link && (s->link->sh_flags & SHF_PRIVATE)) - free_section(s->link); - if (s->hash && (s->hash->sh_flags & SHF_PRIVATE)) - s->hash->link = NULL, free_section(s->hash); tcc_free(s->data); - tcc_free(s); } /* realloc section and set its content to zero */ @@ -10506,15 +10506,16 @@ void tcc_delete(TCCState *s1) tcc_cleanup(); /* free all sections */ - free_section(s1->dynsymtab_section); - for(i = 1; i < s1->nb_sections; i++) free_section(s1->sections[i]); - tcc_free(s1->sections); - + dynarray_reset(&s1->sections, &s1->nb_sections); + + for(i = 0; i < s1->nb_priv_sections; i++) + free_section(s1->priv_sections[i]); + dynarray_reset(&s1->priv_sections, &s1->nb_priv_sections); + /* free any loaded DLLs */ - for ( i = 0; i < s1->nb_loaded_dlls; i++) - { + for ( i = 0; i < s1->nb_loaded_dlls; i++) { DLLReference *ref = s1->loaded_dlls[i]; if ( ref->handle ) dlclose(ref->handle); |
