Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/include/linux
File: coff.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
[0] Fix | Delete
/* This file is derived from the GAS 2.1.4 assembler control file.
[1] Fix | Delete
The GAS product is under the GNU General Public License, version 2 or later.
[2] Fix | Delete
As such, this file is also under that license.
[3] Fix | Delete
[4] Fix | Delete
If the file format changes in the COFF object, this file should be
[5] Fix | Delete
subsequently updated to reflect the changes.
[6] Fix | Delete
[7] Fix | Delete
The actual loader module only uses a few of these structures. The full
[8] Fix | Delete
set is documented here because I received the full set. If you wish
[9] Fix | Delete
more information about COFF, then O'Reilly has a very excellent book.
[10] Fix | Delete
*/
[11] Fix | Delete
[12] Fix | Delete
#define E_SYMNMLEN 8 /* Number of characters in a symbol name */
[13] Fix | Delete
#define E_FILNMLEN 14 /* Number of characters in a file name */
[14] Fix | Delete
#define E_DIMNUM 4 /* Number of array dimensions in auxiliary entry */
[15] Fix | Delete
[16] Fix | Delete
/*
[17] Fix | Delete
* These defines are byte order independent. There is no alignment of fields
[18] Fix | Delete
* permitted in the structures. Therefore they are declared as characters
[19] Fix | Delete
* and the values loaded from the character positions. It also makes it
[20] Fix | Delete
* nice to have it "endian" independent.
[21] Fix | Delete
*/
[22] Fix | Delete
[23] Fix | Delete
/* Load a short int from the following tables with little-endian formats */
[24] Fix | Delete
#define COFF_SHORT_L(ps) ((short)(((unsigned short)((unsigned char)ps[1])<<8)|\
[25] Fix | Delete
((unsigned short)((unsigned char)ps[0]))))
[26] Fix | Delete
[27] Fix | Delete
/* Load a long int from the following tables with little-endian formats */
[28] Fix | Delete
#define COFF_LONG_L(ps) (((long)(((unsigned long)((unsigned char)ps[3])<<24) |\
[29] Fix | Delete
((unsigned long)((unsigned char)ps[2])<<16) |\
[30] Fix | Delete
((unsigned long)((unsigned char)ps[1])<<8) |\
[31] Fix | Delete
((unsigned long)((unsigned char)ps[0])))))
[32] Fix | Delete
[33] Fix | Delete
/* Load a short int from the following tables with big-endian formats */
[34] Fix | Delete
#define COFF_SHORT_H(ps) ((short)(((unsigned short)((unsigned char)ps[0])<<8)|\
[35] Fix | Delete
((unsigned short)((unsigned char)ps[1]))))
[36] Fix | Delete
[37] Fix | Delete
/* Load a long int from the following tables with big-endian formats */
[38] Fix | Delete
#define COFF_LONG_H(ps) (((long)(((unsigned long)((unsigned char)ps[0])<<24) |\
[39] Fix | Delete
((unsigned long)((unsigned char)ps[1])<<16) |\
[40] Fix | Delete
((unsigned long)((unsigned char)ps[2])<<8) |\
[41] Fix | Delete
((unsigned long)((unsigned char)ps[3])))))
[42] Fix | Delete
[43] Fix | Delete
/* These may be overridden later by brain dead implementations which generate
[44] Fix | Delete
a big-endian header with little-endian data. In that case, generate a
[45] Fix | Delete
replacement macro which tests a flag and uses either of the two above
[46] Fix | Delete
as appropriate. */
[47] Fix | Delete
[48] Fix | Delete
#define COFF_LONG(v) COFF_LONG_L(v)
[49] Fix | Delete
#define COFF_SHORT(v) COFF_SHORT_L(v)
[50] Fix | Delete
[51] Fix | Delete
/*** coff information for Intel 386/486. */
[52] Fix | Delete
[53] Fix | Delete
/********************** FILE HEADER **********************/
[54] Fix | Delete
[55] Fix | Delete
struct COFF_filehdr {
[56] Fix | Delete
char f_magic[2]; /* magic number */
[57] Fix | Delete
char f_nscns[2]; /* number of sections */
[58] Fix | Delete
char f_timdat[4]; /* time & date stamp */
[59] Fix | Delete
char f_symptr[4]; /* file pointer to symtab */
[60] Fix | Delete
char f_nsyms[4]; /* number of symtab entries */
[61] Fix | Delete
char f_opthdr[2]; /* sizeof(optional hdr) */
[62] Fix | Delete
char f_flags[2]; /* flags */
[63] Fix | Delete
};
[64] Fix | Delete
[65] Fix | Delete
/*
[66] Fix | Delete
* Bits for f_flags:
[67] Fix | Delete
*
[68] Fix | Delete
* F_RELFLG relocation info stripped from file
[69] Fix | Delete
* F_EXEC file is executable (i.e. no unresolved external
[70] Fix | Delete
* references)
[71] Fix | Delete
* F_LNNO line numbers stripped from file
[72] Fix | Delete
* F_LSYMS local symbols stripped from file
[73] Fix | Delete
* F_MINMAL this is a minimal object file (".m") output of fextract
[74] Fix | Delete
* F_UPDATE this is a fully bound update file, output of ogen
[75] Fix | Delete
* F_SWABD this file has had its bytes swabbed (in names)
[76] Fix | Delete
* F_AR16WR this file has the byte ordering of an AR16WR
[77] Fix | Delete
* (e.g. 11/70) machine
[78] Fix | Delete
* F_AR32WR this file has the byte ordering of an AR32WR machine
[79] Fix | Delete
* (e.g. vax and iNTEL 386)
[80] Fix | Delete
* F_AR32W this file has the byte ordering of an AR32W machine
[81] Fix | Delete
* (e.g. 3b,maxi)
[82] Fix | Delete
* F_PATCH file contains "patch" list in optional header
[83] Fix | Delete
* F_NODF (minimal file only) no decision functions for
[84] Fix | Delete
* replaced functions
[85] Fix | Delete
*/
[86] Fix | Delete
[87] Fix | Delete
#define COFF_F_RELFLG 0000001
[88] Fix | Delete
#define COFF_F_EXEC 0000002
[89] Fix | Delete
#define COFF_F_LNNO 0000004
[90] Fix | Delete
#define COFF_F_LSYMS 0000010
[91] Fix | Delete
#define COFF_F_MINMAL 0000020
[92] Fix | Delete
#define COFF_F_UPDATE 0000040
[93] Fix | Delete
#define COFF_F_SWABD 0000100
[94] Fix | Delete
#define COFF_F_AR16WR 0000200
[95] Fix | Delete
#define COFF_F_AR32WR 0000400
[96] Fix | Delete
#define COFF_F_AR32W 0001000
[97] Fix | Delete
#define COFF_F_PATCH 0002000
[98] Fix | Delete
#define COFF_F_NODF 0002000
[99] Fix | Delete
[100] Fix | Delete
#define COFF_I386MAGIC 0x14c /* Linux's system */
[101] Fix | Delete
[102] Fix | Delete
#if 0 /* Perhaps, someday, these formats may be used. */
[103] Fix | Delete
#define COFF_I386PTXMAGIC 0x154
[104] Fix | Delete
#define COFF_I386AIXMAGIC 0x175 /* IBM's AIX system */
[105] Fix | Delete
#define COFF_I386BADMAG(x) ((COFF_SHORT((x).f_magic) != COFF_I386MAGIC) \
[106] Fix | Delete
&& COFF_SHORT((x).f_magic) != COFF_I386PTXMAGIC \
[107] Fix | Delete
&& COFF_SHORT((x).f_magic) != COFF_I386AIXMAGIC)
[108] Fix | Delete
#else
[109] Fix | Delete
#define COFF_I386BADMAG(x) (COFF_SHORT((x).f_magic) != COFF_I386MAGIC)
[110] Fix | Delete
#endif
[111] Fix | Delete
[112] Fix | Delete
#define COFF_FILHDR struct COFF_filehdr
[113] Fix | Delete
#define COFF_FILHSZ sizeof(COFF_FILHDR)
[114] Fix | Delete
[115] Fix | Delete
/********************** AOUT "OPTIONAL HEADER" **********************/
[116] Fix | Delete
[117] Fix | Delete
/* Linux COFF must have this "optional" header. Standard COFF has no entry
[118] Fix | Delete
location for the "entry" point. They normally would start with the first
[119] Fix | Delete
location of the .text section. This is not a good idea for linux. So,
[120] Fix | Delete
the use of this "optional" header is not optional. It is required.
[121] Fix | Delete
[122] Fix | Delete
Do not be tempted to assume that the size of the optional header is
[123] Fix | Delete
a constant and simply index the next byte by the size of this structure.
[124] Fix | Delete
Use the 'f_opthdr' field in the main coff header for the size of the
[125] Fix | Delete
structure actually written to the file!!
[126] Fix | Delete
*/
[127] Fix | Delete
[128] Fix | Delete
typedef struct
[129] Fix | Delete
{
[130] Fix | Delete
char magic[2]; /* type of file */
[131] Fix | Delete
char vstamp[2]; /* version stamp */
[132] Fix | Delete
char tsize[4]; /* text size in bytes, padded to FW bdry */
[133] Fix | Delete
char dsize[4]; /* initialized data " " */
[134] Fix | Delete
char bsize[4]; /* uninitialized data " " */
[135] Fix | Delete
char entry[4]; /* entry pt. */
[136] Fix | Delete
char text_start[4]; /* base of text used for this file */
[137] Fix | Delete
char data_start[4]; /* base of data used for this file */
[138] Fix | Delete
}
[139] Fix | Delete
COFF_AOUTHDR;
[140] Fix | Delete
[141] Fix | Delete
#define COFF_AOUTSZ (sizeof(COFF_AOUTHDR))
[142] Fix | Delete
[143] Fix | Delete
#define COFF_STMAGIC 0401
[144] Fix | Delete
#define COFF_OMAGIC 0404
[145] Fix | Delete
#define COFF_JMAGIC 0407 /* dirty text and data image, can't share */
[146] Fix | Delete
#define COFF_DMAGIC 0410 /* dirty text segment, data aligned */
[147] Fix | Delete
#define COFF_ZMAGIC 0413 /* The proper magic number for executables */
[148] Fix | Delete
#define COFF_SHMAGIC 0443 /* shared library header */
[149] Fix | Delete
[150] Fix | Delete
/********************** SECTION HEADER **********************/
[151] Fix | Delete
[152] Fix | Delete
struct COFF_scnhdr {
[153] Fix | Delete
char s_name[8]; /* section name */
[154] Fix | Delete
char s_paddr[4]; /* physical address, aliased s_nlib */
[155] Fix | Delete
char s_vaddr[4]; /* virtual address */
[156] Fix | Delete
char s_size[4]; /* section size */
[157] Fix | Delete
char s_scnptr[4]; /* file ptr to raw data for section */
[158] Fix | Delete
char s_relptr[4]; /* file ptr to relocation */
[159] Fix | Delete
char s_lnnoptr[4]; /* file ptr to line numbers */
[160] Fix | Delete
char s_nreloc[2]; /* number of relocation entries */
[161] Fix | Delete
char s_nlnno[2]; /* number of line number entries */
[162] Fix | Delete
char s_flags[4]; /* flags */
[163] Fix | Delete
};
[164] Fix | Delete
[165] Fix | Delete
#define COFF_SCNHDR struct COFF_scnhdr
[166] Fix | Delete
#define COFF_SCNHSZ sizeof(COFF_SCNHDR)
[167] Fix | Delete
[168] Fix | Delete
/*
[169] Fix | Delete
* names of "special" sections
[170] Fix | Delete
*/
[171] Fix | Delete
[172] Fix | Delete
#define COFF_TEXT ".text"
[173] Fix | Delete
#define COFF_DATA ".data"
[174] Fix | Delete
#define COFF_BSS ".bss"
[175] Fix | Delete
#define COFF_COMMENT ".comment"
[176] Fix | Delete
#define COFF_LIB ".lib"
[177] Fix | Delete
[178] Fix | Delete
#define COFF_SECT_TEXT 0 /* Section for instruction code */
[179] Fix | Delete
#define COFF_SECT_DATA 1 /* Section for initialized globals */
[180] Fix | Delete
#define COFF_SECT_BSS 2 /* Section for un-initialized globals */
[181] Fix | Delete
#define COFF_SECT_REQD 3 /* Minimum number of sections for good file */
[182] Fix | Delete
[183] Fix | Delete
#define COFF_STYP_REG 0x00 /* regular segment */
[184] Fix | Delete
#define COFF_STYP_DSECT 0x01 /* dummy segment */
[185] Fix | Delete
#define COFF_STYP_NOLOAD 0x02 /* no-load segment */
[186] Fix | Delete
#define COFF_STYP_GROUP 0x04 /* group segment */
[187] Fix | Delete
#define COFF_STYP_PAD 0x08 /* .pad segment */
[188] Fix | Delete
#define COFF_STYP_COPY 0x10 /* copy section */
[189] Fix | Delete
#define COFF_STYP_TEXT 0x20 /* .text segment */
[190] Fix | Delete
#define COFF_STYP_DATA 0x40 /* .data segment */
[191] Fix | Delete
#define COFF_STYP_BSS 0x80 /* .bss segment */
[192] Fix | Delete
#define COFF_STYP_INFO 0x200 /* .comment section */
[193] Fix | Delete
#define COFF_STYP_OVER 0x400 /* overlay section */
[194] Fix | Delete
#define COFF_STYP_LIB 0x800 /* library section */
[195] Fix | Delete
[196] Fix | Delete
/*
[197] Fix | Delete
* Shared libraries have the following section header in the data field for
[198] Fix | Delete
* each library.
[199] Fix | Delete
*/
[200] Fix | Delete
[201] Fix | Delete
struct COFF_slib {
[202] Fix | Delete
char sl_entsz[4]; /* Size of this entry */
[203] Fix | Delete
char sl_pathndx[4]; /* size of the header field */
[204] Fix | Delete
};
[205] Fix | Delete
[206] Fix | Delete
#define COFF_SLIBHD struct COFF_slib
[207] Fix | Delete
#define COFF_SLIBSZ sizeof(COFF_SLIBHD)
[208] Fix | Delete
[209] Fix | Delete
/********************** LINE NUMBERS **********************/
[210] Fix | Delete
[211] Fix | Delete
/* 1 line number entry for every "breakpointable" source line in a section.
[212] Fix | Delete
* Line numbers are grouped on a per function basis; first entry in a function
[213] Fix | Delete
* grouping will have l_lnno = 0 and in place of physical address will be the
[214] Fix | Delete
* symbol table index of the function name.
[215] Fix | Delete
*/
[216] Fix | Delete
[217] Fix | Delete
struct COFF_lineno {
[218] Fix | Delete
union {
[219] Fix | Delete
char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
[220] Fix | Delete
char l_paddr[4]; /* (physical) address of line number */
[221] Fix | Delete
} l_addr;
[222] Fix | Delete
char l_lnno[2]; /* line number */
[223] Fix | Delete
};
[224] Fix | Delete
[225] Fix | Delete
#define COFF_LINENO struct COFF_lineno
[226] Fix | Delete
#define COFF_LINESZ 6
[227] Fix | Delete
[228] Fix | Delete
/********************** SYMBOLS **********************/
[229] Fix | Delete
[230] Fix | Delete
#define COFF_E_SYMNMLEN 8 /* # characters in a short symbol name */
[231] Fix | Delete
#define COFF_E_FILNMLEN 14 /* # characters in a file name */
[232] Fix | Delete
#define COFF_E_DIMNUM 4 /* # array dimensions in auxiliary entry */
[233] Fix | Delete
[234] Fix | Delete
/*
[235] Fix | Delete
* All symbols and sections have the following definition
[236] Fix | Delete
*/
[237] Fix | Delete
[238] Fix | Delete
struct COFF_syment
[239] Fix | Delete
{
[240] Fix | Delete
union {
[241] Fix | Delete
char e_name[E_SYMNMLEN]; /* Symbol name (first 8 characters) */
[242] Fix | Delete
struct {
[243] Fix | Delete
char e_zeroes[4]; /* Leading zeros */
[244] Fix | Delete
char e_offset[4]; /* Offset if this is a header section */
[245] Fix | Delete
} e;
[246] Fix | Delete
} e;
[247] Fix | Delete
[248] Fix | Delete
char e_value[4]; /* Value (address) of the segment */
[249] Fix | Delete
char e_scnum[2]; /* Section number */
[250] Fix | Delete
char e_type[2]; /* Type of section */
[251] Fix | Delete
char e_sclass[1]; /* Loader class */
[252] Fix | Delete
char e_numaux[1]; /* Number of auxiliary entries which follow */
[253] Fix | Delete
};
[254] Fix | Delete
[255] Fix | Delete
#define COFF_N_BTMASK (0xf) /* Mask for important class bits */
[256] Fix | Delete
#define COFF_N_TMASK (0x30) /* Mask for important type bits */
[257] Fix | Delete
#define COFF_N_BTSHFT (4) /* # bits to shift class field */
[258] Fix | Delete
#define COFF_N_TSHIFT (2) /* # bits to shift type field */
[259] Fix | Delete
[260] Fix | Delete
/*
[261] Fix | Delete
* Auxiliary entries because the main table is too limiting.
[262] Fix | Delete
*/
[263] Fix | Delete
[264] Fix | Delete
union COFF_auxent {
[265] Fix | Delete
[266] Fix | Delete
/*
[267] Fix | Delete
* Debugger information
[268] Fix | Delete
*/
[269] Fix | Delete
[270] Fix | Delete
struct {
[271] Fix | Delete
char x_tagndx[4]; /* str, un, or enum tag indx */
[272] Fix | Delete
union {
[273] Fix | Delete
struct {
[274] Fix | Delete
char x_lnno[2]; /* declaration line number */
[275] Fix | Delete
char x_size[2]; /* str/union/array size */
[276] Fix | Delete
} x_lnsz;
[277] Fix | Delete
char x_fsize[4]; /* size of function */
[278] Fix | Delete
} x_misc;
[279] Fix | Delete
[280] Fix | Delete
union {
[281] Fix | Delete
struct { /* if ISFCN, tag, or .bb */
[282] Fix | Delete
char x_lnnoptr[4]; /* ptr to fcn line # */
[283] Fix | Delete
char x_endndx[4]; /* entry ndx past block end */
[284] Fix | Delete
} x_fcn;
[285] Fix | Delete
[286] Fix | Delete
struct { /* if ISARY, up to 4 dimen. */
[287] Fix | Delete
char x_dimen[E_DIMNUM][2];
[288] Fix | Delete
} x_ary;
[289] Fix | Delete
} x_fcnary;
[290] Fix | Delete
[291] Fix | Delete
char x_tvndx[2]; /* tv index */
[292] Fix | Delete
} x_sym;
[293] Fix | Delete
[294] Fix | Delete
/*
[295] Fix | Delete
* Source file names (debugger information)
[296] Fix | Delete
*/
[297] Fix | Delete
[298] Fix | Delete
union {
[299] Fix | Delete
char x_fname[E_FILNMLEN];
[300] Fix | Delete
struct {
[301] Fix | Delete
char x_zeroes[4];
[302] Fix | Delete
char x_offset[4];
[303] Fix | Delete
} x_n;
[304] Fix | Delete
} x_file;
[305] Fix | Delete
[306] Fix | Delete
/*
[307] Fix | Delete
* Section information
[308] Fix | Delete
*/
[309] Fix | Delete
[310] Fix | Delete
struct {
[311] Fix | Delete
char x_scnlen[4]; /* section length */
[312] Fix | Delete
char x_nreloc[2]; /* # relocation entries */
[313] Fix | Delete
char x_nlinno[2]; /* # line numbers */
[314] Fix | Delete
} x_scn;
[315] Fix | Delete
[316] Fix | Delete
/*
[317] Fix | Delete
* Transfer vector (branch table)
[318] Fix | Delete
*/
[319] Fix | Delete
[320] Fix | Delete
struct {
[321] Fix | Delete
char x_tvfill[4]; /* tv fill value */
[322] Fix | Delete
char x_tvlen[2]; /* length of .tv */
[323] Fix | Delete
char x_tvran[2][2]; /* tv range */
[324] Fix | Delete
} x_tv; /* info about .tv section (in auxent of symbol .tv)) */
[325] Fix | Delete
};
[326] Fix | Delete
[327] Fix | Delete
#define COFF_SYMENT struct COFF_syment
[328] Fix | Delete
#define COFF_SYMESZ 18
[329] Fix | Delete
#define COFF_AUXENT union COFF_auxent
[330] Fix | Delete
#define COFF_AUXESZ 18
[331] Fix | Delete
[332] Fix | Delete
#define COFF_ETEXT "etext"
[333] Fix | Delete
[334] Fix | Delete
/********************** RELOCATION DIRECTIVES **********************/
[335] Fix | Delete
[336] Fix | Delete
struct COFF_reloc {
[337] Fix | Delete
char r_vaddr[4]; /* Virtual address of item */
[338] Fix | Delete
char r_symndx[4]; /* Symbol index in the symtab */
[339] Fix | Delete
char r_type[2]; /* Relocation type */
[340] Fix | Delete
};
[341] Fix | Delete
[342] Fix | Delete
#define COFF_RELOC struct COFF_reloc
[343] Fix | Delete
#define COFF_RELSZ 10
[344] Fix | Delete
[345] Fix | Delete
#define COFF_DEF_DATA_SECTION_ALIGNMENT 4
[346] Fix | Delete
#define COFF_DEF_BSS_SECTION_ALIGNMENT 4
[347] Fix | Delete
#define COFF_DEF_TEXT_SECTION_ALIGNMENT 4
[348] Fix | Delete
[349] Fix | Delete
/* For new sections we haven't heard of before */
[350] Fix | Delete
#define COFF_DEF_SECTION_ALIGNMENT 4
[351] Fix | Delete
[352] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function