diff -urN emacs-23.1-old/lib-src/ChangeLog emacs-23.1/lib-src/ChangeLog
--- emacs-23.1-old/lib-src/ChangeLog	2009-09-17 17:59:45.000000000 -0400
+++ emacs-23.1/lib-src/ChangeLog	2009-09-17 18:02:47.000000000 -0400
@@ -1,3 +1,7 @@
+2009-09-09  Erik Charlebois  <erikcharlebois@gmail.com>
+
+	* movemail.c (error): Change fprintf to fputs to fix warning.
+ 
 2009-07-29  Chong Yidong  <cyd@stupidchicken.com>
 
 	* Version 23.1 released.
diff -urN emacs-23.1-old/lib-src/movemail.c emacs-23.1/lib-src/movemail.c
--- emacs-23.1-old/lib-src/movemail.c	2009-09-17 17:59:45.000000000 -0400
+++ emacs-23.1/lib-src/movemail.c	2009-09-17 18:00:00.000000000 -0400
@@ -622,7 +622,7 @@
   else if (s2)
     fprintf (stderr, s1, s2);
   else
-    fprintf (stderr, s1);
+    fputs (s1, stderr);
   fprintf (stderr, "\n");
 }
 
diff -urN emacs-23.1-old/src/ChangeLog emacs-23.1/src/ChangeLog
--- emacs-23.1-old/src/ChangeLog	2009-09-17 17:59:50.000000000 -0400
+++ emacs-23.1/src/ChangeLog	2009-09-17 18:03:14.000000000 -0400
@@ -1,3 +1,53 @@
+2009-09-09  Erik Charlebois  <erikcharlebois@gmail.com>
+
+	* emacs.c (main): Remove extra format specifier to fix warning.
+
+	* font.c (font_unparse_xlfd): Print EMACS_INT with %ld.
+	(font_unparse_fcname): Print EMACS_INT with %ld.
+
+	* menu.c (find_and_return_menu_selection): Fix truncation warning.
+
+	* nsfns.m (x-close-connection): Remove PSFlush call. Does not do anything
+	on Cocoa. Does not exist in 64-bit Cocoa.
+	(xw-color-values): Use CGFloat instead of float.
+
+	* nsfont.m (ns_char_width): Use sizeWithAttributes: instead of
+	widthOfString:, which does no exist in 64-bit Cocoa.
+	(ns_findfonts): Print EMACS_INT with %ld.
+	(nsfont_list_family): Print EMACS_INT with %ld.
+	(nsfont_open): Use Core Text for OS X 10.5 and later.
+	(nsfont_close): Release Core Text resource.
+	(ns_uni_to_glyphs): Use NSUInteger when calling Cocoa APIs.
+	(layoutOptions): Use NSUInteger in method signature.
+	(insertGlyphs): Use NSUIntger in method signature.
+	(setIntAttribute): Use NSInteger and NSUInteger in method signature.
+
+	* nsgui.h: Add typedefs for NSUInteger, NSInteger and CGFloat for
+	pre-10.5 OS X and GNUstep.
+
+	* nsimage.m (setXBMColor): Use CGFloat for calls to Cocoa.
+	(getPixelAtX): Use CGFloat for calls to Cocoa.
+
+	* nsmenu.m (addItemWithWidgetValue): Use NSInteger for call to Cocoa.
+	(fillWithWidgetValue): sizeToFit is deprecated (does nothing). Remove
+	call for OS X 10.5 and later.
+	(initWithContentRect): Use NSUInteger in method signature.
+
+	* nsterm.h: Use Core Text on OS X 10.5 and later.
+
+	* nsterm.m (mouseDown): Remove redundant leading 0s in format specifier.
+	(ns_query_color): Use CGFloat for calls to Cocoa.
+	(characterIndexForPoint): Use NUSInteger in method signature.
+	(draggingEntered): Use NSDragOperation in method signature.
+	(scrollerWidth): Use CGFloat in method signature.
+	(setPosition): Use setDoubleValue: and setKnobProportion: on 10.5 and
+	later since setFloatVAlue:knobProportion: is deprecated.
+	(mouseDown): Use %ld to print NSScrollerPart.
+
+	* process.c (list_processes_1): Use %ld to print EMACS_INT.
+
+	* unexmacosx.c (read_load_commands): Use %ld to print vm_address_t.
+
 2009-07-29  Chong Yidong  <cyd@stupidchicken.com>
 
 	* Version 23.1 released.
diff -urN emacs-23.1-old/src/emacs.c emacs-23.1/src/emacs.c
--- emacs-23.1-old/src/emacs.c	2009-09-17 17:59:50.000000000 -0400
+++ emacs-23.1/src/emacs.c	2009-09-17 18:00:00.000000000 -0400
@@ -1182,7 +1182,7 @@
             argv[skip_args] = fdStr;
 
             execv (argv[0], argv);
-            fprintf (stderr, "emacs daemon: exec failed: %d\t%d\n", errno);
+            fprintf (stderr, "emacs daemon: exec failed: %d\n", errno);
             exit (1);
           }
 
diff -urN emacs-23.1-old/src/font.c emacs-23.1/src/font.c
--- emacs-23.1-old/src/font.c	2009-09-17 17:59:50.000000000 -0400
+++ emacs-23.1/src/font.c	2009-09-17 18:00:00.000000000 -0400
@@ -1357,7 +1357,7 @@
     {
       f[XLFD_AVGWIDTH_INDEX] = alloca (11);
       len += sprintf (f[XLFD_AVGWIDTH_INDEX],
-		      "%d", XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1;
+		      "%ld", (long) XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1;
     }
   else
     f[XLFD_AVGWIDTH_INDEX] = "*", len += 2;
@@ -1673,7 +1673,7 @@
     }
 
   if (INTEGERP (AREF (font, FONT_DPI_INDEX)))
-    len += sprintf (work, ":dpi=%d", XINT (AREF (font, FONT_DPI_INDEX)));
+    len += sprintf (work, ":dpi=%ld", (long) XINT (AREF (font, FONT_DPI_INDEX)));
   if (INTEGERP (AREF (font, FONT_SPACING_INDEX)))
     len += strlen (":spacing=100");
   if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX)))
@@ -1686,7 +1686,7 @@
       if (STRINGP (val))
 	len += SBYTES (val);
       else if (INTEGERP (val))
-	len += sprintf (work, "%d", XINT (val));
+	len += sprintf (work, "%ld", (long) XINT (val));
       else if (SYMBOLP (val))
 	len += (NILP (val) ? 5 : 4); /* for "false" or "true" */
     }
@@ -1713,9 +1713,10 @@
       p += sprintf (p, ":%s=%s", style_names[i],
 		    SDATA (SYMBOL_NAME (styles[i])));
   if (INTEGERP (AREF (font, FONT_DPI_INDEX)))
-    p += sprintf (p, ":dpi=%d", XINT (AREF (font, FONT_DPI_INDEX)));
+    p += sprintf (p, ":dpi=%ld", (long) XINT (AREF (font, FONT_DPI_INDEX)));
   if (INTEGERP (AREF (font, FONT_SPACING_INDEX)))
-    p += sprintf (p, ":spacing=%d", XINT (AREF (font, FONT_SPACING_INDEX)));
+    p += sprintf (p, ":spacing=%ld",
+            (long) XINT (AREF (font, FONT_SPACING_INDEX)));
   if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX)))
     {
       if (XINT (AREF (font, FONT_AVGWIDTH_INDEX)) == 0)
diff -urN emacs-23.1-old/src/menu.c emacs-23.1/src/menu.c
--- emacs-23.1-old/src/menu.c	2009-09-17 17:59:50.000000000 -0400
+++ emacs-23.1/src/menu.c	2009-09-17 18:00:00.000000000 -0400
@@ -1005,7 +1005,7 @@
         {
           entry
             = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE];
-          if ((int) (EMACS_INT)client_data ==  (int)(&XVECTOR (menu_items)->contents[i]))
+          if ((EMACS_INT)client_data == (EMACS_INT)(&XVECTOR (menu_items)->contents[i]))
             {
               if (keymaps != 0)
                 {
diff -urN emacs-23.1-old/src/nsfns.m emacs-23.1/src/nsfns.m
--- emacs-23.1-old/src/nsfns.m	2009-09-17 17:59:51.000000000 -0400
+++ emacs-23.1/src/nsfns.m	2009-09-17 18:02:09.000000000 -0400
@@ -1770,9 +1770,7 @@
      Lisp_Object display;
 {
   check_ns ();
-#ifdef NS_IMPL_COCOA
-  PSFlush ();
-#endif
+
   /*ns_delete_terminal (dpyinfo->terminal); */
   [NSApp terminate: NSApp];
   return Qnil;
@@ -2239,7 +2237,7 @@
      Lisp_Object color, frame;
 {
   NSColor * col;
-  float red, green, blue, alpha;
+  CGFloat red, green, blue, alpha;
   Lisp_Object rgba[4];
 
   check_ns ();
diff -urN emacs-23.1-old/src/nsfont.m emacs-23.1/src/nsfont.m
--- emacs-23.1-old/src/nsfont.m	2009-09-17 17:59:51.000000000 -0400
+++ emacs-23.1/src/nsfont.m	2009-09-17 18:00:00.000000000 -0400
@@ -238,7 +238,10 @@
 	    return w;
       }
 #endif
-    w = [sfont widthOfString: cstr];
+    NSDictionary *attrsDictionary =
+        [NSDictionary dictionaryWithObject: sfont
+                      forKey: NSFontAttributeName];
+    w = [cstr sizeWithAttributes: attrsDictionary].width;
     return max (w, 2.0);
 }
 
@@ -510,7 +513,8 @@
       return ns_fallback_entity ();
 
     if (NSFONT_TRACE)
-	fprintf (stderr, "    Returning %d entities.\n", XINT (Flength (list)));
+	fprintf (stderr, "    Returning %ld entities.\n",
+            (long) XINT (Flength (list)));
 
     return list;
 }
@@ -616,8 +620,8 @@
   /* FIXME: escape the name? */
 
   if (NSFONT_TRACE)
-    fprintf (stderr, "nsfont: list families returning %d entries\n",
-            XINT (Flength (list)));
+    fprintf (stderr, "nsfont: list families returning %ld entries\n",
+            (long) XINT (Flength (list)));
 
   return list;
 }
@@ -834,14 +838,27 @@
                 ((CFStringRef)@"Monaco", kATSOptionFlagsDefault);
             }
         }
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+      font_info->ctfont =
+          CTFontCreateWithPlatformFont (atsFont, 0.0f, NULL, NULL);
+      font_info->cgfont = CTFontCopyGraphicsFont (font_info->ctfont, NULL);
+#else
       font_info->cgfont = CGFontCreateWithPlatformFont ((void*)&atsFont);
+#endif
     }
 #endif
 
     /* set up metrics portion of font struct */
     font->ascent = [sfont ascender];
     font->descent = -[sfont descender];
-    font->min_width = [sfont widthOfString: @"|"]; /* FIXME */
+ 
+    /* FIXME */
+    NSDictionary *attrsDictionary =
+        [NSDictionary dictionaryWithObject: sfont
+                      forKey: NSFontAttributeName];
+    font->min_width = [@"|" sizeWithAttributes: attrsDictionary].width;
+
     font->space_width = lrint (ns_char_width (sfont, ' '));
     font->average_width = lrint (font_info->width);
     font->max_width = lrint (font_info->max_bounds.width);
@@ -881,6 +898,9 @@
   [font_info->nsfont release];
 #ifdef NS_IMPL_COCOA
   CGFontRelease (font_info->cgfont);
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+  CFRelease (font_info->ctfont);
+#endif
 #endif
   xfree (font_info->name);
   xfree (font_info);
@@ -1301,7 +1321,7 @@
     NSGlyphGenerator *glyphGenerator = [NSGlyphGenerator sharedGlyphGenerator];
     /*NSCharacterSet *coveredChars = [nsfont coveredCharacterSet]; */
     unsigned int numGlyphs = [font_info->nsfont numberOfGlyphs];
-    unsigned int gInd =0, cInd =0;
+    NSUInteger gInd =0, cInd =0;
 
     [glyphStorage setString: allChars font: font_info->nsfont];
     [glyphGenerator generateGlyphsForGlyphStorage: glyphStorage
@@ -1432,7 +1452,7 @@
 }
 
 /* NSGlyphStorage protocol */
-- (unsigned int)layoutOptions
+- (NSUInteger)layoutOptions
 {
   return 0;
 }
@@ -1442,9 +1462,9 @@
   return attrStr;
 }
 
-- (void)insertGlyphs: (const NSGlyph *)glyphs length: (unsigned int)length
-        forStartingGlyphAtIndex: (unsigned int)glyphIndex
-        characterIndex: (unsigned int)charIndex
+- (void)insertGlyphs: (const NSGlyph *)glyphs length: (NSUInteger)length
+        forStartingGlyphAtIndex: (NSUInteger)glyphIndex
+        characterIndex: (NSUInteger)charIndex
 {
   len = glyphIndex+length;
   for (i =glyphIndex; i<len; i++)
@@ -1453,8 +1473,8 @@
     maxGlyph = len;
 }
 
-- (void)setIntAttribute: (int)attributeTag value: (int)val
-        forGlyphAtIndex: (unsigned)glyphIndex
+- (void)setIntAttribute: (NSInteger)attributeTag value: (NSInteger)val
+        forGlyphAtIndex: (NSUInteger)glyphIndex
 {
   return;
 }
diff -urN emacs-23.1-old/src/nsgui.h emacs-23.1/src/nsgui.h
--- emacs-23.1-old/src/nsgui.h	2009-09-17 17:59:51.000000000 -0400
+++ emacs-23.1/src/nsgui.h	2009-09-17 18:00:00.000000000 -0400
@@ -128,13 +128,25 @@
       unsigned width, height;
 } XRectangle;
 
+#if !defined(__OBJC__) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
+#ifdef _LP64
+typedef unsigned long NSUInteger;
+typedef long NSInteger;
+typedef double CGFloat;
+#else
+typedef unsigned int NSUInteger;
+typedef int NSInteger;
+typedef float CGFloat;
+#endif
+#endif
+
 #ifndef __OBJC__
-typedef struct _NSPoint { float x, y; } NSPoint;
-typedef struct _NSSize  { float width, height; } NSSize;
+typedef struct _NSPoint { CGFloat x, y; } NSPoint;
+typedef struct _NSSize  { CGFloat width, height; } NSSize;
 typedef struct _NSRect  { NSPoint origin; NSSize size; } NSRect;
 #endif
 
-#define NativeRectangle struct _NSRect
+#define NativeRectangle NSRect
 
 #define CONVERT_TO_XRECT(xr, nr)		\
   ((xr).x     = (nr).origin.x,			\
diff -urN emacs-23.1-old/src/nsimage.m emacs-23.1/src/nsimage.m
--- emacs-23.1-old/src/nsimage.m	2009-09-17 17:59:51.000000000 -0400
+++ emacs-23.1/src/nsimage.m	2009-09-17 18:00:00.000000000 -0400
@@ -329,7 +329,7 @@
   NSSize s = [self size];
   int len = (int) s.width * s.height;
   unsigned char *planes[5];
-  float r, g, b, a;
+  CGFloat r, g, b, a;
   NSColor *rgbColor;
 
   if (bmRep == nil || color == nil)
@@ -431,7 +431,7 @@
   else if (onTiger)
     {
       NSColor *color = [bmRep colorAtX: x y: y];
-      float r, g, b, a;
+      CGFloat r, g, b, a;
       [color getRed: &r green: &g blue: &b alpha: &a];
       return ((int)(a * 255.0) << 24)
         | ((int)(r * 255.0) << 16) | ((int)(g * 255.0) << 8)
diff -urN emacs-23.1-old/src/nsmenu.m emacs-23.1/src/nsmenu.m
--- emacs-23.1-old/src/nsmenu.m	2009-09-17 17:59:51.000000000 -0400
+++ emacs-23.1/src/nsmenu.m	2009-09-17 18:00:00.000000000 -0400
@@ -656,7 +656,7 @@
       else
         [item setState: NSOffState];
 
-      [item setTag: (int)wv->call_data];
+      [item setTag: (NSInteger)wv->call_data];
     }
 
   return item;
@@ -708,7 +708,7 @@
 #ifdef NS_IMPL_GNUSTEP
   if ([[self window] isVisible])
     [self sizeToFit];
-#else
+#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
   if ([self supermenu] == nil)
     [self sizeToFit];
 #endif
@@ -1611,7 +1611,7 @@
 #define TEXTHEIGHT	20.0
 #define MINCELLWIDTH	90.0
 
-- initWithContentRect: (NSRect)contentRect styleMask: (unsigned int)aStyle
+- initWithContentRect: (NSRect)contentRect styleMask: (NSUInteger)aStyle
               backing: (NSBackingStoreType)backingType defer: (BOOL)flag
 {
   NSSize spacing = {SPACER, SPACER};
diff -urN emacs-23.1-old/src/nsterm.h emacs-23.1/src/nsterm.h
--- emacs-23.1-old/src/nsterm.h	2009-09-17 17:59:51.000000000 -0400
+++ emacs-23.1/src/nsterm.h	2009-09-17 18:00:00.000000000 -0400
@@ -420,9 +420,16 @@
 #else /* GNUstep or OS X < 10.3 */
   void *cgfont;
 #endif
+  /* ctFont is used only on OS X 10.5+ */
+#if defined (NS_IMPL_COCOA) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
+  CTFontRef ctfont;
+#else /* GNUstep or OS X < 10.5 */
+  void *ctfont;
+#endif
 #else /* ! OBJC */
   void *nsfont;
   void *cgfont;
+  void *ctfont;
 #endif
   char bold, ital;  /* convenience flags */
   char synthItal;
diff -urN emacs-23.1-old/src/nsterm.m emacs-23.1/src/nsterm.m
--- emacs-23.1-old/src/nsterm.m	2009-09-17 17:59:51.000000000 -0400
+++ emacs-23.1/src/nsterm.m	2009-09-17 18:00:00.000000000 -0400
@@ -1556,7 +1556,7 @@
      Convert a color to a lisp string with the RGB equivalent
    -------------------------------------------------------------------------- */
 {
-  float red, green, blue, alpha, gray;
+  CGFloat red, green, blue, alpha, gray;
   char buf[1024];
   const char *str;
   NSTRACE (ns_color_to_lisp);
@@ -1576,13 +1576,13 @@
     {
       [[col colorUsingColorSpaceName: NSCalibratedWhiteColorSpace]
             getWhite: &gray alpha: &alpha];
-      snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx",
+      snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
 		lrint (gray * 0xff), lrint (gray * 0xff), lrint (gray * 0xff));
       UNBLOCK_INPUT;
       return build_string (buf);
     }
 
-  snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx",
+  snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
             lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff));
 
   UNBLOCK_INPUT;
@@ -1598,7 +1598,7 @@
          and set color_def pixel to the resulting index.
    -------------------------------------------------------------------------- */
 {
-  float r, g, b, a;
+  CGFloat r, g, b, a;
 
   [((NSColor *)col) getRed: &r green: &g blue: &b alpha: &a];
   color_def->red   = r * 65535;
@@ -4816,7 +4816,7 @@
   return NSMakeRange (NSNotFound, 0);
 }
 
-- (unsigned int)characterIndexForPoint: (NSPoint)thePoint
+- (NSUInteger)characterIndexForPoint: (NSPoint)thePoint
 {
   if (NS_KEYLOG)
     NSLog (@"characterIndexForPoint request");
@@ -5493,7 +5493,7 @@
 /* NSDraggingDestination protocol methods.  Actually this is not really a
    protocol, but a category of Object.  O well...  */
 
--(unsigned int) draggingEntered: (id <NSDraggingInfo>) sender
+-(NSDragOperation) draggingEntered: (id <NSDraggingInfo>) sender
 {
   NSTRACE (draggingEntered);
   return NSDragOperationGeneric;
@@ -5778,7 +5778,7 @@
 #define SCROLL_BAR_FIRST_DELAY 0.5
 #define SCROLL_BAR_CONTINUOUS_DELAY (1.0 / 15)
 
-+ (float) scrollerWidth
++ (CGFloat) scrollerWidth
 {
   /* TODO: if we want to allow variable widths, this is the place to do it,
            however neither GNUstep nor Cocoa support it very well */
@@ -5909,14 +5909,26 @@
   em_whole = whole;
 
   if (portion >= whole)
-    [self setFloatValue: 0.0 knobProportion: 1.0];
+    {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+      [self setDoubleValue: 0.0];
+      [self setKnobProportion: 1.0];
+#else
+      [self setFloatValue: 0.0 knobProportion: 1.0];
+#endif
+    }
   else
     {
       float pos, por;
       portion = max ((float)whole*min_portion/pixel_height, portion);
       pos = (float)position / (whole - portion);
       por = (float)portion/whole;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+      [self setDoubleValue: pos];
+      [self setKnobProportion: por];
+#else
       [self setFloatValue: pos knobProportion: por];
+#endif
     }
 #ifdef NS_IMPL_GNUSTEP
   [self display];
@@ -6021,7 +6033,8 @@
     case NSScrollerKnobSlot:  /* GNUstep-only */
       last_hit_part = scroll_bar_move_ratio; break;
     default:  /* NSScrollerNoPart? */
-      fprintf (stderr, "EmacsScoller-mouseDown: unexpected part %d\n", part);
+      fprintf (stderr, "EmacsScoller-mouseDown: unexpected part %ld\n",
+             (long) part);
       return;
     }
 
diff -urN emacs-23.1-old/src/process.c emacs-23.1/src/process.c
--- emacs-23.1-old/src/process.c	2009-09-17 17:59:51.000000000 -0400
+++ emacs-23.1/src/process.c	2009-09-17 18:00:00.000000000 -0400
@@ -1519,7 +1519,7 @@
 	    insert_string ("?");
 	  if (INTEGERP (speed))
 	    {
-	      sprintf (tembuf, " at %d b/s", XINT (speed));
+	      sprintf (tembuf, " at %ld b/s", (long) XINT (speed));
 	      insert_string (tembuf);
 	    }
 	  insert_string (")\n");
diff -urN emacs-23.1-old/src/s/darwin.h emacs-23.1/src/s/darwin.h
--- emacs-23.1-old/src/s/darwin.h	2009-09-17 17:59:51.000000000 -0400
+++ emacs-23.1/src/s/darwin.h	2009-09-18 12:12:22.000000000 -0400
@@ -171,6 +171,9 @@
 #define malloc unexec_malloc
 #define realloc unexec_realloc
 #define free unexec_free
+/* Don't use posix_memalign because it is not compatible with
+   unexmacosx.c.  */
+#undef HAVE_POSIX_MEMALIGN
 #endif
 
 /* The ncurses library has been moved out of the System framework in
diff -urN emacs-23.1-old/src/unexmacosx.c emacs-23.1/src/unexmacosx.c
--- emacs-23.1-old/src/unexmacosx.c	2009-09-17 17:59:51.000000000 -0400
+++ emacs-23.1/src/unexmacosx.c	2009-09-18 12:12:22.000000000 -0400
@@ -582,6 +582,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          ");
     }
@@ -676,8 +684,8 @@
 	}
     }
 
-  printf ("Highest address of load commands in input file: %#8x\n",
-	  infile_lc_highest_addr);
+  printf ("Highest address of load commands in input file: %#8lx\n",
+	  (long) infile_lc_highest_addr);
 
   printf ("Lowest offset of all sections in __TEXT segment: %#8lx\n",
 	  text_seg_lowest_offset);
@@ -819,6 +827,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))
@@ -1086,6 +1095,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
@@ -1152,6 +1191,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;

