diff -u -r ../emacs-22.3.org/configure ./configure
--- ../emacs-22.3.org/configure	2008-09-06 01:21:51.000000000 +0900
+++ ./configure	2009-09-27 09:49:25.000000000 +0900
@@ -15486,7 +15486,7 @@
 __fpending mblen mbrlen mbsinit strsignal setitimer ualarm index rindex \
 sendto recvfrom getsockopt setsockopt getsockname getpeername \
 gai_strerror mkstemp getline getdelim mremap memmove fsync sync bzero \
-memset memcmp difftime memcpy mempcpy mblen mbrlen posix_memalign
+memset memcmp difftime memcpy mempcpy mblen mbrlen
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for $ac_func" >&5
diff -u -r ../emacs-22.3.org/configure.in ./configure.in
--- ../emacs-22.3.org/configure.in	2008-08-13 03:35:40.000000000 +0900
+++ ./configure.in	2009-09-27 09:49:32.000000000 +0900
@@ -2628,7 +2628,7 @@
 __fpending mblen mbrlen mbsinit strsignal setitimer ualarm index rindex \
 sendto recvfrom getsockopt setsockopt getsockname getpeername \
 gai_strerror mkstemp getline getdelim mremap memmove fsync sync bzero \
-memset memcmp difftime memcpy mempcpy mblen mbrlen posix_memalign)
+memset memcmp difftime memcpy mempcpy mblen mbrlen)
 
 AC_CHECK_HEADERS(sys/un.h)
 
diff -u -r ../emacs-22.3.org/src/s/darwin.h ./src/s/darwin.h
--- ../emacs-22.3.org/src/s/darwin.h	2008-07-24 01:40:47.000000000 +0900
+++ ./src/s/darwin.h	2009-09-27 09:50:14.000000000 +0900
@@ -260,7 +260,8 @@
 /* Definitions for how to compile & link.  */
 
 /* Indicate that we are compiling for Mac OS X.  */
-#define C_SWITCH_SYSTEM -fpascal-strings -DMAC_OSX
+/* #define C_SWITCH_SYSTEM -fpascal-strings -DMAC_OSX */
+#define C_SWITCH_SYSTEM -DMAC_OSX
 
 #ifdef HAVE_CARBON
 
diff -u -r ../emacs-22.3.org/src/unexmacosx.c ./src/unexmacosx.c
--- ../emacs-22.3.org/src/unexmacosx.c	2008-01-08 13:29:48.000000000 +0900
+++ ./src/unexmacosx.c	2009-09-27 09:53:56.000000000 +0900
@@ -584,6 +584,14 @@
       printf ("LC_UUID          ");
       break;
 #endif
+#ifdef LC_DYLD_INFO
+    case LC_DYLD_INFO:
+      printf ("LC_DYLD_INFO     ");
+      break;
+    case LC_DYLD_INFO_ONLY:
+      printf ("LC_DYLD_INFO_ONLY");
+      break;
+#endif
     default:
       printf ("unknown          ");
     }
@@ -821,6 +829,7 @@
 	       || strncmp (sectp->sectname, "__const", 16) == 0
 	       || strncmp (sectp->sectname, "__cfstring", 16) == 0
 	       || strncmp (sectp->sectname, "__gcc_except_tab", 16) == 0
+	       || strncmp (sectp->sectname, "__program_vars", 16) == 0
 	       || strncmp (sectp->sectname, "__objc_", 7) == 0)
 	{
 	  if (!unexec_copy (sectp->offset, old_file_offset, sectp->size))
@@ -1088,6 +1097,36 @@
   curr_header_offset += lc->cmdsize;
 }
 
+#ifdef LC_DYLD_INFO
+/* Copy a LC_DYLD_INFO(_ONLY) load command from the input file to the output
+   file, adjusting the file offset fields.  */
+static void
+copy_dyld_info (struct load_command *lc, long delta)
+{
+  struct dyld_info_command *dip = (struct dyld_info_command *) lc;
+
+  if (dip->rebase_off > 0)
+    dip->rebase_off += delta;
+  if (dip->bind_off > 0)
+    dip->bind_off += delta;
+  if (dip->weak_bind_off > 0)
+    dip->weak_bind_off += delta;
+  if (dip->lazy_bind_off > 0)
+    dip->lazy_bind_off += delta;
+  if (dip->export_off > 0)
+    dip->export_off += delta;
+
+  printf ("Writing ");
+  print_load_command_name (lc->cmd);
+  printf (" command\n");
+
+  if (!unexec_write (curr_header_offset, lc, lc->cmdsize))
+    unexec_error ("cannot write dyld info command to header");
+
+  curr_header_offset += lc->cmdsize;
+}
+#endif
+
 /* Copy other kinds of load commands from the input file to the output
    file, ones that do not require adjustments of file offsets.  */
 static void
@@ -1154,6 +1193,12 @@
       case LC_TWOLEVEL_HINTS:
 	copy_twolevelhints (lca[i], linkedit_delta);
 	break;
+#ifdef LC_DYLD_INFO
+      case LC_DYLD_INFO:
+      case LC_DYLD_INFO_ONLY:
+	copy_dyld_info (lca[i], linkedit_delta);
+	break;
+#endif
       default:
 	copy_other (lca[i]);
 	break;
@@ -1320,6 +1365,8 @@
 void
 unexec_free (void *ptr)
 {
+  if (ptr == NULL)
+    return;
   if (in_dumped_exec)
     {
       if (!ptr_in_unexec_regions (ptr))

