o Use C99 designated initializer to properly handle ELFOSABI_STANDALONE.

o  In elf_get_byte(), cast through uint8_t and not char to avoid sign
   extension.
This commit is contained in:
marcel 2011-10-16 14:11:05 +00:00
parent 2cc524e371
commit 4718565769

View File

@ -282,11 +282,12 @@ const char *ei_data[] = {
"ELFDATANONE", "ELFDATA2LSB", "ELFDATA2MSB"
};
const char *ei_abis[] = {
const char *ei_abis[256] = {
"ELFOSABI_SYSV", "ELFOSABI_HPUX", "ELFOSABI_NETBSD", "ELFOSABI_LINUX",
"ELFOSABI_HURD", "ELFOSABI_86OPEN", "ELFOSABI_SOLARIS",
"ELFOSABI_MONTEREY", "ELFOSABI_IRIX", "ELFOSABI_FREEBSD",
"ELFOSABI_TRU64", "ELFOSABI_MODESTO", "ELFOSABI_OPENBSD"
"ELFOSABI_HURD", "ELFOSABI_86OPEN", "ELFOSABI_SOLARIS", "ELFOSABI_AIX",
"ELFOSABI_IRIX", "ELFOSABI_FREEBSD", "ELFOSABI_TRU64",
"ELFOSABI_MODESTO", "ELFOSABI_OPENBSD",
[255] = "ELFOSABI_STANDALONE"
};
const char *p_types[] = {
@ -931,10 +932,10 @@ elf_get_byte(Elf32_Ehdr *e, void *base, elf_member_t member)
val = 0;
switch (e->e_ident[EI_CLASS]) {
case ELFCLASS32:
val = ((char *)base)[elf32_offsets[member]];
val = ((uint8_t *)base)[elf32_offsets[member]];
break;
case ELFCLASS64:
val = ((char *)base)[elf64_offsets[member]];
val = ((uint8_t *)base)[elf64_offsets[member]];
break;
case ELFCLASSNONE:
errx(1, "invalid class");