export class, data, elfversion, osabi and abiversion ident header fields

This commit is contained in:
David du Colombier 2017-07-27 23:25:37 +02:00
parent 25e679c0c2
commit d18527e32e
3 changed files with 20 additions and 0 deletions

View File

@ -27,6 +27,13 @@ struct Fhdr {
/* Private */ /* Private */
... ...
/* ELF Identification */
uint8_t class; /* File class */
uint8_t data; /* Data encoding */
uint8_t elfversion; /* File version */
uint8_t osabi; /* Operating system/ABI identification */
uint8_t abiversion; /* ABI version */
/* ELF Header */ /* ELF Header */
uint16_t type; uint16_t type;
uint16_t machine; uint16_t machine;

6
elf.c
View File

@ -509,6 +509,12 @@ readident(FILE *f, Fhdr *fp)
if (i == nelem(data)) if (i == nelem(data))
return -1; return -1;
fp->class = buf[EI_CLASS];
fp->data = buf[EI_DATA];
fp->elfversion = buf[EI_VERSION];
fp->osabi = buf[EI_OSABI];
fp->abiversion = buf[EI_ABIVERSION];
return p - buf; return p - buf;
} }

7
elf.h
View File

@ -16,6 +16,13 @@ struct Fhdr {
int (*readelfphdr)(FILE*, Fhdr*); int (*readelfphdr)(FILE*, Fhdr*);
int (*readelfstrndx)(FILE*, Fhdr*); int (*readelfstrndx)(FILE*, Fhdr*);
/* ELF Identification */
uint8_t class; /* File class */
uint8_t data; /* Data encoding */
uint8_t elfversion; /* File version */
uint8_t osabi; /* Operating system/ABI identification */
uint8_t abiversion; /* ABI version */
/* ELF Header */ /* ELF Header */
uint16_t type; uint16_t type;
uint16_t machine; uint16_t machine;