aboutsummaryrefslogtreecommitdiff
path: root/libelf/libelf_ehdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'libelf/libelf_ehdr.c')
-rw-r--r--libelf/libelf_ehdr.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libelf/libelf_ehdr.c b/libelf/libelf_ehdr.c
index 363a0a834b9f..d59f61f2ba1e 100644
--- a/libelf/libelf_ehdr.c
+++ b/libelf/libelf_ehdr.c
@@ -33,7 +33,7 @@
#include "_libelf.h"
-ELFTC_VCSID("$Id: libelf_ehdr.c 2225 2011-11-26 18:55:54Z jkoshy $");
+ELFTC_VCSID("$Id: libelf_ehdr.c 3009 2014-03-23 01:49:59Z jkoshy $");
/*
* Retrieve counts for sections, phdrs and the section string table index
@@ -45,7 +45,8 @@ _libelf_load_extended(Elf *e, int ec, uint64_t shoff, uint16_t phnum,
{
Elf_Scn *scn;
size_t fsz;
- int (*xlator)(char *_d, size_t _dsz, char *_s, size_t _c, int _swap);
+ int (*xlator)(unsigned char *_d, size_t _dsz, unsigned char *_s,
+ size_t _c, int _swap);
uint32_t shtype;
assert(STAILQ_EMPTY(&e->e_u.e_elf.e_scn));
@@ -62,8 +63,8 @@ _libelf_load_extended(Elf *e, int ec, uint64_t shoff, uint16_t phnum,
return (0);
xlator = _libelf_get_translator(ELF_T_SHDR, ELF_TOMEMORY, ec);
- (*xlator)((char *) &scn->s_shdr, sizeof(scn->s_shdr),
- e->e_rawfile + shoff, (size_t) 1,
+ (*xlator)((unsigned char *) &scn->s_shdr, sizeof(scn->s_shdr),
+ (unsigned char *) e->e_rawfile + shoff, (size_t) 1,
e->e_byteorder != LIBELF_PRIVATE(byteorder));
#define GET_SHDR_MEMBER(M) ((ec == ELFCLASS32) ? scn->s_shdr.s_shdr32.M : \
@@ -74,7 +75,7 @@ _libelf_load_extended(Elf *e, int ec, uint64_t shoff, uint16_t phnum,
return (0);
}
- e->e_u.e_elf.e_nscn = GET_SHDR_MEMBER(sh_size);
+ e->e_u.e_elf.e_nscn = (size_t) GET_SHDR_MEMBER(sh_size);
e->e_u.e_elf.e_nphdr = (phnum != PN_XNUM) ? phnum :
GET_SHDR_MEMBER(sh_info);
e->e_u.e_elf.e_strndx = (strndx != SHN_XINDEX) ? strndx :
@@ -92,7 +93,7 @@ _libelf_load_extended(Elf *e, int ec, uint64_t shoff, uint16_t phnum,
eh->e_ident[EI_MAG3] = ELFMAG3; \
eh->e_ident[EI_CLASS] = ELFCLASS##SZ; \
eh->e_ident[EI_DATA] = ELFDATANONE; \
- eh->e_ident[EI_VERSION] = LIBELF_PRIVATE(version); \
+ eh->e_ident[EI_VERSION] = LIBELF_PRIVATE(version) & 0xFFU; \
eh->e_machine = EM_NONE; \
eh->e_type = ELF_K_NONE; \
eh->e_version = LIBELF_PRIVATE(version); \
@@ -105,7 +106,8 @@ _libelf_ehdr(Elf *e, int ec, int allocate)
size_t fsz, msz;
uint16_t phnum, shnum, strndx;
uint64_t shoff;
- int (*xlator)(char *_d, size_t _dsz, char *_s, size_t _c, int _swap);
+ int (*xlator)(unsigned char *_d, size_t _dsz, unsigned char *_s,
+ size_t _c, int _swap);
assert(ec == ELFCLASS32 || ec == ELFCLASS64);
@@ -167,7 +169,7 @@ _libelf_ehdr(Elf *e, int ec, int allocate)
return (ehdr);
xlator = _libelf_get_translator(ELF_T_EHDR, ELF_TOMEMORY, ec);
- (*xlator)(ehdr, msz, e->e_rawfile, (size_t) 1,
+ (*xlator)((unsigned char*) ehdr, msz, e->e_rawfile, (size_t) 1,
e->e_byteorder != LIBELF_PRIVATE(byteorder));
/*