* unexhp9k800.c: Remove due to lack of legal papers.
* m/sr2k.h, m/hp800.h: Remove due to dependence on above.
This commit is contained in:
parent
65849ada63
commit
b99e3557ef
4 changed files with 6 additions and 669 deletions
|
@ -1,3 +1,9 @@
|
|||
2007-01-27 Chong Yidong <cyd@stupidchicken.com>
|
||||
|
||||
* unexhp9k800.c: Remove due to lack of legal papers.
|
||||
|
||||
* m/sr2k.h, m/hp800.h: Remove due to dependence on above.
|
||||
|
||||
2007-01-27 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* keyboard.c (Fthis_command_keys, Fthis_command_keys_vector): Doc fix.
|
||||
|
|
187
src/m/hp800.h
187
src/m/hp800.h
|
@ -1,187 +0,0 @@
|
|||
/* machine description file for hp9000 series 800 machines.
|
||||
Copyright (C) 1987, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
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 2, 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
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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. */
|
||||
|
||||
|
||||
/* The following line tells the configuration script what sort of
|
||||
operating system this machine is likely to run.
|
||||
USUAL-OPSYS="hpux" */
|
||||
|
||||
/* Define WORDS_BIG_ENDIAN iff lowest-numbered byte in a word
|
||||
is the most significant byte. */
|
||||
|
||||
#define WORDS_BIG_ENDIAN
|
||||
|
||||
/* Define NO_ARG_ARRAY if you cannot take the address of the first of a
|
||||
* group of arguments and treat it as an array of the arguments. */
|
||||
|
||||
#define NO_ARG_ARRAY
|
||||
|
||||
/* Define WORD_MACHINE if addresses and such have
|
||||
* to be corrected before they can be used as byte counts. */
|
||||
|
||||
#undef WORD_MACHINE
|
||||
|
||||
/* Now define a symbol for the cpu type, if your compiler
|
||||
does not define it automatically:
|
||||
Ones defined so far include vax, m68000, ns16000, pyramid,
|
||||
orion, tahoe, APOLLO and many others */
|
||||
#ifndef hp9000s800
|
||||
# define hp9000s800
|
||||
#endif
|
||||
|
||||
/* Use type int rather than a union, to represent Lisp_Object */
|
||||
/* This is desirable for most machines. */
|
||||
|
||||
#define NO_UNION_TYPE
|
||||
|
||||
/* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend
|
||||
the bit field into an int. In other words, if bit fields
|
||||
are always unsigned.
|
||||
|
||||
If you use NO_UNION_TYPE, this flag does not matter. */
|
||||
|
||||
#define EXPLICIT_SIGN_EXTEND
|
||||
|
||||
/* The standard definitions of these macros would work ok,
|
||||
but these are faster because the constants are short. */
|
||||
|
||||
|
||||
#define XUINT(a) (((unsigned)(a) << BITS_PER_INT-VALBITS) >> BITS_PER_INT-VALBITS)
|
||||
|
||||
#define XSET(var, type, ptr) \
|
||||
((var) = ((int)(type) << VALBITS) + (((unsigned) (ptr) << BITS_PER_INT-VALBITS) >> BITS_PER_INT-VALBITS))
|
||||
|
||||
/* Common definitions for HPUX and GNU/Linux. */
|
||||
|
||||
#if defined (__hpux) || defined (GNU_LINUX)
|
||||
/* Now define a symbol for the cpu type, if your compiler
|
||||
does not define it automatically:
|
||||
Ones defined so far include vax, m68000, ns16000, pyramid,
|
||||
orion, tahoe, APOLLO and many others */
|
||||
#ifndef hp9000s800
|
||||
# define hp9000s800
|
||||
#endif
|
||||
|
||||
/* Define CANNOT_DUMP on machines where unexec does not work.
|
||||
Then the function dump-emacs will not be defined
|
||||
and temacs will do (load "loadup") automatically unless told otherwise. */
|
||||
|
||||
#undef CANNOT_DUMP
|
||||
|
||||
/* Define NO_REMAP if memory segmentation makes it not work well
|
||||
to change the boundary between the text section and data section
|
||||
when Emacs is dumped. If you define this, the preloaded Lisp
|
||||
code will not be sharable; but that's better than failing completely. */
|
||||
|
||||
#define NO_REMAP
|
||||
|
||||
#endif /* __hpux or GNU_LINUX */
|
||||
|
||||
/* Stuff for just GNU/Linux. */
|
||||
|
||||
#ifdef GNU_LINUX
|
||||
|
||||
/* Data type of load average, as read out of kmem. */
|
||||
|
||||
#define LOAD_AVE_TYPE long
|
||||
|
||||
/* Convert that into an integer that is 100 for a load average of 1.0 */
|
||||
|
||||
#define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE)
|
||||
|
||||
#endif /* GNU_LINUX */
|
||||
|
||||
/* Stuff for just HPUX. */
|
||||
|
||||
#ifdef __hpux
|
||||
|
||||
/* Define VIRT_ADDR_VARIES if the virtual addresses of
|
||||
pure and impure space as loaded can vary, and even their
|
||||
relative order cannot be relied on.
|
||||
|
||||
Otherwise Emacs assumes that text space precedes data space,
|
||||
numerically. */
|
||||
|
||||
#define VIRT_ADDR_VARIES
|
||||
|
||||
/* the data segment on this machine always starts at address 0x40000000. */
|
||||
|
||||
#define DATA_SEG_BITS 0x40000000
|
||||
|
||||
#define DATA_START 0x40000000
|
||||
#define TEXT_START 0x00000000
|
||||
|
||||
/* This machine requires completely different unexec code
|
||||
which lives in a separate file. Specify the file name. */
|
||||
|
||||
#define UNEXEC unexhp9k800.o
|
||||
|
||||
#define LIBS_MACHINE
|
||||
#define LIBS_DEBUG
|
||||
|
||||
/* Include the file bsdtty.h, since this machine has job control. */
|
||||
#define NEED_BSDTTY
|
||||
|
||||
/* Data type of load average, as read out of kmem. */
|
||||
|
||||
#define LOAD_AVE_TYPE double
|
||||
|
||||
/* Convert that into an integer that is 100 for a load average of 1.0 */
|
||||
|
||||
#define LOAD_AVE_CVT(x) ((int) (x * 100.0))
|
||||
|
||||
/* The symbol in the kernel where the load average is found
|
||||
is named _avenrun. At this time there are two major flavors
|
||||
of hp-ux (there is the s800 and s300 (s200) flavors). The
|
||||
differences are thusly moved to the corresponding machine description file.
|
||||
*/
|
||||
|
||||
/* no underscore please */
|
||||
#define LDAV_SYMBOL "avenrun"
|
||||
|
||||
#if 0 /* Supposedly no longer true. */
|
||||
/* In hpux, for unknown reasons, S_IFLNK is defined even though
|
||||
symbolic links do not exist.
|
||||
Make sure our conditionals based on S_IFLNK are not confused.
|
||||
|
||||
Here we assume that stat.h is included before config.h
|
||||
so that we can override it here. */
|
||||
|
||||
#undef S_IFLNK
|
||||
#endif
|
||||
|
||||
/* On USG systems these have different names. */
|
||||
|
||||
#define index strchr
|
||||
#define rindex strrchr
|
||||
|
||||
#endif /* __hpux */
|
||||
|
||||
/* Systems with GCC don't need to lose. */
|
||||
#ifdef __NetBSD__
|
||||
# ifdef __GNUC__
|
||||
# define alloca __builtin_alloca
|
||||
# define HAVE_ALLOCA
|
||||
# endif /* __GNUC__ */
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
/* arch-tag: 809436e6-1645-4b92-b40d-2de5d6e7227c
|
||||
(do not change this comment) */
|
160
src/m/sr2k.h
160
src/m/sr2k.h
|
@ -1,160 +0,0 @@
|
|||
/* machine description file for Hitachi SR2001/SR2201 machines.
|
||||
Copyright (C) 1996, 2001, 2002, 2003, 2004, 2005,
|
||||
2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
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 2, 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
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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. */
|
||||
|
||||
|
||||
/* The following line tells the configuration script what sort of
|
||||
operating system this machine is likely to run.
|
||||
USUAL-OPSYS="hpux" */
|
||||
|
||||
/* Define WORDS_BIG_ENDIAN iff lowest-numbered byte in a word
|
||||
is the most significant byte. */
|
||||
|
||||
#define WORDS_BIG_ENDIAN
|
||||
|
||||
/* Define NO_ARG_ARRAY if you cannot take the address of the first of a
|
||||
* group of arguments and treat it as an array of the arguments. */
|
||||
|
||||
#define NO_ARG_ARRAY
|
||||
|
||||
/* Define WORD_MACHINE if addresses and such have
|
||||
* to be corrected before they can be used as byte counts. */
|
||||
|
||||
#undef WORD_MACHINE
|
||||
|
||||
/* Now define a symbol for the cpu type, if your compiler
|
||||
does not define it automatically:
|
||||
Ones defined so far include vax, m68000, ns16000, pyramid,
|
||||
orion, tahoe, APOLLO and many others */
|
||||
#ifndef hp9000s800
|
||||
# define hp9000s800
|
||||
#endif
|
||||
|
||||
/* Use type int rather than a union, to represent Lisp_Object */
|
||||
/* This is desirable for most machines. */
|
||||
|
||||
#define NO_UNION_TYPE
|
||||
|
||||
/* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend
|
||||
the bit field into an int. In other words, if bit fields
|
||||
are always unsigned.
|
||||
|
||||
If you use NO_UNION_TYPE, this flag does not matter. */
|
||||
|
||||
#define EXPLICIT_SIGN_EXTEND
|
||||
|
||||
/* The standard definitions of these macros would work ok,
|
||||
but these are faster because the constants are short. */
|
||||
|
||||
|
||||
#define XUINT(a) (((unsigned)(a) << BITS_PER_INT-VALBITS) >> BITS_PER_INT-VALBITS)
|
||||
|
||||
#define XSET(var, type, ptr) \
|
||||
((var) = ((int)(type) << VALBITS) + (((unsigned) (ptr) << BITS_PER_INT-VALBITS) >> BITS_PER_INT-VALBITS))
|
||||
|
||||
/* #ifdef __hpux */
|
||||
/* Now define a symbol for the cpu type, if your compiler
|
||||
does not define it automatically:
|
||||
Ones defined so far include vax, m68000, ns16000, pyramid,
|
||||
orion, tahoe, APOLLO and many others */
|
||||
|
||||
#ifndef hp9000s800
|
||||
# define hp9000s800
|
||||
#endif
|
||||
|
||||
|
||||
/* Data type of load average, as read out of kmem. */
|
||||
|
||||
#define LOAD_AVE_TYPE double
|
||||
|
||||
/* Convert that into an integer that is 100 for a load average of 1.0 */
|
||||
|
||||
#define LOAD_AVE_CVT(x) ((int) (x * 100.0))
|
||||
|
||||
|
||||
/* Define CANNOT_DUMP on machines where unexec does not work.
|
||||
Then the function dump-emacs will not be defined
|
||||
and temacs will do (load "loadup") automatically unless told otherwise. */
|
||||
|
||||
#undef CANNOT_DUMP
|
||||
|
||||
/* Define VIRT_ADDR_VARIES if the virtual addresses of
|
||||
pure and impure space as loaded can vary, and even their
|
||||
relative order cannot be relied on.
|
||||
|
||||
Otherwise Emacs assumes that text space precedes data space,
|
||||
numerically. */
|
||||
|
||||
#define VIRT_ADDR_VARIES
|
||||
|
||||
/* the data segment on this machine always starts at address 0x40000000. */
|
||||
|
||||
#define DATA_SEG_BITS 0x40000000
|
||||
|
||||
#define DATA_START 0x40000000
|
||||
#define TEXT_START 0x00000000
|
||||
|
||||
/* Define NO_REMAP if memory segmentation makes it not work well
|
||||
to change the boundary between the text section and data section
|
||||
when Emacs is dumped. If you define this, the preloaded Lisp
|
||||
code will not be sharable; but that's better than failing completely. */
|
||||
|
||||
#define NO_REMAP
|
||||
|
||||
/* This machine requires completely different unexec code
|
||||
which lives in a separate file. Specify the file name. */
|
||||
|
||||
#define UNEXEC unexhp9k800.o
|
||||
|
||||
#define LIBS_MACHINE
|
||||
#define LIBS_DEBUG
|
||||
|
||||
/* Include the file bsdtty.h, since this machine has job control. */
|
||||
/* #define NEED_BSDTTY */
|
||||
|
||||
/* The symbol in the kernel where the load average is found
|
||||
is named _avenrun. At this time there are two major flavors
|
||||
of hp-ux (there is the s800 and s300 (s200) flavors). The
|
||||
differences are thusly moved to the corresponding machine description file.
|
||||
*/
|
||||
|
||||
/* no underscore please */
|
||||
#define LDAV_SYMBOL "avenrun"
|
||||
|
||||
#if 0 /* Supposedly no longer true. */
|
||||
/* In hpux, for unknown reasons, S_IFLNK is defined even though
|
||||
symbolic links do not exist.
|
||||
Make sure our conditionals based on S_IFLNK are not confused.
|
||||
|
||||
Here we assume that stat.h is included before config.h
|
||||
so that we can override it here. */
|
||||
|
||||
#undef S_IFLNK
|
||||
#endif
|
||||
|
||||
/* On USG systems these have different names. */
|
||||
|
||||
#define index strchr
|
||||
#define rindex strrchr
|
||||
|
||||
/* #endif */
|
||||
|
||||
/* arch-tag: 4ced5b51-ffe6-4be1-9954-eb40657023a5
|
||||
(do not change this comment) */
|
|
@ -1,322 +0,0 @@
|
|||
/* Unexec for HP 9000 Series 800 machines.
|
||||
Bob Desinger <hpsemc!bd@hplabs.hp.com>
|
||||
|
||||
Note that the GNU project considers support for HP operation a
|
||||
peripheral activity which should not be allowed to divert effort
|
||||
from development of the GNU system. Changes in this code will be
|
||||
installed when users send them in, but aside from that we don't
|
||||
plan to think about it, or about whether other Emacs maintenance
|
||||
might break it.
|
||||
|
||||
|
||||
Unexec creates a copy of the old a.out file, and replaces the old data
|
||||
area with the current data area. When the new file is executed, the
|
||||
process will see the same data structures and data values that the
|
||||
original process had when unexec was called.
|
||||
|
||||
Unlike other versions of unexec, this one copies symbol table and
|
||||
debug information to the new a.out file. Thus, the new a.out file
|
||||
may be debugged with symbolic debuggers.
|
||||
|
||||
If you fix any bugs in this, I'd like to incorporate your fixes.
|
||||
Send them to uunet!hpda!hpsemc!jmorris or jmorris%hpsemc@hplabs.HP.COM.
|
||||
|
||||
CAVEATS:
|
||||
This routine saves the current value of all static and external
|
||||
variables. This means that any data structure that needs to be
|
||||
initialized must be explicitly reset. Variables will not have their
|
||||
expected default values.
|
||||
|
||||
Unfortunately, the HP-UX signal handler has internal initialization
|
||||
flags which are not explicitly reset. Thus, for signals to work in
|
||||
conjunction with this routine, the following code must executed when
|
||||
the new process starts up.
|
||||
|
||||
void _sigreturn ();
|
||||
...
|
||||
sigsetreturn (_sigreturn);
|
||||
*/
|
||||
|
||||
#ifdef emacs
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <a.out.h>
|
||||
|
||||
#ifdef HPUX_USE_SHLIBS
|
||||
#include <dl.h>
|
||||
#endif
|
||||
|
||||
/* brk value to restore, stored as a global.
|
||||
This is really used only if we used shared libraries. */
|
||||
static long brk_on_dump = 0;
|
||||
|
||||
/* Called from main, if we use shared libraries. */
|
||||
int
|
||||
run_time_remap (ignored)
|
||||
char *ignored;
|
||||
{
|
||||
brk ((char *) brk_on_dump);
|
||||
}
|
||||
|
||||
#undef roundup
|
||||
#define roundup(x,n) (((x) + ((n) - 1)) & ~((n) - 1)) /* n is power of 2 */
|
||||
#define min(x,y) (((x) < (y)) ? (x) : (y))
|
||||
|
||||
|
||||
/* 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 old, new;
|
||||
int old_size, new_size;
|
||||
struct header hdr;
|
||||
struct som_exec_auxhdr auxhdr;
|
||||
long i;
|
||||
|
||||
/* For the greatest flexibility, should create a temporary file in
|
||||
the same directory as the new file. When everything is complete,
|
||||
rename the temp file to the new name.
|
||||
This way, a program could update its own a.out file even while
|
||||
it is still executing. If problems occur, everything is still
|
||||
intact. NOT implemented. */
|
||||
|
||||
/* Open the input and output a.out files */
|
||||
old = open (old_name, O_RDONLY);
|
||||
if (old < 0)
|
||||
{ perror (old_name); exit (1); }
|
||||
new = open (new_name, O_CREAT|O_RDWR|O_TRUNC, 0777);
|
||||
if (new < 0)
|
||||
{ perror (new_name); exit (1); }
|
||||
|
||||
/* Read the old headers */
|
||||
read_header (old, &hdr, &auxhdr);
|
||||
|
||||
brk_on_dump = (long) sbrk (0);
|
||||
|
||||
/* Decide how large the new and old data areas are */
|
||||
old_size = auxhdr.exec_dsize;
|
||||
/* I suspect these two statements are separate
|
||||
to avoid a compiler bug in hpux version 8. */
|
||||
i = (long) sbrk (0);
|
||||
new_size = i - auxhdr.exec_dmem;
|
||||
|
||||
/* Copy the old file to the new, up to the data space */
|
||||
lseek (old, 0, 0);
|
||||
copy_file (old, new, auxhdr.exec_dfile);
|
||||
|
||||
/* Skip the old data segment and write a new one */
|
||||
lseek (old, old_size, 1);
|
||||
save_data_space (new, &hdr, &auxhdr, new_size);
|
||||
|
||||
/* Copy the rest of the file */
|
||||
copy_rest (old, new);
|
||||
|
||||
/* Update file pointers since we probably changed size of data area */
|
||||
update_file_ptrs (new, &hdr, &auxhdr, auxhdr.exec_dfile, new_size-old_size);
|
||||
|
||||
/* Save the modified header */
|
||||
write_header (new, &hdr, &auxhdr);
|
||||
|
||||
/* Close the binary file */
|
||||
close (old);
|
||||
close (new);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Save current data space in the file, update header. */
|
||||
|
||||
save_data_space (file, hdr, auxhdr, size)
|
||||
int file;
|
||||
struct header *hdr;
|
||||
struct som_exec_auxhdr *auxhdr;
|
||||
int size;
|
||||
{
|
||||
/* Write the entire data space out to the file */
|
||||
if (write (file, auxhdr->exec_dmem, size) != size)
|
||||
{ perror ("Can't save new data space"); exit (1); }
|
||||
|
||||
/* Update the header to reflect the new data size */
|
||||
auxhdr->exec_dsize = size;
|
||||
auxhdr->exec_bsize = 0;
|
||||
}
|
||||
|
||||
/* Update the values of file pointers when something is inserted. */
|
||||
|
||||
update_file_ptrs (file, hdr, auxhdr, location, offset)
|
||||
int file;
|
||||
struct header *hdr;
|
||||
struct som_exec_auxhdr *auxhdr;
|
||||
unsigned int location;
|
||||
int offset;
|
||||
{
|
||||
struct subspace_dictionary_record subspace;
|
||||
int i;
|
||||
|
||||
/* Increase the overall size of the module */
|
||||
hdr->som_length += offset;
|
||||
|
||||
/* Update the various file pointers in the header */
|
||||
#define update(ptr) if (ptr > location) ptr = ptr + offset
|
||||
update (hdr->aux_header_location);
|
||||
update (hdr->space_strings_location);
|
||||
update (hdr->init_array_location);
|
||||
update (hdr->compiler_location);
|
||||
update (hdr->symbol_location);
|
||||
update (hdr->fixup_request_location);
|
||||
update (hdr->symbol_strings_location);
|
||||
update (hdr->unloadable_sp_location);
|
||||
update (auxhdr->exec_tfile);
|
||||
update (auxhdr->exec_dfile);
|
||||
|
||||
/* Do for each subspace dictionary entry */
|
||||
lseek (file, hdr->subspace_location, 0);
|
||||
for (i = 0; i < hdr->subspace_total; i++)
|
||||
{
|
||||
if (read (file, &subspace, sizeof (subspace)) != sizeof (subspace))
|
||||
{ perror ("Can't read subspace record"); exit (1); }
|
||||
|
||||
/* If subspace has a file location, update it */
|
||||
if (subspace.initialization_length > 0
|
||||
&& subspace.file_loc_init_value > location)
|
||||
{
|
||||
subspace.file_loc_init_value += offset;
|
||||
lseek (file, -sizeof (subspace), 1);
|
||||
if (write (file, &subspace, sizeof (subspace)) != sizeof (subspace))
|
||||
{ perror ("Can't update subspace record"); exit (1); }
|
||||
}
|
||||
}
|
||||
|
||||
/* Do for each initialization pointer record */
|
||||
/* (I don't think it applies to executable files, only relocatables) */
|
||||
#undef update
|
||||
}
|
||||
|
||||
/* Read in the header records from an a.out file. */
|
||||
|
||||
read_header (file, hdr, auxhdr)
|
||||
int file;
|
||||
struct header *hdr;
|
||||
struct som_exec_auxhdr *auxhdr;
|
||||
{
|
||||
|
||||
/* Read the header in */
|
||||
lseek (file, 0, 0);
|
||||
if (read (file, hdr, sizeof (*hdr)) != sizeof (*hdr))
|
||||
{ perror ("Couldn't read header from a.out file"); exit (1); }
|
||||
|
||||
if (hdr->a_magic != EXEC_MAGIC && hdr->a_magic != SHARE_MAGIC
|
||||
&& hdr->a_magic != DEMAND_MAGIC)
|
||||
{
|
||||
fprintf (stderr, "a.out file doesn't have legal magic number\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
lseek (file, hdr->aux_header_location, 0);
|
||||
if (read (file, auxhdr, sizeof (*auxhdr)) != sizeof (*auxhdr))
|
||||
{
|
||||
perror ("Couldn't read auxiliary header from a.out file");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Write out the header records into an a.out file. */
|
||||
|
||||
write_header (file, hdr, auxhdr)
|
||||
int file;
|
||||
struct header *hdr;
|
||||
struct som_exec_auxhdr *auxhdr;
|
||||
{
|
||||
/* Update the checksum */
|
||||
hdr->checksum = calculate_checksum (hdr);
|
||||
|
||||
/* Write the header back into the a.out file */
|
||||
lseek (file, 0, 0);
|
||||
if (write (file, hdr, sizeof (*hdr)) != sizeof (*hdr))
|
||||
{ perror ("Couldn't write header to a.out file"); exit (1); }
|
||||
lseek (file, hdr->aux_header_location, 0);
|
||||
if (write (file, auxhdr, sizeof (*auxhdr)) != sizeof (*auxhdr))
|
||||
{ perror ("Couldn't write auxiliary header to a.out file"); exit (1); }
|
||||
}
|
||||
|
||||
/* Calculate the checksum of a SOM header record. */
|
||||
|
||||
calculate_checksum (hdr)
|
||||
struct header *hdr;
|
||||
{
|
||||
int checksum, i, *ptr;
|
||||
|
||||
checksum = 0; ptr = (int *) hdr;
|
||||
|
||||
for (i = 0; i < sizeof (*hdr) / sizeof (int) - 1; i++)
|
||||
checksum ^= ptr[i];
|
||||
|
||||
return (checksum);
|
||||
}
|
||||
|
||||
/* Copy size bytes from the old file to the new one. */
|
||||
|
||||
copy_file (old, new, size)
|
||||
int new, old;
|
||||
int size;
|
||||
{
|
||||
int len;
|
||||
int buffer[8192]; /* word aligned will be faster */
|
||||
|
||||
for (; size > 0; size -= len)
|
||||
{
|
||||
len = min (size, sizeof (buffer));
|
||||
if (read (old, buffer, len) != len)
|
||||
{ perror ("Read failure on a.out file"); exit (1); }
|
||||
if (write (new, buffer, len) != len)
|
||||
{ perror ("Write failure in a.out file"); exit (1); }
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy the rest of the file, up to EOF. */
|
||||
|
||||
copy_rest (old, new)
|
||||
int new, old;
|
||||
{
|
||||
int buffer[4096];
|
||||
int len;
|
||||
|
||||
/* Copy bytes until end of file or error */
|
||||
while ((len = read (old, buffer, sizeof (buffer))) > 0)
|
||||
if (write (new, buffer, len) != len) break;
|
||||
|
||||
if (len != 0)
|
||||
{ perror ("Unable to copy the rest of the file"); exit (1); }
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
display_header (hdr, auxhdr)
|
||||
struct header *hdr;
|
||||
struct som_exec_auxhdr *auxhdr;
|
||||
{
|
||||
/* Display the header information (debug) */
|
||||
printf ("\n\nFILE HEADER\n");
|
||||
printf ("magic number %d \n", hdr->a_magic);
|
||||
printf ("text loc %.8x size %d \n", auxhdr->exec_tmem, auxhdr->exec_tsize);
|
||||
printf ("data loc %.8x size %d \n", auxhdr->exec_dmem, auxhdr->exec_dsize);
|
||||
printf ("entry %x \n", auxhdr->exec_entry);
|
||||
printf ("Bss segment size %u\n", auxhdr->exec_bsize);
|
||||
printf ("\n");
|
||||
printf ("data file loc %d size %d\n",
|
||||
auxhdr->exec_dfile, auxhdr->exec_dsize);
|
||||
printf ("som_length %d\n", hdr->som_length);
|
||||
printf ("unloadable sploc %d size %d\n",
|
||||
hdr->unloadable_sp_location, hdr->unloadable_sp_size);
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* arch-tag: d55a09ac-9427-4ec4-8496-cb9d7710774f
|
||||
(do not change this comment) */
|
Loading…
Add table
Reference in a new issue