Fix sellinux pointer code in tccrun.

Free all memory on exit in __bound_exit.
This commit is contained in:
herman ten brugge 2019-12-23 20:23:18 +01:00
parent f150f93854
commit 269042503e
2 changed files with 13 additions and 13 deletions

View File

@ -522,17 +522,6 @@ void __attribute__((destructor)) __bound_exit(void)
}
#endif
#if TREE_REUSE
while (tree_free_list) {
Tree *next = tree_free_list->left;
#if MALLOC_REDIR
free_redir (tree_free_list);
#else
free (tree_free_list);
#endif
tree_free_list = next;
}
#endif
for (i = 0; i < FREE_REUSE_SIZE; i++) {
if (free_reuse_list[i]) {
tree = splay_delete ((size_t) free_reuse_list[i], tree);
@ -551,6 +540,17 @@ void __attribute__((destructor)) __bound_exit(void)
}
tree = splay_delete (tree->start, tree);
}
#if TREE_REUSE
while (tree_free_list) {
Tree *next = tree_free_list->left;
#if MALLOC_REDIR
free_redir (tree_free_list);
#else
free (tree_free_list);
#endif
tree_free_list = next;
}
#endif
EXIT_SEM ();
inited = 0;
#ifdef BOUND_STATISTIC

View File

@ -254,14 +254,14 @@ static int tcc_relocate_ex(TCCState *s1, void *ptr, addr_t ptr_diff)
length = s->data_offset;
ptr = (void*)s->sh_addr;
if (s->sh_flags & SHF_EXECINSTR)
ptr = (char*)ptr - ptr_diff;
ptr = (char*)((addr_t)ptr - ptr_diff);
if (NULL == s->data || s->sh_type == SHT_NOBITS)
memset(ptr, 0, length);
else
memcpy(ptr, s->data, length);
/* mark executable sections as executable in memory */
if (s->sh_flags & SHF_EXECINSTR)
set_pages_executable(s1, (char*)ptr + ptr_diff, length);
set_pages_executable(s1, (char*)((addr_t)ptr + ptr_diff), length);
}
#ifdef _WIN64