mirror of https://github.com/0intro/libelf
add elfdata function
This commit is contained in:
parent
8ccad71508
commit
859ed02491
|
@ -67,6 +67,7 @@ int readelf(FILE *f, Fhdr *fp);
|
|||
uint8_t* readelfsection(FILE *f, char *name, uint64_t *size, Fhdr *fp);
|
||||
void freeelf(Fhdr *fp);
|
||||
char* elfclass(uint8_t class);
|
||||
char* elfdata(uint8_t data);
|
||||
char* elftype(uint16_t type);
|
||||
char* elfmachine(uint16_t machine);
|
||||
char* elfversion(uint8_t version);
|
||||
|
|
1
elf.h
1
elf.h
|
@ -51,6 +51,7 @@ int readelf(FILE*, Fhdr*);
|
|||
uint8_t* readelfsection(FILE*, char*, uint64_t*, Fhdr*);
|
||||
void freeelf(Fhdr*);
|
||||
char* elfclass(uint8_t);
|
||||
char* elfdata(uint8_t);
|
||||
char* elftype(uint16_t);
|
||||
char* elfmachine(uint16_t);
|
||||
char* elfversion(uint8_t);
|
||||
|
|
15
str.c
15
str.c
|
@ -17,6 +17,21 @@ elfclass(uint8_t class)
|
|||
return "Unknown class";
|
||||
}
|
||||
|
||||
static char* datastr[] = {
|
||||
[ELFDATANONE] = "Invalid data encoding",
|
||||
[ELFDATA2LSB] = "Litte-endian",
|
||||
[ELFDATA2MSB] = "Big-endian",
|
||||
};
|
||||
|
||||
char*
|
||||
elfdata(uint8_t data)
|
||||
{
|
||||
if(data < nelem(datastr) && datastr[data])
|
||||
return datastr[data];
|
||||
|
||||
return "Unknown data";
|
||||
}
|
||||
|
||||
char *machinestr[] = {
|
||||
[EM_NONE] = "No machine",
|
||||
[EM_M32] = "AT&T WE 32100",
|
||||
|
|
Loading…
Reference in New Issue