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
13731373 /* add tcc runtime libraries */
13741374 ST_FUNC void tcc_add_runtime(TCCState *s1)
13751375 {
1376− tcc_add_bcheck(s1);
1377−
13781376 /* add libc */
13791377 if (!s1->nostdlib) {
13801378 tcc_add_library(s1, "c");
@@ -1386,6 +1384,14 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) · 5 unmodified lines
13861384 #else
13871385 tcc_add_support(s1, "libtcc1.a");
13881386 #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) {
13891395 /* add crt end if not memory output */
13901396 if (s1->output_type != TCC_OUTPUT_MEMORY)
13911397 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