2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2018-09-18 09:11:08 +02:00
|
|
|
* Copyright (C) 2017-2018 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
|
|
namespace CLElfLib {
|
2018-08-13 08:33:10 +02:00
|
|
|
using ElfSectionHeaderStorage = std::vector<SElf64SectionHeader>;
|
2017-12-21 00:45:38 +01:00
|
|
|
/******************************************************************************\
|
|
|
|
|
|
|
|
|
|
Class: CElfReader
|
|
|
|
|
|
|
|
|
|
Description: Class to provide simpler interaction with the ELF standard
|
2018-08-13 08:33:10 +02:00
|
|
|
binary object. SElf64Header defines the ELF header type and
|
2017-12-21 00:45:38 +01:00
|
|
|
SElf64SectionHeader defines the section header type.
|
|
|
|
|
|
|
|
|
|
\******************************************************************************/
|
|
|
|
|
class CElfReader {
|
|
|
|
|
public:
|
2018-08-13 08:33:10 +02:00
|
|
|
CElfReader(ElfBinaryStorage &elfBinary);
|
|
|
|
|
ElfSectionHeaderStorage &getSectionHeaders() {
|
|
|
|
|
return sectionHeaders;
|
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-08-13 08:33:10 +02:00
|
|
|
const SElf64Header *getElfHeader();
|
|
|
|
|
char *getSectionData(Elf64_Off dataOffset);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
protected:
|
2018-08-13 08:33:10 +02:00
|
|
|
void validateElfBinary(ElfBinaryStorage &elfBinary);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-08-13 08:33:10 +02:00
|
|
|
ElfSectionHeaderStorage sectionHeaders;
|
|
|
|
|
char *beginBinary;
|
|
|
|
|
const SElf64Header *elf64Header;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
} // namespace CLElfLib
|