mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-26 03:50:07 +08:00
Fix sellinux pointer code in tccrun.
Free all memory on exit in __bound_exit.
This commit is contained in:
parent
f150f93854
commit
269042503e
22
lib/bcheck.c
22
lib/bcheck.c
@ -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
|
||||
|
4
tccrun.c
4
tccrun.c
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user