This adds byte order as an attribute for object files by
introducing new members to the ObjectFile class. This is
populated by the looking at the ELF headers.
Change-Id: Ibe55699175cc0295e0c9d49bdbe02e580988bc4f
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
determineArch();
determineOpSys();
+ determineByteOrder();
entry = ehdr.e_entry;
_programHeaderCount = ehdr.e_phnum;
}
}
+void
+ElfObject::determineByteOrder()
+{
+ auto edata = ehdr.e_ident[EI_DATA];
+ if (edata == ELFDATANONE)
+ panic("invalid ELF data encoding");
+ byteOrder = (edata == ELFDATA2MSB) ? ByteOrder::big : ByteOrder::little;
+}
+
void
ElfObject::handleLoadableSegment(GElf_Phdr phdr, int seg_num)
{
void determineArch();
void determineOpSys();
+ void determineByteOrder();
void handleLoadableSegment(GElf_Phdr phdr, int seg_num);
// These values are provided to a linux process by the kernel, so we
#include "base/loader/symtab.hh"
#include "base/logging.hh"
#include "base/types.hh"
+#include "enums/ByteOrder.hh"
namespace Loader
{
protected:
Arch arch = UnknownArch;
OpSys opSys = UnknownOpSys;
+ ByteOrder byteOrder = ByteOrder::little;
SymbolTable _symtab;
Arch getArch() const { return arch; }
OpSys getOpSys() const { return opSys; }
+ ByteOrder getByteOrder() const { return byteOrder; }
const SymbolTable &symtab() const { return _symtab; }