Skip to content
Permalink
Browse files
Fix enums conflicts
Enums changes (C++/C):

ELF:
  * s/SECTION_TYPES/ELF_SECTION_TYPES/
  * s/SECTION_FLAGS/ELF_SECTION_FLAGS/
  * s/SYMBOL_TYPES/ELF_SYMBOL_TYPES/
  * s/SEGMENT_FLAGS/ELF_SEGMENT_FLAGS/

MachO:
  * s/SECTION_TYPES/MACHO_SECTION_TYPES/
  * s/SECTION_FLAGS/MACHO_SECTION_FLAGS/
  * s/SYMBOL_TYPES/MACHO_SYMBOL_TYPES/
  * s/SEGMENTS_FLAGS/MACHO_SEGMENTS_FLAGS/

PE:
  * s/SECTION_TYPES/PE_SECTION_TYPES/

Resolve #32
  • Loading branch information
romainthomas committed Aug 21, 2017
1 parent 117f866 commit 66b4cd4
Show file tree
Hide file tree
Showing 59 changed files with 523 additions and 524 deletions.
@@ -46,16 +46,16 @@ extern "C"
return LIEF::ELF::to_string(static_cast<LIEF::ELF::DYNAMIC_TAGS>(e));
}

const char* SECTION_TYPES_to_string(enum SECTION_TYPES e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::SECTION_TYPES>(e));
const char* ELF_SECTION_TYPES_to_string(enum ELF_SECTION_TYPES e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_SECTION_TYPES>(e));
}

const char* SECTION_FLAGS_to_string(enum SECTION_FLAGS e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::SECTION_FLAGS>(e));
const char* ELF_SECTION_FLAGS_to_string(enum ELF_SECTION_FLAGS e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_SECTION_FLAGS>(e));
}

const char* SYMBOL_TYPES_to_string(enum SYMBOL_TYPES e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::SYMBOL_TYPES>(e));
const char* ELF_SYMBOL_TYPES_to_string(enum ELF_SYMBOL_TYPES e) {
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_SYMBOL_TYPES>(e));
}

const char* ELF_CLASS_to_string(enum ELF_CLASS e) {
@@ -36,7 +36,7 @@ void init_c_sections(Elf_Binary_t* c_binary, Binary* binary) {

c_binary->sections[i]->name = b_section.name().c_str();
c_binary->sections[i]->flags = b_section.flags();
c_binary->sections[i]->type = static_cast<enum ::SECTION_TYPES>(b_section.type());
c_binary->sections[i]->type = static_cast<enum ::ELF_SECTION_TYPES>(b_section.type());
c_binary->sections[i]->virtual_address = b_section.virtual_address();
c_binary->sections[i]->offset = b_section.file_offset();
c_binary->sections[i]->original_size = b_section.original_size();
@@ -28,7 +28,7 @@ void init_c_dynamic_symbols(Elf_Binary_t* c_binary, Binary* binary) {
Symbol& b_sym = dyn_symb[i];
c_binary->dynamic_symbols[i] = static_cast<Elf_Symbol_t*>(malloc(sizeof(Elf_Symbol_t)));
c_binary->dynamic_symbols[i]->name = b_sym.name().c_str();
c_binary->dynamic_symbols[i]->type = static_cast<enum ::SYMBOL_TYPES>(b_sym.type());
c_binary->dynamic_symbols[i]->type = static_cast<enum ::ELF_SYMBOL_TYPES>(b_sym.type());
c_binary->dynamic_symbols[i]->binding = static_cast<enum ::SYMBOL_BINDINGS>(b_sym.binding());
c_binary->dynamic_symbols[i]->other = b_sym.other();
c_binary->dynamic_symbols[i]->shndx = b_sym.shndx();
@@ -55,7 +55,7 @@ void init_c_static_symbols(Elf_Binary_t* c_binary, Binary* binary) {
Symbol& b_sym = static_symb[i];
c_binary->static_symbols[i] = static_cast<Elf_Symbol_t*>(malloc(sizeof(Elf_Symbol_t)));
c_binary->static_symbols[i]->name = b_sym.name().c_str();
c_binary->static_symbols[i]->type = static_cast<enum ::SYMBOL_TYPES>(b_sym.type());
c_binary->static_symbols[i]->type = static_cast<enum ::ELF_SYMBOL_TYPES>(b_sym.type());
c_binary->static_symbols[i]->binding = static_cast<enum ::SYMBOL_BINDINGS>(b_sym.binding());
c_binary->static_symbols[i]->other = b_sym.other();
c_binary->static_symbols[i]->shndx = b_sym.shndx();
@@ -48,13 +48,13 @@ const char* HEADER_FLAGS_to_string(enum HEADER_FLAGS e) {
}


const char* MachO_SECTION_TYPES_to_string(enum SECTION_TYPES e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::SECTION_TYPES>(e));
const char* MACHO_SECTION_TYPES_to_string(enum MACHO_SECTION_TYPES e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::MACHO_SECTION_TYPES>(e));
}


const char* MachO_SYMBOL_TYPES_to_string(enum SYMBOL_TYPES e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::SYMBOL_TYPES>(e));
const char* MACHO_SYMBOL_TYPES_to_string(enum MACHO_SYMBOL_TYPES e) {
return LIEF::MachO::to_string(static_cast<LIEF::MachO::MACHO_SYMBOL_TYPES>(e));
}


@@ -39,7 +39,7 @@ void init_c_sections(Macho_Binary_t* c_binary, Binary* binary) {
c_binary->sections[i]->relocation_offset = section.relocation_offset();
c_binary->sections[i]->numberof_relocations = section.numberof_relocations();
c_binary->sections[i]->flags = section.flags();
c_binary->sections[i]->type = static_cast<enum ::SECTION_TYPES>(section.type());
c_binary->sections[i]->type = static_cast<enum ::MACHO_SECTION_TYPES>(section.type());
c_binary->sections[i]->reserved1 = section.reserved1();
c_binary->sections[i]->reserved2 = section.reserved2();
c_binary->sections[i]->reserved3 = section.reserved3();
@@ -30,9 +30,9 @@ DLL_PUBLIC const char* VERSION_to_string(enum VERSION e);
DLL_PUBLIC const char* ARCH_to_string(enum ARCH e);
DLL_PUBLIC const char* SEGMENT_TYPES_to_string(enum SEGMENT_TYPES e);
DLL_PUBLIC const char* DYNAMIC_TAGS_to_string(enum DYNAMIC_TAGS e);
DLL_PUBLIC const char* SECTION_TYPES_to_string(enum SECTION_TYPES e);
DLL_PUBLIC const char* SECTION_FLAGS_to_string(enum SECTION_FLAGS e);
DLL_PUBLIC const char* SYMBOL_TYPES_to_string(enum SYMBOL_TYPES e);
DLL_PUBLIC const char* ELF_SECTION_TYPES_to_string(enum ELF_SECTION_TYPES e);
DLL_PUBLIC const char* ELF_SECTION_FLAGS_to_string(enum ELF_SECTION_FLAGS e);
DLL_PUBLIC const char* ELF_SYMBOL_TYPES_to_string(enum ELF_SYMBOL_TYPES e);
DLL_PUBLIC const char* ELF_CLASS_to_string(enum ELF_CLASS e);
DLL_PUBLIC const char* ELF_DATA_to_string(enum ELF_DATA e);
DLL_PUBLIC const char* OS_ABI_to_string(enum OS_ABI e);
@@ -33,19 +33,19 @@ extern "C" {
#endif

struct Elf_Section_t {
const char* name;
uint32_t flags;
enum SECTION_TYPES type;
uint64_t virtual_address;
uint64_t offset;
uint64_t original_size;
uint32_t link;
uint32_t info;
uint64_t alignment;
uint64_t entry_size;
uint64_t size;
uint8_t* content;
double entropy;
const char* name;
uint32_t flags;
enum ELF_SECTION_TYPES type;
uint64_t virtual_address;
uint64_t offset;
uint64_t original_size;
uint32_t link;
uint32_t info;
uint64_t alignment;
uint64_t entry_size;
uint64_t size;
uint8_t* content;
double entropy;
};

typedef struct Elf_Section_t Elf_Section_t;
@@ -33,16 +33,16 @@ extern "C" {
#endif

struct Elf_Symbol_t {
const char* name;
enum SYMBOL_TYPES type;
enum SYMBOL_BINDINGS binding;
uint8_t information;
uint8_t other;
uint16_t shndx;
uint64_t value;
uint64_t size;
bool is_exported; /**< Whether or not the symbol is exported */
bool is_imported; /**< Whether or not the symbol is imported */
const char* name;
enum ELF_SYMBOL_TYPES type;
enum SYMBOL_BINDINGS binding;
uint8_t information;
uint8_t other;
uint16_t shndx;
uint64_t value;
uint64_t size;
bool is_exported; /**< Whether or not the symbol is exported */
bool is_imported; /**< Whether or not the symbol is imported */
};

typedef struct Elf_Symbol_t Elf_Symbol_t;
@@ -28,8 +28,8 @@ DLL_PUBLIC const char* MACHO_TYPES_to_string(enum MACHO_TYPES e);
DLL_PUBLIC const char* FILE_TYPES_to_string(enum FILE_TYPES e);
DLL_PUBLIC const char* CPU_TYPES_to_string(enum CPU_TYPES e);
DLL_PUBLIC const char* HEADER_FLAGS_to_string(enum HEADER_FLAGS e);
DLL_PUBLIC const char* MachO_SECTION_TYPES_to_string(enum SECTION_TYPES e);
DLL_PUBLIC const char* MachO_SYMBOL_TYPES_to_string(enum SYMBOL_TYPES e);
DLL_PUBLIC const char* MACHO_SECTION_TYPES_to_string(enum MACHO_SECTION_TYPES e);
DLL_PUBLIC const char* MACHO_SYMBOL_TYPES_to_string(enum MACHO_SYMBOL_TYPES e);
DLL_PUBLIC const char* N_LIST_TYPES_to_string(enum N_LIST_TYPES e);
DLL_PUBLIC const char* SYMBOL_DESCRIPTIONS_to_string(enum SYMBOL_DESCRIPTIONS e);

@@ -32,20 +32,20 @@ extern "C" {

struct Macho_Section_t {

const char* name;
uint32_t alignment;
uint32_t relocation_offset;
uint32_t numberof_relocations;
uint32_t flags;
enum SECTION_TYPES type;
uint32_t reserved1;
uint32_t reserved2;
uint32_t reserved3;
uint64_t virtual_address;
uint64_t offset;
uint64_t size;
uint8_t* content;
double entropy;
const char* name;
uint32_t alignment;
uint32_t relocation_offset;
uint32_t numberof_relocations;
uint32_t flags;
enum MACHO_SECTION_TYPES type;
uint32_t reserved1;
uint32_t reserved2;
uint32_t reserved3;
uint64_t virtual_address;
uint64_t offset;
uint64_t size;
uint8_t* content;
double entropy;
};

typedef struct Macho_Section_t Macho_Section_t;
@@ -49,8 +49,8 @@ void init_ELF_Section_class(py::module& m) {
".. warning:: The value will probably change when re-building binary.")

.def_property("type",
static_cast<getter_t<SECTION_TYPES>>(&Section::type),
static_cast<setter_t<SECTION_TYPES>>(&Section::type),
static_cast<getter_t<ELF_SECTION_TYPES>>(&Section::type),
static_cast<setter_t<ELF_SECTION_TYPES>>(&Section::type),
"Return a " RST_CLASS_REF(lief.ELF.SECTION_TYPES) "")

.def_property("flags",
@@ -118,7 +118,7 @@ void init_ELF_Section_class(py::module& m) {


.def("has",
static_cast<bool (Section::*)(SECTION_FLAGS) const>(&Section::has),
static_cast<bool (Section::*)(ELF_SECTION_FLAGS) const>(&Section::has),
"Check if the given " RST_CLASS_REF(lief.ELF.SECTION_FLAGS) " is present",
"flag"_a)

@@ -135,11 +135,11 @@ void init_ELF_Section_class(py::module& m) {
return LIEF::Hash::hash(section);
})

.def(py::self += SECTION_FLAGS())
.def(py::self -= SECTION_FLAGS())
.def(py::self += ELF_SECTION_FLAGS())
.def(py::self -= ELF_SECTION_FLAGS())

.def("__contains__",
static_cast<bool (Section::*)(SECTION_FLAGS) const>(&Section::has),
static_cast<bool (Section::*)(ELF_SECTION_FLAGS) const>(&Section::has),
"Check if the given " RST_CLASS_REF(lief.ELF.SECTION_FLAGS) " is present")


@@ -104,7 +104,7 @@ void init_ELF_Segment_class(py::module& m) {


.def("has",
static_cast<bool (Segment::*)(SEGMENT_FLAGS) const>(&Segment::has),
static_cast<bool (Segment::*)(ELF_SEGMENT_FLAGS) const>(&Segment::has),
"Check if the given " RST_CLASS_REF(lief.ELF.SEGMENT_FLAGS) " is present",
"flag"_a)

@@ -132,11 +132,11 @@ void init_ELF_Segment_class(py::module& m) {
return LIEF::Hash::hash(segment);
})

.def(py::self += SEGMENT_FLAGS())
.def(py::self -= SEGMENT_FLAGS())
.def(py::self += ELF_SEGMENT_FLAGS())
.def(py::self -= ELF_SEGMENT_FLAGS())

.def("__contains__",
static_cast<bool (Segment::*)(SEGMENT_FLAGS) const>(&Segment::has),
static_cast<bool (Segment::*)(ELF_SEGMENT_FLAGS) const>(&Segment::has),
"Check if the given " RST_CLASS_REF(lief.ELF.SEGMENT_FLAGS) " is present")

.def("__contains__",
@@ -39,8 +39,8 @@ void init_ELF_Symbol_class(py::module& m) {
"Symbol's unmangled name")

.def_property("type",
static_cast<getter_t<SYMBOL_TYPES>>(&Symbol::type),
static_cast<setter_t<SYMBOL_TYPES>>(&Symbol::type),
static_cast<getter_t<ELF_SYMBOL_TYPES>>(&Symbol::type),
static_cast<setter_t<ELF_SYMBOL_TYPES>>(&Symbol::type),
"A symbol's type provides a general classification for the associated entity")

.def_property("binding",

0 comments on commit 66b4cd4

Please sign in to comment.