summaryrefslogtreecommitdiffstats
path: root/usr.sbin/kgzip/elfhdr.c
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2003-03-11 11:45:43 +0000
committerru <ru@FreeBSD.org>2003-03-11 11:45:43 +0000
commit1620c05a8d0e629f775d3a7dd201fc4822387ee4 (patch)
treea7c1258165b86e8473af6e1d335a71e2424089f1 /usr.sbin/kgzip/elfhdr.c
parenta88b815b0805cd6a43776e97af0263e0149451e9 (diff)
downloadFreeBSD-src-1620c05a8d0e629f775d3a7dd201fc4822387ee4.zip
FreeBSD-src-1620c05a8d0e629f775d3a7dd201fc4822387ee4.tar.gz
Convert kgzip(8) to be an i386 cross-tool. This is needed for
cross-releasing i386 on different architectures. This version provides an i386 version of <a.out.h>, and handles endianness. Tested on: alpha, sparc64
Diffstat (limited to 'usr.sbin/kgzip/elfhdr.c')
-rw-r--r--usr.sbin/kgzip/elfhdr.c91
1 files changed, 46 insertions, 45 deletions
diff --git a/usr.sbin/kgzip/elfhdr.c b/usr.sbin/kgzip/elfhdr.c
index d3abec7..50bb0b7 100644
--- a/usr.sbin/kgzip/elfhdr.c
+++ b/usr.sbin/kgzip/elfhdr.c
@@ -28,6 +28,7 @@
#include <stddef.h>
#include "elfhdr.h"
+#include "endian.h"
#define KGZ_FIX_NSIZE 0 /* Run-time fixup */
@@ -42,80 +43,80 @@ const struct kgz_elfhdr elfhdr = {
ELFCLASS32, ELFDATA2LSB, EV_CURRENT, 0,
'F', 'r', 'e', 'e', 'B', 'S', 'D', 0
},
- ET_EXEC, /* e_type */
- EM_386, /* e_machine */
- EV_CURRENT, /* e_version */
+ HTOLE16(ET_EXEC), /* e_type */
+ HTOLE16(EM_386), /* e_machine */
+ HTOLE32(EV_CURRENT), /* e_version */
0, /* e_entry */
0, /* e_phoff */
- offsetof(struct kgz_elfhdr, sh), /* e_shoff */
+ HTOLE32(offsetof(struct kgz_elfhdr, sh)), /* e_shoff */
0, /* e_flags */
- sizeof(Elf32_Ehdr), /* e_ehsize */
+ HTOLE16(sizeof(Elf32_Ehdr)), /* e_ehsize */
0, /* e_phentsize */
0, /* e_phnum */
- sizeof(Elf32_Shdr), /* e_shentsize */
- KGZ_SHNUM, /* e_shnum */
- KGZ_SH_SHSTRTAB /* e_shstrndx */
+ HTOLE16(sizeof(Elf32_Shdr)), /* e_shentsize */
+ HTOLE16(KGZ_SHNUM), /* e_shnum */
+ HTOLE16(KGZ_SH_SHSTRTAB) /* e_shstrndx */
},
/* Section header */
{
{
0, /* sh_name */
- SHT_NULL, /* sh_type */
+ HTOLE32(SHT_NULL), /* sh_type */
0, /* sh_flags */
0, /* sh_addr */
0, /* sh_offset */
0, /* sh_size */
- SHN_UNDEF, /* sh_link */
+ HTOLE32(SHN_UNDEF), /* sh_link */
0, /* sh_info */
0, /* sh_addralign */
0 /* sh_entsize */
},
{
- offsetof(struct kgz_shstrtab, symtab), /* sh_name */
- SHT_SYMTAB, /* sh_type */
+ HTOLE32(offsetof(struct kgz_shstrtab, symtab)), /* sh_name */
+ HTOLE32(SHT_SYMTAB), /* sh_type */
0, /* sh_flags */
0, /* sh_addr */
- offsetof(struct kgz_elfhdr, st), /* sh_offset */
- sizeof(Elf32_Sym) * KGZ_STNUM, /* sh_size */
- KGZ_SH_STRTAB, /* sh_link */
- 1, /* sh_info */
- 4, /* sh_addralign */
- sizeof(Elf32_Sym) /* sh_entsize */
+ HTOLE32(offsetof(struct kgz_elfhdr, st)), /* sh_offset */
+ HTOLE32(sizeof(Elf32_Sym) * KGZ_STNUM), /* sh_size */
+ HTOLE32(KGZ_SH_STRTAB), /* sh_link */
+ HTOLE32(1), /* sh_info */
+ HTOLE32(4), /* sh_addralign */
+ HTOLE32(sizeof(Elf32_Sym)) /* sh_entsize */
},
{
- offsetof(struct kgz_shstrtab, shstrtab), /* sh_name */
- SHT_STRTAB, /* sh_type */
+ HTOLE32(offsetof(struct kgz_shstrtab, shstrtab)), /* sh_name */
+ HTOLE32(SHT_STRTAB), /* sh_type */
0, /* sh_flags */
0, /* sh_addr */
- offsetof(struct kgz_elfhdr, shstrtab), /* sh_offset */
- sizeof(struct kgz_shstrtab), /* sh_size */
- SHN_UNDEF, /* sh_link */
+ HTOLE32(offsetof(struct kgz_elfhdr, shstrtab)), /* sh_offset */
+ HTOLE32(sizeof(struct kgz_shstrtab)), /* sh_size */
+ HTOLE32(SHN_UNDEF), /* sh_link */
0, /* sh_info */
- 1, /* sh_addralign */
+ HTOLE32(1), /* sh_addralign */
0 /* sh_entsize */
},
{
- offsetof(struct kgz_shstrtab, strtab), /* sh_name */
- SHT_STRTAB, /* sh_type */
+ HTOLE32(offsetof(struct kgz_shstrtab, strtab)), /* sh_name */
+ HTOLE32(SHT_STRTAB), /* sh_type */
0, /* sh_flags */
0, /* sh_addr */
- offsetof(struct kgz_elfhdr, strtab), /* sh_offset */
- sizeof(struct kgz_strtab), /* sh_size */
- SHN_UNDEF, /* sh_link */
+ HTOLE32(offsetof(struct kgz_elfhdr, strtab)), /* sh_offset */
+ HTOLE32(sizeof(struct kgz_strtab)), /* sh_size */
+ HTOLE32(SHN_UNDEF), /* sh_link */
0, /* sh_info */
- 1, /* sh_addralign */
+ HTOLE32(1), /* sh_addralign */
0 /* sh_entsize */
},
{
- offsetof(struct kgz_shstrtab, data), /* sh_name */
- SHT_PROGBITS, /* sh_type */
- SHF_ALLOC | SHF_WRITE, /* sh_flags */
+ HTOLE32(offsetof(struct kgz_shstrtab, data)), /* sh_name */
+ HTOLE32(SHT_PROGBITS), /* sh_type */
+ HTOLE32(SHF_ALLOC | SHF_WRITE), /* sh_flags */
0, /* sh_addr */
- sizeof(struct kgz_elfhdr), /* sh_offset */
- sizeof(struct kgz_hdr) + KGZ_FIX_NSIZE, /* sh_size */
- SHN_UNDEF, /* sh_link */
+ HTOLE32(sizeof(struct kgz_elfhdr)), /* sh_offset */
+ HTOLE32(sizeof(struct kgz_hdr) + KGZ_FIX_NSIZE), /* sh_size */
+ HTOLE32(SHN_UNDEF), /* sh_link */
0, /* sh_info */
- 4, /* sh_addralign */
+ HTOLE32(4), /* sh_addralign */
0 /* sh_entsize */
}
},
@@ -127,23 +128,23 @@ const struct kgz_elfhdr elfhdr = {
0, /* st_size */
0, /* st_info */
0, /* st_other */
- SHN_UNDEF /* st_shndx */
+ HTOLE16(SHN_UNDEF) /* st_shndx */
},
{
- offsetof(struct kgz_strtab, kgz), /* st_name */
+ HTOLE32(offsetof(struct kgz_strtab, kgz)), /* st_name */
0, /* st_value */
- sizeof(struct kgz_hdr), /* st_size */
+ HTOLE32(sizeof(struct kgz_hdr)), /* st_size */
ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT), /* st_info */
0, /* st_other */
- KGZ_SH_DATA /* st_shndx */
+ HTOLE16(KGZ_SH_DATA) /* st_shndx */
},
{
- offsetof(struct kgz_strtab, kgz_ndata), /* st_name */
- sizeof(struct kgz_hdr), /* st_value */
- KGZ_FIX_NSIZE, /* st_size */
+ HTOLE32(offsetof(struct kgz_strtab, kgz_ndata)), /* st_name */
+ HTOLE32(sizeof(struct kgz_hdr)), /* st_value */
+ HTOLE32(KGZ_FIX_NSIZE), /* st_size */
ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT), /* st_info */
0, /* st_other */
- KGZ_SH_DATA /* st_shndx */
+ HTOLE16(KGZ_SH_DATA) /* st_shndx */
}
},
/* Section header string table */
OpenPOWER on IntegriCloud