Commit dd5ecd6b authored by Dan Nicolaescu's avatar Dan Nicolaescu

Remove unused arguments for unexec.

The third one is never used, and the last two are always passed as zero.
* src/emacs.c (unexec): Add declaration.
(Fdump_emacs): Only pass the first two arguments to unexec.
Simplify #ifdef.
* src/unexw32.c (unexec):
* src/unexsol.c (unexec):
* src/unexhp9k800.c (unexec):
* src/unexcw.c (unexec): Remove the last 3 arguments, unused.
* src/unexelf.c (unexec): Remove the last 3 arguments, unused.
(find_section): Use const.
* src/unexmacosx.c (unexec): Remove the last 3 arguments, unused.
(unexec_error): Declare it NO_RETURN.
* src/unexcoff.c (make_hdr): Assume bss_start is always zero, remove
it as an argument, remove data_start and entry_address arguments, unused.
(unexec): Remove bss_start, data_start and
entry_address arguments.
* src/unexaix.c (make_hdr): Assume bss_start is always zero, remove
it as an argument, remove data_start and entry_address arguments, unused.
(unexec): Remove bss_start, data_start and
entry_address arguments.
parent e1b69165
2010-10-03 Dan Nicolaescu <dann@ics.uci.edu>
Remove unused arguments for unexec.
The third one is never used, and the last two are always passed as zero.
* emacs.c (unexec): Add declaration.
(Fdump_emacs): Only pass the first two arguments to unexec.
Simplify #ifdef.
* unexw32.c (unexec):
* unexsol.c (unexec):
* unexhp9k800.c (unexec):
* unexcw.c (unexec): Remove the last 3 arguments, unused.
* unexelf.c (unexec): Remove the last 3 arguments, unused.
(find_section): Use const.
* unexmacosx.c (unexec): Remove the last 3 arguments, unused.
(unexec_error): Declare it NO_RETURN.
* unexcoff.c (make_hdr): Assume bss_start is always zero, remove
it as an argument, remove data_start and entry_address arguments, unused.
(unexec): Remove bss_start, data_start and
entry_address arguments.
* unexaix.c (make_hdr): Assume bss_start is always zero, remove
it as an argument, remove data_start and entry_address arguments, unused.
(unexec): Remove bss_start, data_start and
entry_address arguments.
2010-10-03 Juanma Barranquero <lekktu@gmail.com>
* makefile.w32-in (TAGS, TAGS-LISP, TAGS-gmake): Add $(FONTOBJ).
......
......@@ -2118,6 +2118,10 @@ shut_down_emacs (int sig, int no_x, Lisp_Object stuff)
#ifndef CANNOT_DUMP
/* FIXME: maybe this should go into header file, config.h seems the
only one appropriate. */
extern int unexec (const char *, const char *);
DEFUN ("dump-emacs", Fdump_emacs, Sdump_emacs, 2, 2, 0,
doc: /* Dump current state of Emacs into executable file FILENAME.
Take symbols from SYMFILE (presumably the file you executed to run Emacs).
......@@ -2185,13 +2189,13 @@ You must run Emacs in batch mode in order to dump it. */)
Meanwhile, my_edata is not valid on Windows. */
memory_warnings (my_edata, malloc_warning);
#endif /* not WINDOWSNT */
#endif
#if !defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD) && !defined SYNC_INPUT
#if defined (HAVE_GTK_AND_PTHREAD) && !defined SYNC_INPUT
/* Pthread may call malloc before main, and then we will get an endless
loop, because pthread_self (see alloc.c) calls malloc the first time
it is called on some systems. */
reset_malloc_hooks ();
#endif
#endif /* not SYSTEM_MALLOC */
#ifdef DOUG_LEA_MALLOC
malloc_state_ptr = malloc_get_state ();
#endif
......@@ -2199,8 +2203,7 @@ You must run Emacs in batch mode in order to dump it. */)
#ifdef USE_MMAP_FOR_BUFFERS
mmap_set_vars (0);
#endif
unexec (SDATA (filename),
!NILP (symfile) ? SDATA (symfile) : 0, my_edata, 0, 0);
unexec (SDATA (filename), !NILP (symfile) ? SDATA (symfile) : 0);
#ifdef USE_MMAP_FOR_BUFFERS
mmap_set_vars (1);
#endif
......
......@@ -31,24 +31,13 @@ what you give them. Help stamp out software-hoarding! */
* Mike Sperber <sperber@informatik.uni-tuebingen.de>
*
* 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 *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.
*
* data_start and entry_address are ignored.
*
* 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
* sbrk(2).
*
*/
#ifndef emacs
......@@ -143,10 +132,7 @@ static void write_segment (int, char *, char *);
*
* driving logic.
*/
int unexec (char *new_name, char *a_name,
unsigned data_start,
unsigned bss_start,
unsigned entry_address)
int unexec (const char *new_name, const char *a_name)
{
int new = -1, a_out = -1;
......@@ -159,8 +145,6 @@ int unexec (char *new_name, char *a_name,
PERROR (new_name);
}
if (make_hdr (new, a_out,
data_start, bss_start,
entry_address,
a_name, new_name) < 0
|| copy_text_and_data (new) < 0
|| copy_sym (new, a_out, a_name, new_name) < 0
......@@ -186,12 +170,11 @@ int unexec (char *new_name, char *a_name,
*/
static int
make_hdr (int new, int a_out,
unsigned data_start, unsigned bss_start,
unsigned entry_address,
char *a_name, char *new_name)
{
int scns;
unsigned int bss_end;
unsigned int bss_start;
unsigned int data_start;
struct scnhdr section[MAX_SECTIONS];
struct scnhdr * f_thdr; /* Text section header */
......@@ -211,22 +194,8 @@ make_hdr (int new, int a_out,
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. */
{
......@@ -311,7 +280,7 @@ make_hdr (int new, int a_out,
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_dhdr->s_size = f_ohdr.dsize;
f_bhdr->s_size = f_ohdr.bsize;
......
......@@ -34,37 +34,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
* 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
*
......@@ -186,15 +162,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 +180,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 +262,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));
......@@ -571,8 +533,7 @@ 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)
unexec (const char *new_name, const char *a_name)
{
int new = -1, a_out = -1;
......@@ -585,7 +546,7 @@ 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
......
......@@ -248,8 +248,7 @@ add_exe_suffix_if_necessary (const char *name, char *modified)
}
int
unexec (char *outfile, char *infile, unsigned start_data, unsigned d1,
unsigned d2)
unexec (const char *outfile, const char *infile)
{
char infile_buffer[FILENAME_MAX];
char outfile_buffer[FILENAME_MAX];
......
......@@ -33,34 +33,13 @@ what you give them. Help stamp out software-hoarding! */
* Modified heavily since then.
*
* Synopsis:
* unexec (new_name, old_name, data_start, bss_start, entry_address)
* char *new_name, *old_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 old_name is non-NULL, the symbol table will be taken from the given file.
* On some machines, an existing old_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.
*
* 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.
*
*/
/* Even more heavily modified by james@bigtex.cactus.org of Dell Computer Co.
......@@ -610,7 +589,7 @@ round_up (ElfW(Addr) x, ElfW(Addr) y)
if NOERROR is 0; we return -1 if NOERROR is nonzero. */
static int
find_section (const char *name, char *section_names, char *file_name,
find_section (const char *name, const char *section_names, const char *file_name,
ElfW(Ehdr) *old_file_h, ElfW(Shdr) *old_section_h, int noerror)
{
int idx;
......@@ -646,8 +625,7 @@ find_section (const char *name, char *section_names, char *file_name,
*
*/
void
unexec (char *new_name, char *old_name, unsigned int data_start,
unsigned int bss_start, unsigned int entry_address)
unexec (const char *new_name, const char *old_name)
{
int new_file, old_file, new_file_size;
......
......@@ -79,12 +79,9 @@ run_time_remap (ignored)
/* Create a new a.out file, same as old but with current data space */
unexec (new_name, old_name, new_end_of_text, dummy1, dummy2)
char new_name[]; /* name of the new a.out file to be created */
char old_name[]; /* name of the old a.out file */
char *new_end_of_text; /* ptr to new edata/etext; NOT USED YET */
int dummy1, dummy2; /* not used by emacs */
int
unexec (const char *new_name, /* name of the new a.out file to be created */
const char *old_name) /* name of the old a.out file */
{
int old, new;
int old_size, new_size;
......
......@@ -190,6 +190,8 @@ static off_t data_segment_old_fileoff = 0;
static struct segment_command *data_segment_scp;
static void unexec_error (const char *format, ...) NO_RETURN;
/* Read N bytes from infd into memory starting at address DEST.
Return true if successful, false otherwise. */
static int
......@@ -1217,9 +1219,8 @@ dump_it (void)
from it. The file names of the output and input files are outfile
and infile, respectively. The three other parameters are
ignored. */
void
unexec (char *outfile, char *infile, void *start_data, void *start_bss,
void *entry_address)
int
unexec (const char *outfile, const char *infile)
{
if (in_dumped_exec)
unexec_error ("Unexec from a dumped executable is not supported.");
......@@ -1249,6 +1250,7 @@ unexec (char *outfile, char *infile, void *start_data, void *start_bss,
dump_it ();
close (outfd);
return 0;
}
......
......@@ -10,8 +10,7 @@
#include "coding.h"
int
unexec (char *new_name, char *old_name, unsigned int data_start,
unsigned int bss_start, unsigned int entry_address)
unexec (const char *new_name, const char *old_name)
{
Lisp_Object data;
Lisp_Object errstring;
......
......@@ -724,9 +724,8 @@ copy_executable_and_dump_data (file_data *p_infile,
/* Dump out .data and .bss sections into a new executable. */
void
unexec (char *new_name, char *old_name, void *start_data, void *start_bss,
void *entry_address)
int
unexec (const char *new_name, const char *old_name)
{
file_data in_file, out_file;
char out_filename[MAX_PATH], in_filename[MAX_PATH];
......@@ -821,6 +820,8 @@ unexec (char *new_name, char *old_name, void *start_data, void *start_bss,
close_file_data (&in_file);
close_file_data (&out_file);
return 0;
}
/* eof */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment