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:
parent
2cc524e371
commit
4718565769
@ -282,11 +282,12 @@ const char *ei_data[] = {
|
|||||||
"ELFDATANONE", "ELFDATA2LSB", "ELFDATA2MSB"
|
"ELFDATANONE", "ELFDATA2LSB", "ELFDATA2MSB"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *ei_abis[] = {
|
const char *ei_abis[256] = {
|
||||||
"ELFOSABI_SYSV", "ELFOSABI_HPUX", "ELFOSABI_NETBSD", "ELFOSABI_LINUX",
|
"ELFOSABI_SYSV", "ELFOSABI_HPUX", "ELFOSABI_NETBSD", "ELFOSABI_LINUX",
|
||||||
"ELFOSABI_HURD", "ELFOSABI_86OPEN", "ELFOSABI_SOLARIS",
|
"ELFOSABI_HURD", "ELFOSABI_86OPEN", "ELFOSABI_SOLARIS", "ELFOSABI_AIX",
|
||||||
"ELFOSABI_MONTEREY", "ELFOSABI_IRIX", "ELFOSABI_FREEBSD",
|
"ELFOSABI_IRIX", "ELFOSABI_FREEBSD", "ELFOSABI_TRU64",
|
||||||
"ELFOSABI_TRU64", "ELFOSABI_MODESTO", "ELFOSABI_OPENBSD"
|
"ELFOSABI_MODESTO", "ELFOSABI_OPENBSD",
|
||||||
|
[255] = "ELFOSABI_STANDALONE"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *p_types[] = {
|
const char *p_types[] = {
|
||||||
@ -931,10 +932,10 @@ elf_get_byte(Elf32_Ehdr *e, void *base, elf_member_t member)
|
|||||||
val = 0;
|
val = 0;
|
||||||
switch (e->e_ident[EI_CLASS]) {
|
switch (e->e_ident[EI_CLASS]) {
|
||||||
case ELFCLASS32:
|
case ELFCLASS32:
|
||||||
val = ((char *)base)[elf32_offsets[member]];
|
val = ((uint8_t *)base)[elf32_offsets[member]];
|
||||||
break;
|
break;
|
||||||
case ELFCLASS64:
|
case ELFCLASS64:
|
||||||
val = ((char *)base)[elf64_offsets[member]];
|
val = ((uint8_t *)base)[elf64_offsets[member]];
|
||||||
break;
|
break;
|
||||||
case ELFCLASSNONE:
|
case ELFCLASSNONE:
|
||||||
errx(1, "invalid class");
|
errx(1, "invalid class");
|
||||||
|
Loading…
Reference in New Issue
Block a user