mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-26 08:00:09 +08:00
Fix relocation of __bound_init
When bound check is enabled, tcc tries to relocate a call to __bound_init in _init. This means that relocation (in tcc_add_bcheck) must be done after libtcc1.a (which countains __bound_init) is loaded but before crtn.o is loaded as this finalize _init.
This commit is contained in:
parent
40e3859739
commit
ec1c83081d
10
tccelf.c
10
tccelf.c
@ -1373,8 +1373,6 @@ static inline int tcc_add_support(TCCState *s1, const char *filename)
|
|||||||
/* add tcc runtime libraries */
|
/* add tcc runtime libraries */
|
||||||
ST_FUNC void tcc_add_runtime(TCCState *s1)
|
ST_FUNC void tcc_add_runtime(TCCState *s1)
|
||||||
{
|
{
|
||||||
tcc_add_bcheck(s1);
|
|
||||||
|
|
||||||
/* add libc */
|
/* add libc */
|
||||||
if (!s1->nostdlib) {
|
if (!s1->nostdlib) {
|
||||||
tcc_add_library(s1, "c");
|
tcc_add_library(s1, "c");
|
||||||
@ -1386,6 +1384,14 @@ ST_FUNC void tcc_add_runtime(TCCState *s1)
|
|||||||
#else
|
#else
|
||||||
tcc_add_support(s1, "libtcc1.a");
|
tcc_add_support(s1, "libtcc1.a");
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* tcc_add_bcheck tries to relocate a call to __bound_init in _init so
|
||||||
|
libtcc1.a must be loaded before for __bound_init to be defined and
|
||||||
|
crtn.o must be loaded after to not finalize _init too early. */
|
||||||
|
tcc_add_bcheck(s1);
|
||||||
|
|
||||||
|
if (!s1->nostdlib) {
|
||||||
/* add crt end if not memory output */
|
/* add crt end if not memory output */
|
||||||
if (s1->output_type != TCC_OUTPUT_MEMORY)
|
if (s1->output_type != TCC_OUTPUT_MEMORY)
|
||||||
tcc_add_crt(s1, "crtn.o");
|
tcc_add_crt(s1, "crtn.o");
|
||||||
|
Loading…
Reference in New Issue
Block a user