This commit cleans and modernizes the code base of LIEF.

Among the changes:

- It removes the ``and, or, not`` keywords
- It updates the Documentation
- It moves the internal structures in the ``details::`` namespace
This commit is contained in:
rthomas
2022-01-27 18:50:12 +01:00
committed by Romain Thomas
parent 540049d0d9
commit a615adbee4
625 changed files with 15701 additions and 15535 deletions
+39 -23
View File
@@ -34,19 +34,23 @@ using setter_t = void (Header::*)(T);
template<>
void create<Header>(py::module& m) {
py::class_<Header, LIEF::Object>(m, "Header")
py::class_<Header, LIEF::Object>(m, "Header",
R"delim(
Class which represents the ELF's header. This is the ELF structure
that starts an ELF file.
)delim")
.def(py::init<>())
.def_property("identity_class",
static_cast<getter_t<ELF_CLASS>>(&Header::identity_class),
static_cast<setter_t<ELF_CLASS>>(&Header::identity_class),
"Return header's " RST_CLASS_REF(lief.ELF.ELF_CLASS) "."
"Header's " RST_CLASS_REF(lief.ELF.ELF_CLASS) "."
)
.def_property("identity_data",
static_cast<getter_t<ELF_DATA>>(&Header::identity_data),
static_cast<setter_t<ELF_DATA>>(&Header::identity_data),
"Return header's " RST_CLASS_REF(lief.ELF.ELF_DATA) "."
"Specify the data encoding: " RST_CLASS_REF(lief.ELF.ELF_DATA) "."
)
.def_property("identity_version",
@@ -58,13 +62,13 @@ void create<Header>(py::module& m) {
.def_property("identity_os_abi",
static_cast<getter_t<OS_ABI>>(&Header::identity_os_abi),
static_cast<setter_t<OS_ABI>>(&Header::identity_os_abi),
"Return header's " RST_CLASS_REF(lief.ELF.OS_ABI) "."
"Identifies the version of the ABI for which the object is prepared (" RST_CLASS_REF(lief.ELF.OS_ABI) ")."
)
.def_property("identity_abi_version",
static_cast<getter_t<uint32_t>>(&Header::identity_abi_version),
static_cast<setter_t<uint32_t>>(&Header::identity_abi_version),
"Return ABI version (integer)."
"Return the ABI version (integer)."
)
.def_property("identity",
@@ -88,81 +92,89 @@ void create<Header>(py::module& m) {
std::string error_str = py::repr(obj).cast<std::string>();
error_str = error_str + " is not supported!";
throw py::type_error(error_str.c_str());
},
"Return header's identity.",
"Header's identity.",
py::return_value_policy::reference_internal
)
.def_property("file_type",
static_cast<getter_t<E_TYPE>>(&Header::file_type),
static_cast<setter_t<E_TYPE>>(&Header::file_type),
"Return binary's " RST_CLASS_REF(lief.ELF.E_TYPE) ". It determine if the binary \
"Return binary's " RST_CLASS_REF(lief.ELF.E_TYPE) ". This field determines if the binary \
is a executable, a library..."
)
.def_property("machine_type",
static_cast<getter_t<ARCH>>(&Header::machine_type),
static_cast<setter_t<ARCH>>(&Header::machine_type),
"Return target architecture (" RST_CLASS_REF(lief.ELF.ARCH) ")")
"Return the target architecture (" RST_CLASS_REF(lief.ELF.ARCH) ")")
.def_property("object_file_version",
static_cast<getter_t<VERSION>>(&Header::object_file_version),
static_cast<setter_t<VERSION>>(&Header::object_file_version),
"Return " RST_CLASS_REF(lief.ELF.VERSION) "")
"Return the " RST_CLASS_REF(lief.ELF.VERSION) "")
.def_property("entrypoint",
static_cast<getter_t<uint64_t>>(&Header::entrypoint),
static_cast<setter_t<uint64_t>>(&Header::entrypoint),
"Return binary entry point")
"Return the binary entry point")
.def_property("program_header_offset",
static_cast<getter_t<uint64_t>>(&Header::program_headers_offset),
static_cast<setter_t<uint64_t>>(&Header::program_headers_offset),
"Return file offset to the program header table")
"Offset of program table (also known as segments table)")
.def_property("section_header_offset",
static_cast<getter_t<uint64_t>>(&Header::section_headers_offset),
static_cast<setter_t<uint64_t>>(&Header::section_headers_offset),
"Return file offset to the section header table")
"Offset of section table")
.def_property("processor_flag",
static_cast<getter_t<uint32_t>>(&Header::processor_flag),
static_cast<setter_t<uint32_t>>(&Header::processor_flag))
static_cast<setter_t<uint32_t>>(&Header::processor_flag),
"Processor-specific flags")
.def_property_readonly("arm_flags_list",
&Header::arm_flags_list,
"Return list of " RST_CLASS_REF(lief.ELF.ARM_EFLAGS) " present in "
"Return a list of " RST_CLASS_REF(lief.ELF.ARM_EFLAGS) " present in "
":attr:`~lief.ELF.Header.processor_flag`",
py::return_value_policy::reference_internal)
.def_property_readonly("mips_flags_list",
&Header::mips_flags_list,
"Return list of " RST_CLASS_REF(lief.ELF.MIPS_EFLAGS) " present in "
"Return a list of " RST_CLASS_REF(lief.ELF.MIPS_EFLAGS) " present in "
":attr:`~lief.ELF.Header.processor_flag`",
py::return_value_policy::reference_internal)
.def_property_readonly("ppc64_flags_list",
&Header::ppc64_flags_list,
"Return list of " RST_CLASS_REF(lief.ELF.PPC64_EFLAGS) " present in "
"Return a list of " RST_CLASS_REF(lief.ELF.PPC64_EFLAGS) " present in "
":attr:`~lief.ELF.Header.processor_flag`",
py::return_value_policy::reference_internal)
.def_property_readonly("hexagon_flags_list",
&Header::hexagon_flags_list,
"Return list of " RST_CLASS_REF(lief.ELF.HEXAGON_EFLAGS) " present in "
"Return a list of " RST_CLASS_REF(lief.ELF.HEXAGON_EFLAGS) " present in "
":attr:`~lief.ELF.Header.processor_flag`",
py::return_value_policy::reference_internal)
.def_property("header_size",
static_cast<getter_t<uint32_t>>(&Header::header_size),
static_cast<setter_t<uint32_t>>(&Header::header_size),
"Return the size of the ELF header")
R"delim(
Return the size of the ELF header
This size should be 64 for an ``ELF64`` binary and 52 for an ``ELF32``.
)delim")
.def_property("program_header_size",
static_cast<getter_t<uint32_t>>(&Header::program_header_size),
static_cast<setter_t<uint32_t>>(&Header::program_header_size),
"Return this size of a program header entry")
R"delim(
Return the size of a Segment header (:class:`lief.ELF.Segment`)
This size should be 56 for a ``ELF64`` binary and 32 for an ``ELF32``.
)delim")
.def_property("numberof_segments",
static_cast<getter_t<uint32_t>>(&Header::numberof_segments),
@@ -172,17 +184,21 @@ void create<Header>(py::module& m) {
.def_property("section_header_size",
static_cast<getter_t<uint32_t>>(&Header::section_header_size),
static_cast<setter_t<uint32_t>>(&Header::section_header_size),
"Return the size of a section header entry")
R"delim(
Return the size of a Section header (:class:`lief.ELF.Section`)
This size should be 64 for a ``ELF64`` binary and 40 for an ``ELF32``.
)delim")
.def_property("numberof_sections",
static_cast<getter_t<uint32_t>>(&Header::numberof_sections),
static_cast<setter_t<uint32_t>>(&Header::numberof_sections),
"Return the number of section's headers")
"Return the number of sections")
.def_property("section_name_table_idx",
static_cast<getter_t<uint32_t>>(&Header::section_name_table_idx),
static_cast<setter_t<uint32_t>>(&Header::section_name_table_idx),
"Return the section index which hold sections's name")
"Return the section index which contains sections' names")
.def("__eq__", &Header::operator==)
.def("__ne__", &Header::operator!=)