elf.h

Go to the documentation of this file.
00001 /*      $NetBSD: elf.h,v 1.2 1995/03/28 18:19:14 jtc Exp $      */
00002 
00003 /*
00004  * Copyright (c) 1994 Ted Lemon
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. All advertising materials mentioning features or use of this software
00015  *    must display the following acknowledgement:
00016  *      This product includes software developed by the University of
00017  *      California, Berkeley and its contributors.
00018  * 4. Neither the name of the University nor the names of its contributors
00019  *    may be used to endorse or promote products derived from this software
00020  *    without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  */
00035 
00036 #ifndef __MACHINE_ELF_H__
00037 #define __MACHINE_ELF_H__
00038 
00039 /* ELF executable header... */
00040 struct ehdr {
00041   char elf_magic [4];           /* Elf magic number... */
00042   unsigned long magic [3];      /* Magic number... */
00043   unsigned short type;          /* Object file type... */
00044   unsigned short machine;       /* Machine ID... */
00045   unsigned long version;        /* File format version... */
00046   unsigned long entry;          /* Entry point... */
00047   unsigned long phoff;          /* Program header table offset... */
00048   unsigned long shoff;          /* Section header table offset... */
00049   unsigned long flags;          /* Processor-specific flags... */
00050   unsigned short ehsize;        /* Elf header size in bytes... */
00051   unsigned short phsize;        /* Program header size... */
00052   unsigned short phcount;       /* Program header count... */
00053   unsigned short shsize;        /* Section header size... */
00054   unsigned short shcount;       /* Section header count... */
00055   unsigned short shstrndx;      /* Section header string table index... */
00056 };
00057 
00058 /* Program header... */
00059 struct phdr {
00060   unsigned long type;           /* Segment type... */
00061   unsigned long offset;         /* File offset... */
00062   unsigned long vaddr;          /* Virtual address... */
00063   unsigned long paddr;          /* Physical address... */
00064   unsigned long filesz;         /* Size of segment in file... */
00065   unsigned long memsz;          /* Size of segment in memory... */
00066   unsigned long flags;          /* Segment flags... */
00067   unsigned long align;          /* Alighment, file and memory... */
00068 };
00069 
00070 /* Section header... */
00071 struct shdr {
00072   unsigned long name;           /* Offset into string table of section name */
00073   unsigned long type;           /* Type of section... */
00074   unsigned long flags;          /* Section flags... */
00075   unsigned long addr;           /* Section virtual address at execution... */
00076   unsigned long offset;         /* Section file offset... */
00077   unsigned long size;           /* Section size... */
00078   unsigned long link;           /* Link to another section... */
00079   unsigned long info;           /* Additional section info... */
00080   unsigned long align;          /* Section alignment... */
00081   unsigned long esize;          /* Entry size if section holds table... */
00082 };
00083 
00084 /* Symbol table entry... */
00085 struct sym {
00086   unsigned long name;           /* Index into strtab of symbol name. */
00087   unsigned long value;          /* Section offset, virt addr or common align. */
00088   unsigned long size;           /* Size of object referenced. */
00089   unsigned type    : 4;         /* Symbol type (e.g., function, data)... */
00090   unsigned binding : 4;         /* Symbol binding (e.g., global, local)... */
00091   unsigned char other;          /* Unused. */
00092   unsigned short shndx;         /* Section containing symbol. */
00093 };
00094 
00095 /* Values for program header type field */
00096 
00097 #define PT_NULL         0               /* Program header table entry unused */
00098 #define PT_LOAD         1               /* Loadable program segment */
00099 #define PT_DYNAMIC      2               /* Dynamic linking information */
00100 #define PT_INTERP       3               /* Program interpreter */
00101 #define PT_NOTE         4               /* Auxiliary information */
00102 #define PT_SHLIB        5               /* Reserved, unspecified semantics */
00103 #define PT_PHDR         6               /* Entry for header table itself */
00104 #define PT_LOPROC       0x70000000      /* Processor-specific */
00105 #define PT_HIPROC       0x7FFFFFFF      /* Processor-specific */
00106 #define PT_MIPS_REGINFO PT_LOPROC       /* Mips reginfo section... */
00107 
00108 /* Program segment permissions, in program header flags field */
00109 
00110 #define PF_X            (1 << 0)        /* Segment is executable */
00111 #define PF_W            (1 << 1)        /* Segment is writable */
00112 #define PF_R            (1 << 2)        /* Segment is readable */
00113 #define PF_MASKPROC     0xF0000000      /* Processor-specific reserved bits */
00114 
00115 /* Reserved section indices... */
00116 #define SHN_UNDEF       0
00117 #define SHN_ABS         0xfff1
00118 #define SHN_COMMON      0xfff2
00119 #define SHN_MIPS_ACOMMON 0xfff0
00120 
00121 /* Symbol bindings... */
00122 #define STB_LOCAL       0
00123 #define STB_GLOBAL      1
00124 #define STB_WEAK        2
00125 
00126 /* Symbol types... */
00127 #define STT_NOTYPE      0
00128 #define STT_OBJECT      1
00129 #define STT_FUNC        2
00130 #define STT_SECTION     3
00131 #define STT_FILE        4
00132 
00133 #define ELF_HDR_SIZE    (sizeof (struct ehdr))
00134 #ifdef _KERNEL
00135 int     pmax_elf_makecmds __P((struct proc *, struct exec_package *));
00136 #endif /* _KERNEL */
00137 #endif /* __MACHINE_ELF_H__ */

Generated on Fri Nov 5 07:24:46 2010 for ejtag debug tools for loongson 232 cpu by  doxygen 1.5.6