as rich copied from mike

This commit is contained in:
K. Richard Pixley 1991-03-25 22:25:08 +00:00
parent fcd5c2934e
commit 61a153e5c1
5 changed files with 886 additions and 0 deletions

461
gas/a.out.gnu.h Executable file
View file

@ -0,0 +1,461 @@
#ifndef __A_OUT_GNU_H__
#define __A_OUT_GNU_H__
#include "target.h" /* Figure out which target and host systems */
#define __GNU_EXEC_MACROS__
#ifndef __STRUCT_EXEC_OVERRIDE__
struct exec
{
unsigned long a_info; /* Use macros N_MAGIC, etc for access */
unsigned a_text; /* length of text, in bytes */
unsigned a_data; /* length of data, in bytes */
unsigned a_bss; /* length of uninitialized data area for file, in bytes */
unsigned a_syms; /* length of symbol table data in file, in bytes */
unsigned a_entry; /* start address */
unsigned a_trsize; /* length of relocation info for text, in bytes */
unsigned a_drsize; /* length of relocation info for data, in bytes */
};
#endif /* __STRUCT_EXEC_OVERRIDE__ */
/* these go in the N_MACHTYPE field */
/* These symbols could be defined by code from Suns...punt 'em */
#undef M_OLDSUN2
#undef M_68010
#undef M_68020
#undef M_SPARC
enum machine_type {
M_OLDSUN2 = 0,
M_68010 = 1,
M_68020 = 2,
M_SPARC = 3,
/* skip a bunch so we don't run into any of sun's numbers */
M_386 = 100,
M_29K = 101,
};
#define N_MAGIC(exec) ((exec).a_info & 0xffff)
#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
#define N_SET_INFO(exec, magic, type, flags) \
((exec).a_info = ((magic) & 0xffff) \
| (((int)(type) & 0xff) << 16) \
| (((flags) & 0xff) << 24))
#define N_SET_MAGIC(exec, magic) \
((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
#define N_SET_MACHTYPE(exec, machtype) \
((exec).a_info = \
((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
#define N_SET_FLAGS(exec, flags) \
((exec).a_info = \
((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
/* Code indicating object file or impure executable. */
#define OMAGIC 0407
/* Code indicating pure executable. */
#define NMAGIC 0410
/* Code indicating demand-paged executable. */
#define ZMAGIC 0413
#define N_BADMAG(x) \
(N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
&& N_MAGIC(x) != ZMAGIC)
#define _N_BADMAG(x) \
(N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
&& N_MAGIC(x) != ZMAGIC)
#define _N_HDROFF(x) (1024 - sizeof (struct exec))
#define N_TXTOFF(x) \
(N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
/* Address of text segment in memory after it is loaded. */
/* Don't load things at zero, it encourages zero-pointer bugs */
#ifndef TEXT_START_ADDR
#define TEXT_START_ADDR 0x10000
#endif
#define N_TXTADDR(x) TEXT_START_ADDR
/* Address of data segment in memory after it is loaded.
Note that it is up to you to define SEGMENT_SIZE
on machines not listed here. */
#ifndef SEGMENT_SIZE
#if defined(vax) || defined(hp300) || defined(pyr)
#define SEGMENT_SIZE page_size
#endif
#ifdef sony
#define SEGMENT_SIZE 0x2000
#endif /* Sony. */
#ifdef is68k
#define SEGMENT_SIZE 0x20000
#endif
#if defined(m68k) && defined(PORTAR)
#define PAGE_SIZE 0x400
#define SEGMENT_SIZE PAGE_SIZE
#endif
#endif
#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
#ifndef N_DATADDR
#define N_DATADDR(x) \
(N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
: (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
#endif
/* Address of bss segment in memory after it is loaded. */
#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
struct nlist {
union {
char *n_name;
struct nlist *n_next;
long n_strx;
} n_un;
unsigned char n_type;
char n_other;
short n_desc;
unsigned long n_value;
};
#define N_UNDF 0
#define N_ABS 2
#define N_TEXT 4
#define N_DATA 6
#define N_BSS 8
#define N_FN 15
#define N_EXT 1
#define N_TYPE 036
#define N_STAB 0340
/* The following type indicates the definition of a symbol as being
an indirect reference to another symbol. The other symbol
appears as an undefined reference, immediately following this symbol.
Indirection is asymmetrical. The other symbol's value will be used
to satisfy requests for the indirect symbol, but not vice versa.
If the other symbol does not have a definition, libraries will
be searched to find a definition. */
#define N_INDR 0xa
/* The following symbols refer to set elements.
All the N_SET[ATDB] symbols with the same name form one set.
Space is allocated for the set in the text section, and each set
element's value is stored into one word of the space.
The first word of the space is the length of the set (number of elements).
The address of the set is made into an N_SETV symbol
whose name is the same as the name of the set.
This symbol acts like a N_DATA global symbol
in that it can satisfy undefined external references. */
/* These appear as input to LD, in a .o file. */
#define N_SETA 0x14 /* Absolute set element symbol */
#define N_SETT 0x16 /* Text set element symbol */
#define N_SETD 0x18 /* Data set element symbol */
#define N_SETB 0x1A /* Bss set element symbol */
/* This is output from LD. */
#define N_SETV 0x1C /* Pointer to set vector in data area. */
/* This structure describes a single relocation to be performed.
The text-relocation section of the file is a vector of these structures,
all of which apply to the text section.
Likewise, the data-relocation section applies to the data section. */
#if TARGET == TARGET_SPARC || TARGET == TARGET_AM29K
/*
* The following enum and struct were borrowed from
* sunOS /usr/include/sun4/a.out.h and extended to handle
* other machines.
*/
enum reloc_type
{
RELOC_8, RELOC_16, RELOC_32, RELOC_DISP8,
RELOC_DISP16, RELOC_DISP32, RELOC_WDISP30, RELOC_WDISP22,
RELOC_HI22, RELOC_22, RELOC_13, RELOC_LO10,
RELOC_SFA_BASE, RELOC_SFA_OFF13, RELOC_BASE10, RELOC_BASE13,
RELOC_BASE22, RELOC_PC10, RELOC_PC22, RELOC_JMP_TBL,
RELOC_SEGOFF16, RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE,
/* 29K relocation types */
RELOC_JUMPTARG, RELOC_CONST, RELOC_CONSTH,
NO_RELOC
};
#define RELOC_TYPE_NAMES \
"8", "16", "32", "DISP8", \
"DISP16", "DISP32", "WDISP30", "WDISP22", \
"HI22", "22", "13", "LO10", \
"SFA_BASE", "SFAOFF13", "BASE10", "BASE13", \
"BASE22", "PC10", "PC22", "JMP_TBL", \
"SEGOFF16", "GLOB_DAT", "JMP_SLOT", "RELATIVE", \
"JUMPTARG", "CONST", "CONSTH", \
"NO_RELOC", \
"XXX_28", "XXX_29", "XXX_30", "XXX_31"
struct reloc_info_extended
{
unsigned long r_address;
unsigned int r_index:24;
# define r_symbolnum r_index
unsigned r_extern:1;
unsigned :2;
enum reloc_type r_type:5;
long int r_addend;
};
/* Let programs know what they're dealing with */
#define RELOC_EXTENDED 1
#undef relocation_info
#define relocation_info reloc_info_extended
#define RELOC_ADDRESS(r) ((r)->r_address)
#define RELOC_EXTERN_P(r) ((r)->r_extern)
#define RELOC_TYPE(r) ((r)->r_index)
#define RELOC_EXTENDED_TYPE(r) ((r)->r_type)
#define RELOC_SYMBOL(r) ((r)->r_index)
#define RELOC_MEMORY_SUB_P(r) 0
#define RELOC_MEMORY_ADD_P(r) 0
#define RELOC_ADD_EXTRA(r) ((r)->r_addend)
#define RELOC_PCREL_P(r) \
( ((r)->r_type >= RELOC_DISP8 && (r)->r_type <= RELOC_WDISP22) \
|| (r)->r_type == RELOC_JUMPTARG )
#define RELOC_VALUE_RIGHTSHIFT(r) (reloc_target_rightshift[(r)->r_type])
#define RELOC_TARGET_SIZE(r) (reloc_target_size[(r)->r_type])
#define RELOC_TARGET_BITPOS(r) 0
#define RELOC_TARGET_BITSIZE(r) (reloc_target_bitsize[(r)->r_type])
/* Note that these are very dependent on the order of the enums in
enum reloc_type (in a.out.h); if they change the following must be
changed */
/* Also note that some of these may be incorrect; I have no information */
#ifndef __STDC__
#define const /**/
#endif
static const int reloc_target_rightshift[] = {
0, 0, 0, 0,
0, 0, 2, 2,
10, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
2, 0,16, /* 29K jumptarg, const, consth */
0,
};
#define RELOC_SIZE_SPLIT16 13
static const int reloc_target_size[] = {
0, 1, 2, 0,
1, 2, 2, 2,
2, 2, 2, 2,
2, 2, 2, 2,
2, 2, 2, 2,
2, 2, 2, 2,
RELOC_SIZE_SPLIT16, RELOC_SIZE_SPLIT16, RELOC_SIZE_SPLIT16,
0,
};
static const int reloc_target_bitsize[] = {
8, 16, 32, 8,
16, 32, 30, 22,
22, 22, 13, 10,
32, 32, 16, 0,
0, 0, 0, 0, /* dunno */
0, 0, 0, 0,
16, 16, 16, /* 29K jumptarg, const, consth */
0,
};
#define MAX_ALIGNMENT (sizeof (double))
#else /* Not SPARC or AM29K */
struct relocation_info
{
/* Address (within segment) to be relocated. */
int r_address;
/* The meaning of r_symbolnum depends on r_extern. */
unsigned int r_symbolnum:24;
/* Nonzero means value is a pc-relative offset
and it should be relocated for changes in its own address
as well as for changes in the symbol or section specified. */
unsigned int r_pcrel:1;
/* Length (as exponent of 2) of the field to be relocated.
Thus, a value of 2 indicates 1<<2 bytes. */
unsigned int r_length:2;
/* 1 => relocate with value of symbol.
r_symbolnum is the index of the symbol
in file's the symbol table.
0 => relocate with the address of a segment.
r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
(the N_EXT bit may be set also, but signifies nothing). */
unsigned int r_extern:1;
/* Four bits that aren't used, but when writing an object file
it is desirable to clear them. */
unsigned int r_pad:4;
};
#endif
/*
* Ok. Following are the relocation information macros. If your
* system should not be able to use the default set (below), you must
* define the following:
* relocation_info: This must be typedef'd (or #define'd) to the type
* of structure that is stored in the relocation info section of your
* a.out files. Often this is defined in the a.out.h for your system.
*
* RELOC_ADDRESS (rval): Offset into the current section of the
* <whatever> to be relocated. *Must be an lvalue*.
*
* RELOC_EXTERN_P (rval): Is this relocation entry based on an
* external symbol (1), or was it fully resolved upon entering the
* loader (0) in which case some combination of the value in memory
* (if RELOC_MEMORY_ADD_P) and the extra (if RELOC_ADD_EXTRA) contains
* what the value of the relocation actually was. *Must be an lvalue*.
*
* RELOC_TYPE (rval): If this entry was fully resolved upon
* entering the loader, what type should it be relocated as?
*
* RELOC_EXTENDED_TYPE (rval): If this entry is for a machine using
* extended relocatino, what type of field is it? (For example, on RISC
* machines, odd-sized displacements or split displacements occur.)
*
* RELOC_SYMBOL (rval): If this entry was not fully resolved upon
* entering the loader, what is the index of it's symbol in the symbol
* table? *Must be a lvalue*.
*
* RELOC_MEMORY_ADD_P (rval): This should return true if the final
* relocation value output here should be added to memory, or if the
* section of memory described should simply be set to the relocation
* value.
*
* RELOC_ADD_EXTRA (rval): (Optional) This macro, if defined, gives
* an extra value to be added to the relocation value based on the
* individual relocation entry. *Must be an lvalue if defined*.
*
* RELOC_PCREL_P (rval): True if the relocation value described is
* pc relative.
*
* RELOC_VALUE_RIGHTSHIFT (rval): Number of bits right to shift the
* final relocation value before putting it where it belongs.
*
* RELOC_TARGET_SIZE (rval): log to the base 2 of the number of
* bytes of size this relocation entry describes; 1 byte == 0; 2 bytes
* == 1; 4 bytes == 2, and etc. This is somewhat redundant (we could
* do everything in terms of the bit operators below), but having this
* macro could end up producing better code on machines without fancy
* bit twiddling. Also, it's easier to understand/code big/little
* endian distinctions with this macro.
*
* RELOC_TARGET_BITPOS (rval): The starting bit position within the
* object described in RELOC_TARGET_SIZE in which the relocation value
* will go.
*
* RELOC_TARGET_BITSIZE (rval): How many bits are to be replaced
* with the bits of the relocation value. It may be assumed by the
* code that the relocation value will fit into this many bits. This
* may be larger than RELOC_TARGET_SIZE if such be useful.
*
*
* Things I haven't implemented
* ----------------------------
*
* Values for RELOC_TARGET_SIZE other than 0, 1, or 2.
*
* Pc relative relocation for External references.
*/
#if TARGET == TARGET_SEQUENT
#define RELOC_ADDRESS(r) ((r)->r_address)
#define RELOC_EXTERN_P(r) ((r)->r_extern)
#define RELOC_TYPE(r) ((r)->r_symbolnum)
#define RELOC_SYMBOL(r) ((r)->r_symbolnum)
#define RELOC_MEMORY_SUB_P(r) ((r)->r_bsr)
#define RELOC_MEMORY_ADD_P(r) 1
#undef RELOC_ADD_EXTRA
#define RELOC_PCREL_P(r) ((r)->r_pcrel || (r)->r_bsr)
#define RELOC_VALUE_RIGHTSHIFT(r) 0
#define RELOC_TARGET_SIZE(r) ((r)->r_length)
#define RELOC_TARGET_BITPOS(r) 0
#define RELOC_TARGET_BITSIZE(r) 32
#endif
/* Default macros */
#ifndef RELOC_ADDRESS
#define RELOC_ADDRESS(r) ((r)->r_address)
#define RELOC_EXTERN_P(r) ((r)->r_extern)
#define RELOC_TYPE(r) ((r)->r_symbolnum)
#define RELOC_SYMBOL(r) ((r)->r_symbolnum)
#define RELOC_MEMORY_SUB_P(r) 0
#define RELOC_MEMORY_ADD_P(r) 1
#undef RELOC_ADD_EXTRA
#define RELOC_PCREL_P(r) ((r)->r_pcrel)
#define RELOC_VALUE_RIGHTSHIFT(r) 0
#define RELOC_TARGET_SIZE(r) ((r)->r_length)
#define RELOC_TARGET_BITPOS(r) 0
#define RELOC_TARGET_BITSIZE(r) 32
#endif
/* Maximum alignment required of a common'd variable. If a var of this
size or larger is allocated in BSS when nobody defines it, it gets
this alignment. */
#ifndef MAX_ALIGNMENT
#define MAX_ALIGNMENT (sizeof (int))
#endif
/* Definitions for routines that read and write GNU a.out files */
enum objfile_kind {
OBJFILE_ERROR,
OBJFILE_UNKNOWN,
OBJFILE_SINGLE,
OBJFILE_ARCHIVE,
};
enum objfile_kind read_aout_header(); /* (desc, &header) read&swap header */
/* Read an a.out header from DESC and call rel_fn(DESC, header)
if it is an object file, lib_fn(DESC) if it is a library, else
call err_fn("msg") */
void handle_aout_header(); /* (desc, rel_fn, lib_fn, err_fn) */
/* Byte-swapping definitions */
void swap_aoutheader(); /* BSD a.out header */
short swap_getshort ();
void swap_putshort();
long swap_getlong ();
void swap_putlong();
void swap_reloc_info_in(); /* BSD relocation information */
void swap_reloc_info_out(); /* BSD relocation information */
void swap_nlists(); /* BSD symbol name lists */
void swap_root_updates(); /* GDB Symseg */
/* Bring on the encapsulation, if configured in! */
#ifdef COFF_ENCAPSULATE
#include "a.out.encap.h"
#endif
#endif /* __A_OUT_GNU_H__ */

172
include/a.out.encap.h Executable file
View file

@ -0,0 +1,172 @@
/* Another try at encapsulating bsd object files in coff.
Copyright (C) 1988, 1989, Free Software Foundation, Inc.
Written by Pace Willisson 12/9/88
This file 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 1, or (at your option)
any later version.
This file 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 this file; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* This time, we will only use the coff headers to tell the kernel
* 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
* sections, and the vaddr for the bss. As far as coff is concerned,
* there is no symbol table, relocation, or line numbers.
*
* A normal bsd header (struct exec) is placed after the coff headers,
* and before the real text. I defined a the new fields 'a_machtype'
* and a_flags. If a_machtype is M_386, and a_flags & A_ENCAP is
* true, then the bsd header is preceeded by a coff header. Macros
* 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
* macros HEADER_OFFSET, etc do this. Look at nm.c, dis.c, etc
* for examples.
*/
#ifndef A_OUT_ENCAP_H_SEEN
#define A_OUT_ENCAP_H_SEEN
#include "a.out.gnu.h"
/* Figure out what our target machine is */
#include "target.h"
#define N_FLAGS_COFF_ENCAPSULATE 0x20 /* coff header precedes bsd header */
/* Describe the COFF header used for encapsulation. */
struct coffheader
{
/* filehdr */
unsigned short f_magic;
unsigned short f_nscns;
long f_timdat;
long f_symptr;
long f_nsyms;
unsigned short f_opthdr;
unsigned short f_flags;
/* aouthdr */
short magic;
short vstamp;
long tsize;
long dsize;
long bsize;
long entry;
long text_start;
long data_start;
struct coffscn
{
char s_name[8];
long s_paddr;
long s_vaddr;
long s_size;
long s_scnptr;
long s_relptr;
long s_lnnoptr;
unsigned short s_nreloc;
unsigned short s_nlnno;
long s_flags;
} scns[3]; /* text, data, bss */
};
/* Describe some of the parameters of the encapsulation,
including how to find the encapsulated BSD header. */
#if TARGET == TARGET_I386
#define COFF_MAGIC 0514 /* I386MAGIC */
#endif
#if TARGET == TARGET_M68K
#define COFF_MAGIC 0520 /* MC68MAGIC */
#endif
#if TARGET == TARGET_SPARC
#define COFF_MAGIC UNKNOWN!!! /* Used by TTI */
#endif
#if TARGET == TARGET_AM29K
#define COFF_MAGIC 0x17A /* Used by asm29k cross-tools */
#endif
#ifdef COFF_MAGIC
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) \
(__header_offset_temp = 0, \
fread ((char *)&__header_offset_temp, sizeof (short), 1, (f)), \
fseek ((f), -sizeof (short), 1), \
(__header_offset_temp==COFF_MAGIC || __header_offset_temp == \
((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
#define HEADER_OFFSET(f) 0
#define HEADER_OFFSET_FD(fd) 0
#endif
#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
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
offset just past the header (and a matching TXTADDR), excluding
the headers from the text segment proper but keeping the physical
layout and the virtual memory layout page-aligned.
Non-encapsulated a.out files that are linked ZMAGIC have a text
segment that starts at 0 and an N_TXTADR similarly offset to 0.
They too are page-aligned with each other, but they include the
a.out header as part of the text.
The _N_HDROFF gets sizeof struct exec added to it, so we have
to compensate here. See <a.out.gnu.h>. */
#define _N_HDROFF(x) ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
sizeof (struct coffheader) : -sizeof (struct exec))
/* Address of text segment in memory after it is loaded. */
#define N_TXTADDR(x) \
(TEXT_START_ADDR + \
((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
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 N_DATADDR(x) \
((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
(SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))) : \
(N_TXTADDR(x)+(x).a_text))
#endif /* A_OUT_ENCAP_H_SEEN */

55
include/ranlib.h Executable file
View file

@ -0,0 +1,55 @@
/* ranlib.h -- archive library index member definition for GNU.
Copyright (C) 1990 Free Software Foundation, Inc.
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* The Symdef member of an archive contains two things:
a table that maps symbol-string offsets to file offsets,
and a symbol-string table. All the symbol names are
run together (each with trailing null) in the symbol-string
table. There is a single longword bytecount on the front
of each of these tables. Thus if we have two symbols,
"foo" and "_bar", that are in archive members at offsets
200 and 900, it would look like this:
16 ; byte count of index table
0 ; offset of "foo" in string table
200 ; offset of foo-module in file
4 ; offset of "bar" in string table
900 ; offset of bar-module in file
9 ; byte count of string table
"foo\0_bar\0" ; string table */
/* Format of __.SYMDEF:
First, a longword containing the size of the 'symdef' data that follows.
Second, zero or more 'symdef' structures.
Third, a longword containing the length of symbol name strings.
Fourth, zero or more symbol name strings (each followed by a null). */
struct symdef
{
union
{
unsigned long string_offset; /* In the file */
char *name; /* In memory, sometimes */
} s;
unsigned long file_offset;
};
/* Compatability with BSD code */
#define ranlib symdef
#define ran_un s
#define ran_str string_offset
#define ran_name name
#define ran_off file_offset

182
include/stab.def Executable file
View file

@ -0,0 +1,182 @@
/* Table of DBX symbol codes for the GNU system.
Copyright (C) 1988 Free Software Foundation, Inc.
This program 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 1, or (at your option)
any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Global variable. Only the name is significant.
To find the address, look in the corresponding external symbol. */
__define_stab (N_GSYM, 0x20, "GSYM")
/* Function name for BSD Fortran. Only the name is significant.
To find the address, look in the corresponding external symbol. */
__define_stab (N_FNAME, 0x22, "FNAME")
/* Function name or text-segment variable for C. Value is its address.
Desc is supposedly starting line number, but GCC doesn't set it
and DBX seems not to miss it. */
__define_stab (N_FUN, 0x24, "FUN")
/* Data-segment variable with internal linkage. Value is its address. */
__define_stab (N_STSYM, 0x26, "STSYM")
/* BSS-segment variable with internal linkage. Value is its address. */
__define_stab (N_LCSYM, 0x28, "LCSYM")
/* Name of main routine. Only the name is significant.
This is not used in C. */
__define_stab (N_MAIN, 0x2a, "MAIN")
/* Register variable. Value is number of register. */
__define_stab (N_RSYM, 0x40, "RSYM")
/* Structure or union element. Value is offset in the structure. */
__define_stab (N_SSYM, 0x60, "SSYM")
/* Parameter variable. Value is offset from argument pointer.
(On most machines the argument pointer is the same as the frame pointer. */
__define_stab (N_PSYM, 0xa0, "PSYM")
/* Automatic variable in the stack. Value is offset from frame pointer.
Also used for type descriptions. */
__define_stab (N_LSYM, 0x80, "LSYM")
/* Alternate entry point. Value is its address. */
__define_stab (N_ENTRY, 0xa4, "ENTRY")
/* Name of main source file.
Value is starting text address of the compilation. */
__define_stab (N_SO, 0x64, "SO")
/* Name of sub-source file.
Value is starting text address of the compilation. */
__define_stab (N_SOL, 0x84, "SOL")
/* Line number in text segment. Desc is the line number;
value is corresponding address. */
__define_stab (N_SLINE, 0x44, "SLINE")
/* Similar, for data segment. */
__define_stab (N_DSLINE, 0x66, "DSLINE")
/* Similar, for bss segment. */
__define_stab (N_BSLINE, 0x68, "BSLINE")
/* Beginning of an include file. Only Sun uses this.
In an object file, only the name is significant.
The Sun linker puts data into some of the other fields. */
__define_stab (N_BINCL, 0x82, "BINCL")
/* End of an include file. No name.
These two act as brackets around the file's output.
In an object file, there is no significant data in this entry.
The Sun linker puts data into some of the fields. */
__define_stab (N_EINCL, 0xa2, "EINCL")
/* Place holder for deleted include file.
This appears only in output from the Sun linker. */
__define_stab (N_EXCL, 0xc2, "EXCL")
/* Beginning of lexical block.
The desc is the nesting level in lexical blocks.
The value is the address of the start of the text for the block.
The variables declared inside the block *precede* the N_LBRAC symbol. */
__define_stab (N_LBRAC, 0xc0, "LBRAC")
/* End of a lexical block. Desc matches the N_LBRAC's desc.
The value is the address of the end of the text for the block. */
__define_stab (N_RBRAC, 0xe0, "RBRAC")
/* Begin named common block. Only the name is significant. */
__define_stab (N_BCOMM, 0xe2, "BCOMM")
/* Begin named common block. Only the name is significant
(and it should match the N_BCOMM). */
__define_stab (N_ECOMM, 0xe4, "ECOMM")
/* End common (local name): value is address.
I'm not sure how this is used. */
__define_stab (N_ECOML, 0xe8, "ECOML")
/* Second symbol entry containing a length-value for the preceding entry.
The value is the length. */
__define_stab (N_LENG, 0xfe, "LENG")
/* Global symbol in Pascal.
Supposedly the value is its line number; I'm skeptical. */
__define_stab (N_PC, 0x30, "PC")
/* Modula-2 compilation unit. Can someone say what info it contains? */
__define_stab (N_M2C, 0x42, "M2C")
/* Modula-2 scope information. Can someone say what info it contains? */
__define_stab (N_SCOPE, 0xc4, "SCOPE")
/* Sun's source-code browser stabs. ?? Don't know what the fields are.
Supposedly the field is "path to associated .cb file". */
__define_stab (N_BROWS, 0x48, "BROWS")
/* GNU C++ exception stabs. */
/* GNU C++ exception variable. Name is variable name. */
__define_stab (N_EHDECL, 0x50, "EHDECL")
/* GNU C++ `catch' clause. Value is its address. Desc is nonzero if
this entry is immediately followed by a CAUGHT stab saying what exception
was caught. Multiple CAUGHT stabs means that multiple exceptions
can be caught here. If Desc is 0, it means all exceptions are caught
here. */
__define_stab (N_CATCH, 0x54, "CATCH")
/* These STAB's are used on Gould systems for Non-Base register symbols
or something like that. FIXME. I have assigned the values at random
since I don't have a Gould here. Fixups from Gould folk welcome... */
__define_stab (N_NBTEXT, 0xF0, "NBTEXT")
__define_stab (N_NBDATA, 0xF2, "NBDATA")
__define_stab (N_NBBSS, 0xF4, "NBBSS")
__define_stab (N_NBSTS, 0xF6, "NBSTS")
__define_stab (N_NBLCS, 0xF8, "NBLCS")
__define_stab (N_NSYMS, 0xFA, "NSYMS")
/* The above information, in matrix format.
STAB MATRIX
_________________________________________________
| 00 - 1F are not dbx stab symbols |
| Entries with bits 01 set are external symbols |
| N_UNDEF | N_ABS | N_TEXT | N_DATA |
| N_BSS | N_COMM | | N_FN |
|_______________________________________________|
| 20 GSYM | 22 FNAME | 24 FUN | 26 STSYM |
| 28 LCSYM | 2A MAIN | 2C | 2E |
| 30 PC | 32 | 34 | 36 |
| 38 | 3A | 3C | 3E |
| 40 RSYM | 42 M2C | 44 SLINE | 46 |
| 48 BROWS | 4A | 4C | 4E |
| 50 EHDECL | 52 | 54 CATCH | 56 |
| 58 | 5A | 5C | 5E |
| 60 SSYM | 62 | 64 SO | 66 DSLINE |
| 68 BSLINE | 6A | 6C | 6E |
| 70 | 72 | 74 | 76 |
| 78 | 7A | 7C | 7E |
| 80 LSYM | 82 BINCL | 84 SOL | 86 |
| 88 | 8A | 8C | 8E |
| 90 | 92 | 94 | 96 |
| 98 | 9A | 9C | 9E |
| A0 PSYM | A2 EINCL | A4 ENTRY | A6 |
| A8 | AA | AC | AE |
| B0 | B2 | B4 | B6 |
| B8 | BA | BC | BE |
| C0 LBRAC | C2 EXCL | C4 SCOPE | C6 |
| C8 | CA | CC | CE |
| D0 | D2 | D4 | D6 |
| D8 | DA | DC | DE |
| E0 RBRAC | E2 BCOMM | E4 ECOMM | E6 |
| E8 ECOML | EA | EC | EE |
| F0 | F2 | F4 | F6 |
| F8 | FA | FC | FE LENG |
+-----------------------------------------------+
*/

16
include/stab.gnu.h Executable file
View file

@ -0,0 +1,16 @@
#ifndef __GNU_STAB__
/* Indicate the GNU stab.h is in use. */
#define __GNU_STAB__
#define __define_stab(NAME, CODE, STRING) NAME=CODE,
enum __stab_debug_code
{
#include "stab.def"
};
#undef __define_stab
#endif /* __GNU_STAB_ */