/* Dump Emacs in Mach-O format for use on Mac OS X.
- Copyright (C) 2001-2012 Free Software Foundation, Inc.
+ Copyright (C) 2001-2014 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#undef free
#include "unexec.h"
+#include "lisp.h"
#include <stdio.h>
#include <fcntl.h>
#include <assert.h>
+/* LC_DATA_IN_CODE is not defined in mach-o/loader.h on OS X 10.7.
+ But it is used if we build with "Command Line Tools for Xcode 4.5
+ (OS X Lion) - September 2012". */
+#ifndef LC_DATA_IN_CODE
+#define LC_DATA_IN_CODE 0x29 /* table of non-instructions in __text */
+#endif
+
#ifdef _LP64
#define mach_header mach_header_64
#define segment_command segment_command_64
printf ("LC_MAIN ");
break;
#endif
+#ifdef LC_DATA_IN_CODE
+ case LC_DATA_IN_CODE:
+ printf ("LC_DATA_IN_CODE ");
+ break;
+#endif
#ifdef LC_SOURCE_VERSION
case LC_SOURCE_VERSION:
printf ("LC_SOURCE_VERSION");
#endif
#ifdef LC_FUNCTION_STARTS
-/* Copy a LC_FUNCTION_STARTS/LC_DYLIB_CODE_SIGN_DRS load command from
- the input file to the output file, adjusting the data offset
- field. */
+/* Copy a LC_FUNCTION_STARTS/LC_DATA_IN_CODE/LC_DYLIB_CODE_SIGN_DRS
+ load command from the input file to the output file, adjusting the
+ data offset field. */
static void
copy_linkedit_data (struct load_command *lc, long delta)
{
#endif
#ifdef LC_FUNCTION_STARTS
case LC_FUNCTION_STARTS:
+#ifdef LC_DATA_IN_CODE
+ case LC_DATA_IN_CODE:
+#endif
#ifdef LC_DYLIB_CODE_SIGN_DRS
case LC_DYLIB_CODE_SIGN_DRS:
#endif
unexec_error ("Unexec from a dumped executable is not supported.");
pagesize = getpagesize ();
- infd = open (infile, O_RDONLY, 0);
+ infd = emacs_open (infile, O_RDONLY, 0);
if (infd < 0)
{
unexec_error ("cannot open input file `%s'", infile);
}
- outfd = open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755);
+ outfd = emacs_open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755);
if (outfd < 0)
{
- close (infd);
+ emacs_close (infd);
unexec_error ("cannot open output file `%s'", outfile);
}
dump_it ();
- close (outfd);
+ emacs_close (outfd);
}