From c4c3d514670877e532c2fe23a287c152a1cd9104 Mon Sep 17 00:00:00 2001 From: Clifford Matthews Date: Sun, 7 Jun 2009 17:49:06 -0600 Subject: [PATCH] More Mac OS X mods (native still doesn't work, but we're closer). --- README | 8 ++++---- runtime/native/i386/process.c | 14 +++++++++++++- runtime/native/i386/template.c | 13 +++---------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/README b/README index fce3ec2..421eb64 100644 --- a/README +++ b/README @@ -36,10 +36,10 @@ glibc-devel.i386 and libgcc.i386) then try this hack make make install -To compile syn68k on Mac OS X (tested under 10.5.7), you currently have to -override the cleanup script, since the stock script (i486-cleanup.pl) will -consume all of syn68k.s. However, even if you do this, the resultant binary -will not work. +To compile syn68k on Mac OS X (tested under 10.5.7), you currently +have to override the cleanup script, since the stock script +(i486-cleanup.pl) will consume all of syn68k.s. However, even if you +do this, the resultant binary will not work with native code. ./autogen.sh CLEANUP='' ./configure diff --git a/runtime/native/i386/process.c b/runtime/native/i386/process.c index 5608bfd..ac27921 100644 --- a/runtime/native/i386/process.c +++ b/runtime/native/i386/process.c @@ -416,12 +416,24 @@ create_asmdata (const template_t *t, int num_operands) new_code = !new_code; } + /* + * Use local labels so we get smaller branches even on Mac OS X. The + * following note comes from the Mac OS X Assembler reference: + * + * Note: The Mac OS X assembler for Intel i386 processors always + * produces branch instructions that are long (32 bits) for non-local + * labels. This allows the link editor to do procedure ordering (see + * the description of the -sectorder option in the ld(1) man page). + */ + fprintf (fp, " asm volatile (\"\\n\"\n" " \"%scode_start_%d:\\n\\t\"\n" " \"%s\\n\"\n" + " \"Lcode_end_%d:\\n\"\n" " \"%scode_end_%d:\");\n", - symbol_prefix, current, code[new_code], symbol_prefix, current); + symbol_prefix, current, code[new_code], current, + symbol_prefix, current); /* Try the next combination of operands. */ for (op = num_operands - 1; op >= 0; op--) diff --git a/runtime/native/i386/template.c b/runtime/native/i386/template.c index 9c0eb29..deeef50 100644 --- a/runtime/native/i386/template.c +++ b/runtime/native/i386/template.c @@ -4,13 +4,6 @@ /* $Id: template.c 61 2004-12-21 23:44:50Z ctm $ */ -#if defined(HAVE_SYMBOL_UNDERSCORE) -# define SYMBOL_PREFIX "_" -#else -# define SYMBOL_PREFIX "" -#endif - - const template_t template[] = { #define BINARY_OP(op, dstio, memout) \ @@ -633,7 +626,7 @@ const template_t template[] = { { SIZE_32, REGISTER, INOUT } } }, { "i386_call_abs", "", "", "", "volatile", "v", - "call " SYMBOL_PREFIX "%P0", + "call L%P0", { "addr" }, { { BROKEN_SIZE_32, CONSTANT, IN } } }, @@ -716,7 +709,7 @@ const template_t template[] = #define CONDL_BRANCH(op, flags) \ { "i386_" op, flags, "", "", "volatile", "v", \ - op " " SYMBOL_PREFIX "%P0", \ + op " L%P0", \ { "target" }, \ { { BROKEN_SIZE_32, CONSTANT, IN } } } @@ -736,7 +729,7 @@ const template_t template[] = CONDL_BRANCH ("js", "s"), { "i386_jmp", "", "", "", "volatile", "v", - "jmp " SYMBOL_PREFIX "%P0", + "jmp L%P0", { "target" }, { { BROKEN_SIZE_32, CONSTANT, IN } } }, { "i386_jmp_reg", "", "", "", "volatile", "-",