summaryrefslogtreecommitdiffstats
path: root/usr.sbin/btxld/elfh.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/btxld/elfh.c')
-rw-r--r--usr.sbin/btxld/elfh.c103
1 files changed, 52 insertions, 51 deletions
diff --git a/usr.sbin/btxld/elfh.c b/usr.sbin/btxld/elfh.c
index 0f0928b..75b7e33 100644
--- a/usr.sbin/btxld/elfh.c
+++ b/usr.sbin/btxld/elfh.c
@@ -30,6 +30,7 @@
#include <stddef.h>
#include "elfh.h"
+#include "endian.h"
#define SET_ME 0xeeeeeeee /* filled in by btxld */
@@ -43,80 +44,80 @@ const struct elfh 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 */
- SET_ME, /* e_entry */
- offsetof(struct elfh, p), /* e_phoff */
- offsetof(struct elfh, sh), /* e_shoff */
+ HTOLE16(ET_EXEC), /* e_type */
+ HTOLE16(EM_386), /* e_machine */
+ HTOLE32(EV_CURRENT), /* e_version */
+ HTOLE32(SET_ME), /* e_entry */
+ HTOLE32(offsetof(struct elfh, p)), /* e_phoff */
+ HTOLE32(offsetof(struct elfh, sh)), /* e_shoff */
0, /* e_flags */
- sizeof(elfhdr.e), /* e_ehsize */
- sizeof(elfhdr.p[0]), /* e_phentsize */
- sizeof(elfhdr.p) / sizeof(elfhdr.p[0]), /* e_phnum */
- sizeof(elfhdr.sh[0]), /* e_shentsize */
- sizeof(elfhdr.sh) / sizeof(elfhdr.sh[0]), /* e_shnum */
- 1 /* e_shstrndx */
+ HTOLE16(sizeof(elfhdr.e)), /* e_ehsize */
+ HTOLE16(sizeof(elfhdr.p[0])), /* e_phentsize */
+ HTOLE16(sizeof(elfhdr.p) / sizeof(elfhdr.p[0])), /* e_phnum */
+ HTOLE16(sizeof(elfhdr.sh[0])), /* e_shentsize */
+ HTOLE16(sizeof(elfhdr.sh) / sizeof(elfhdr.sh[0])), /* e_shnum */
+ HTOLE16(1) /* e_shstrndx */
},
{
{
- PT_LOAD, /* p_type */
- sizeof(elfhdr), /* p_offset */
- SET_ME, /* p_vaddr */
- SET_ME, /* p_paddr */
- SET_ME, /* p_filesz */
- SET_ME, /* p_memsz */
- PF_R | PF_X, /* p_flags */
- 0x1000 /* p_align */
+ HTOLE32(PT_LOAD), /* p_type */
+ HTOLE32(sizeof(elfhdr)), /* p_offset */
+ HTOLE32(SET_ME), /* p_vaddr */
+ HTOLE32(SET_ME), /* p_paddr */
+ HTOLE32(SET_ME), /* p_filesz */
+ HTOLE32(SET_ME), /* p_memsz */
+ HTOLE32(PF_R | PF_X), /* p_flags */
+ HTOLE32(0x1000) /* p_align */
},
{
- PT_LOAD, /* p_type */
- SET_ME, /* p_offset */
- SET_ME, /* p_vaddr */
- SET_ME, /* p_paddr */
- SET_ME, /* p_filesz */
- SET_ME, /* p_memsz */
- PF_R | PF_W, /* p_flags */
- 0x1000 /* p_align */
+ HTOLE32(PT_LOAD), /* p_type */
+ HTOLE32(SET_ME), /* p_offset */
+ HTOLE32(SET_ME), /* p_vaddr */
+ HTOLE32(SET_ME), /* p_paddr */
+ HTOLE32(SET_ME), /* p_filesz */
+ HTOLE32(SET_ME), /* p_memsz */
+ HTOLE32(PF_R | PF_W), /* p_flags */
+ HTOLE32(0x1000) /* p_align */
}
},
{
{
- 0, SHT_NULL, 0, 0, 0, 0, SHN_UNDEF, 0, 0, 0
+ 0, HTOLE32(SHT_NULL), 0, 0, 0, 0, HTOLE32(SHN_UNDEF), 0, 0, 0
},
{
- 1, /* sh_name */
- SHT_STRTAB, /* sh_type */
+ HTOLE32(1), /* sh_name */
+ HTOLE32(SHT_STRTAB), /* sh_type */
0, /* sh_flags */
0, /* sh_addr */
- offsetof(struct elfh, shstrtab), /* sh_offset */
- sizeof(elfhdr.shstrtab), /* sh_size */
- SHN_UNDEF, /* sh_link */
+ HTOLE32(offsetof(struct elfh, shstrtab)), /* sh_offset */
+ HTOLE32(sizeof(elfhdr.shstrtab)), /* sh_size */
+ HTOLE32(SHN_UNDEF), /* sh_link */
0, /* sh_info */
- 1, /* sh_addralign */
+ HTOLE32(1), /* sh_addralign */
0 /* sh_entsize */
},
{
- 0xb, /* sh_name */
- SHT_PROGBITS, /* sh_type */
- SHF_EXECINSTR | SHF_ALLOC, /* sh_flags */
- SET_ME, /* sh_addr */
- SET_ME, /* sh_offset */
- SET_ME, /* sh_size */
- SHN_UNDEF, /* sh_link */
+ HTOLE32(0xb), /* sh_name */
+ HTOLE32(SHT_PROGBITS), /* sh_type */
+ HTOLE32(SHF_EXECINSTR | SHF_ALLOC), /* sh_flags */
+ HTOLE32(SET_ME), /* sh_addr */
+ HTOLE32(SET_ME), /* sh_offset */
+ HTOLE32(SET_ME), /* sh_size */
+ HTOLE32(SHN_UNDEF), /* sh_link */
0, /* sh_info */
- 4, /* sh_addralign */
+ HTOLE32(4), /* sh_addralign */
0 /* sh_entsize */
},
{
- 0x11, /* sh_name */
- SHT_PROGBITS, /* sh_type */
- SHF_ALLOC | SHF_WRITE, /* sh_flags */
- SET_ME, /* sh_addr */
- SET_ME, /* sh_offset */
- SET_ME, /* sh_size */
- SHN_UNDEF, /* sh_link */
+ HTOLE32(0x11), /* sh_name */
+ HTOLE32(SHT_PROGBITS), /* sh_type */
+ HTOLE32(SHF_ALLOC | SHF_WRITE), /* sh_flags */
+ HTOLE32(SET_ME), /* sh_addr */
+ HTOLE32(SET_ME), /* sh_offset */
+ HTOLE32(SET_ME), /* sh_size */
+ HTOLE32(SHN_UNDEF), /* sh_link */
0, /* sh_info */
- 4, /* sh_addralign */
+ HTOLE32(4), /* sh_addralign */
0 /* sh_entsize */
}
},
OpenPOWER on IntegriCloud