/* Dump Emacs in Mach-O format for use on Mac OS X.
Copyright (C) 2001, 2002, 2003, 2004, 2005,
- 2006, 2007, 2008 Free Software Foundation, Inc.
+ 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GNU Emacs.
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Contributed by Andrew Choi (akochoi@mac.com). */
char buf[UNEXEC_COPY_BUFSZ];
ssize_t bytes;
- bzero (buf, UNEXEC_COPY_BUFSZ);
+ memset (buf, 0, UNEXEC_COPY_BUFSZ);
if (lseek (outfd, dest, SEEK_SET) != dest)
return 0;
case LC_UUID:
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 ");
|| 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))
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
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;
void
unexec_free (void *ptr)
{
+ if (ptr == NULL)
+ return;
if (in_dumped_exec)
{
if (!ptr_in_unexec_regions (ptr))