diff options
| author | Thomas Preud'homme <robotux@celest.fr> | 2014-03-17 23:14:38 +0800 |
|---|---|---|
| committer | Thomas Preud'homme <robotux@celest.fr> | 2014-03-17 23:14:38 +0800 |
| commit | ec1c83081dd741bd18ca1821bf52535c444dc111 (patch) | |
| tree | 671577499ee3abdfd0cb332ab033dbd4f132384f /tccelf.c | |
| parent | 40e38597391aa05a61cef1c36e844690665c411a (diff) | |
| download | tinycc-ec1c83081dd741bd18ca1821bf52535c444dc111.tar.gz tinycc-ec1c83081dd741bd18ca1821bf52535c444dc111.tar.bz2 | |
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.
Diffstat (limited to 'tccelf.c')
| -rw-r--r-- | tccelf.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1373,8 +1373,6 @@ static inline int tcc_add_support(TCCState *s1, const char *filename) /* add tcc runtime libraries */ ST_FUNC void tcc_add_runtime(TCCState *s1) { - tcc_add_bcheck(s1); - /* add libc */ if (!s1->nostdlib) { tcc_add_library(s1, "c"); @@ -1386,6 +1384,14 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) #else tcc_add_support(s1, "libtcc1.a"); #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 */ if (s1->output_type != TCC_OUTPUT_MEMORY) tcc_add_crt(s1, "crtn.o"); |
