coff.h revision b8e299dddd091ae24e0c08c45d91b8f937bd14d2
/* This file was implemented from the information in the book
Understanding and Using COFF
Gintaras R. Gircys
O'Reilly, 1988
and by looking at the Linux kernel code.
It is therefore most likely free to use...
If the file format changes in the COFF object, this file should be
subsequently updated to reflect the changes.
The actual loader module only uses a few of the COFF structures.
Only those are included here. If you wish more information about
COFF, thein check out the book mentioned above.
*/
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#ifndef _COFF_H
#define _COFF_H
/*
* Intel 386/486
*/
/*
* FILE HEADER
*/
typedef struct COFF_filehdr {
unsigned short f_magic; /* magic number */
unsigned short f_nscns; /* number of sections */
long f_timdat; /* time & date stamp */
long f_symptr; /* file pointer to symtab */
long f_nsyms; /* number of symtab entries */
unsigned short f_opthdr; /* sizeof(optional hdr) */
unsigned short f_flags; /* flags */
} FILHDR;
/*
* SECTION HEADER
*/
typedef struct COFF_scnhdr {
long s_paddr; /* physical address */
long s_vaddr; /* virtual address */
long s_size; /* section size */
long s_scnptr; /* raw data for section */
long s_relptr; /* relocation */
long s_lnnoptr; /* line numbers */
unsigned short s_nreloc; /* number of relocation entries */
unsigned short s_nlnno; /* number of line number entries */
long s_flags; /* flags */
} SCNHDR;
#define COFF_SCNHDR struct COFF_scnhdr
#define COFF_SCNHSZ sizeof(COFF_SCNHDR)
#define SCNHSZ COFF_SCNHSZ
/*
* the optional COFF header as used by Linux COFF
*/
typedef struct {
} AOUTHDR;
/*
* SYMBOLS
*/
typedef struct COFF_syment {
union {
struct {
long _n_zeroes; /* Leading zeros */
long _n_offset; /* Offset for a header section */
} _n_n;
} _n;
long n_value; /* address of the segment */
short n_scnum; /* Section number */
unsigned short n_type; /* Type of section */
char n_sclass; /* Loader class */
char n_numaux; /* Number of aux entries following */
} SYMENT;
#define SYMNMLEN COFF_E_SYMNMLEN
/* Special section number found in the symbol section */
#define N_UNDEF 0
#define N_ABS -1
#define N_DEBUG -2
/* Symbol storage class values */
#define C_NULL 0
#define C_EXT 2
#define C_FILE 103
#define C_HIDEXT 107
/*
* AUX Entries
*/
typedef struct COFF_auxent {
long x_scnlen;
long x_parmhash;
unsigned short x_snhash;
unsigned char x_smtyp;
unsigned char x_smclas;
long x_stab;
unsigned short x_snstab;
} AUXENT;
/* Auxillary Symbol type values */
#define XTY_ER 0 /* Enternal Reference */
/* Auxillary Symbol storage mapping class values */
#define XMC_PR 0 /* Program code */
/*
* RELOCATION DIRECTIVES
*/
typedef struct COFF_reloc {
long r_vaddr; /* Virtual address of item */
long r_symndx; /* Symbol index in the symtab */
#if defined(__powerpc__)
union {
unsigned short _r_type; /* old style coff relocation type */
struct {
char _r_rsize; /* sign and reloc bit len */
char _r_rtype; /* toc relocation type */
} _r_r;
} _r;
#else
unsigned short r_type; /* Relocation type */
#endif
} RELOC;
#define COFF_RELOC struct COFF_reloc
#define COFF_RELSZ 10
#define RELSZ COFF_RELSZ
/*
* x86 Relocation types
*/
#define R_ABS 000
#define R_DIR32 006
#define R_PCRLONG 024
#if defined(__powerpc__)
/*
* Power PC
*/
/*
* POWER and PowerPC - relocation types
*/
/* modifiable instruction */
/* modifiable to R_RBR */
#endif /* __powerpc */
#endif /* _COFF_H */