Fix OpenBSD PIE binary linking

This commit is contained in:
Brian Callahan 2022-08-21 12:37:09 -04:00
parent 20a1ebf854
commit 2acf65f7e6
2 changed files with 7 additions and 4 deletions

View file

@ -924,7 +924,7 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
#if TARGETOS_OpenBSD
if (output_type != TCC_OUTPUT_DLL)
tcc_add_crt(s, "crt0.o");
if (output_type & TCC_OUTPUT_DYN)
if (output_type == TCC_OUTPUT_DLL)
tcc_add_crt(s, "crtbeginS.o");
else
tcc_add_crt(s, "crtbegin.o");

View file

@ -1518,14 +1518,17 @@ ST_FUNC void tcc_add_runtime(TCCState *s1)
if (s1->output_type != TCC_OUTPUT_MEMORY) {
#if defined TCC_TARGET_MACHO
/* nothing to do */
#elif TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
#elif TARGETOS_FreeBSD || TARGETOS_NetBSD
if (s1->output_type & TCC_OUTPUT_DYN)
tcc_add_crt(s1, "crtendS.o");
else
tcc_add_crt(s1, "crtend.o");
# if !TARGETOS_OpenBSD
tcc_add_crt(s1, "crtn.o");
# endif
#elif TARGETOS_OpenBSD
if (s1->output_type == TCC_OUTPUT_DLL)
tcc_add_crt(s1, "crtendS.o");
else
tcc_add_crt(s1, "crtend.o");
#elif TARGETOS_ANDROID
if (s1->output_type == TCC_OUTPUT_DLL)
tcc_add_crt(s1, "crtend_so.o");