Copyright 2001 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 2 of the License, 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef __A_OUT_ADOBE_H__
#define __A_OUT_ADOBE_H__
#define BYTES_IN_WORD 4
struct external_exec
{
bfd_byte e_info[4];
bfd_byte e_text[BYTES_IN_WORD];
bfd_byte e_data[BYTES_IN_WORD];
bfd_byte e_bss[BYTES_IN_WORD];
bfd_byte e_syms[BYTES_IN_WORD];
bfd_byte e_entry[BYTES_IN_WORD];
bfd_byte e_trsize[BYTES_IN_WORD];
bfd_byte e_drsize[BYTES_IN_WORD];
};
#define EXEC_BYTES_SIZE (4 + BYTES_IN_WORD * 7)
#undef ZMAGIC
#define ZMAGIC 0xAD0BE /* Cute, eh? */
#undef OMAGIC
#undef NMAGIC
#define N_BADMAG(x) ((x).a_info != ZMAGIC)
to be a function of the a.out header (e.g. machine type). */
#ifndef N_SEGSIZE
#define N_SEGSIZE(x) SEGMENT_SIZE
#endif
#undef N_SEGSIZE /* FIXMEXXXX */
file header. It contains N segment descriptors, followed by one with
a type of zero.
The actual text of the segments starts at N_TXTOFF in the file,
regardless of how many or how few segment headers there are. */
struct external_segdesc {
unsigned char e_type[1];
unsigned char e_size[3];
unsigned char e_virtbase[4];
unsigned char e_filebase[4];
};
struct internal_segdesc {
unsigned int a_type:8;
unsigned int a_size:24;
bfd_vma a_virtbase;
unsigned int a_filebase;
};
#define N_TXTADDR(x) \
FIXME?! */
#define N_TXTOFF(x) 2048
#define N_TXTSIZE(x) ((x).a_text)
#define N_DATADDR(x)
#define N_BSSADDR(x)
#define N_DATOFF(x) ( N_TXTOFF(x) + N_TXTSIZE(x) )
#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 )
struct external_nlist {
bfd_byte e_strx[BYTES_IN_WORD];
bfd_byte e_type[1];
bfd_byte e_other[1];
bfd_byte e_desc[2];
bfd_byte e_value[BYTES_IN_WORD];
};
#define EXTERNAL_NLIST_SIZE (BYTES_IN_WORD+4+BYTES_IN_WORD)
struct internal_nlist {
unsigned long n_strx;
unsigned char n_type;
unsigned char n_other;
unsigned short n_desc;
bfd_vma n_value;
};
#define N_UNDF 0 /* Undefined symbol */
#define N_ABS 2 /* Absolute symbol -- defined at particular addr */
#define N_TEXT 4 /* Text sym -- defined at offset in text seg */
#define N_DATA 6 /* Data sym -- defined at offset in data seg */
#define N_BSS 8 /* BSS sym -- defined at offset in zero'd seg */
#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) */
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. */
#define N_EXT 1 /* External symbol (as opposed to local-to-this-file) */
#define N_TYPE 0x1e
#define N_STAB 0xe0 /* If any of these bits are on, it's a debug symbol */
#define N_INDR 0x0a
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
elements 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. */
#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 */
#define N_SETV 0x1C /* Pointer to set vector in data area. */
in the table will be undefined. When the symbol is referenced, the
message is printed. */
#define N_WARNING 0x1e
There are two types of relocation flavours for a.out systems,
standard and extended. The standard form is used on systems where the
instruction has room for all the bits of an offset to the operand, whilst
the extended form is used when an address operand has to be split over n
instructions. Eg, on the 68k, each move instruction can reference
the target with a displacement of 16 or 32 bits. On the sparc, move
instructions use an offset of 14 bits, so the offset is stored in
the reloc field, and the data in the section is ignored.
*/
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. */
struct reloc_std_external {
bfd_byte r_address[BYTES_IN_WORD];
bfd_byte r_index[3];
bfd_byte r_type[1];
};
#define RELOC_STD_BITS_PCREL_BIG 0x80
#define RELOC_STD_BITS_PCREL_LITTLE 0x01
#define RELOC_STD_BITS_LENGTH_BIG 0x60
#define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */
#define RELOC_STD_BITS_LENGTH_LITTLE 0x06
#define RELOC_STD_BITS_LENGTH_SH_LITTLE 1
#define RELOC_STD_BITS_EXTERN_BIG 0x10
#define RELOC_STD_BITS_EXTERN_LITTLE 0x08
#define RELOC_STD_BITS_BASEREL_BIG 0x08
#define RELOC_STD_BITS_BASEREL_LITTLE 0x08
#define RELOC_STD_BITS_JMPTABLE_BIG 0x04
#define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04
#define RELOC_STD_BITS_RELATIVE_BIG 0x02
#define RELOC_STD_BITS_RELATIVE_LITTLE 0x02
#define RELOC_STD_SIZE (BYTES_IN_WORD + 3 + 1) /* Bytes per relocation entry */
struct reloc_std_internal
{
bfd_vma r_address;
unsigned int r_symbolnum:24;
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;
Thus, a value of 2 indicates 1<<2 bytes. */
unsigned int r_length:2;
r_symbolnum is the index of the symbol
in files 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;
be undocumented. */
unsigned int r_baserel:1;
unsigned int r_jmptable:1;
unsigned int r_relative:1;
unsigned int r_pad:1;
};
struct reloc_ext_external {
bfd_byte r_address[BYTES_IN_WORD];
bfd_byte r_index[3];
bfd_byte r_type[1];
bfd_byte r_addend[BYTES_IN_WORD];
};
#define RELOC_EXT_BITS_EXTERN_BIG 0x80
#define RELOC_EXT_BITS_EXTERN_LITTLE 0x01
#define RELOC_EXT_BITS_TYPE_BIG 0x1F
#define RELOC_EXT_BITS_TYPE_SH_BIG 0
#define RELOC_EXT_BITS_TYPE_LITTLE 0xF8
#define RELOC_EXT_BITS_TYPE_SH_LITTLE 3
#define RELOC_EXT_SIZE (BYTES_IN_WORD + 3 + 1 + BYTES_IN_WORD)
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,
RELOC_11,
RELOC_WDISP2_14,
RELOC_WDISP19,
RELOC_HHI22,
RELOC_HLO10,
RELOC_JUMPTARG,
RELOC_CONST,
RELOC_CONSTH,
NO_RELOC
};
struct reloc_internal {
bfd_vma r_address;
long r_index;
enum reloc_type r_type;
bfd_vma r_addend;
};
#endif