diff --git a/cli/Makefile b/cli/Makefile index c1918d3c3848b..a5a018174e070 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -54,7 +54,11 @@ $(BUILDDIR)/loader_exe.o : $(SRCDIR)/loader_exe.c $(HEADERS) $(BUILDDIR)/loader_exe.dbg.obj : $(SRCDIR)/loader_exe.c $(HEADERS) @$(call PRINT_CC, $(CC) $(DEBUGFLAGS) $(LOADER_CFLAGS) -c $< -o $@) $(BUILDDIR)/loader_trampolines.o : $(SRCDIR)/trampolines/trampolines_$(ARCH).S - @$(call PRINT_CC, $(CC) $(DEBUGFLAGS) $(LOADER_CFLAGS) $< -c -o $@) + @$(call PRINT_CC, $(CC) $(SHIPFLAGS) $(LOADER_CFLAGS) $< -c -o $@) + +# Debugging target to help us see what kind of code is being generated for our trampolines +dump-trampolines: $(SRCDIR)/trampolines/trampolines_$(ARCH).S + $(CC) $(SHIPFLAGS) $(LOADER_CFLAGS) $< -S | sed -E 's/ ((%%)|;) /\n/g' | sed -E 's/.global/\n.global/g' DIRS = $(build_bindir) $(build_libdir) $(DIRS): diff --git a/cli/trampolines/trampolines_aarch64.S b/cli/trampolines/trampolines_aarch64.S index 174962bb80614..63c044e2ef8d1 100644 --- a/cli/trampolines/trampolines_aarch64.S +++ b/cli/trampolines/trampolines_aarch64.S @@ -1,12 +1,27 @@ #include "../../src/jl_exported_funcs.inc" +// On macOS, we need to prepend underscores on symbols +#if defined(__APPLE__) && defined(__MACH__) +#define CNAME(x) _##x +#define PAGE(x) x##@PAGE +#define PAGEOFF(x) x##@PAGEOFF +#define SEP %% +#else +#define CNAME(x) x +#define PAGE(x) x +#define PAGEOFF(x) #:lo12:##x +#define SEP ; +#endif + #define XX(name) \ -.global name; \ -.cfi_startproc; \ -name##:; \ - adrp x0, name##_addr; \ - ldr x0, [x0, #:lo12:name##_addr]; \ - br x0; \ -.cfi_endproc; \ +.global CNAME(name) SEP \ +.cfi_startproc SEP \ +.p2align 2 SEP \ +CNAME(name)##: SEP \ + adrp x0, PAGE(CNAME(name##_addr)) SEP \ + ldr x0, [x0, PAGEOFF(CNAME(name##_addr))] SEP \ + br x0 SEP \ +.cfi_endproc SEP \ + JL_EXPORTED_FUNCS(XX) #undef XX