History

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.

Thomas Preud'homme committed 12 years ago

Commit ec1c8301 parent 40e38591 file · +8 −2Browse files

Unified · Split

tccelf.c+8−2
@@ -1373,8 +1373,6 @@ static inline int tcc_add_support(TCCState *s1, const char *filename) · 1372 unmodified lines
1373/* add tcc runtime libraries */1373/* add tcc runtime libraries */
1374ST_FUNC void tcc_add_runtime(TCCState *s1)1374ST_FUNC void tcc_add_runtime(TCCState *s1)
1375{1375{
1376 tcc_add_bcheck(s1);
1377
1378 /* add libc */1376 /* add libc */
1379 if (!s1->nostdlib) {1377 if (!s1->nostdlib) {
1380 tcc_add_library(s1, "c");1378 tcc_add_library(s1, "c");
@@ -1386,6 +1384,14 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) · 5 unmodified lines
1386#else1384#else
1387 tcc_add_support(s1, "libtcc1.a");1385 tcc_add_support(s1, "libtcc1.a");
1388#endif1386#endif
1387 }
1388
1389 /* tcc_add_bcheck tries to relocate a call to __bound_init in _init so
1390 libtcc1.a must be loaded before for __bound_init to be defined and
1391 crtn.o must be loaded after to not finalize _init too early. */
1392 tcc_add_bcheck(s1);
1393
1394 if (!s1->nostdlib) {
1389 /* add crt end if not memory output */1395 /* add crt end if not memory output */
1390 if (s1->output_type != TCC_OUTPUT_MEMORY)1396 if (s1->output_type != TCC_OUTPUT_MEMORY)
1391 tcc_add_crt(s1, "crtn.o");1397 tcc_add_crt(s1, "crtn.o");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t