xref: /illumos-gate/usr/src/tools/btxld/elfh.h (revision 0cc5983c)
1*0cc5983cSToomas Soome /*
2*0cc5983cSToomas Soome  * Copyright (c) 1998 Robert Nordier
3*0cc5983cSToomas Soome  * All rights reserved.
4*0cc5983cSToomas Soome  *
5*0cc5983cSToomas Soome  * Redistribution and use in source and binary forms, with or without
6*0cc5983cSToomas Soome  * modification, are permitted provided that the following conditions
7*0cc5983cSToomas Soome  * are met:
8*0cc5983cSToomas Soome  * 1. Redistributions of source code must retain the above copyright
9*0cc5983cSToomas Soome  *    notice, this list of conditions and the following disclaimer.
10*0cc5983cSToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
11*0cc5983cSToomas Soome  *    notice, this list of conditions and the following disclaimer in the
12*0cc5983cSToomas Soome  *    documentation and/or other materials provided with the distribution.
13*0cc5983cSToomas Soome  *
14*0cc5983cSToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
15*0cc5983cSToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*0cc5983cSToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17*0cc5983cSToomas Soome  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
18*0cc5983cSToomas Soome  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
19*0cc5983cSToomas Soome  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
20*0cc5983cSToomas Soome  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
21*0cc5983cSToomas Soome  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22*0cc5983cSToomas Soome  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23*0cc5983cSToomas Soome  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24*0cc5983cSToomas Soome  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*0cc5983cSToomas Soome  *
26*0cc5983cSToomas Soome  * $FreeBSD$
27*0cc5983cSToomas Soome  */
28*0cc5983cSToomas Soome 
29*0cc5983cSToomas Soome #include <sys/elf.h>
30*0cc5983cSToomas Soome 
31*0cc5983cSToomas Soome /* e_ident */
32*0cc5983cSToomas Soome #define	IS_ELF(ehdr)	((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
33*0cc5983cSToomas Soome 			 (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
34*0cc5983cSToomas Soome 			 (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
35*0cc5983cSToomas Soome 			 (ehdr).e_ident[EI_MAG3] == ELFMAG3)
36*0cc5983cSToomas Soome 
37*0cc5983cSToomas Soome struct elfh {
38*0cc5983cSToomas Soome     Elf32_Ehdr e;		/* ELF header */
39*0cc5983cSToomas Soome     Elf32_Phdr p[2];		/* program header */
40*0cc5983cSToomas Soome     Elf32_Shdr sh[4];		/* section header */
41*0cc5983cSToomas Soome     char shstrtab[28];		/* section header string table */
42*0cc5983cSToomas Soome };
43*0cc5983cSToomas Soome 
44*0cc5983cSToomas Soome extern const struct elfh elfhdr;	/* ELF header template */
45