diff options
| author | Jim Blandy | 1992-01-13 21:48:08 +0000 |
|---|---|---|
| committer | Jim Blandy | 1992-01-13 21:48:08 +0000 |
| commit | 265a9e559da4ac72d154ecd638c51801b3e97847 (patch) | |
| tree | 633e4dc50761c2cd5201a7874e23eee9e51aecea /src/unexec.c | |
| parent | d427b66a664c0e1ffc818dfa5b87b45b4857d2ae (diff) | |
| download | emacs-265a9e559da4ac72d154ecd638c51801b3e97847.tar.gz emacs-265a9e559da4ac72d154ecd638c51801b3e97847.zip | |
*** empty log message ***
Diffstat (limited to 'src/unexec.c')
| -rw-r--r-- | src/unexec.c | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/src/unexec.c b/src/unexec.c index ccd67451203..4d4cf20fd55 100644 --- a/src/unexec.c +++ b/src/unexec.c | |||
| @@ -74,6 +74,13 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 74 | * COFF | 74 | * COFF |
| 75 | 75 | ||
| 76 | Define this if your system uses COFF for executables. | 76 | Define this if your system uses COFF for executables. |
| 77 | |||
| 78 | * COFF_ENCAPSULATE | ||
| 79 | |||
| 80 | Define this if you are using the GNU coff encapsulated a.out format. | ||
| 81 | This is closer to a.out than COFF. You should *not* define COFF if | ||
| 82 | you define COFF_ENCAPSULATE | ||
| 83 | |||
| 77 | Otherwise we assume you use Berkeley format. | 84 | Otherwise we assume you use Berkeley format. |
| 78 | 85 | ||
| 79 | * NO_REMAP | 86 | * NO_REMAP |
| @@ -165,7 +172,13 @@ pointer looks like an int) but not on all machines. | |||
| 165 | 172 | ||
| 166 | #ifndef CANNOT_UNEXEC /* most of rest of file */ | 173 | #ifndef CANNOT_UNEXEC /* most of rest of file */ |
| 167 | 174 | ||
| 175 | #ifdef COFF_ENCAPSULATE | ||
| 176 | int need_coff_header = 1; | ||
| 177 | #include <coff-encap/a.out.encap.h> /* The location might be a poor assumption */ | ||
| 178 | #else | ||
| 168 | #include <a.out.h> | 179 | #include <a.out.h> |
| 180 | #endif | ||
| 181 | |||
| 169 | /* Define getpagesize () if the system does not. | 182 | /* Define getpagesize () if the system does not. |
| 170 | Note that this may depend on symbols defined in a.out.h | 183 | Note that this may depend on symbols defined in a.out.h |
| 171 | */ | 184 | */ |
| @@ -173,7 +186,7 @@ pointer looks like an int) but not on all machines. | |||
| 173 | 186 | ||
| 174 | #ifndef makedev /* Try to detect types.h already loaded */ | 187 | #ifndef makedev /* Try to detect types.h already loaded */ |
| 175 | #include <sys/types.h> | 188 | #include <sys/types.h> |
| 176 | #endif | 189 | #endif /* makedev */ |
| 177 | #include <stdio.h> | 190 | #include <stdio.h> |
| 178 | #include <sys/stat.h> | 191 | #include <sys/stat.h> |
| 179 | #include <errno.h> | 192 | #include <errno.h> |
| @@ -218,7 +231,7 @@ static EXEC_HDR_TYPE hdr, ohdr; | |||
| 218 | 231 | ||
| 219 | #else /* not HPUX */ | 232 | #else /* not HPUX */ |
| 220 | 233 | ||
| 221 | #if defined (USG) && !defined (IBMAIX) && !defined (IRIS) | 234 | #if defined (USG) && !defined (IBMAIX) && !defined (IRIS) && !defined (COFF_ENCAPSULATE) |
| 222 | static struct bhdr hdr, ohdr; | 235 | static struct bhdr hdr, ohdr; |
| 223 | #define a_magic fmagic | 236 | #define a_magic fmagic |
| 224 | #define a_text tsize | 237 | #define a_text tsize |
| @@ -241,6 +254,11 @@ static EXEC_HDR_TYPE hdr, ohdr; | |||
| 241 | static int unexec_text_start; | 254 | static int unexec_text_start; |
| 242 | static int unexec_data_start; | 255 | static int unexec_data_start; |
| 243 | 256 | ||
| 257 | #ifdef COFF_ENCAPSULATE | ||
| 258 | /* coffheader is defined in the GNU a.out.encap.h file. */ | ||
| 259 | struct coffheader coffheader; | ||
| 260 | #endif | ||
| 261 | |||
| 244 | #endif /* not COFF */ | 262 | #endif /* not COFF */ |
| 245 | 263 | ||
| 246 | static int pagemask; | 264 | static int pagemask; |
| @@ -624,6 +642,16 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) | |||
| 624 | /* Get symbol table info from header of a.out file if given one. */ | 642 | /* Get symbol table info from header of a.out file if given one. */ |
| 625 | if (a_out >= 0) | 643 | if (a_out >= 0) |
| 626 | { | 644 | { |
| 645 | #ifdef COFF_ENCAPSULATE | ||
| 646 | if (read (a_out, &coffheader, sizeof coffheader) != sizeof coffheader) | ||
| 647 | { | ||
| 648 | PERROR(a_name); | ||
| 649 | } | ||
| 650 | if (coffheader.f_magic != COFF_MAGIC) | ||
| 651 | { | ||
| 652 | ERROR1("%s doesn't have legal coff magic number\n", a_name); | ||
| 653 | } | ||
| 654 | #endif | ||
| 627 | if (read (a_out, &ohdr, sizeof hdr) != sizeof hdr) | 655 | if (read (a_out, &ohdr, sizeof hdr) != sizeof hdr) |
| 628 | { | 656 | { |
| 629 | PERROR (a_name); | 657 | PERROR (a_name); |
| @@ -637,7 +665,14 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) | |||
| 637 | } | 665 | } |
| 638 | else | 666 | else |
| 639 | { | 667 | { |
| 668 | #ifdef COFF_ENCAPSULATE | ||
| 669 | /* We probably could without too much trouble. The code is in gld | ||
| 670 | * but I don't have that much time or incentive. | ||
| 671 | */ | ||
| 672 | ERROR0 ("can't build a COFF file from scratch yet"); | ||
| 673 | #else | ||
| 640 | bzero (hdr, sizeof hdr); | 674 | bzero (hdr, sizeof hdr); |
| 675 | #endif | ||
| 641 | } | 676 | } |
| 642 | 677 | ||
| 643 | unexec_text_start = (long) start_of_text (); | 678 | unexec_text_start = (long) start_of_text (); |
| @@ -666,6 +701,32 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) | |||
| 666 | 701 | ||
| 667 | #endif /* not NO_REMAP */ | 702 | #endif /* not NO_REMAP */ |
| 668 | 703 | ||
| 704 | #ifdef COFF_ENCAPSULATE | ||
| 705 | /* We are encapsulating BSD format within COFF format. */ | ||
| 706 | { | ||
| 707 | struct coffscn *tp, *dp, *bp; | ||
| 708 | tp = &coffheader.scns[0]; | ||
| 709 | dp = &coffheader.scns[1]; | ||
| 710 | bp = &coffheader.scns[2]; | ||
| 711 | tp->s_size = hdr.a_text + sizeof(struct exec); | ||
| 712 | dp->s_paddr = data_start; | ||
| 713 | dp->s_vaddr = data_start; | ||
| 714 | dp->s_size = hdr.a_data; | ||
| 715 | bp->s_paddr = dp->s_vaddr + dp->s_size; | ||
| 716 | bp->s_vaddr = bp->s_paddr; | ||
| 717 | bp->s_size = hdr.a_bss; | ||
| 718 | coffheader.tsize = tp->s_size; | ||
| 719 | coffheader.dsize = dp->s_size; | ||
| 720 | coffheader.bsize = bp->s_size; | ||
| 721 | coffheader.text_start = tp->s_vaddr; | ||
| 722 | coffheader.data_start = dp->s_vaddr; | ||
| 723 | } | ||
| 724 | if (write (new, &coffheader, sizeof coffheader) != sizeof coffheader) | ||
| 725 | { | ||
| 726 | PERROR(new_name); | ||
| 727 | } | ||
| 728 | #endif /* COFF_ENCAPSULATE */ | ||
| 729 | |||
| 669 | if (write (new, &hdr, sizeof hdr) != sizeof hdr) | 730 | if (write (new, &hdr, sizeof hdr) != sizeof hdr) |
| 670 | { | 731 | { |
| 671 | PERROR (new_name); | 732 | PERROR (new_name); |