add elfosabi function

This commit is contained in:
David du Colombier 2017-07-27 23:36:55 +02:00
parent 859ed02491
commit f6cc9faf01
3 changed files with 31 additions and 0 deletions

View File

@ -68,6 +68,7 @@ uint8_t* readelfsection(FILE *f, char *name, uint64_t *size, Fhdr *fp);
void freeelf(Fhdr *fp); void freeelf(Fhdr *fp);
char* elfclass(uint8_t class); char* elfclass(uint8_t class);
char* elfdata(uint8_t data); char* elfdata(uint8_t data);
char* elfosabi(uint8_t osabi);
char* elftype(uint16_t type); char* elftype(uint16_t type);
char* elfmachine(uint16_t machine); char* elfmachine(uint16_t machine);
char* elfversion(uint8_t version); char* elfversion(uint8_t version);

1
elf.h
View File

@ -52,6 +52,7 @@ uint8_t* readelfsection(FILE*, char*, uint64_t*, Fhdr*);
void freeelf(Fhdr*); void freeelf(Fhdr*);
char* elfclass(uint8_t); char* elfclass(uint8_t);
char* elfdata(uint8_t); char* elfdata(uint8_t);
char* elfosabi(uint8_t);
char* elftype(uint16_t); char* elftype(uint16_t);
char* elfmachine(uint16_t); char* elfmachine(uint16_t);
char* elfversion(uint8_t); char* elfversion(uint8_t);

29
str.c
View File

@ -32,6 +32,35 @@ elfdata(uint8_t data)
return "Unknown data"; return "Unknown data";
} }
static char* osabistr[] = {
[ELFOSABI_NONE] = "No extensions or unspecified",
[ELFOSABI_HPUX] = "Hewlett-Packard HP-UX",
[ELFOSABI_NETBSD] = "NetBSD",
[ELFOSABI_GNU] = "GNU ",
[ELFOSABI_SOLARIS] = "Sun Solaris",
[ELFOSABI_AIX] = "AIX",
[ELFOSABI_IRIX] = "IRIX",
[ELFOSABI_FREEBSD] = "FreeBSD",
[ELFOSABI_TRU64] = "Compaq TRU64 UNIX",
[ELFOSABI_MODESTO] = "Novell Modesto",
[ELFOSABI_OPENBSD] = "Open BSD",
[ELFOSABI_OPENVMS] = "Open VMS",
[ELFOSABI_NSK] = "Hewlett-Packard Non-Stop Kernel",
[ELFOSABI_AROS] = "Amiga Research OS",
[ELFOSABI_FENIXOS] = "The FenixOS highly scalable multi-core OS",
[ELFOSABI_CLOUDABI] = "Nuxi CloudABI",
[ELFOSABI_OPENVOS] = "Stratus Technologies OpenVOS",
};
char*
elfosabi(uint8_t data)
{
if(data < nelem(osabistr) && osabistr[data])
return osabistr[data];
return "Unknown osabi";
}
char *machinestr[] = { char *machinestr[] = {
[EM_NONE] = "No machine", [EM_NONE] = "No machine",
[EM_M32] = "AT&T WE 32100", [EM_M32] = "AT&T WE 32100",