Roll in some changes. Unlikely to compile yet.

This commit is contained in:
John Gilmore
1991-10-11 11:11:46 +00:00
parent 2c3f93e56d
commit 1b78540a99

View File

@ -1,4 +1,4 @@
/* Another try at encapsulating bsd object files in coff. /* Yet Another Try at encapsulating bsd object files in coff.
Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc. Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
Written by Pace Willisson 12/9/88 Written by Pace Willisson 12/9/88
@ -20,7 +20,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* /*
* This time, we will only use the coff headers to tell the kernel * We only use the coff headers to tell the kernel
* how to exec the file. Therefore, the only fields that need to * how to exec the file. Therefore, the only fields that need to
* be filled in are the scnptr and vaddr for the text and data * be filled in are the scnptr and vaddr for the text and data
* sections, and the vaddr for the bss. As far as coff is concerned, * sections, and the vaddr for the bss. As far as coff is concerned,
@ -33,13 +33,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
* like N_TXTOFF and N_TXTADDR use this field to find the bsd header. * like N_TXTOFF and N_TXTADDR use this field to find the bsd header.
* *
* The only problem is to track down the bsd exec header. The * The only problem is to track down the bsd exec header. The
* macros HEADER_OFFSET, etc do this. Look at nm.c, dis.c, etc * macros HEADER_OFFSET, etc do this.
* for examples.
*/ */
#ifndef A_OUT_ENCAP_H_SEEN
#define A_OUT_ENCAP_H_SEEN
#include "a.out.gnu.h"
#define N_FLAGS_COFF_ENCAPSULATE 0x20 /* coff header precedes bsd header */ #define N_FLAGS_COFF_ENCAPSULATE 0x20 /* coff header precedes bsd header */
@ -76,67 +71,38 @@ struct coffheader
unsigned short s_nreloc; unsigned short s_nreloc;
unsigned short s_nlnno; unsigned short s_nlnno;
long s_flags; long s_flags;
} scns[3]; /* text, data, bss */ } scns[3];
}; };
/* Describe some of the parameters of the encapsulation, /* Describe some of the parameters of the encapsulation,
including how to find the encapsulated BSD header. */ including how to find the encapsulated BSD header. */
#if TARGET == TARGET_I386 /* FIXME, this is dumb. The same tools can't handle a.outs for different
#define COFF_MAGIC 0514 /* I386MAGIC */ architectures, just because COFF_MAGIC is different; so you need a
#endif separate GNU nm for every architecture!!? Unfortunately, it needs to
#if TARGET == TARGET_M68K be this way, since the COFF_MAGIC value is determined by the kernel
#define COFF_MAGIC 0520 /* MC68MAGIC */ we're trying to fool here. */
#endif
#if TARGET == TARGET_SPARC #define COFF_MAGIC_I386 0514 /* I386MAGIC */
#define COFF_MAGIC UNKNOWN!!! /* Used by TTI */ #define COFF_MAGIC_M68K 0520 /* MC68MAGIC */
#endif #define COFF_MAGIC_A29K 0x17A /* Used by asm29k cross-tools */
#if TARGET == TARGET_AM29K
#define COFF_MAGIC 0x17A /* Used by asm29k cross-tools */
#endif
#ifdef COFF_MAGIC #ifdef COFF_MAGIC
short __header_offset_temp; short __header_offset_temp;
/* FIXME, this is dumb. The same tools can't handle a.outs for different
architectures, just because COFF_MAGIC is different; so you need a
separate GNU nm for every architecture!!? Also note that for
expediency, this macros accepts COFF_MAGIC in either byte order.
The right thing to do is to call read_aout_header to handle all this. */
#define HEADER_OFFSET(f) \ #define HEADER_OFFSET(f) \
(__header_offset_temp = 0, \ (__header_offset_temp = 0, \
fread ((char *)&__header_offset_temp, sizeof (short), 1, (f)), \ fread ((char *)&__header_offset_temp, sizeof (short), 1, (f)), \
fseek ((f), -sizeof (short), 1), \ fseek ((f), -sizeof (short), 1), \
(__header_offset_temp==COFF_MAGIC || __header_offset_temp == \ __header_offset_temp==COFF_MAGIC ? sizeof(struct coffheader) : 0)
((COFF_MAGIC >> 8)|((COFF_MAGIC&0xFF)<<8)) \
? sizeof(struct coffheader) : 0))
#define HEADER_OFFSET_FD(fd) \
(__header_offset_temp = 0, \
read (fd, (char *)&__header_offset_temp, sizeof (short)), \
lseek ((fd), -sizeof (short), 1), \
(__header_offset_temp==COFF_MAGIC || __header_offset_temp == \
((COFF_MAGIC >> 8)|((COFF_MAGIC&0xFF)<<8)) \
? sizeof(struct coffheader) : 0))
#else #else
#define HEADER_OFFSET(f) 0 #define HEADER_OFFSET(f) 0
#define HEADER_OFFSET_FD(fd) 0
#endif #endif
#define HEADER_SEEK(f) (fseek ((f), HEADER_OFFSET((f)), 1)) #define HEADER_SEEK(f) (fseek ((f), HEADER_OFFSET((f)), 1))
#define HEADER_SEEK_FD(fd) (lseek ((fd), HEADER_OFFSET_FD((fd)), 1))
/* Describe the characteristics of the BSD header /* Describe the characteristics of the BSD header
that appears inside the encapsulation. */ that appears inside the encapsulation. */
#undef _N_HDROFF
#undef N_TXTADDR
#undef N_DATADDR
/* Encapsulated coff files that are linked ZMAGIC have a text segment /* Encapsulated coff files that are linked ZMAGIC have a text segment
offset just past the header (and a matching TXTADDR), excluding offset just past the header (and a matching TXTADDR), excluding
the headers from the text segment proper but keeping the physical the headers from the text segment proper but keeping the physical
@ -150,23 +116,20 @@ short __header_offset_temp;
The _N_HDROFF gets sizeof struct exec added to it, so we have The _N_HDROFF gets sizeof struct exec added to it, so we have
to compensate here. See <a.out.gnu.h>. */ to compensate here. See <a.out.gnu.h>. */
#undef _N_HDROFF
#undef N_TXTADDR
#undef N_DATADDR
#define _N_HDROFF(x) ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \ #define _N_HDROFF(x) ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
sizeof (struct coffheader) : -sizeof (struct exec)) sizeof (struct coffheader) : 0)
/* Address of text segment in memory after it is loaded. */ /* Address of text segment in memory after it is loaded. */
#define N_TXTADDR(x) \ #define N_TXTADDR(x) \
(TEXT_START_ADDR + \
((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \ ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
sizeof (struct coffheader) + sizeof (struct exec) : 0)) sizeof (struct coffheader) + sizeof (struct exec) : 0)
/* I have no idea what this is doing here. -- gnu@toad.com 20Mar90
Perhaps it is to give a size that is acceptable to any machine? */
#undef SEGMENT_SIZE
#define SEGMENT_SIZE 0x400000 #define SEGMENT_SIZE 0x400000
#define N_DATADDR(x) \ #define N_DATADDR(x) \
((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \ ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
(SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))) : \ (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))) : \
(N_TXTADDR(x)+(x).a_text)) (N_TXTADDR(x)+(x).a_text))
#endif /* A_OUT_ENCAP_H_SEEN */