mirror of
https://github.com/ctm/syn68k.git
synced 2025-01-22 22:30:52 +00:00
Fixed native code generation for Mac OS X (but still have other Mac OS X problems).
This commit is contained in:
parent
d0035f4d92
commit
944f070990
9
README
9
README
@ -36,12 +36,9 @@ glibc-devel.i386 and libgcc.i386) then try this hack
|
|||||||
make
|
make
|
||||||
make install
|
make install
|
||||||
|
|
||||||
Syn68k doesn't currently compile under Mac OS X (tested under 10.5.7)
|
Syn68k currently doesn't build under Mac OS X (tested under 10.5.7)
|
||||||
due to the use of leading underscores in the symbol table (this is
|
do to our unconditional use of "-z execstack" when linking as well as
|
||||||
easily fixed) and and due to their version of ld not knowing that
|
the fact that i486-cleanup.pl essentially consumes all of syn68k.s.
|
||||||
-2147483648 is a valid 32-bit relative offset (the error message is
|
|
||||||
ld: rel32 out of range in _code_start_24 in _code_start_24). That's a
|
|
||||||
little harder to fix.
|
|
||||||
|
|
||||||
To test syn68k, run test/syngentest and compare the output to
|
To test syn68k, run test/syngentest and compare the output to
|
||||||
test/output/10000. It should be the same. If you want to be
|
test/output/10000. It should be the same. If you want to be
|
||||||
|
7
TODO
7
TODO
@ -1,6 +1,9 @@
|
|||||||
$Id: TODO 77 2005-01-04 23:51:13Z ctm $
|
Mac OS X fixes:
|
||||||
|
|
||||||
Make it so that we can install libsyn68k.a and the .h files
|
Don't link with -z execstack if that's going to fail
|
||||||
|
|
||||||
|
figure out why i486-cleanup.pl basically eats all
|
||||||
|
of syn68k.s
|
||||||
|
|
||||||
Make so we can build the various debug versions, non-native, etc.
|
Make so we can build the various debug versions, non-native, etc.
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ AC_INIT(syn68k, 1.0, ctm@ardi.com)
|
|||||||
AM_INIT_AUTOMAKE
|
AM_INIT_AUTOMAKE
|
||||||
|
|
||||||
AC_CONFIG_SRCDIR([syngen/main.c])
|
AC_CONFIG_SRCDIR([syngen/main.c])
|
||||||
AC_CONFIG_HEADER([config.h])
|
AC_CONFIG_HEADERS([include/config.h])
|
||||||
|
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
@ -114,6 +114,11 @@ AC_C_INLINE
|
|||||||
AC_TYPE_SIZE_T
|
AC_TYPE_SIZE_T
|
||||||
AC_C_VOLATILE
|
AC_C_VOLATILE
|
||||||
|
|
||||||
|
AC_LTDL_SYMBOL_USCORE
|
||||||
|
if test x"$ac_cv_sys_symbol_underscore" = xyes ; then
|
||||||
|
AC_DEFINE(HAVE_SYMBOL_UNDERSCORE, 1, [Define if C symbols have leading underscores])
|
||||||
|
fi
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_FUNC_ALLOCA
|
AC_FUNC_ALLOCA
|
||||||
AC_FUNC_ERROR_AT_LINE
|
AC_FUNC_ERROR_AT_LINE
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: process.c 82 2005-05-11 23:41:32Z ctm $ */
|
#include "config.h"
|
||||||
|
|
||||||
#include "template.h"
|
#include "template.h"
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
@ -291,11 +291,24 @@ typedef struct
|
|||||||
long value[MAX_VALUE_SET_ENTRIES];
|
long value[MAX_VALUE_SET_ENTRIES];
|
||||||
} value_set_t;
|
} value_set_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The addition of BROKEN_SIZE_32 (see template.h) and
|
||||||
|
* immediate_values[3] is a hacky workaround for Mac OS X's ld which
|
||||||
|
* doesn't recognize 0x80000000 (-2147483648) as a legitimate 32-bit
|
||||||
|
* relocatable offset. This prevents calls and jumps from being
|
||||||
|
* properly analyzed.
|
||||||
|
*
|
||||||
|
* For now we sacrifice the analysis of that bit pattern in the few
|
||||||
|
* template entries that would normally have it. We currently do this
|
||||||
|
* unconditionally because nobody has yet written a configure macro to
|
||||||
|
* detect this problem and then only use "BROKEN_SIZE_32" when we have
|
||||||
|
* a broken ld.
|
||||||
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
create_asmdata (const template_t *t, int num_operands)
|
create_asmdata (const template_t *t, int num_operands)
|
||||||
{
|
{
|
||||||
static const value_set_t immediate_values[3] =
|
static const value_set_t immediate_values[] =
|
||||||
{ { 12, { 0, 1, 2, -1, -2, 127, -128, -127, 0x37, -100, 0x12, -97 } },
|
{ { 12, { 0, 1, 2, -1, -2, 127, -128, -127, 0x37, -100, 0x12, -97 } },
|
||||||
{ 23, { 0, 1, 2, 0xFF, 0xFE, 127, -129, -128, -127, 128, 0x37,
|
{ 23, { 0, 1, 2, 0xFF, 0xFE, 127, -129, -128, -127, 128, 0x37,
|
||||||
-100, 0x12, -97, 32767, -32768, -32767, -1, -2, 0x871,
|
-100, 0x12, -97, 32767, -32768, -32767, -1, -2, 0x871,
|
||||||
@ -305,6 +318,12 @@ create_asmdata (const template_t *t, int num_operands)
|
|||||||
32767, -32768, -32767, -1, 0xFFFE, 0x871, 0xFA03,
|
32767, -32768, -32767, -1, 0xFFFE, 0x871, 0xFA03,
|
||||||
0x1234, 0x8765, 0x7FFFFFFF, 0x80000000, 0x80000001,
|
0x1234, 0x8765, 0x7FFFFFFF, 0x80000000, 0x80000001,
|
||||||
0xFFFFFFFF, 0xFFFFFFFE, 0x871529, 0x392332, 0xFA034433,
|
0xFFFFFFFF, 0xFFFFFFFE, 0x871529, 0x392332, 0xFA034433,
|
||||||
|
0x12345678, 0x87654321 } },
|
||||||
|
{ 32, { 0, 1, 2, 0xFF, 0xFE, 128, -129, 127, -128, -127, 0x37, -100,
|
||||||
|
0x12, -97,
|
||||||
|
32767, -32768, -32767, -1, 0xFFFE, 0x871, 0xFA03,
|
||||||
|
0x1234, 0x8765, 0x7FFFFFFF, 0x80000001,
|
||||||
|
0xFFFFFFFF, 0xFFFFFFFE, 0x871529, 0x392332, 0xFA034433,
|
||||||
0x12345678, 0x87654321 } }
|
0x12345678, 0x87654321 } }
|
||||||
};
|
};
|
||||||
#if 0
|
#if 0
|
||||||
@ -377,6 +396,11 @@ create_asmdata (const template_t *t, int num_operands)
|
|||||||
{
|
{
|
||||||
char code[2][1024];
|
char code[2][1024];
|
||||||
int new_code = 0;
|
int new_code = 0;
|
||||||
|
#if defined(HAVE_SYMBOL_UNDERSCORE)
|
||||||
|
const char *symbol_prefix = "_";
|
||||||
|
#else
|
||||||
|
const char *symbol_prefix = "";
|
||||||
|
#endif
|
||||||
|
|
||||||
strcpy (&code[new_code][0], t->code);
|
strcpy (&code[new_code][0], t->code);
|
||||||
for (op = 0; op < num_operands; op++)
|
for (op = 0; op < num_operands; op++)
|
||||||
@ -394,10 +418,10 @@ create_asmdata (const template_t *t, int num_operands)
|
|||||||
|
|
||||||
fprintf (fp,
|
fprintf (fp,
|
||||||
" asm volatile (\"\\n\"\n"
|
" asm volatile (\"\\n\"\n"
|
||||||
" \"code_start_%d:\\n\\t\"\n"
|
" \"%scode_start_%d:\\n\\t\"\n"
|
||||||
" \"%s\\n\"\n"
|
" \"%s\\n\"\n"
|
||||||
" \"code_end_%d:\");\n",
|
" \"%scode_end_%d:\");\n",
|
||||||
current, code[new_code], current);
|
symbol_prefix, current, code[new_code], symbol_prefix, current);
|
||||||
|
|
||||||
/* Try the next combination of operands. */
|
/* Try the next combination of operands. */
|
||||||
for (op = num_operands - 1; op >= 0; op--)
|
for (op = num_operands - 1; op >= 0; op--)
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "template.h"
|
#include "template.h"
|
||||||
|
|
||||||
/* $Id: template.c 61 2004-12-21 23:44:50Z ctm $ */
|
/* $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[] =
|
const template_t template[] =
|
||||||
{
|
{
|
||||||
#define BINARY_OP(op, dstio, memout) \
|
#define BINARY_OP(op, dstio, memout) \
|
||||||
@ -624,9 +633,9 @@ const template_t template[] =
|
|||||||
{ { SIZE_32, REGISTER, INOUT } } },
|
{ { SIZE_32, REGISTER, INOUT } } },
|
||||||
|
|
||||||
{ "i386_call_abs", "", "", "", "volatile", "v",
|
{ "i386_call_abs", "", "", "", "volatile", "v",
|
||||||
"call %P0",
|
"call " SYMBOL_PREFIX "%P0",
|
||||||
{ "addr" },
|
{ "addr" },
|
||||||
{ { SIZE_32, CONSTANT, IN } } },
|
{ { BROKEN_SIZE_32, CONSTANT, IN } } },
|
||||||
|
|
||||||
{ "i386_cbtw", "", "", "(reg8 AL)", "(reg16 AX)", "-",
|
{ "i386_cbtw", "", "", "(reg8 AL)", "(reg16 AX)", "-",
|
||||||
"cbtw",
|
"cbtw",
|
||||||
@ -707,9 +716,9 @@ const template_t template[] =
|
|||||||
|
|
||||||
#define CONDL_BRANCH(op, flags) \
|
#define CONDL_BRANCH(op, flags) \
|
||||||
{ "i386_" op, flags, "", "", "volatile", "v", \
|
{ "i386_" op, flags, "", "", "volatile", "v", \
|
||||||
op " %P0", \
|
op " " SYMBOL_PREFIX "%P0", \
|
||||||
{ "target" }, \
|
{ "target" }, \
|
||||||
{ { SIZE_32, CONSTANT, IN } } }
|
{ { BROKEN_SIZE_32, CONSTANT, IN } } }
|
||||||
|
|
||||||
CONDL_BRANCH ("jc", "c"),
|
CONDL_BRANCH ("jc", "c"),
|
||||||
CONDL_BRANCH ("jbe", "cz"),
|
CONDL_BRANCH ("jbe", "cz"),
|
||||||
@ -727,9 +736,9 @@ const template_t template[] =
|
|||||||
CONDL_BRANCH ("js", "s"),
|
CONDL_BRANCH ("js", "s"),
|
||||||
|
|
||||||
{ "i386_jmp", "", "", "", "volatile", "v",
|
{ "i386_jmp", "", "", "", "volatile", "v",
|
||||||
"jmp %P0",
|
"jmp " SYMBOL_PREFIX "%P0",
|
||||||
{ "target" },
|
{ "target" },
|
||||||
{ { SIZE_32, CONSTANT, IN } } },
|
{ { BROKEN_SIZE_32, CONSTANT, IN } } },
|
||||||
{ "i386_jmp_reg", "", "", "", "volatile", "-",
|
{ "i386_jmp_reg", "", "", "", "volatile", "-",
|
||||||
"jmp *%0",
|
"jmp *%0",
|
||||||
{ "target" },
|
{ "target" },
|
||||||
|
@ -16,7 +16,12 @@ typedef enum
|
|||||||
IN, OUT, INOUT
|
IN, OUT, INOUT
|
||||||
} io_t;
|
} io_t;
|
||||||
|
|
||||||
typedef enum { SIZE_8, SIZE_16, SIZE_32 } byte_size_t;
|
/* BROKEN_SIZE_32 is a variant of SIZE_32 that is only used with addresses
|
||||||
|
that cause trouble on Mac OS X's ld. The problem ld doesn't recognize
|
||||||
|
0x80000000 (-2147483648) as a legitimate 32-bit relative offset. See
|
||||||
|
the extended comment in process.c for more info */
|
||||||
|
|
||||||
|
typedef enum { SIZE_8, SIZE_16, SIZE_32, BROKEN_SIZE_32 } byte_size_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user