The ELFIO library consists of two independent parts: ELF File Reader (IELFI) and ELF Producer (IELFO). Each is represented by its own set of interfaces. The library does not contain any classes that need to be explicitly instantiated. ELFIO itself provides the interfaces that are used to access the library's functionality.
To make the program recognize all ELFIO interface classes, the ELFIO.h header file is needed. This header file defines all standard definitions from the TIS documentation.
#include <ELFIO.h>
This chapter will explain how to work with the reader component of the ELFIO library. The first step is to get a pointer onto the ELF File Reader:
IELFI* pReader; ELFIO::GetInstance()->CreateELFI( &pReader );
Now, that there is a pointer on the IELFI interface: initialize the object by loading the ELF file:
char* filename = "file.o"; pReader->Load( filename );
From here, there is access to the ELF header. This makes it possible to request file parameters such as encoding, machine type, entry point, etc. To get the encoding of the file use:
unsigned char encoding = pReader->GetEncoding();
Please note: standard types and constants from the TIS document are defined in the ELFTypes.h header file. This file is included automatically into the project. For example: ELFDATA2LSB and ELFDATA2MSB constants define a value for little and big endian encoding.