• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision61a153e5c167fceabc6fd145d7659efef2046d6d (tree)
Zeit1991-03-26 07:25:08
AutorK. Richard Pixley <rich@cygn...>
CommiterK. Richard Pixley

Log Message

as rich copied from mike

Ändern Zusammenfassung

Diff

--- /dev/null
+++ b/gas/a.out.gnu.h
@@ -0,0 +1,461 @@
1+#ifndef __A_OUT_GNU_H__
2+#define __A_OUT_GNU_H__
3+
4+#include "target.h" /* Figure out which target and host systems */
5+
6+#define __GNU_EXEC_MACROS__
7+
8+#ifndef __STRUCT_EXEC_OVERRIDE__
9+
10+struct exec
11+{
12+ unsigned long a_info; /* Use macros N_MAGIC, etc for access */
13+ unsigned a_text; /* length of text, in bytes */
14+ unsigned a_data; /* length of data, in bytes */
15+ unsigned a_bss; /* length of uninitialized data area for file, in bytes */
16+ unsigned a_syms; /* length of symbol table data in file, in bytes */
17+ unsigned a_entry; /* start address */
18+ unsigned a_trsize; /* length of relocation info for text, in bytes */
19+ unsigned a_drsize; /* length of relocation info for data, in bytes */
20+};
21+
22+#endif /* __STRUCT_EXEC_OVERRIDE__ */
23+
24+/* these go in the N_MACHTYPE field */
25+/* These symbols could be defined by code from Suns...punt 'em */
26+#undef M_OLDSUN2
27+#undef M_68010
28+#undef M_68020
29+#undef M_SPARC
30+enum machine_type {
31+ M_OLDSUN2 = 0,
32+ M_68010 = 1,
33+ M_68020 = 2,
34+ M_SPARC = 3,
35+ /* skip a bunch so we don't run into any of sun's numbers */
36+ M_386 = 100,
37+ M_29K = 101,
38+};
39+
40+#define N_MAGIC(exec) ((exec).a_info & 0xffff)
41+#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
42+#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
43+#define N_SET_INFO(exec, magic, type, flags) \
44+ ((exec).a_info = ((magic) & 0xffff) \
45+ | (((int)(type) & 0xff) << 16) \
46+ | (((flags) & 0xff) << 24))
47+#define N_SET_MAGIC(exec, magic) \
48+ ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
49+
50+#define N_SET_MACHTYPE(exec, machtype) \
51+ ((exec).a_info = \
52+ ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
53+
54+#define N_SET_FLAGS(exec, flags) \
55+ ((exec).a_info = \
56+ ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
57+
58+/* Code indicating object file or impure executable. */
59+#define OMAGIC 0407
60+/* Code indicating pure executable. */
61+#define NMAGIC 0410
62+/* Code indicating demand-paged executable. */
63+#define ZMAGIC 0413
64+
65+#define N_BADMAG(x) \
66+ (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
67+ && N_MAGIC(x) != ZMAGIC)
68+
69+#define _N_BADMAG(x) \
70+ (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
71+ && N_MAGIC(x) != ZMAGIC)
72+
73+#define _N_HDROFF(x) (1024 - sizeof (struct exec))
74+
75+#define N_TXTOFF(x) \
76+ (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
77+
78+#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
79+
80+#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
81+
82+#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
83+
84+#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
85+
86+#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
87+
88+/* Address of text segment in memory after it is loaded. */
89+/* Don't load things at zero, it encourages zero-pointer bugs */
90+#ifndef TEXT_START_ADDR
91+#define TEXT_START_ADDR 0x10000
92+#endif
93+#define N_TXTADDR(x) TEXT_START_ADDR
94+
95+/* Address of data segment in memory after it is loaded.
96+ Note that it is up to you to define SEGMENT_SIZE
97+ on machines not listed here. */
98+#ifndef SEGMENT_SIZE
99+#if defined(vax) || defined(hp300) || defined(pyr)
100+#define SEGMENT_SIZE page_size
101+#endif
102+#ifdef sony
103+#define SEGMENT_SIZE 0x2000
104+#endif /* Sony. */
105+#ifdef is68k
106+#define SEGMENT_SIZE 0x20000
107+#endif
108+#if defined(m68k) && defined(PORTAR)
109+#define PAGE_SIZE 0x400
110+#define SEGMENT_SIZE PAGE_SIZE
111+#endif
112+#endif
113+
114+#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
115+
116+#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
117+
118+#ifndef N_DATADDR
119+#define N_DATADDR(x) \
120+ (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
121+ : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
122+#endif
123+
124+/* Address of bss segment in memory after it is loaded. */
125+#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
126+
127+struct nlist {
128+ union {
129+ char *n_name;
130+ struct nlist *n_next;
131+ long n_strx;
132+ } n_un;
133+ unsigned char n_type;
134+ char n_other;
135+ short n_desc;
136+ unsigned long n_value;
137+};
138+
139+#define N_UNDF 0
140+#define N_ABS 2
141+#define N_TEXT 4
142+#define N_DATA 6
143+#define N_BSS 8
144+#define N_FN 15
145+
146+#define N_EXT 1
147+#define N_TYPE 036
148+#define N_STAB 0340
149+
150+/* The following type indicates the definition of a symbol as being
151+ an indirect reference to another symbol. The other symbol
152+ appears as an undefined reference, immediately following this symbol.
153+
154+ Indirection is asymmetrical. The other symbol's value will be used
155+ to satisfy requests for the indirect symbol, but not vice versa.
156+ If the other symbol does not have a definition, libraries will
157+ be searched to find a definition. */
158+#define N_INDR 0xa
159+
160+/* The following symbols refer to set elements.
161+ All the N_SET[ATDB] symbols with the same name form one set.
162+ Space is allocated for the set in the text section, and each set
163+ element's value is stored into one word of the space.
164+ The first word of the space is the length of the set (number of elements).
165+
166+ The address of the set is made into an N_SETV symbol
167+ whose name is the same as the name of the set.
168+ This symbol acts like a N_DATA global symbol
169+ in that it can satisfy undefined external references. */
170+
171+/* These appear as input to LD, in a .o file. */
172+#define N_SETA 0x14 /* Absolute set element symbol */
173+#define N_SETT 0x16 /* Text set element symbol */
174+#define N_SETD 0x18 /* Data set element symbol */
175+#define N_SETB 0x1A /* Bss set element symbol */
176+
177+/* This is output from LD. */
178+#define N_SETV 0x1C /* Pointer to set vector in data area. */
179+
180+/* This structure describes a single relocation to be performed.
181+ The text-relocation section of the file is a vector of these structures,
182+ all of which apply to the text section.
183+ Likewise, the data-relocation section applies to the data section. */
184+
185+#if TARGET == TARGET_SPARC || TARGET == TARGET_AM29K
186+/*
187+ * The following enum and struct were borrowed from
188+ * sunOS /usr/include/sun4/a.out.h and extended to handle
189+ * other machines.
190+ */
191+
192+enum reloc_type
193+{
194+ RELOC_8, RELOC_16, RELOC_32, RELOC_DISP8,
195+ RELOC_DISP16, RELOC_DISP32, RELOC_WDISP30, RELOC_WDISP22,
196+ RELOC_HI22, RELOC_22, RELOC_13, RELOC_LO10,
197+ RELOC_SFA_BASE, RELOC_SFA_OFF13, RELOC_BASE10, RELOC_BASE13,
198+ RELOC_BASE22, RELOC_PC10, RELOC_PC22, RELOC_JMP_TBL,
199+ RELOC_SEGOFF16, RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE,
200+
201+/* 29K relocation types */
202+ RELOC_JUMPTARG, RELOC_CONST, RELOC_CONSTH,
203+
204+ NO_RELOC
205+};
206+
207+#define RELOC_TYPE_NAMES \
208+"8", "16", "32", "DISP8", \
209+"DISP16", "DISP32", "WDISP30", "WDISP22", \
210+"HI22", "22", "13", "LO10", \
211+"SFA_BASE", "SFAOFF13", "BASE10", "BASE13", \
212+"BASE22", "PC10", "PC22", "JMP_TBL", \
213+"SEGOFF16", "GLOB_DAT", "JMP_SLOT", "RELATIVE", \
214+"JUMPTARG", "CONST", "CONSTH", \
215+"NO_RELOC", \
216+"XXX_28", "XXX_29", "XXX_30", "XXX_31"
217+
218+struct reloc_info_extended
219+{
220+ unsigned long r_address;
221+ unsigned int r_index:24;
222+# define r_symbolnum r_index
223+ unsigned r_extern:1;
224+ unsigned :2;
225+ enum reloc_type r_type:5;
226+ long int r_addend;
227+};
228+
229+/* Let programs know what they're dealing with */
230+#define RELOC_EXTENDED 1
231+
232+#undef relocation_info
233+#define relocation_info reloc_info_extended
234+#define RELOC_ADDRESS(r) ((r)->r_address)
235+#define RELOC_EXTERN_P(r) ((r)->r_extern)
236+#define RELOC_TYPE(r) ((r)->r_index)
237+#define RELOC_EXTENDED_TYPE(r) ((r)->r_type)
238+#define RELOC_SYMBOL(r) ((r)->r_index)
239+#define RELOC_MEMORY_SUB_P(r) 0
240+#define RELOC_MEMORY_ADD_P(r) 0
241+#define RELOC_ADD_EXTRA(r) ((r)->r_addend)
242+#define RELOC_PCREL_P(r) \
243+ ( ((r)->r_type >= RELOC_DISP8 && (r)->r_type <= RELOC_WDISP22) \
244+ || (r)->r_type == RELOC_JUMPTARG )
245+#define RELOC_VALUE_RIGHTSHIFT(r) (reloc_target_rightshift[(r)->r_type])
246+#define RELOC_TARGET_SIZE(r) (reloc_target_size[(r)->r_type])
247+#define RELOC_TARGET_BITPOS(r) 0
248+#define RELOC_TARGET_BITSIZE(r) (reloc_target_bitsize[(r)->r_type])
249+
250+/* Note that these are very dependent on the order of the enums in
251+ enum reloc_type (in a.out.h); if they change the following must be
252+ changed */
253+/* Also note that some of these may be incorrect; I have no information */
254+#ifndef __STDC__
255+#define const /**/
256+#endif
257+static const int reloc_target_rightshift[] = {
258+ 0, 0, 0, 0,
259+ 0, 0, 2, 2,
260+ 10, 0, 0, 0,
261+ 0, 0, 0, 0,
262+ 0, 0, 0, 0,
263+ 0, 0, 0, 0,
264+ 2, 0,16, /* 29K jumptarg, const, consth */
265+ 0,
266+};
267+#define RELOC_SIZE_SPLIT16 13
268+static const int reloc_target_size[] = {
269+ 0, 1, 2, 0,
270+ 1, 2, 2, 2,
271+ 2, 2, 2, 2,
272+ 2, 2, 2, 2,
273+ 2, 2, 2, 2,
274+ 2, 2, 2, 2,
275+ RELOC_SIZE_SPLIT16, RELOC_SIZE_SPLIT16, RELOC_SIZE_SPLIT16,
276+ 0,
277+};
278+static const int reloc_target_bitsize[] = {
279+ 8, 16, 32, 8,
280+ 16, 32, 30, 22,
281+ 22, 22, 13, 10,
282+ 32, 32, 16, 0,
283+ 0, 0, 0, 0, /* dunno */
284+ 0, 0, 0, 0,
285+ 16, 16, 16, /* 29K jumptarg, const, consth */
286+ 0,
287+};
288+
289+#define MAX_ALIGNMENT (sizeof (double))
290+
291+#else /* Not SPARC or AM29K */
292+
293+struct relocation_info
294+{
295+ /* Address (within segment) to be relocated. */
296+ int r_address;
297+ /* The meaning of r_symbolnum depends on r_extern. */
298+ unsigned int r_symbolnum:24;
299+ /* Nonzero means value is a pc-relative offset
300+ and it should be relocated for changes in its own address
301+ as well as for changes in the symbol or section specified. */
302+ unsigned int r_pcrel:1;
303+ /* Length (as exponent of 2) of the field to be relocated.
304+ Thus, a value of 2 indicates 1<<2 bytes. */
305+ unsigned int r_length:2;
306+ /* 1 => relocate with value of symbol.
307+ r_symbolnum is the index of the symbol
308+ in file's the symbol table.
309+ 0 => relocate with the address of a segment.
310+ r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
311+ (the N_EXT bit may be set also, but signifies nothing). */
312+ unsigned int r_extern:1;
313+ /* Four bits that aren't used, but when writing an object file
314+ it is desirable to clear them. */
315+ unsigned int r_pad:4;
316+};
317+#endif
318+
319+/*
320+ * Ok. Following are the relocation information macros. If your
321+ * system should not be able to use the default set (below), you must
322+ * define the following:
323+
324+ * relocation_info: This must be typedef'd (or #define'd) to the type
325+ * of structure that is stored in the relocation info section of your
326+ * a.out files. Often this is defined in the a.out.h for your system.
327+ *
328+ * RELOC_ADDRESS (rval): Offset into the current section of the
329+ * <whatever> to be relocated. *Must be an lvalue*.
330+ *
331+ * RELOC_EXTERN_P (rval): Is this relocation entry based on an
332+ * external symbol (1), or was it fully resolved upon entering the
333+ * loader (0) in which case some combination of the value in memory
334+ * (if RELOC_MEMORY_ADD_P) and the extra (if RELOC_ADD_EXTRA) contains
335+ * what the value of the relocation actually was. *Must be an lvalue*.
336+ *
337+ * RELOC_TYPE (rval): If this entry was fully resolved upon
338+ * entering the loader, what type should it be relocated as?
339+ *
340+ * RELOC_EXTENDED_TYPE (rval): If this entry is for a machine using
341+ * extended relocatino, what type of field is it? (For example, on RISC
342+ * machines, odd-sized displacements or split displacements occur.)
343+ *
344+ * RELOC_SYMBOL (rval): If this entry was not fully resolved upon
345+ * entering the loader, what is the index of it's symbol in the symbol
346+ * table? *Must be a lvalue*.
347+ *
348+ * RELOC_MEMORY_ADD_P (rval): This should return true if the final
349+ * relocation value output here should be added to memory, or if the
350+ * section of memory described should simply be set to the relocation
351+ * value.
352+ *
353+ * RELOC_ADD_EXTRA (rval): (Optional) This macro, if defined, gives
354+ * an extra value to be added to the relocation value based on the
355+ * individual relocation entry. *Must be an lvalue if defined*.
356+ *
357+ * RELOC_PCREL_P (rval): True if the relocation value described is
358+ * pc relative.
359+ *
360+ * RELOC_VALUE_RIGHTSHIFT (rval): Number of bits right to shift the
361+ * final relocation value before putting it where it belongs.
362+ *
363+ * RELOC_TARGET_SIZE (rval): log to the base 2 of the number of
364+ * bytes of size this relocation entry describes; 1 byte == 0; 2 bytes
365+ * == 1; 4 bytes == 2, and etc. This is somewhat redundant (we could
366+ * do everything in terms of the bit operators below), but having this
367+ * macro could end up producing better code on machines without fancy
368+ * bit twiddling. Also, it's easier to understand/code big/little
369+ * endian distinctions with this macro.
370+ *
371+ * RELOC_TARGET_BITPOS (rval): The starting bit position within the
372+ * object described in RELOC_TARGET_SIZE in which the relocation value
373+ * will go.
374+ *
375+ * RELOC_TARGET_BITSIZE (rval): How many bits are to be replaced
376+ * with the bits of the relocation value. It may be assumed by the
377+ * code that the relocation value will fit into this many bits. This
378+ * may be larger than RELOC_TARGET_SIZE if such be useful.
379+ *
380+ *
381+ * Things I haven't implemented
382+ * ----------------------------
383+ *
384+ * Values for RELOC_TARGET_SIZE other than 0, 1, or 2.
385+ *
386+ * Pc relative relocation for External references.
387+ */
388+#if TARGET == TARGET_SEQUENT
389+#define RELOC_ADDRESS(r) ((r)->r_address)
390+#define RELOC_EXTERN_P(r) ((r)->r_extern)
391+#define RELOC_TYPE(r) ((r)->r_symbolnum)
392+#define RELOC_SYMBOL(r) ((r)->r_symbolnum)
393+#define RELOC_MEMORY_SUB_P(r) ((r)->r_bsr)
394+#define RELOC_MEMORY_ADD_P(r) 1
395+#undef RELOC_ADD_EXTRA
396+#define RELOC_PCREL_P(r) ((r)->r_pcrel || (r)->r_bsr)
397+#define RELOC_VALUE_RIGHTSHIFT(r) 0
398+#define RELOC_TARGET_SIZE(r) ((r)->r_length)
399+#define RELOC_TARGET_BITPOS(r) 0
400+#define RELOC_TARGET_BITSIZE(r) 32
401+#endif
402+
403+/* Default macros */
404+#ifndef RELOC_ADDRESS
405+#define RELOC_ADDRESS(r) ((r)->r_address)
406+#define RELOC_EXTERN_P(r) ((r)->r_extern)
407+#define RELOC_TYPE(r) ((r)->r_symbolnum)
408+#define RELOC_SYMBOL(r) ((r)->r_symbolnum)
409+#define RELOC_MEMORY_SUB_P(r) 0
410+#define RELOC_MEMORY_ADD_P(r) 1
411+#undef RELOC_ADD_EXTRA
412+#define RELOC_PCREL_P(r) ((r)->r_pcrel)
413+#define RELOC_VALUE_RIGHTSHIFT(r) 0
414+#define RELOC_TARGET_SIZE(r) ((r)->r_length)
415+#define RELOC_TARGET_BITPOS(r) 0
416+#define RELOC_TARGET_BITSIZE(r) 32
417+#endif
418+
419+/* Maximum alignment required of a common'd variable. If a var of this
420+ size or larger is allocated in BSS when nobody defines it, it gets
421+ this alignment. */
422+
423+#ifndef MAX_ALIGNMENT
424+#define MAX_ALIGNMENT (sizeof (int))
425+#endif
426+
427+
428+/* Definitions for routines that read and write GNU a.out files */
429+
430+enum objfile_kind {
431+ OBJFILE_ERROR,
432+ OBJFILE_UNKNOWN,
433+ OBJFILE_SINGLE,
434+ OBJFILE_ARCHIVE,
435+};
436+
437+enum objfile_kind read_aout_header(); /* (desc, &header) read&swap header */
438+
439+/* Read an a.out header from DESC and call rel_fn(DESC, header)
440+ if it is an object file, lib_fn(DESC) if it is a library, else
441+ call err_fn("msg") */
442+void handle_aout_header(); /* (desc, rel_fn, lib_fn, err_fn) */
443+
444+/* Byte-swapping definitions */
445+
446+void swap_aoutheader(); /* BSD a.out header */
447+short swap_getshort ();
448+void swap_putshort();
449+long swap_getlong ();
450+void swap_putlong();
451+void swap_reloc_info_in(); /* BSD relocation information */
452+void swap_reloc_info_out(); /* BSD relocation information */
453+void swap_nlists(); /* BSD symbol name lists */
454+void swap_root_updates(); /* GDB Symseg */
455+
456+/* Bring on the encapsulation, if configured in! */
457+#ifdef COFF_ENCAPSULATE
458+#include "a.out.encap.h"
459+#endif
460+
461+#endif /* __A_OUT_GNU_H__ */
--- /dev/null
+++ b/include/a.out.encap.h
@@ -0,0 +1,172 @@
1+/* Another try at encapsulating bsd object files in coff.
2+ Copyright (C) 1988, 1989, Free Software Foundation, Inc.
3+ Written by Pace Willisson 12/9/88
4+
5+ This file is free software; you can redistribute it and/or modify
6+ it under the terms of the GNU General Public License as published by
7+ the Free Software Foundation; either version 1, or (at your option)
8+ any later version.
9+
10+ This file is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ GNU General Public License for more details.
14+
15+ You should have received a copy of the GNU General Public License
16+ along with this file; if not, write to the Free Software
17+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
18+
19+/*
20+ * This time, we will only use the coff headers to tell the kernel
21+ * how to exec the file. Therefore, the only fields that need to
22+ * be filled in are the scnptr and vaddr for the text and data
23+ * sections, and the vaddr for the bss. As far as coff is concerned,
24+ * there is no symbol table, relocation, or line numbers.
25+ *
26+ * A normal bsd header (struct exec) is placed after the coff headers,
27+ * and before the real text. I defined a the new fields 'a_machtype'
28+ * and a_flags. If a_machtype is M_386, and a_flags & A_ENCAP is
29+ * true, then the bsd header is preceeded by a coff header. Macros
30+ * like N_TXTOFF and N_TXTADDR use this field to find the bsd header.
31+ *
32+ * The only problem is to track down the bsd exec header. The
33+ * macros HEADER_OFFSET, etc do this. Look at nm.c, dis.c, etc
34+ * for examples.
35+ */
36+#ifndef A_OUT_ENCAP_H_SEEN
37+#define A_OUT_ENCAP_H_SEEN
38+
39+#include "a.out.gnu.h"
40+
41+/* Figure out what our target machine is */
42+#include "target.h"
43+
44+#define N_FLAGS_COFF_ENCAPSULATE 0x20 /* coff header precedes bsd header */
45+
46+/* Describe the COFF header used for encapsulation. */
47+
48+struct coffheader
49+{
50+ /* filehdr */
51+ unsigned short f_magic;
52+ unsigned short f_nscns;
53+ long f_timdat;
54+ long f_symptr;
55+ long f_nsyms;
56+ unsigned short f_opthdr;
57+ unsigned short f_flags;
58+ /* aouthdr */
59+ short magic;
60+ short vstamp;
61+ long tsize;
62+ long dsize;
63+ long bsize;
64+ long entry;
65+ long text_start;
66+ long data_start;
67+ struct coffscn
68+ {
69+ char s_name[8];
70+ long s_paddr;
71+ long s_vaddr;
72+ long s_size;
73+ long s_scnptr;
74+ long s_relptr;
75+ long s_lnnoptr;
76+ unsigned short s_nreloc;
77+ unsigned short s_nlnno;
78+ long s_flags;
79+ } scns[3]; /* text, data, bss */
80+};
81+
82+/* Describe some of the parameters of the encapsulation,
83+ including how to find the encapsulated BSD header. */
84+
85+#if TARGET == TARGET_I386
86+#define COFF_MAGIC 0514 /* I386MAGIC */
87+#endif
88+#if TARGET == TARGET_M68K
89+#define COFF_MAGIC 0520 /* MC68MAGIC */
90+#endif
91+#if TARGET == TARGET_SPARC
92+#define COFF_MAGIC UNKNOWN!!! /* Used by TTI */
93+#endif
94+#if TARGET == TARGET_AM29K
95+#define COFF_MAGIC 0x17A /* Used by asm29k cross-tools */
96+#endif
97+
98+#ifdef COFF_MAGIC
99+short __header_offset_temp;
100+
101+/* FIXME, this is dumb. The same tools can't handle a.outs for different
102+ architectures, just because COFF_MAGIC is different; so you need a
103+ separate GNU nm for every architecture!!? Also note that for
104+ expediency, this macros accepts COFF_MAGIC in either byte order.
105+ The right thing to do is to call read_aout_header to handle all this. */
106+
107+#define HEADER_OFFSET(f) \
108+ (__header_offset_temp = 0, \
109+ fread ((char *)&__header_offset_temp, sizeof (short), 1, (f)), \
110+ fseek ((f), -sizeof (short), 1), \
111+ (__header_offset_temp==COFF_MAGIC || __header_offset_temp == \
112+ ((COFF_MAGIC >> 8)|((COFF_MAGIC&0xFF)<<8)) \
113+ ? sizeof(struct coffheader) : 0))
114+
115+#define HEADER_OFFSET_FD(fd) \
116+ (__header_offset_temp = 0, \
117+ read (fd, (char *)&__header_offset_temp, sizeof (short)), \
118+ lseek ((fd), -sizeof (short), 1), \
119+ (__header_offset_temp==COFF_MAGIC || __header_offset_temp == \
120+ ((COFF_MAGIC >> 8)|((COFF_MAGIC&0xFF)<<8)) \
121+ ? sizeof(struct coffheader) : 0))
122+
123+
124+#else
125+#define HEADER_OFFSET(f) 0
126+#define HEADER_OFFSET_FD(fd) 0
127+#endif
128+
129+#define HEADER_SEEK(f) (fseek ((f), HEADER_OFFSET((f)), 1))
130+#define HEADER_SEEK_FD(fd) (lseek ((fd), HEADER_OFFSET_FD((fd)), 1))
131+
132+
133+/* Describe the characteristics of the BSD header
134+ that appears inside the encapsulation. */
135+
136+#undef _N_HDROFF
137+#undef N_TXTADDR
138+#undef N_DATADDR
139+
140+/* Encapsulated coff files that are linked ZMAGIC have a text segment
141+ offset just past the header (and a matching TXTADDR), excluding
142+ the headers from the text segment proper but keeping the physical
143+ layout and the virtual memory layout page-aligned.
144+
145+ Non-encapsulated a.out files that are linked ZMAGIC have a text
146+ segment that starts at 0 and an N_TXTADR similarly offset to 0.
147+ They too are page-aligned with each other, but they include the
148+ a.out header as part of the text.
149+
150+ The _N_HDROFF gets sizeof struct exec added to it, so we have
151+ to compensate here. See <a.out.gnu.h>. */
152+
153+#define _N_HDROFF(x) ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
154+ sizeof (struct coffheader) : -sizeof (struct exec))
155+
156+/* Address of text segment in memory after it is loaded. */
157+#define N_TXTADDR(x) \
158+ (TEXT_START_ADDR + \
159+ ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
160+ sizeof (struct coffheader) + sizeof (struct exec) : 0))
161+
162+/* I have no idea what this is doing here. -- gnu@toad.com 20Mar90
163+ Perhaps it is to give a size that is acceptable to any machine? */
164+#undef SEGMENT_SIZE
165+#define SEGMENT_SIZE 0x400000
166+
167+#define N_DATADDR(x) \
168+ ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
169+ (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))) : \
170+ (N_TXTADDR(x)+(x).a_text))
171+
172+#endif /* A_OUT_ENCAP_H_SEEN */
--- /dev/null
+++ b/include/ranlib.h
@@ -0,0 +1,55 @@
1+/* ranlib.h -- archive library index member definition for GNU.
2+ Copyright (C) 1990 Free Software Foundation, Inc.
3+
4+ This program is free software; you can redistribute it and/or modify
5+ it under the terms of the GNU General Public License as published by
6+ the Free Software Foundation.
7+
8+ This program is distributed in the hope that it will be useful,
9+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ GNU General Public License for more details.
12+
13+ You should have received a copy of the GNU General Public License
14+ along with this program; if not, write to the Free Software
15+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
16+
17+/* The Symdef member of an archive contains two things:
18+ a table that maps symbol-string offsets to file offsets,
19+ and a symbol-string table. All the symbol names are
20+ run together (each with trailing null) in the symbol-string
21+ table. There is a single longword bytecount on the front
22+ of each of these tables. Thus if we have two symbols,
23+ "foo" and "_bar", that are in archive members at offsets
24+ 200 and 900, it would look like this:
25+ 16 ; byte count of index table
26+ 0 ; offset of "foo" in string table
27+ 200 ; offset of foo-module in file
28+ 4 ; offset of "bar" in string table
29+ 900 ; offset of bar-module in file
30+ 9 ; byte count of string table
31+ "foo\0_bar\0" ; string table */
32+
33+/* Format of __.SYMDEF:
34+ First, a longword containing the size of the 'symdef' data that follows.
35+ Second, zero or more 'symdef' structures.
36+ Third, a longword containing the length of symbol name strings.
37+ Fourth, zero or more symbol name strings (each followed by a null). */
38+
39+struct symdef
40+ {
41+ union
42+ {
43+ unsigned long string_offset; /* In the file */
44+ char *name; /* In memory, sometimes */
45+ } s;
46+ unsigned long file_offset;
47+ };
48+
49+/* Compatability with BSD code */
50+
51+#define ranlib symdef
52+#define ran_un s
53+#define ran_str string_offset
54+#define ran_name name
55+#define ran_off file_offset
--- /dev/null
+++ b/include/stab.def
@@ -0,0 +1,182 @@
1+/* Table of DBX symbol codes for the GNU system.
2+ Copyright (C) 1988 Free Software Foundation, Inc.
3+
4+ This program is free software; you can redistribute it and/or modify
5+ it under the terms of the GNU General Public License as published by
6+ the Free Software Foundation; either version 1, or (at your option)
7+ any later version.
8+
9+ This program is distributed in the hope that it will be useful,
10+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ GNU General Public License for more details.
13+
14+ You should have received a copy of the GNU General Public License
15+ along with this program; if not, write to the Free Software
16+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17+
18+/* Global variable. Only the name is significant.
19+ To find the address, look in the corresponding external symbol. */
20+__define_stab (N_GSYM, 0x20, "GSYM")
21+
22+/* Function name for BSD Fortran. Only the name is significant.
23+ To find the address, look in the corresponding external symbol. */
24+__define_stab (N_FNAME, 0x22, "FNAME")
25+
26+/* Function name or text-segment variable for C. Value is its address.
27+ Desc is supposedly starting line number, but GCC doesn't set it
28+ and DBX seems not to miss it. */
29+__define_stab (N_FUN, 0x24, "FUN")
30+
31+/* Data-segment variable with internal linkage. Value is its address. */
32+__define_stab (N_STSYM, 0x26, "STSYM")
33+
34+/* BSS-segment variable with internal linkage. Value is its address. */
35+__define_stab (N_LCSYM, 0x28, "LCSYM")
36+
37+/* Name of main routine. Only the name is significant.
38+ This is not used in C. */
39+__define_stab (N_MAIN, 0x2a, "MAIN")
40+
41+/* Register variable. Value is number of register. */
42+__define_stab (N_RSYM, 0x40, "RSYM")
43+
44+/* Structure or union element. Value is offset in the structure. */
45+__define_stab (N_SSYM, 0x60, "SSYM")
46+
47+/* Parameter variable. Value is offset from argument pointer.
48+ (On most machines the argument pointer is the same as the frame pointer. */
49+__define_stab (N_PSYM, 0xa0, "PSYM")
50+
51+/* Automatic variable in the stack. Value is offset from frame pointer.
52+ Also used for type descriptions. */
53+__define_stab (N_LSYM, 0x80, "LSYM")
54+
55+/* Alternate entry point. Value is its address. */
56+__define_stab (N_ENTRY, 0xa4, "ENTRY")
57+
58+/* Name of main source file.
59+ Value is starting text address of the compilation. */
60+__define_stab (N_SO, 0x64, "SO")
61+
62+/* Name of sub-source file.
63+ Value is starting text address of the compilation. */
64+__define_stab (N_SOL, 0x84, "SOL")
65+
66+/* Line number in text segment. Desc is the line number;
67+ value is corresponding address. */
68+__define_stab (N_SLINE, 0x44, "SLINE")
69+/* Similar, for data segment. */
70+__define_stab (N_DSLINE, 0x66, "DSLINE")
71+/* Similar, for bss segment. */
72+__define_stab (N_BSLINE, 0x68, "BSLINE")
73+
74+/* Beginning of an include file. Only Sun uses this.
75+ In an object file, only the name is significant.
76+ The Sun linker puts data into some of the other fields. */
77+__define_stab (N_BINCL, 0x82, "BINCL")
78+/* End of an include file. No name.
79+ These two act as brackets around the file's output.
80+ In an object file, there is no significant data in this entry.
81+ The Sun linker puts data into some of the fields. */
82+__define_stab (N_EINCL, 0xa2, "EINCL")
83+/* Place holder for deleted include file.
84+ This appears only in output from the Sun linker. */
85+__define_stab (N_EXCL, 0xc2, "EXCL")
86+
87+/* Beginning of lexical block.
88+ The desc is the nesting level in lexical blocks.
89+ The value is the address of the start of the text for the block.
90+ The variables declared inside the block *precede* the N_LBRAC symbol. */
91+__define_stab (N_LBRAC, 0xc0, "LBRAC")
92+/* End of a lexical block. Desc matches the N_LBRAC's desc.
93+ The value is the address of the end of the text for the block. */
94+__define_stab (N_RBRAC, 0xe0, "RBRAC")
95+
96+/* Begin named common block. Only the name is significant. */
97+__define_stab (N_BCOMM, 0xe2, "BCOMM")
98+/* Begin named common block. Only the name is significant
99+ (and it should match the N_BCOMM). */
100+__define_stab (N_ECOMM, 0xe4, "ECOMM")
101+/* End common (local name): value is address.
102+ I'm not sure how this is used. */
103+__define_stab (N_ECOML, 0xe8, "ECOML")
104+/* Second symbol entry containing a length-value for the preceding entry.
105+ The value is the length. */
106+__define_stab (N_LENG, 0xfe, "LENG")
107+
108+/* Global symbol in Pascal.
109+ Supposedly the value is its line number; I'm skeptical. */
110+__define_stab (N_PC, 0x30, "PC")
111+
112+/* Modula-2 compilation unit. Can someone say what info it contains? */
113+__define_stab (N_M2C, 0x42, "M2C")
114+/* Modula-2 scope information. Can someone say what info it contains? */
115+__define_stab (N_SCOPE, 0xc4, "SCOPE")
116+
117+/* Sun's source-code browser stabs. ?? Don't know what the fields are.
118+ Supposedly the field is "path to associated .cb file". */
119+__define_stab (N_BROWS, 0x48, "BROWS")
120+
121+/* GNU C++ exception stabs. */
122+
123+/* GNU C++ exception variable. Name is variable name. */
124+__define_stab (N_EHDECL, 0x50, "EHDECL")
125+
126+/* GNU C++ `catch' clause. Value is its address. Desc is nonzero if
127+ this entry is immediately followed by a CAUGHT stab saying what exception
128+ was caught. Multiple CAUGHT stabs means that multiple exceptions
129+ can be caught here. If Desc is 0, it means all exceptions are caught
130+ here. */
131+__define_stab (N_CATCH, 0x54, "CATCH")
132+
133+/* These STAB's are used on Gould systems for Non-Base register symbols
134+ or something like that. FIXME. I have assigned the values at random
135+ since I don't have a Gould here. Fixups from Gould folk welcome... */
136+__define_stab (N_NBTEXT, 0xF0, "NBTEXT")
137+__define_stab (N_NBDATA, 0xF2, "NBDATA")
138+__define_stab (N_NBBSS, 0xF4, "NBBSS")
139+__define_stab (N_NBSTS, 0xF6, "NBSTS")
140+__define_stab (N_NBLCS, 0xF8, "NBLCS")
141+__define_stab (N_NSYMS, 0xFA, "NSYMS")
142+
143+/* The above information, in matrix format.
144+
145+ STAB MATRIX
146+ _________________________________________________
147+ | 00 - 1F are not dbx stab symbols |
148+ | Entries with bits 01 set are external symbols |
149+ | N_UNDEF | N_ABS | N_TEXT | N_DATA |
150+ | N_BSS | N_COMM | | N_FN |
151+ |_______________________________________________|
152+ | 20 GSYM | 22 FNAME | 24 FUN | 26 STSYM |
153+ | 28 LCSYM | 2A MAIN | 2C | 2E |
154+ | 30 PC | 32 | 34 | 36 |
155+ | 38 | 3A | 3C | 3E |
156+ | 40 RSYM | 42 M2C | 44 SLINE | 46 |
157+ | 48 BROWS | 4A | 4C | 4E |
158+ | 50 EHDECL | 52 | 54 CATCH | 56 |
159+ | 58 | 5A | 5C | 5E |
160+ | 60 SSYM | 62 | 64 SO | 66 DSLINE |
161+ | 68 BSLINE | 6A | 6C | 6E |
162+ | 70 | 72 | 74 | 76 |
163+ | 78 | 7A | 7C | 7E |
164+ | 80 LSYM | 82 BINCL | 84 SOL | 86 |
165+ | 88 | 8A | 8C | 8E |
166+ | 90 | 92 | 94 | 96 |
167+ | 98 | 9A | 9C | 9E |
168+ | A0 PSYM | A2 EINCL | A4 ENTRY | A6 |
169+ | A8 | AA | AC | AE |
170+ | B0 | B2 | B4 | B6 |
171+ | B8 | BA | BC | BE |
172+ | C0 LBRAC | C2 EXCL | C4 SCOPE | C6 |
173+ | C8 | CA | CC | CE |
174+ | D0 | D2 | D4 | D6 |
175+ | D8 | DA | DC | DE |
176+ | E0 RBRAC | E2 BCOMM | E4 ECOMM | E6 |
177+ | E8 ECOML | EA | EC | EE |
178+ | F0 | F2 | F4 | F6 |
179+ | F8 | FA | FC | FE LENG |
180+ +-----------------------------------------------+
181+
182+*/
--- /dev/null
+++ b/include/stab.gnu.h
@@ -0,0 +1,16 @@
1+#ifndef __GNU_STAB__
2+
3+/* Indicate the GNU stab.h is in use. */
4+
5+#define __GNU_STAB__
6+
7+#define __define_stab(NAME, CODE, STRING) NAME=CODE,
8+
9+enum __stab_debug_code
10+{
11+#include "stab.def"
12+};
13+
14+#undef __define_stab
15+
16+#endif /* __GNU_STAB_ */