1 /* Yet Another Try at encapsulating bsd object files in coff.
2 Copyright 1988, 1989, 1991 Free Software Foundation, Inc.
3 Written by Pace Willisson 12/9/88
5 This file is obsolete. It needs to be converted to just define a bunch
6 of stuff that BFD can use to do coff-encapsulated files. --gnu@cygnus.com
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
23 * We only use the coff headers to tell the kernel
24 * how to exec the file. Therefore, the only fields that need to
25 * be filled in are the scnptr and vaddr for the text and data
26 * sections, and the vaddr for the bss. As far as coff is concerned,
27 * there is no symbol table, relocation, or line numbers.
29 * A normal bsd header (struct exec) is placed after the coff headers,
30 * and before the real text. I defined a the new fields 'a_machtype'
31 * and a_flags. If a_machtype is M_386, and a_flags & A_ENCAP is
32 * true, then the bsd header is preceeded by a coff header. Macros
33 * like N_TXTOFF and N_TXTADDR use this field to find the bsd header.
35 * The only problem is to track down the bsd exec header. The
36 * macros HEADER_OFFSET, etc do this.
39 #define N_FLAGS_COFF_ENCAPSULATE 0x20 /* coff header precedes bsd header */
41 /* Describe the COFF header used for encapsulation. */
46 unsigned short f_magic
;
47 unsigned short f_nscns
;
51 unsigned short f_opthdr
;
52 unsigned short f_flags
;
71 unsigned short s_nreloc
;
72 unsigned short s_nlnno
;
77 /* Describe some of the parameters of the encapsulation,
78 including how to find the encapsulated BSD header. */
80 /* FIXME, this is dumb. The same tools can't handle a.outs for different
81 architectures, just because COFF_MAGIC is different; so you need a
82 separate GNU nm for every architecture!!? Unfortunately, it needs to
83 be this way, since the COFF_MAGIC value is determined by the kernel
84 we're trying to fool here. */
86 #define COFF_MAGIC_I386 0514 /* I386MAGIC */
87 #define COFF_MAGIC_M68K 0520 /* MC68MAGIC */
90 short __header_offset_temp
;
91 #define HEADER_OFFSET(f) \
92 (__header_offset_temp = 0, \
93 fread ((char *)&__header_offset_temp, sizeof (short), 1, (f)), \
94 fseek ((f), -sizeof (short), 1), \
95 __header_offset_temp==COFF_MAGIC ? sizeof(struct coffheader) : 0)
97 #define HEADER_OFFSET(f) 0
100 #define HEADER_SEEK(f) (fseek ((f), HEADER_OFFSET((f)), 1))
102 /* Describe the characteristics of the BSD header
103 that appears inside the encapsulation. */
105 /* Encapsulated coff files that are linked ZMAGIC have a text segment
106 offset just past the header (and a matching TXTADDR), excluding
107 the headers from the text segment proper but keeping the physical
108 layout and the virtual memory layout page-aligned.
110 Non-encapsulated a.out files that are linked ZMAGIC have a text
111 segment that starts at 0 and an N_TXTADR similarly offset to 0.
112 They too are page-aligned with each other, but they include the
113 a.out header as part of the text.
115 The _N_HDROFF gets sizeof struct exec added to it, so we have
116 to compensate here. See <a.out.gnu.h>. */
122 #define _N_HDROFF(x) ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
123 sizeof (struct coffheader) : 0)
125 /* Address of text segment in memory after it is loaded. */
126 #define N_TXTADDR(x) \
127 ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
128 sizeof (struct coffheader) + sizeof (struct exec) : 0)
129 #define SEGMENT_SIZE 0x400000
131 #define N_DATADDR(x) \
132 ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
133 (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))) : \
134 (N_TXTADDR(x)+(x).a_text))
This page took 0.031801 seconds and 4 git commands to generate.