mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-28 04:00:06 +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
|
#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++) {
|
for (i = 0; i < FREE_REUSE_SIZE; i++) {
|
||||||
if (free_reuse_list[i]) {
|
if (free_reuse_list[i]) {
|
||||||
tree = splay_delete ((size_t) free_reuse_list[i], tree);
|
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);
|
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 ();
|
EXIT_SEM ();
|
||||||
inited = 0;
|
inited = 0;
|
||||||
#ifdef BOUND_STATISTIC
|
#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;
|
length = s->data_offset;
|
||||||
ptr = (void*)s->sh_addr;
|
ptr = (void*)s->sh_addr;
|
||||||
if (s->sh_flags & SHF_EXECINSTR)
|
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)
|
if (NULL == s->data || s->sh_type == SHT_NOBITS)
|
||||||
memset(ptr, 0, length);
|
memset(ptr, 0, length);
|
||||||
else
|
else
|
||||||
memcpy(ptr, s->data, length);
|
memcpy(ptr, s->data, length);
|
||||||
/* mark executable sections as executable in memory */
|
/* mark executable sections as executable in memory */
|
||||||
if (s->sh_flags & SHF_EXECINSTR)
|
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
|
#ifdef _WIN64
|
||||||
|
Loading…
Reference in New Issue
Block a user