From dfe031caa6f6dbe80fb5fb003426a25202e4f00a Mon Sep 17 00:00:00 2001 From: Christian Jullien Date: Sun, 29 Nov 2020 08:47:27 +0100 Subject: [PATCH] OpenBSD: Fix crt startup names - WIP --- libtcc.c | 6 +++++- tccelf.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libtcc.c b/libtcc.c index 36986328..01ffe769 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1091,7 +1091,11 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) /* add libc crt1/crti objects */ if ((output_type == TCC_OUTPUT_EXE || output_type == TCC_OUTPUT_DLL) && !s->nostdlib) { -#ifndef TCC_TARGET_MACHO +#if defined(__OpenBSD__) + if (output_type != TCC_OUTPUT_DLL) + tcc_add_crt(s, "crt0.o"); + tcc_add_crt(s, "crtbegin.o"); +#elif !defined(TCC_TARGET_MACHO) /* Mach-O with LC_MAIN doesn't need any crt startup code. */ if (output_type != TCC_OUTPUT_DLL) tcc_add_crt(s, "crt1.o"); diff --git a/tccelf.c b/tccelf.c index aa582856..48d7794c 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1429,7 +1429,11 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) #endif if (strlen(TCC_LIBTCC1) > 0) tcc_add_support(s1, TCC_LIBTCC1); -#ifndef TCC_TARGET_MACHO +#if defined(__OpenBSD__) + /* add crt end if not memory output */ + if (s1->output_type != TCC_OUTPUT_MEMORY) + tcc_add_crt(s1, "crtend.o"); +#elif !defined(TCC_TARGET_MACHO) /* add crt end if not memory output */ if (s1->output_type != TCC_OUTPUT_MEMORY) tcc_add_crt(s1, "crtn.o");