X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/266a86bd7fedf743225c2497956b73ecb2245196..7812ba2dea75097980bb6371381385b417479c74:/src/unexcoff.c diff --git a/src/unexcoff.c b/src/unexcoff.c index cb4b8d603b..ef86a40023 100644 --- a/src/unexcoff.c +++ b/src/unexcoff.c @@ -1,5 +1,4 @@ -/* Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 2001, 2002, 2003, - 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +/* Copyright (C) 1985-1988, 1992-1994, 2001-2011 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -34,37 +33,13 @@ along with GNU Emacs. If not, see . */ * Modified heavily since then. * * Synopsis: - * unexec (new_name, a_name, data_start, bss_start, entry_address) - * char *new_name, *a_name; - * unsigned data_start, bss_start, entry_address; + * unexec (const char *new_name, const char *old_name); * * Takes a snapshot of the program and makes an a.out format file in the * file named by the string argument new_name. * If a_name is non-NULL, the symbol table will be taken from the given file. * On some machines, an existing a_name file is required. * - * The boundaries within the a.out file may be adjusted with the data_start - * and bss_start arguments. Either or both may be given as 0 for defaults. - * - * Data_start gives the boundary between the text segment and the data - * segment of the program. The text segment can contain shared, read-only - * program code and literal data, while the data segment is always unshared - * and unprotected. Data_start gives the lowest unprotected address. - * The value you specify may be rounded down to a suitable boundary - * as required by the machine you are using. - * - * Specifying zero for data_start means the boundary between text and data - * should not be the same as when the program was loaded. - * - * Bss_start indicates how much of the data segment is to be saved in the - * a.out file and restored when the program is executed. It gives the lowest - * unsaved address, and is rounded up to a page boundary. The default when 0 - * is given assumes that the entire data segment is to be stored, including - * the previous data and bss as well as any additional storage allocated with - * break (2). - * - * The new file is set up to start at entry_address. - * * If you make improvements I'd like to get them too. * harpo!utah-cs!thomas, thomas@Utah-20 * @@ -75,6 +50,8 @@ along with GNU Emacs. If not, see . */ */ #include +#include "unexec.h" + #define PERROR(file) report_error (file, new) #ifndef CANNOT_DUMP /* all rest of file! */ @@ -121,14 +98,6 @@ struct aouthdr #include -#ifndef O_RDONLY -#define O_RDONLY 0 -#endif -#ifndef O_RDWR -#define O_RDWR 2 -#endif - - extern char *start_of_data (void); /* Start of initialized data */ static long block_copy_start; /* Old executable start point */ @@ -173,8 +142,7 @@ report_error_1 (int fd, const char *msg, int a1, int a2) error (msg, a1, a2); } -static int make_hdr (int, int, unsigned, unsigned, unsigned, - const char *, const char *); +static int make_hdr (int, int, const char *, const char *); static int copy_text_and_data (int, int); static int copy_sym (int, int, const char *, const char *); static void mark_x (const char *); @@ -186,15 +154,16 @@ static void mark_x (const char *); * Modify the text and data sizes. */ static int -make_hdr (int new, int a_out, unsigned data_start, unsigned bss_start, - unsigned entry_address, const char *a_name, const char *new_name) +make_hdr (int new, int a_out, + const char *a_name, const char *new_name) { auto struct scnhdr f_thdr; /* Text section header */ auto struct scnhdr f_dhdr; /* Data section header */ auto struct scnhdr f_bhdr; /* Bss section header */ auto struct scnhdr scntemp; /* Temporary section header */ register int scns; - unsigned int bss_end; + unsigned int bss_start; + unsigned int data_start; pagemask = getpagesize () - 1; @@ -203,23 +172,8 @@ make_hdr (int new, int a_out, unsigned data_start, unsigned bss_start, data_start = ADDR_CORRECT (data_start); data_start = data_start & ~pagemask; /* (Down) to page boundary. */ - bss_end = ADDR_CORRECT (sbrk (0)) + pagemask; - bss_end &= ~ pagemask; - - /* Adjust data/bss boundary. */ - if (bss_start != 0) - { - bss_start = (ADDR_CORRECT (bss_start) + pagemask); - /* (Up) to page bdry. */ - bss_start &= ~ pagemask; - if (bss_start > bss_end) - { - ERROR1 ("unexec: Specified bss_start (%u) is past end of program", - bss_start); - } - } - else - bss_start = bss_end; + bss_start = ADDR_CORRECT (sbrk (0)) + pagemask; + bss_start &= ~ pagemask; if (data_start > bss_start) /* Can't have negative data size. */ { @@ -300,7 +254,7 @@ make_hdr (int new, int a_out, unsigned data_start, unsigned bss_start, f_hdr.f_flags |= (F_RELFLG | F_EXEC); f_ohdr.dsize = bss_start - f_ohdr.data_start; - f_ohdr.bsize = bss_end - bss_start; + f_ohdr.bsize = 0; f_thdr.s_size = f_ohdr.tsize; f_thdr.s_scnptr = sizeof (f_hdr) + sizeof (f_ohdr); f_thdr.s_scnptr += (f_hdr.f_nscns) * (sizeof (f_thdr)); @@ -570,9 +524,8 @@ adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name) * * driving logic. */ -int -unexec (const char *new_name, const char *a_name, - unsigned data_start, unsigned bss_start, unsigned entry_address) +void +unexec (const char *new_name, const char *a_name) { int new = -1, a_out = -1; @@ -585,24 +538,20 @@ unexec (const char *new_name, const char *a_name, PERROR (new_name); } - if (make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) < 0 + if (make_hdr (new, a_out, a_name, new_name) < 0 || copy_text_and_data (new, a_out) < 0 || copy_sym (new, a_out, a_name, new_name) < 0 || adjust_lnnoptrs (new, a_out, new_name) < 0 ) { close (new); - return -1; + return; } close (new); if (a_out >= 0) close (a_out); mark_x (new_name); - return 0; } #endif /* not CANNOT_DUMP */ - -/* arch-tag: 62409b69-e27a-4a7c-9413-0210d6b54e7f - (do not change this comment) */