From b882cad67e16d5b81ddc96510c14ea543b473aa4 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Fri, 15 May 2020 03:45:00 +0200 Subject: [PATCH] macos: Don't try to load dylibs or linker scripts we ignore dylibs for now (can't inspect them yet for meta-info). Also don't try to load GNU linker scripts, it's simply an unknown file type (e.g. when mentioning Mach-O object files). --- libtcc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libtcc.c b/libtcc.c index 4e42c363..472f0d71 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1096,8 +1096,12 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) ret = -1; #endif } else { +#ifndef TCC_TARGET_MACHO ret = tcc_load_dll(s1, fd, filename, (flags & AFF_REFERENCED_DLL) != 0); +#else + ret = 0; +#endif } break; #endif @@ -1112,12 +1116,15 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) default: #ifdef TCC_TARGET_PE ret = pe_load_file(s1, filename, fd); +#elif defined(TCC_TARGET_MACHO) + ret = -1; #else /* as GNU ld, consider it is an ld script if not recognized */ ret = tcc_load_ldscript(s1, fd); #endif if (ret < 0) - tcc_error_noabort("unrecognized file type"); + tcc_error_noabort("%s: unrecognized file type %d", filename, + obj_type); break; } close(fd);