Merge from gnu/dist/include.

This commit is contained in:
tv 2000-08-10 13:52:05 +00:00
parent 7d27fced15
commit 339b9c00a1
4 changed files with 416 additions and 1 deletions

View File

@ -259,6 +259,7 @@ struct internal_nlist {
#define N_COMM 0x12 /* Common symbol (visible after shared lib dynlink) */
#define N_FN 0x1f /* File name of .o file */
#define N_FN_SEQ 0x0C /* N_FN from Sequent compilers (sigh) */
#define N_SIZE 0x0C /* (NetBSD) symbol size */
/* Note: N_EXT can only be usefully OR-ed with N_UNDF, N_ABS, N_TEXT,
N_DATA, or N_BSS. When the low-order bit of other types is set,
(e.g. N_WARNING versus N_FN), they are two different types. */

209
gnu/dist/toolchain/include/aout/netbsd.h vendored Normal file
View File

@ -0,0 +1,209 @@
/* NetBSD-specific values for a.out files */
/* XXX This file is mostly copied from the sunos counterpart. Most, but
* not all, Sun OS specific things has ben changed, so some comments may
* be slightly wrong. */
/* Size of the text section. */
#define N_TXTSIZE(x) \
(N_IS_QMAGIC (x) ? (x).a_text - EXEC_BYTES_SIZE : \
(N_MAGIC(x) != ZMAGIC) ? (x).a_text : \
N_HEADER_IN_TEXT(x) ? \
(x).a_text - EXEC_BYTES_SIZE: \
(x).a_text \
)
/* Offset in an a.out of the start of the text section. */
#define N_TXTOFF(x) \
(N_MAGIC(x) != ZMAGIC ? EXEC_BYTES_SIZE : \
N_HEADER_IN_TEXT(x) ? \
EXEC_BYTES_SIZE : \
ZMAGIC_DISK_BLOCK_SIZE \
)
/* The address of the data segment in virtual memory. */
#define N_TXTADDR(x) \
(N_IS_QMAGIC (x) ? TARGET_PAGE_SIZE + EXEC_BYTES_SIZE : \
N_MAGIC(x) != ZMAGIC ? 0 : \
N_SHARED_LIB(x) ? \
EXEC_BYTES_SIZE : \
TEXT_START_ADDR + EXEC_BYTES_SIZE \
)
/* When a file is linked against a shared library on NetBSD, the
dynamic bit in the exec header is set, and the first symbol in the
symbol table is __DYNAMIC. Its value is the address of the
following structure. */
struct external_netbsd_dynamic
{
/* The version number of the structure. NetBSD creates files
with version number 8, which is what this structure is based on. */
bfd_byte d_version[4];
/* The virtual address of a 24 byte structure used in debugging.
The contents are filled in at run time by ld.so. */
bfd_byte d_debug[4];
/* The virtual address of another structure with information about
how to relocate the executable at run time. */
bfd_byte d_un[4];
/* compat - now in crt_ldso */
bfd_byte d_entry[4];
};
/* The size of the debugging structure pointed to by the debugger
field of __DYNAMIC. */
#define EXTERNAL_NETBSD_DYNAMIC_DEBUGGER_SIZE (24)
/* The structure pointed to by the d_un field of __DYNAMIC. As far
as I can tell, most of the addresses in this structure are offsets
within the file, but some are actually virtual addresses. */
struct internal_section_dispatch_table
{
/* Linked list of loaded objects. This is filled in at runtime by
ld.so and probably by dlopen. */
unsigned long sdt_loaded;
/* The address of the list of names of shared objects which must be
included at runtime. Each entry in the list is 16 bytes: the 4
byte address of the string naming the object (e.g., for -lc this
is "c"); 4 bytes of flags--the high bit is whether to search for
the object using the library path; the 2 byte major version
number; the 2 byte minor version number; the 4 byte address of
the next entry in the list (zero if this is the last entry). The
version numbers seem to only be non-zero when doing library
searching. */
unsigned long sdt_sods;
/* The address of the path to search for the shared objects which
must be included. This points to a string in PATH format which
is generated from the -L arguments to the linker. According to
the man page, ld.so implicitly adds ${LD_LIBRARY_PATH} to the
beginning of this string and /lib:/usr/lib to the end. The string
is terminated by a null byte. This field is zero if there is no
additional path. */
unsigned long sdt_paths;
/* The address of the global offset table. This appears to be a
virtual address, not a file offset. The first entry in the
global offset table seems to be the virtual address of the
_dynamic structure (the same value as the __DYNAMIC symbol).
The global offset table is used for PIC code to hold the
addresses of variables. A dynamically linked file which does not
itself contain PIC code has a four byte global offset table. */
unsigned long sdt_got;
/* The address of the procedure linkage table. This appears to be a
virtual address, not a file offset.
On a SPARC, the table is composed of 12 byte entries, each of
which consists of three instructions. The first entry is
sethi %hi(0),%g1
jmp %g1
nop
These instructions are changed by ld.so into a jump directly into
ld.so itself. Each subsequent entry is
save %sp, -96, %sp
call <address of first entry in procedure linkage table>
<reloc_number | 0x01000000>
The reloc_number is the number of the reloc to use to resolve
this entry. The reloc will be a JMP_SLOT reloc against some
symbol that is not defined in this object file but should be
defined in a shared object (if it is not, ld.so will report a
runtime error and exit). The constant 0x010000000 turns the
reloc number into a sethi of %g0, which does nothing since %g0 is
hardwired to zero.
When one of these entries is executed, it winds up calling into
ld.so. ld.so looks at the reloc number, available via the return
address, to determine which entry this is. It then looks at the
reloc and patches up the entry in the table into a sethi and jmp
to the real address followed by a nop. This means that the reloc
lookup only has to happen once, and it also means that the
relocation only needs to be done if the function is actually
called. The relocation is expensive because ld.so must look up
the symbol by name.
The size of the procedure linkage table is given by the ld_plt_sz
field. */
unsigned long sdt_plt;
/* The address of the relocs. These are in the same format as
ordinary relocs. Symbol index numbers refer to the symbols
pointed to by ld_stab. I think the only way to determine the
number of relocs is to assume that all the bytes from ld_rel to
ld_hash contain reloc entries. */
unsigned long sdt_rel;
/* The address of a hash table of symbols. The hash table has
roughly the same number of entries as there are dynamic symbols;
I think the only way to get the exact size is to assume that
every byte from ld_hash to ld_stab is devoted to the hash table.
Each entry in the hash table is eight bytes. The first four
bytes are a symbol index into the dynamic symbols. The second
four bytes are the index of the next hash table entry in the
bucket. The ld_buckets field gives the number of buckets, say B.
The first B entries in the hash table each start a bucket which
is chained through the second four bytes of each entry. A value
of zero ends the chain.
The hash function is simply
h = 0;
while (*string != '\0')
h = (h << 1) + *string++;
h &= 0x7fffffff;
To look up a symbol, compute the hash value of the name. Take
the modulos of hash value and the number of buckets. Start at
that entry in the hash table. See if the symbol (from the first
four bytes of the hash table entry) has the name you are looking
for. If not, use the chain field (the second four bytes of the
hash table entry) to move on to the next entry in this bucket.
If the chain field is zero you have reached the end of the
bucket, and the symbol is not in the hash table. */
unsigned long sdt_hash;
/* The address of the symbol table. This is a list of
external_nzlist structures. The string indices are relative to
the ld_symbols field. I think the only way to determine the
number of symbols is to assume that all the bytes between ld_stab
and ld_symbols are external_nzlist structures. */
unsigned long sdt_nzlist;
/* Unusued */
unsigned long sdt_filler2;
/* The number of buckets in the hash table. */
unsigned long sdt_buckets;
/* The address of the symbol string table. The first string in this
string table need not be the empty string. */
unsigned long sdt_strings;
/* The size in bytes of the symbol string table. */
unsigned long sdt_str_sz;
/* The size in bytes of the text segment. */
unsigned long sdt_text_sz;
/* The size in bytes of the procedure linkage table. */
unsigned long sdt_plt_sz;
};
/* The external form of the structure. */
struct external_netbsd_dynamic_link
{
bfd_byte sdt_loaded[4];
bfd_byte sdt_sods[4];
bfd_byte sdt_paths[4];
bfd_byte sdt_got[4];
bfd_byte sdt_plt[4];
bfd_byte sdt_rel[4];
bfd_byte sdt_hash[4];
bfd_byte sdt_nzlist[4];
bfd_byte sdt_filler2[4];
bfd_byte sdt_buckets[4];
bfd_byte sdt_strings[4];
bfd_byte sdt_str_sz[4];
bfd_byte sdt_text_sz[4];
bfd_byte sdt_plt_sz[4];
};

205
gnu/dist/toolchain/include/coff/vax.h vendored Normal file
View File

@ -0,0 +1,205 @@
/*** coff information for vax */
/********************** FILE HEADER **********************/
struct external_filehdr {
char f_magic[2]; /* magic number */
char f_nscns[2]; /* number of sections */
char f_timdat[4]; /* time & date stamp */
char f_symptr[4]; /* file pointer to symtab */
char f_nsyms[4]; /* number of symtab entries */
char f_opthdr[2]; /* sizeof(optional hdr) */
char f_flags[2]; /* flags */
};
/* Bits for f_flags:
* F_RELFLG relocation info stripped from file
* F_EXEC file is executable (no unresolved external references)
* F_LNNO line numbers stripped from file
* F_LSYMS local symbols stripped from file
*/
#define F_RELFLG (0x0001)
#define F_EXEC (0x0002)
#define F_LNNO (0x0004)
#define F_LSYMS (0x0008)
#define VAX_AOUTHDR_OMAGIC 0404 /* object files, eg as output */
#define VAX_AOUTHDR_NMAGIC 0410 /* read only text output */
#define VAX_AOUTHDR_ZMAGIC 0413 /* demand load format, eg normal ld output */
#define VAX_AOUTHDR_STMAGIC 0401 /* target shlib */
#define VAX_AOUTHDR_SHMAGIC 0443 /* host shlib */
#define VAXRWMAGIC 0570 /* vax read-write */
#define VAXROMAGIC 0575 /* vax read-only */
#define VAXBADMAG(x) (((x).f_magic != VAXROMAGIC) \
&& ((x).f_magic != VAXRWMAGIC))
#define FILHDR struct external_filehdr
#define FILHSZ 20
/********************** AOUT "OPTIONAL HEADER" **********************/
typedef struct
{
char magic[2]; /* type of file */
char vstamp[2]; /* version stamp */
char tsize[4]; /* text size in bytes, padded to FW bdry*/
char dsize[4]; /* initialized data " " */
char bsize[4]; /* uninitialized data " " */
char entry[4]; /* entry pt. */
char text_start[4]; /* base of text used for this file */
char data_start[4]; /* base of data used for this file */
}
AOUTHDR;
#define AOUTSZ 28
#define AOUTHDRSZ 28
/********************** SECTION HEADER **********************/
struct external_scnhdr {
char s_name[8]; /* section name */
char s_paddr[4]; /* physical address, aliased s_nlib */
char s_vaddr[4]; /* virtual address */
char s_size[4]; /* section size */
char s_scnptr[4]; /* file ptr to raw data for section */
char s_relptr[4]; /* file ptr to relocation */
char s_lnnoptr[4]; /* file ptr to line numbers */
char s_nreloc[2]; /* number of relocation entries */
char s_nlnno[2]; /* number of line number entries*/
char s_flags[4]; /* flags */
};
#define SCNHDR struct external_scnhdr
#define SCNHSZ 40
/*
* names of "special" sections
*/
#define _TEXT ".text"
#define _DATA ".data"
#define _BSS ".bss"
#define _TV ".tv"
#define _INIT ".init"
#define _FINI ".fini"
/********************** LINE NUMBERS **********************/
/* 1 line number entry for every "breakpointable" source line in a section.
* Line numbers are grouped on a per function basis; first entry in a function
* grouping will have l_lnno = 0 and in place of physical address will be the
* symbol table index of the function name.
*/
struct external_lineno {
union {
char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
char l_paddr[4]; /* (physical) address of line number */
} l_addr;
char l_lnno[2]; /* line number */
};
#define LINENO struct external_lineno
#define LINESZ 6
/********************** SYMBOLS **********************/
#define E_SYMNMLEN 8 /* # characters in a symbol name */
#define E_FILNMLEN 14 /* # characters in a file name */
#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
struct external_syment
{
union {
char e_name[E_SYMNMLEN];
struct {
char e_zeroes[4];
char e_offset[4];
} e;
} e;
char e_value[4];
char e_scnum[2];
char e_type[2];
char e_sclass[1];
char e_numaux[1];
};
#define N_BTMASK (0xf)
#define N_TMASK (0x30)
#define N_BTSHFT (4)
#define N_TSHIFT (2)
union external_auxent {
struct {
char x_tagndx[4]; /* str, un, or enum tag indx */
union {
struct {
char x_lnno[2]; /* declaration line number */
char x_size[2]; /* str/union/array size */
} x_lnsz;
char x_fsize[4]; /* size of function */
} x_misc;
union {
struct { /* if ISFCN, tag, or .bb */
char x_lnnoptr[4]; /* ptr to fcn line # */
char x_endndx[4]; /* entry ndx past block end */
} x_fcn;
struct { /* if ISARY, up to 4 dimen. */
char x_dimen[E_DIMNUM][2];
} x_ary;
} x_fcnary;
char x_tvndx[2]; /* tv index */
} x_sym;
union {
char x_fname[E_FILNMLEN];
struct {
char x_zeroes[4];
char x_offset[4];
} x_n;
} x_file;
struct {
char x_scnlen[4]; /* section length */
char x_nreloc[2]; /* # relocation entries */
char x_nlinno[2]; /* # line numbers */
} x_scn;
struct {
char x_tvfill[4]; /* tv fill value */
char x_tvlen[2]; /* length of .tv */
char x_tvran[2][2]; /* tv range */
} x_tv; /* info about .tv section (in auxent of symbol .tv)) */
};
#define SYMENT struct external_syment
#define SYMESZ 18
#define AUXENT union external_auxent
#define AUXESZ 18
# define _ETEXT "etext"
/********************** RELOCATION DIRECTIVES **********************/
struct external_reloc {
char r_vaddr[4];
char r_symndx[4];
char r_type[2];
};
#define RELOC struct external_reloc
#define RELSZ 10

View File

@ -36,7 +36,7 @@ extern char **dupargv PARAMS ((char **)) ATTRIBUTE_MALLOC;
across different systems, sometimes as "char *" and sometimes as
"const char *" */
#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__)
#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined(__NetBSD__) || defined (__OpenBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__)
extern char *basename PARAMS ((const char *));
#else
extern char *basename ();