History

tccelf: load objects first

It seems to make sense to load any helper objects (such as bcheck.o) first, and then load standard libraries. 29 insertions(+), 29 deletions(-)

grischka committed 4 years ago

Commit d653cf01 parent 7d6979d1 file · +29 −29Browse files

Unified · Split

tccelf.c+29−29
@@ -1471,35 +1471,23 @@ static void tcc_tcov_add_file(TCCState *s1, const char *filename) · 1470 unmodified lines
1471ST_FUNC void tcc_add_runtime(TCCState *s1)1471ST_FUNC void tcc_add_runtime(TCCState *s1)
1472{1472{
1473 s1->filetype = 0;1473 s1->filetype = 0;
1474
1474#ifdef CONFIG_TCC_BCHECK1475#ifdef CONFIG_TCC_BCHECK
1475 tcc_add_bcheck(s1);1476 tcc_add_bcheck(s1);
1476#endif1477#endif
1477 tcc_add_pragma_libs(s1);1478 tcc_add_pragma_libs(s1);
1479
1478 /* add libc */1480 /* add libc */
1479 if (!s1->nostdlib) {1481 if (!s1->nostdlib) {
1480 if (s1->option_pthread)1482 int lpthread = s1->option_pthread;
1481 tcc_add_library_err(s1, "pthread");1483
1482 tcc_add_library_err(s1, "c");
1483#ifdef TCC_LIBGCC
1484 if (!s1->static_link) {
1485 if (TCC_LIBGCC[0] == '/')
1486 tcc_add_file(s1, TCC_LIBGCC);
1487 else
1488 tcc_add_dll(s1, TCC_LIBGCC, 0);
1489 }
1490#endif
1491#if TCC_TARGET_ARM && TARGETOS_FreeBSD
1492 tcc_add_library_err(s1, "gcc_s"); // unwind code
1493#endif
1494#ifdef CONFIG_TCC_BCHECK1484#ifdef CONFIG_TCC_BCHECK
1495 if (s1->do_bounds_check && s1->output_type != TCC_OUTPUT_DLL) {1485 if (s1->do_bounds_check && s1->output_type != TCC_OUTPUT_DLL) {
1496 tcc_add_library_err(s1, "pthread");
1497#if !TARGETOS_OpenBSD && !TARGETOS_NetBSD
1498 tcc_add_library_err(s1, "dl");
1499#endif
1500 tcc_add_support(s1, "bcheck.o");1486 tcc_add_support(s1, "bcheck.o");
1501 if (s1->static_link)1487# if !(TARGETOS_OpenBSD || TARGETOS_NetBSD)
1502 tcc_add_library_err(s1, "c");1488 tcc_add_library_err(s1, "dl");
1489# endif
1490 lpthread = 1;
1503 }1491 }
1504#endif1492#endif
1505#ifdef CONFIG_TCC_BACKTRACE1493#ifdef CONFIG_TCC_BACKTRACE
@@ -1511,28 +1499,40 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) · 5 unmodified lines
1511 if (s1->output_type != TCC_OUTPUT_MEMORY)1499 if (s1->output_type != TCC_OUTPUT_MEMORY)
1512 tcc_add_btstub(s1);1500 tcc_add_btstub(s1);
1513 }1501 }
1502#endif
1503 if (lpthread)
1504 tcc_add_library_err(s1, "pthread");
1505 tcc_add_library_err(s1, "c");
1506#ifdef TCC_LIBGCC
1507 if (!s1->static_link) {
1508 if (TCC_LIBGCC[0] == '/')
1509 tcc_add_file(s1, TCC_LIBGCC);
1510 else
1511 tcc_add_dll(s1, TCC_LIBGCC, 0);
1512 }
1513#endif
1514#if defined TCC_TARGET_ARM && TARGETOS_FreeBSD
1515 tcc_add_library_err(s1, "gcc_s"); // unwind code
1514#endif1516#endif
1515 if (TCC_LIBTCC1[0])1517 if (TCC_LIBTCC1[0])
1516 tcc_add_support(s1, TCC_LIBTCC1);1518 tcc_add_support(s1, TCC_LIBTCC1);
1517 1519
1518#if !defined TCC_TARGET_PE && !defined TCC_TARGET_MACHO
1519#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
1520 /* add crt end if not memory output */1520 /* add crt end if not memory output */
1521 if (s1->output_type != TCC_OUTPUT_MEMORY) {1521 if (s1->output_type != TCC_OUTPUT_MEMORY) {
1522#if defined TCC_TARGET_MACHO
1523 /* nothing to do */
1524#elif TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
1522 if (s1->output_type == TCC_OUTPUT_DLL)1525 if (s1->output_type == TCC_OUTPUT_DLL)
1523 tcc_add_crt(s1, "crtendS.o");1526 tcc_add_crt(s1, "crtendS.o");
1524 else1527 else
1525 tcc_add_crt(s1, "crtend.o");1528 tcc_add_crt(s1, "crtend.o");
1526#if TARGETOS_FreeBSD || TARGETOS_NetBSD1529# if !TARGETOS_OpenBSD
1527 tcc_add_crt(s1, "crtn.o");1530 tcc_add_crt(s1, "crtn.o");
1528#endif1531# endif
1529 }1532#else
1530#elif !defined(TCC_TARGET_MACHO)
1531 /* add crt end if not memory output */
1532 if (s1->output_type != TCC_OUTPUT_MEMORY)
1533 tcc_add_crt(s1, "crtn.o");1533 tcc_add_crt(s1, "crtn.o");
1534#endif1534#endif
1535#endif1535 }
1536 }1536 }
1537}1537}
1538#endif /* ndef TCC_TARGET_PE */1538#endif /* ndef TCC_TARGET_PE */

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