2 * Copyright (c) 1999 Global Technology Associates, Inc.
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.
29 #include <sys/endian.h>
33 #define KGZ_FIX_NSIZE 0 /* Run-time fixup */
36 * Relocatable header template.
38 const struct kgz_elfhdr elfhdr = {
42 ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, /* e_ident */
43 ELFCLASS32, ELFDATA2LSB, EV_CURRENT, 0,
44 'F', 'r', 'e', 'e', 'B', 'S', 'D', 0
46 htole16(ET_EXEC), /* e_type */
47 htole16(EM_386), /* e_machine */
48 htole32(EV_CURRENT), /* e_version */
51 htole32(offsetof(struct kgz_elfhdr, sh)), /* e_shoff */
53 htole16(sizeof(Elf32_Ehdr)), /* e_ehsize */
56 htole16(sizeof(Elf32_Shdr)), /* e_shentsize */
57 htole16(KGZ_SHNUM), /* e_shnum */
58 htole16(KGZ_SH_SHSTRTAB) /* e_shstrndx */
64 htole32(SHT_NULL), /* sh_type */
69 htole32(SHN_UNDEF), /* sh_link */
75 htole32(offsetof(struct kgz_shstrtab, symtab)), /* sh_name */
76 htole32(SHT_SYMTAB), /* sh_type */
79 htole32(offsetof(struct kgz_elfhdr, st)), /* sh_offset */
80 htole32(sizeof(Elf32_Sym) * KGZ_STNUM), /* sh_size */
81 htole32(KGZ_SH_STRTAB), /* sh_link */
82 htole32(1), /* sh_info */
83 htole32(4), /* sh_addralign */
84 htole32(sizeof(Elf32_Sym)) /* sh_entsize */
87 htole32(offsetof(struct kgz_shstrtab, shstrtab)), /* sh_name */
88 htole32(SHT_STRTAB), /* sh_type */
91 htole32(offsetof(struct kgz_elfhdr, shstrtab)), /* sh_offset */
92 htole32(sizeof(struct kgz_shstrtab)), /* sh_size */
93 htole32(SHN_UNDEF), /* sh_link */
95 htole32(1), /* sh_addralign */
99 htole32(offsetof(struct kgz_shstrtab, strtab)), /* sh_name */
100 htole32(SHT_STRTAB), /* sh_type */
103 htole32(offsetof(struct kgz_elfhdr, strtab)), /* sh_offset */
104 htole32(sizeof(struct kgz_strtab)), /* sh_size */
105 htole32(SHN_UNDEF), /* sh_link */
107 htole32(1), /* sh_addralign */
111 htole32(offsetof(struct kgz_shstrtab, data)), /* sh_name */
112 htole32(SHT_PROGBITS), /* sh_type */
113 htole32(SHF_ALLOC | SHF_WRITE), /* sh_flags */
115 htole32(sizeof(struct kgz_elfhdr)), /* sh_offset */
116 htole32(sizeof(struct kgz_hdr) + KGZ_FIX_NSIZE), /* sh_size */
117 htole32(SHN_UNDEF), /* sh_link */
119 htole32(4), /* sh_addralign */
131 htole16(SHN_UNDEF) /* st_shndx */
134 htole32(offsetof(struct kgz_strtab, kgz)), /* st_name */
136 htole32(sizeof(struct kgz_hdr)), /* st_size */
137 ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT), /* st_info */
139 htole16(KGZ_SH_DATA) /* st_shndx */
142 htole32(offsetof(struct kgz_strtab, kgz_ndata)), /* st_name */
143 htole32(sizeof(struct kgz_hdr)), /* st_value */
144 htole32(KGZ_FIX_NSIZE), /* st_size */
145 ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT), /* st_info */
147 htole16(KGZ_SH_DATA) /* st_shndx */
150 /* Section header string table */
152 KGZ_SHSTR_ZERO, /* zero */
153 KGZ_SHSTR_SYMTAB, /* symtab */
154 KGZ_SHSTR_SHSTRTAB, /* shstrtab */
155 KGZ_SHSTR_STRTAB, /* strtab */
156 KGZ_SHSTR_DATA /* data */
160 KGZ_STR_ZERO, /* zero */
161 KGZ_STR_KGZ, /* kgz */
162 KGZ_STR_KGZ_NDATA /* kgz_ndata */