[PATCH] vm_x86.dasc: support building on OS X 10.4 and 10.5 intel

  • From: "Kyle J. McKay" <mackyle@xxxxxxxxx>
  • To: Mike Pall <web-07@xxxxxxxxxx>
  • Date: Sat, 18 Jan 2014 05:21:42 -0800

The .uleb128 pseudo op is not supported by the older assemblers
included with OS X 10.4 and 10.5.  Since the values being
encoded are in the range 0x00-0x7F, simply replace the .uleb128
pseudo op with .byte instead since that's what .uleb128 would
generate for values in that range.

The -fno-stack-protector option is not recognized by the older
compiler included with OS X 10.4.  Only add the option when
running on OS X 10.5 or later.

Signed-off-by: Kyle J. McKay <mackyle@xxxxxxxxx>
---

Patch is against master (ef59e548).

With this patch I can successfully build and run on 32-bit 10.4 intel
and 32-bit and 64-bit 10.5 intel.

 src/Makefile    | 4 +++-
 src/vm_x86.dasc | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index 6b4c9f93..ed6daa1b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -294,7 +294,9 @@ ifeq (Darwin,$(TARGET_SYS))
   endif
   TARGET_STRIP+= -x
   TARGET_AR+= 2>/dev/null
-  TARGET_XCFLAGS+= -fno-stack-protector
+  ifneq (,$(shell if test `sysctl -n kern.osrelease | cut -d. -f1` -ge 9; then 
echo 1; fi))
+    TARGET_XCFLAGS+= -fno-stack-protector
+  endif
   TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
   TARGET_DYNXLDOPTS=
   TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version 
$(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc
index a36d2aa7..8a9b536d 100644
--- a/src/vm_x86.dasc
+++ b/src/vm_x86.dasc
@@ -6344,12 +6344,12 @@ static void emit_asm_debug(BuildCtx *ctx)
 #if LJ_64
          "\t.byte 0xe\n\t.byte 16\n"           /* def_cfa_offset */
          "\t.byte 0x86\n\t.byte 0x2\n"         /* offset rbp */
-         "\t.byte 0xd\n\t.uleb128 0x6\n"       /* def_cfa_register rbp */
+         "\t.byte 0xd\n\t.byte 0x6\n"          /* def_cfa_register rbp */
          "\t.byte 0x83\n\t.byte 0x3\n"         /* offset rbx */
 #else
          "\t.byte 0xe\n\t.byte 8\n"            /* def_cfa_offset */
          "\t.byte 0x84\n\t.byte 0x2\n"         /* offset ebp (4 for MACH-O)*/
-         "\t.byte 0xd\n\t.uleb128 0x4\n"       /* def_cfa_register ebp */
+         "\t.byte 0xd\n\t.byte 0x4\n"          /* def_cfa_register ebp */
          "\t.byte 0x83\n\t.byte 0x3\n"         /* offset ebx */
 #endif
          "\t.align " BSZPTR "\n"
-- 
1.8.5


Other related posts:

  • » [PATCH] vm_x86.dasc: support building on OS X 10.4 and 10.5 intel - Kyle J. McKay