aboutsummaryrefslogtreecommitdiff
path: root/libtcc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libtcc.c')
-rw-r--r--libtcc.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/libtcc.c b/libtcc.c
index 99bf783..b4b2615 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1081,7 +1081,19 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
break;
#endif
default:
-#ifdef TCC_TARGET_PE
+#if defined(TCC_TARGET_MACHO)
+ if (s1->output_type == TCC_OUTPUT_MEMORY) {
+ ret = 0;
+#ifdef TCC_IS_NATIVE
+ if (NULL == dlopen(filename, RTLD_GLOBAL | RTLD_LAZY)) {
+ ret = -1;
+ }
+#endif /* TCC_TARGET_MACHO */
+ } else {
+ ret = tcc_load_dll(s1, fd, filename,
+ (flags & AFF_REFERENCED_DLL) != 0);
+ }
+#elif defined(TCC_TARGET_PE)
ret = pe_load_file(s1, filename, fd);
#else
/* as GNU ld, consider it is an ld script if not recognized */
@@ -1143,7 +1155,10 @@ ST_FUNC int tcc_add_crt(TCCState *s, const char *filename)
/* the library name is the same as the argument of the '-l' option */
LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname)
{
-#ifdef TCC_TARGET_PE
+#if defined(TCC_TARGET_MACHO)
+ const char *libs[] = { "%s/lib%s.dylib", "%s/lib%s.a", NULL };
+ const char **pp = s->static_link ? libs + 1 : libs;
+#elif defined(TCC_TARGET_PE)
const char *libs[] = { "%s/%s.def", "%s/lib%s.def", "%s/%s.dll", "%s/lib%s.dll", "%s/lib%s.a", NULL };
const char **pp = s->static_link ? libs + 4 : libs;
#else