2 * Copyright (c) 1998 Robert Nordier
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
19 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
20 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
21 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * $FreeBSD: src/usr.sbin/btxld/elfh.c,v 1.3 2000/01/04 14:10:36 marcel Exp $
27 * $DragonFly: src/usr.sbin/btxld/elfh.c,v 1.2 2003/06/17 04:29:52 dillon Exp $
30 #include <sys/types.h>
35 #define SET_ME 0xeeeeeeee /* filled in by btxld */
38 * ELF header template.
40 const struct elfh elfhdr
= {
43 ELFMAG0
, ELFMAG1
, ELFMAG2
, ELFMAG3
, /* e_ident */
44 ELFCLASS32
, ELFDATA2LSB
, EV_CURRENT
, 0,
45 'F', 'r', 'e', 'e', 'B', 'S', 'D', 0
48 EM_386
, /* e_machine */
49 EV_CURRENT
, /* e_version */
51 offsetof(struct elfh
, p
), /* e_phoff */
52 offsetof(struct elfh
, sh
), /* e_shoff */
54 sizeof(elfhdr
.e
), /* e_ehsize */
55 sizeof(elfhdr
.p
[0]), /* e_phentsize */
56 sizeof(elfhdr
.p
) / sizeof(elfhdr
.p
[0]), /* e_phnum */
57 sizeof(elfhdr
.sh
[0]), /* e_shentsize */
58 sizeof(elfhdr
.sh
) / sizeof(elfhdr
.sh
[0]), /* e_shnum */
64 sizeof(elfhdr
), /* p_offset */
67 SET_ME
, /* p_filesz */
69 PF_R
| PF_X
, /* p_flags */
74 SET_ME
, /* p_offset */
77 SET_ME
, /* p_filesz */
79 PF_R
| PF_W
, /* p_flags */
85 0, SHT_NULL
, 0, 0, 0, 0, SHN_UNDEF
, 0, 0, 0
89 SHT_STRTAB
, /* sh_type */
92 offsetof(struct elfh
, shstrtab
), /* sh_offset */
93 sizeof(elfhdr
.shstrtab
), /* sh_size */
94 SHN_UNDEF
, /* sh_link */
101 SHT_PROGBITS
, /* sh_type */
102 SHF_EXECINSTR
| SHF_ALLOC
, /* sh_flags */
103 SET_ME
, /* sh_addr */
104 SET_ME
, /* sh_offset */
105 SET_ME
, /* sh_size */
106 SHN_UNDEF
, /* sh_link */
108 4, /* sh_addralign */
113 SHT_PROGBITS
, /* sh_type */
114 SHF_ALLOC
| SHF_WRITE
, /* sh_flags */
115 SET_ME
, /* sh_addr */
116 SET_ME
, /* sh_offset */
117 SET_ME
, /* sh_size */
118 SHN_UNDEF
, /* sh_link */
120 4, /* sh_addralign */
124 "\0.shstrtab\0.text\0.data" /* shstrtab */