History

get rid of "free_section problem" with private sections

grischka committed 17 years ago

Commit 29c8e151 parent c80f81c1 file · +14 −13Browse files

Unified · Split

tcc.c+14−13
@@ -466,6 +466,9 @@ struct TCCState { · 465 unmodified lines
466466 Section **sections;
467467 int nb_sections; /* number of sections, including first dummy section */
468468
469+ Section **priv_sections;
470+ int nb_priv_sections; /* number of private sections */
471+
469472 /* got handling */
470473 Section *got;
471474 Section *plt;
@@ -1294,22 +1297,19 @@ Section *new_section(TCCState *s1, const char *name, int sh_type, int sh_flags) · 822 unmodified lines
12941297 break;
12951298 }
12961299
1297− /* only add section if not private */
1298− if (!(sh_flags & SHF_PRIVATE)) {
1300+ if (sh_flags & SHF_PRIVATE) {
1301+ dynarray_add((void ***)&s1->priv_sections, &s1->nb_priv_sections, sec);
1302+ } else {
12991303 sec->sh_num = s1->nb_sections;
13001304 dynarray_add((void ***)&s1->sections, &s1->nb_sections, sec);
13011305 }
1306+
13021307 return sec;
13031308 }
13041309
13051310 static void free_section(Section *s)
13061311 {
1307− if (s->link && (s->link->sh_flags & SHF_PRIVATE))
1308− free_section(s->link);
1309− if (s->hash && (s->hash->sh_flags & SHF_PRIVATE))
1310− s->hash->link = NULL, free_section(s->hash);
13111312 tcc_free(s->data);
1312− tcc_free(s);
13131313 }
13141314
13151315 /* realloc section and set its content to zero */
@@ -10506,15 +10506,16 @@ void tcc_delete(TCCState *s1) · 9190 unmodified lines
1050610506 tcc_cleanup();
1050710507
1050810508 /* free all sections */
10509− free_section(s1->dynsymtab_section);
10510−
1051110509 for(i = 1; i < s1->nb_sections; i++)
1051210510 free_section(s1->sections[i]);
10513− tcc_free(s1->sections);
10514−
10511+ dynarray_reset(&s1->sections, &s1->nb_sections);
10512+
10513+ for(i = 0; i < s1->nb_priv_sections; i++)
10514+ free_section(s1->priv_sections[i]);
10515+ dynarray_reset(&s1->priv_sections, &s1->nb_priv_sections);
10516+
1051510517 /* free any loaded DLLs */
10516− for ( i = 0; i < s1->nb_loaded_dlls; i++)
10517− {
10518+ for ( i = 0; i < s1->nb_loaded_dlls; i++) {
1051810519 DLLReference *ref = s1->loaded_dlls[i];
1051910520 if ( ref->handle )
1052010521 dlclose(ref->handle);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t