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
466 Section **sections;466 Section **sections;
467 int nb_sections; /* number of sections, including first dummy section */467 int nb_sections; /* number of sections, including first dummy section */
468 468
469 Section **priv_sections;
470 int nb_priv_sections; /* number of private sections */
471
469 /* got handling */472 /* got handling */
470 Section *got;473 Section *got;
471 Section *plt;474 Section *plt;
@@ -1294,22 +1297,19 @@ Section *new_section(TCCState *s1, const char *name, int sh_type, int sh_flags) · 822 unmodified lines
1294 break;1297 break;
1295 }1298 }
1296 1299
1297 /* only add section if not private */1300 if (sh_flags & SHF_PRIVATE) {
1298 if (!(sh_flags & SHF_PRIVATE)) {1301 dynarray_add((void ***)&s1->priv_sections, &s1->nb_priv_sections, sec);
1302 } else {
1299 sec->sh_num = s1->nb_sections;1303 sec->sh_num = s1->nb_sections;
1300 dynarray_add((void ***)&s1->sections, &s1->nb_sections, sec);1304 dynarray_add((void ***)&s1->sections, &s1->nb_sections, sec);
1301 }1305 }
1306
1302 return sec;1307 return sec;
1303}1308}
1304 1309
1305static void free_section(Section *s)1310static void free_section(Section *s)
1306{1311{
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);
1311 tcc_free(s->data);1312 tcc_free(s->data);
1312 tcc_free(s);
1313}1313}
1314 1314
1315/* realloc section and set its content to zero */1315/* realloc section and set its content to zero */
@@ -10506,15 +10506,16 @@ void tcc_delete(TCCState *s1) · 9190 unmodified lines
10506 tcc_cleanup();10506 tcc_cleanup();
10507 10507
10508 /* free all sections */10508 /* free all sections */
10509 free_section(s1->dynsymtab_section);
10510
10511 for(i = 1; i < s1->nb_sections; i++)10509 for(i = 1; i < s1->nb_sections; i++)
10512 free_section(s1->sections[i]);10510 free_section(s1->sections[i]);
10513 tcc_free(s1->sections);10511 dynarray_reset(&s1->sections, &s1->nb_sections);
10514 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
10515 /* free any loaded DLLs */10517 /* free any loaded DLLs */
10516 for ( i = 0; i < s1->nb_loaded_dlls; i++)10518 for ( i = 0; i < s1->nb_loaded_dlls; i++) {
10517 {
10518 DLLReference *ref = s1->loaded_dlls[i];10519 DLLReference *ref = s1->loaded_dlls[i];
10519 if ( ref->handle )10520 if ( ref->handle )
10520 dlclose(ref->handle);10521 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