_IMPLEMENTING LOADABLE KERNEL MODULES FOR LINUX_ by Matt Welsh Listing One /* Header for a.out object and executable files. */ struct exec { unsigned long a_info; /* Describes object file. */ unsigned a_text; /* Length of text segment in bytes */ unsigned a_data; /* Length of data segment */ unsigned a_bss; /* Length of BSS segment */ unsigned a_syms; /* Length of symbol table */ unsigned a_entry; /* Entry point address */ unsigned a_trsize; /* Length of text relocation info */ unsigned a_drsize; /* Length of data relocation info */ }; /* The object file symbol table is an array of struct nlist. */ struct nlist { union { /* Only one of the following are available, based on * context. E.g., n_strx is used when the data is stored * in a file, n_name when in core. */ char *n_name; /* Symbol name */ struct nlist *n_next; /* Next symbol in list */ long n_strx; /* Index to } n_un; unsigned char n_type; /* Type of symbol, e.g., text or data */ char n_other; /* Unused by the system, but useful for insmod */ short n_desc; /* Used by symbolic debuggers */ unsigned n_value; /* Address of this symbol */ }; /* Binary tree of symbols used for relocation. Defined by insmod. */ struct symbol { struct nlist n; struct symbol *child[2]; }; /* Relocation information stored in the module object file */ struct relocation_info { int r_address; /* Address to be relocated */ unsigned int r_symbolnum:24; /* Index of symbol in symbol table */ unsigned int r_pcrel:1; /* 1 for PC-relative offset */ unsigned int r_length:2; /* Relocate (1<