diff --git a/api/c/ELF/DynamicEntry.cpp b/api/c/ELF/DynamicEntry.cpp index 363e661c83..7ed28c1725 100644 --- a/api/c/ELF/DynamicEntry.cpp +++ b/api/c/ELF/DynamicEntry.cpp @@ -34,9 +34,8 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) { for (size_t i = 0; i < dyn_entries.size(); ++i) { DynamicEntry& entry = dyn_entries[i]; switch(entry.tag()) { - case DYNAMIC_TAGS::DT_NEEDED: + case DynamicEntry::TAG::NEEDED: { - auto* e = static_cast( malloc(sizeof(Elf_DynamicEntry_Library_t))); @@ -48,7 +47,7 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) { break; } - case DYNAMIC_TAGS::DT_SONAME: + case DynamicEntry::TAG::SONAME: { auto* e = static_cast( malloc(sizeof(Elf_DynamicEntry_SharedObject_t))); @@ -61,37 +60,37 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) { break; } - case DYNAMIC_TAGS::DT_RPATH: + case DynamicEntry::TAG::RPATH: { auto* e = static_cast( malloc(sizeof(Elf_DynamicEntry_Rpath_t))); e->tag = static_cast(entry.tag()); e->value = entry.value(); - e->rpath = reinterpret_cast(&entry)->name().c_str(); + e->rpath = reinterpret_cast(&entry)->rpath().c_str(); c_binary->dynamic_entries[i] = reinterpret_cast(e); break; } - case DYNAMIC_TAGS::DT_RUNPATH: + case DynamicEntry::TAG::RUNPATH: { auto* e = static_cast( malloc(sizeof(Elf_DynamicEntry_RunPath_t))); e->tag = static_cast(entry.tag()); e->value = entry.value(); - e->runpath = reinterpret_cast(&entry)->name().c_str(); + e->runpath = reinterpret_cast(&entry)->runpath().c_str(); c_binary->dynamic_entries[i] = reinterpret_cast(e); break; } - case DYNAMIC_TAGS::DT_INIT_ARRAY: - case DYNAMIC_TAGS::DT_FINI_ARRAY: - case DYNAMIC_TAGS::DT_PREINIT_ARRAY: + case DynamicEntry::TAG::INIT_ARRAY: + case DynamicEntry::TAG::FINI_ARRAY: + case DynamicEntry::TAG::PREINIT_ARRAY: { auto* e = static_cast( malloc(sizeof(Elf_DynamicEntry_Array_t))); @@ -109,7 +108,7 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) { break; } - case DYNAMIC_TAGS::DT_FLAGS: + case DynamicEntry::TAG::FLAGS: { auto* e = static_cast( malloc(sizeof(Elf_DynamicEntry_Flags_t))); @@ -117,22 +116,13 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) { e->tag = static_cast(entry.tag()); e->value = entry.value(); const DynamicEntryFlags::flags_list_t& flags = reinterpret_cast(&entry)->flags(); - e->flags = static_cast(malloc((flags.size() + 1) * sizeof(enum LIEF_ELF_DYNAMIC_FLAGS))); - e->flags_1 = nullptr; - - auto it = std::begin(flags); - for (size_t i = 0; it != std::end(flags); ++i, ++it) { - e->flags[i] = static_cast(*it); - } - - e->flags[flags.size()] = static_cast(0); c_binary->dynamic_entries[i] = reinterpret_cast(e); break; } - case DYNAMIC_TAGS::DT_FLAGS_1: + case DynamicEntry::TAG::FLAGS_1: { auto* e = static_cast( malloc(sizeof(Elf_DynamicEntry_Flags_t))); @@ -140,16 +130,6 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) { e->tag = static_cast(entry.tag()); e->value = entry.value(); const DynamicEntryFlags::flags_list_t& flags = reinterpret_cast(&entry)->flags(); - e->flags_1 = static_cast(malloc((flags.size() + 1) * sizeof(enum LIEF_ELF_DYNAMIC_FLAGS_1))); - e->flags = nullptr; - - auto it = std::begin(flags); - - for (size_t i = 0; it != std::end(flags); ++i, ++it) { - e->flags_1[i] = static_cast(*it); - } - - e->flags_1[flags.size()] = static_cast(0); c_binary->dynamic_entries[i] = reinterpret_cast(e); break; @@ -170,7 +150,6 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) { } c_binary->dynamic_entries[dyn_entries.size()] = nullptr; - } @@ -179,34 +158,34 @@ void destroy_dynamic_entries(Elf_Binary_t* c_binary) { Elf_DynamicEntry_t **dynamic_entries = c_binary->dynamic_entries; for (size_t idx = 0; dynamic_entries[idx] != nullptr; ++idx) { - switch(static_cast(dynamic_entries[idx]->tag)) { - case DYNAMIC_TAGS::DT_NEEDED: + switch(DynamicEntry::TAG(dynamic_entries[idx]->tag)) { + case DynamicEntry::TAG::NEEDED: { free(reinterpret_cast(dynamic_entries[idx])); break; } - case DYNAMIC_TAGS::DT_SONAME: + case DynamicEntry::TAG::SONAME: { free(reinterpret_cast(dynamic_entries[idx])); break; } - case DYNAMIC_TAGS::DT_RPATH: + case DynamicEntry::TAG::RPATH: { free(reinterpret_cast(dynamic_entries[idx])); break; } - case DYNAMIC_TAGS::DT_RUNPATH: + case DynamicEntry::TAG::RUNPATH: { free(reinterpret_cast(dynamic_entries[idx])); break; } - case DYNAMIC_TAGS::DT_INIT_ARRAY: - case DYNAMIC_TAGS::DT_FINI_ARRAY: - case DYNAMIC_TAGS::DT_PREINIT_ARRAY: + case DynamicEntry::TAG::INIT_ARRAY: + case DynamicEntry::TAG::FINI_ARRAY: + case DynamicEntry::TAG::PREINIT_ARRAY: { Elf_DynamicEntry_Array_t* entry_array=reinterpret_cast(dynamic_entries[idx]); free(entry_array->array); @@ -214,24 +193,21 @@ void destroy_dynamic_entries(Elf_Binary_t* c_binary) { break; } - case DYNAMIC_TAGS::DT_FLAGS: + case DynamicEntry::TAG::FLAGS: { Elf_DynamicEntry_Flags_t* entry_flags=reinterpret_cast(dynamic_entries[idx]); - free(entry_flags->flags); free(entry_flags); break; } - case DYNAMIC_TAGS::DT_FLAGS_1: + case DynamicEntry::TAG::FLAGS_1: { Elf_DynamicEntry_Flags_t* entry_flags=reinterpret_cast(dynamic_entries[idx]); - free(entry_flags->flags_1); free(entry_flags); break; } default: { - free(dynamic_entries[idx]); } diff --git a/api/c/ELF/EnumToString.cpp b/api/c/ELF/EnumToString.cpp index 59375ce36c..a48314c81d 100644 --- a/api/c/ELF/EnumToString.cpp +++ b/api/c/ELF/EnumToString.cpp @@ -15,6 +15,8 @@ */ #include "LIEF/ELF/EnumToString.h" #include "LIEF/ELF/EnumToString.hpp" +#include "LIEF/ELF/DynamicEntry.hpp" +#include "LIEF/ELF/DynamicEntryFlags.hpp" #include "LIEF/ELF/enums.h" #include "LIEF/ELF/enums.hpp" @@ -42,7 +44,7 @@ extern "C" } const char* DYNAMIC_TAGS_to_string(enum LIEF_ELF_DYNAMIC_TAGS e) { - return LIEF::ELF::to_string(static_cast(e)); + return LIEF::ELF::to_string(LIEF::ELF::DynamicEntry::TAG(e)); } const char* ELF_SECTION_TYPES_to_string(enum LIEF_ELF_ELF_SECTION_TYPES e) { @@ -68,13 +70,4 @@ extern "C" const char* OS_ABI_to_string(enum LIEF_ELF_OS_ABI e) { return LIEF::ELF::to_string(static_cast(e)); } - - const char* DYNAMIC_FLAGS_to_string(enum LIEF_ELF_DYNAMIC_FLAGS e) { - return LIEF::ELF::to_string(static_cast(e)); - } - - const char* DYNAMIC_FLAGS_1_to_string(enum LIEF_ELF_DYNAMIC_FLAGS_1 e) { - return LIEF::ELF::to_string(static_cast(e)); - } - } diff --git a/api/c/include/LIEF/ELF/DynamicEntry.h b/api/c/include/LIEF/ELF/DynamicEntry.h index 3b26c3bf42..8ff57d808a 100644 --- a/api/c/include/LIEF/ELF/DynamicEntry.h +++ b/api/c/include/LIEF/ELF/DynamicEntry.h @@ -59,12 +59,9 @@ struct Elf_DynamicEntry_RunPath_t { const char* runpath; }; - struct Elf_DynamicEntry_Flags_t { uint64_t tag; uint64_t value; - enum LIEF_ELF_DYNAMIC_FLAGS *flags; - enum LIEF_ELF_DYNAMIC_FLAGS_1 *flags_1; }; typedef struct Elf_DynamicEntry_t Elf_DynamicEntry_t; diff --git a/api/c/include/LIEF/ELF/EnumToString.h b/api/c/include/LIEF/ELF/EnumToString.h index d84912e8d8..aabdc7d2ed 100644 --- a/api/c/include/LIEF/ELF/EnumToString.h +++ b/api/c/include/LIEF/ELF/EnumToString.h @@ -36,8 +36,6 @@ LIEF_API const char* ELF_SYMBOL_TYPES_to_string(enum LIEF_ELF_ELF_SYMBOL_TYPES e LIEF_API const char* ELF_CLASS_to_string(enum LIEF_ELF_ELF_CLASS e); LIEF_API const char* ELF_DATA_to_string(enum LIEF_ELF_ELF_DATA e); LIEF_API const char* OS_ABI_to_string(enum LIEF_ELF_OS_ABI e); -LIEF_API const char* DYNAMIC_FLAGS_to_string(enum LIEF_ELF_DYNAMIC_FLAGS e); -LIEF_API const char* DYNAMIC_FLAGS_1_to_string(enum LIEF_ELF_DYNAMIC_FLAGS_1 e); #ifdef __cplusplus } diff --git a/api/python/examples/elf_reader.py b/api/python/examples/elf_reader.py index 50c83d03df..3e05700fd6 100644 --- a/api/python/examples/elf_reader.py +++ b/api/python/examples/elf_reader.py @@ -167,18 +167,18 @@ def print_dynamic_entries(binary): f_value = "|{:<16} | 0x{:<8x}| {:<20}|" print(f_title.format("Tag", "Value", "Info")) for entry in dynamic_entries: - if entry.tag == ELF.DYNAMIC_TAGS.NULL: + if entry.tag == ELF.DynamicEntry.TAG.NULL: continue - if entry.tag in [ELF.DYNAMIC_TAGS.SONAME, ELF.DYNAMIC_TAGS.NEEDED, ELF.DYNAMIC_TAGS.RUNPATH, ELF.DYNAMIC_TAGS.RPATH]: + if entry.tag in [ELF.DynamicEntry.TAG.SONAME, ELF.DynamicEntry.TAG.NEEDED, ELF.DynamicEntry.TAG.RUNPATH, ELF.DynamicEntry.TAG.RPATH]: print(f_value.format(str(entry.tag).split(".")[-1], entry.value, entry.name)) - elif type(entry) is ELF.DynamicEntryArray: # [ELF.DYNAMIC_TAGS.INIT_ARRAY,ELF.DYNAMIC_TAGS.FINI_ARRAY]: + elif type(entry) is ELF.DynamicEntryArray: # [ELF.DynamicEntry.TAG.INIT_ARRAY,ELF.DynamicEntry.TAG.FINI_ARRAY]: print(f_value.format(str(entry.tag).split(".")[-1], entry.value, ", ".join(map(hex, entry.array)))) - elif entry.tag == ELF.DYNAMIC_TAGS.FLAGS: - flags_str = " - ".join([str(ELF.DYNAMIC_FLAGS(s)).split(".")[-1] for s in entry.flags]) + elif entry.tag == ELF.DynamicEntry.TAG.FLAGS: + flags_str = " - ".join([str(ELF.DynamicEntryFlags.FLAG(s)).split(".")[-1] for s in entry.flags]) print(f_value.format(str(entry.tag).split(".")[-1], entry.value, flags_str)) - elif entry.tag == ELF.DYNAMIC_TAGS.FLAGS_1: - flags_str = " - ".join([str(ELF.DYNAMIC_FLAGS_1(s)).split(".")[-1] for s in entry.flags]) + elif entry.tag == ELF.DynamicEntry.TAG.FLAGS_1: + flags_str = " - ".join([str(ELF.DynamicEntryFlags.FLAG(s)).split(".")[-1] for s in entry.flags]) print(f_value.format(str(entry.tag).split(".")[-1], entry.value, flags_str)) else: print(f_value.format(str(entry.tag).split(".")[-1], entry.value, "")) diff --git a/api/python/lief/ART.pyi b/api/python/lief/ART.pyi index a637cda901..0f8ff965de 100644 --- a/api/python/lief/ART.pyi +++ b/api/python/lief/ART.pyi @@ -60,6 +60,13 @@ class STORAGE_MODES: UNCOMPRESSED: ClassVar[STORAGE_MODES] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... def android_version(art_version: int) -> lief.Android.ANDROID_VERSIONS: ... @overload diff --git a/api/python/lief/Android.pyi b/api/python/lief/Android.pyi index 12b3797c54..66b9f9e12b 100644 --- a/api/python/lief/Android.pyi +++ b/api/python/lief/Android.pyi @@ -15,6 +15,13 @@ class ANDROID_VERSIONS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.Android.ANDROID_VERSIONS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... diff --git a/api/python/lief/DEX.pyi b/api/python/lief/DEX.pyi index 9d3fff2751..194c43007b 100644 --- a/api/python/lief/DEX.pyi +++ b/api/python/lief/DEX.pyi @@ -34,6 +34,13 @@ class ACCESS_FLAGS: VOLATILE: ClassVar[ACCESS_FLAGS] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... class Class(lief.Object): class it_fields: @@ -249,6 +256,13 @@ class MapItem(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.DEX.MapItem.TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... def __init__(self, *args, **kwargs) -> None: ... @@ -322,6 +336,13 @@ class Type(lief.Object): VOID_T: ClassVar[Type.PRIMITIVES] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... class TYPES: ARRAY: ClassVar[Type.TYPES] = ... @@ -330,6 +351,13 @@ class Type(lief.Object): UNKNOWN: ClassVar[Type.TYPES] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... def __init__(self, *args, **kwargs) -> None: ... @staticmethod def pretty_name(primitive: lief.DEX.Type.PRIMITIVES) -> str: ... diff --git a/api/python/lief/ELF.pyi b/api/python/lief/ELF.pyi index d0a030d545..45a5b4e9bc 100644 --- a/api/python/lief/ELF.pyi +++ b/api/python/lief/ELF.pyi @@ -12,6 +12,8 @@ import lief.ELF.CoreFile # type: ignore import lief.ELF.CorePrPsInfo # type: ignore import lief.ELF.CorePrStatus # type: ignore import lief.ELF.CorePrStatus.Registers # type: ignore +import lief.ELF.DynamicEntry # type: ignore +import lief.ELF.DynamicEntryFlags # type: ignore import lief.ELF.Note # type: ignore import lief.ELF.NoteAbi # type: ignore import lief.ELF.NoteGnuProperty # type: ignore @@ -33,6 +35,13 @@ class AArch64Feature(NoteGnuProperty.Property): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.AArch64Feature.FEATURE: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... def __init__(self, *args, **kwargs) -> None: ... @@ -222,6 +231,13 @@ class ARCH: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.ARCH: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -240,18 +256,41 @@ class ARM_EFLAGS: def from_value(arg: int, /) -> lief.ELF.ARM_EFLAGS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.ELF.ARM_EFLAGS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.ELF.ARM_EFLAGS, /) -> lief.ELF.ARM_EFLAGS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.ELF.ARM_EFLAGS, /) -> int: ... @property def value(self) -> int: ... @@ -270,6 +309,13 @@ class Binary(lief.Binary): SEGMENT_GAP: ClassVar[Binary.PHDR_RELOC] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... class it_dyn_static_symbols: def __init__(self, *args, **kwargs) -> None: ... @@ -381,7 +427,7 @@ class Binary(lief.Binary): @overload def extend(self, segment: lief.ELF.Section, size: int) -> lief.ELF.Section: ... @overload - def get(self, tag: lief.ELF.DYNAMIC_TAGS) -> lief.ELF.DynamicEntry: ... + def get(self, tag: lief.ELF.DynamicEntry.TAG) -> lief.ELF.DynamicEntry: ... @overload def get(self, type: lief.ELF.SEGMENT_TYPES) -> lief.ELF.Segment: ... @overload @@ -400,7 +446,7 @@ class Binary(lief.Binary): def get_static_symbol(self, symbol_name: str) -> lief.ELF.Symbol: ... def get_strings(self, min_size: int = ...) -> list[str]: ... @overload - def has(self, tag: lief.ELF.DYNAMIC_TAGS) -> bool: ... + def has(self, tag: lief.ELF.DynamicEntry.TAG) -> bool: ... @overload def has(self, type: lief.ELF.SEGMENT_TYPES) -> bool: ... @overload @@ -422,7 +468,7 @@ class Binary(lief.Binary): @overload def remove(self, dynamic_entry: lief.ELF.DynamicEntry) -> None: ... @overload - def remove(self, tag: lief.ELF.DYNAMIC_TAGS) -> None: ... + def remove(self, tag: lief.ELF.DynamicEntry.TAG) -> None: ... @overload def remove(self, section: lief.ELF.Section, clear: bool = ...) -> None: ... @overload @@ -449,7 +495,7 @@ class Binary(lief.Binary): @overload def __contains__(self, arg: lief.ELF.SEGMENT_TYPES, /) -> bool: ... @overload - def __contains__(self, arg: lief.ELF.DYNAMIC_TAGS, /) -> bool: ... + def __contains__(self, arg: lief.ELF.DynamicEntry.TAG, /) -> bool: ... @overload def __contains__(self, arg: lief.ELF.Note.TYPE, /) -> bool: ... @overload @@ -459,7 +505,7 @@ class Binary(lief.Binary): @overload def __getitem__(self, arg: lief.ELF.Note.TYPE, /) -> lief.ELF.Note: ... @overload - def __getitem__(self, arg: lief.ELF.DYNAMIC_TAGS, /) -> lief.ELF.DynamicEntry: ... + def __getitem__(self, arg: lief.ELF.DynamicEntry.TAG, /) -> lief.ELF.DynamicEntry: ... @overload def __getitem__(self, arg: lief.ELF.SECTION_TYPES, /) -> lief.ELF.Section: ... @overload @@ -473,7 +519,7 @@ class Binary(lief.Binary): @overload def __isub__(self, arg: lief.ELF.DynamicEntry, /) -> lief.ELF.Binary: ... @overload - def __isub__(self, arg: lief.ELF.DYNAMIC_TAGS, /) -> lief.ELF.Binary: ... + def __isub__(self, arg: lief.ELF.DynamicEntry.TAG, /) -> lief.ELF.Binary: ... @overload def __isub__(self, arg: lief.ELF.Note, /) -> lief.ELF.Binary: ... @overload @@ -610,6 +656,13 @@ class CoreAuxv(Note): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.CoreAuxv.TYPE: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... def __init__(self, *args, **kwargs) -> None: ... @@ -730,6 +783,13 @@ class CorePrStatus(Note): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.CorePrStatus.Registers.AARCH64: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -755,6 +815,13 @@ class CorePrStatus(Note): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.CorePrStatus.Registers.ARM: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -780,6 +847,13 @@ class CorePrStatus(Note): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.CorePrStatus.Registers.X86: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -809,6 +883,13 @@ class CorePrStatus(Note): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.CorePrStatus.Registers.X86_64: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... def __init__(self, *args, **kwargs) -> None: ... @@ -890,191 +971,6 @@ class CoreSigInfo(Note): signo: Optional[int] def __init__(self, *args, **kwargs) -> None: ... -class DYNAMIC_FLAGS: - BIND_NOW: ClassVar[DYNAMIC_FLAGS] = ... - ORIGIN: ClassVar[DYNAMIC_FLAGS] = ... - STATIC_TLS: ClassVar[DYNAMIC_FLAGS] = ... - SYMBOLIC: ClassVar[DYNAMIC_FLAGS] = ... - TEXTREL: ClassVar[DYNAMIC_FLAGS] = ... - __name__: Any - def __init__(self, *args, **kwargs) -> None: ... - @staticmethod - def from_value(arg: int, /) -> lief.ELF.DYNAMIC_FLAGS: ... - def __abs__(self) -> Any: ... - def __add__(self, other) -> Any: ... - def __floordiv__(self, other) -> Any: ... - def __lshift__(self, other) -> Any: ... - def __mul__(self, other) -> Any: ... - def __neg__(self) -> Any: ... - def __radd__(self, other) -> Any: ... - def __rfloordiv__(self, other) -> Any: ... - def __rlshift__(self, other) -> Any: ... - def __rmul__(self, other) -> Any: ... - def __rrshift__(self, other) -> Any: ... - def __rshift__(self, other) -> Any: ... - def __rsub__(self, other) -> Any: ... - def __sub__(self, other) -> Any: ... - @property - def value(self) -> int: ... - -class DYNAMIC_FLAGS_1: - CONFALT: ClassVar[DYNAMIC_FLAGS_1] = ... - DIRECT: ClassVar[DYNAMIC_FLAGS_1] = ... - DISPRELDNE: ClassVar[DYNAMIC_FLAGS_1] = ... - DISPRELPND: ClassVar[DYNAMIC_FLAGS_1] = ... - EDITED: ClassVar[DYNAMIC_FLAGS_1] = ... - ENDFILTEE: ClassVar[DYNAMIC_FLAGS_1] = ... - GLOBAL: ClassVar[DYNAMIC_FLAGS_1] = ... - GLOBAUDIT: ClassVar[DYNAMIC_FLAGS_1] = ... - GROUP: ClassVar[DYNAMIC_FLAGS_1] = ... - IGNMULDEF: ClassVar[DYNAMIC_FLAGS_1] = ... - INITFIRST: ClassVar[DYNAMIC_FLAGS_1] = ... - INTERPOSE: ClassVar[DYNAMIC_FLAGS_1] = ... - LOADFLTR: ClassVar[DYNAMIC_FLAGS_1] = ... - NODEFLIB: ClassVar[DYNAMIC_FLAGS_1] = ... - NODELETE: ClassVar[DYNAMIC_FLAGS_1] = ... - NODIRECT: ClassVar[DYNAMIC_FLAGS_1] = ... - NODUMP: ClassVar[DYNAMIC_FLAGS_1] = ... - NOHDR: ClassVar[DYNAMIC_FLAGS_1] = ... - NOKSYMS: ClassVar[DYNAMIC_FLAGS_1] = ... - NOOPEN: ClassVar[DYNAMIC_FLAGS_1] = ... - NORELOC: ClassVar[DYNAMIC_FLAGS_1] = ... - NOW: ClassVar[DYNAMIC_FLAGS_1] = ... - ORIGIN: ClassVar[DYNAMIC_FLAGS_1] = ... - PIE: ClassVar[DYNAMIC_FLAGS_1] = ... - SINGLETON: ClassVar[DYNAMIC_FLAGS_1] = ... - SYMINTPOSE: ClassVar[DYNAMIC_FLAGS_1] = ... - TRANS: ClassVar[DYNAMIC_FLAGS_1] = ... - __name__: Any - def __init__(self, *args, **kwargs) -> None: ... - @staticmethod - def from_value(arg: int, /) -> lief.ELF.DYNAMIC_FLAGS_1: ... - def __abs__(self) -> Any: ... - def __add__(self, other) -> Any: ... - def __floordiv__(self, other) -> Any: ... - def __lshift__(self, other) -> Any: ... - def __mul__(self, other) -> Any: ... - def __neg__(self) -> Any: ... - def __radd__(self, other) -> Any: ... - def __rfloordiv__(self, other) -> Any: ... - def __rlshift__(self, other) -> Any: ... - def __rmul__(self, other) -> Any: ... - def __rrshift__(self, other) -> Any: ... - def __rshift__(self, other) -> Any: ... - def __rsub__(self, other) -> Any: ... - def __sub__(self, other) -> Any: ... - @property - def value(self) -> int: ... - -class DYNAMIC_TAGS: - ANDROID_REL: ClassVar[DYNAMIC_TAGS] = ... - ANDROID_RELA: ClassVar[DYNAMIC_TAGS] = ... - ANDROID_RELASZ: ClassVar[DYNAMIC_TAGS] = ... - ANDROID_RELR: ClassVar[DYNAMIC_TAGS] = ... - ANDROID_RELRCOUNT: ClassVar[DYNAMIC_TAGS] = ... - ANDROID_RELRENT: ClassVar[DYNAMIC_TAGS] = ... - ANDROID_RELRSZ: ClassVar[DYNAMIC_TAGS] = ... - ANDROID_RELSZ: ClassVar[DYNAMIC_TAGS] = ... - ANDROID_REL_OFFSET: ClassVar[DYNAMIC_TAGS] = ... - ANDROID_REL_SIZE: ClassVar[DYNAMIC_TAGS] = ... - BIND_NOW: ClassVar[DYNAMIC_TAGS] = ... - DEBUG: ClassVar[DYNAMIC_TAGS] = ... - FINI: ClassVar[DYNAMIC_TAGS] = ... - FINI_ARRAY: ClassVar[DYNAMIC_TAGS] = ... - FINI_ARRAYSZ: ClassVar[DYNAMIC_TAGS] = ... - FLAGS: ClassVar[DYNAMIC_TAGS] = ... - FLAGS_1: ClassVar[DYNAMIC_TAGS] = ... - GNU_HASH: ClassVar[DYNAMIC_TAGS] = ... - HASH: ClassVar[DYNAMIC_TAGS] = ... - INIT: ClassVar[DYNAMIC_TAGS] = ... - INIT_ARRAY: ClassVar[DYNAMIC_TAGS] = ... - INIT_ARRAYSZ: ClassVar[DYNAMIC_TAGS] = ... - JMPREL: ClassVar[DYNAMIC_TAGS] = ... - MIPS_AUX_DYNAMIC: ClassVar[DYNAMIC_TAGS] = ... - MIPS_BASE_ADDRESS: ClassVar[DYNAMIC_TAGS] = ... - MIPS_COMPACT_SIZE: ClassVar[DYNAMIC_TAGS] = ... - MIPS_CONFLICT: ClassVar[DYNAMIC_TAGS] = ... - MIPS_CONFLICTNO: ClassVar[DYNAMIC_TAGS] = ... - MIPS_CXX_FLAGS: ClassVar[DYNAMIC_TAGS] = ... - MIPS_DELTA_CLASS: ClassVar[DYNAMIC_TAGS] = ... - MIPS_DELTA_CLASSSYM: ClassVar[DYNAMIC_TAGS] = ... - MIPS_DELTA_CLASSSYM_NO: ClassVar[DYNAMIC_TAGS] = ... - MIPS_DELTA_CLASS_NO: ClassVar[DYNAMIC_TAGS] = ... - MIPS_DELTA_INSTANCE: ClassVar[DYNAMIC_TAGS] = ... - MIPS_DELTA_INSTANCE_NO: ClassVar[DYNAMIC_TAGS] = ... - MIPS_DELTA_RELOC: ClassVar[DYNAMIC_TAGS] = ... - MIPS_DELTA_RELOC_NO: ClassVar[DYNAMIC_TAGS] = ... - MIPS_DELTA_SYM: ClassVar[DYNAMIC_TAGS] = ... - MIPS_DELTA_SYM_NO: ClassVar[DYNAMIC_TAGS] = ... - MIPS_DYNSTR_ALIGN: ClassVar[DYNAMIC_TAGS] = ... - MIPS_FLAGS: ClassVar[DYNAMIC_TAGS] = ... - MIPS_GOTSYM: ClassVar[DYNAMIC_TAGS] = ... - MIPS_GP_VALUE: ClassVar[DYNAMIC_TAGS] = ... - MIPS_HIDDEN_GOTIDX: ClassVar[DYNAMIC_TAGS] = ... - MIPS_HIPAGENO: ClassVar[DYNAMIC_TAGS] = ... - MIPS_ICHECKSUM: ClassVar[DYNAMIC_TAGS] = ... - MIPS_INTERFACE: ClassVar[DYNAMIC_TAGS] = ... - MIPS_INTERFACE_SIZE: ClassVar[DYNAMIC_TAGS] = ... - MIPS_IVERSION: ClassVar[DYNAMIC_TAGS] = ... - MIPS_LIBLIST: ClassVar[DYNAMIC_TAGS] = ... - MIPS_LIBLISTNO: ClassVar[DYNAMIC_TAGS] = ... - MIPS_LOCALPAGE_GOTIDX: ClassVar[DYNAMIC_TAGS] = ... - MIPS_LOCAL_GOTIDX: ClassVar[DYNAMIC_TAGS] = ... - MIPS_LOCAL_GOTNO: ClassVar[DYNAMIC_TAGS] = ... - MIPS_MSYM: ClassVar[DYNAMIC_TAGS] = ... - MIPS_OPTIONS: ClassVar[DYNAMIC_TAGS] = ... - MIPS_PERF_SUFFIX: ClassVar[DYNAMIC_TAGS] = ... - MIPS_PIXIE_INIT: ClassVar[DYNAMIC_TAGS] = ... - MIPS_PLTGOT: ClassVar[DYNAMIC_TAGS] = ... - MIPS_PROTECTED_GOTIDX: ClassVar[DYNAMIC_TAGS] = ... - MIPS_RLD_MAP: ClassVar[DYNAMIC_TAGS] = ... - MIPS_RLD_TEXT_RESOLVE_ADDR: ClassVar[DYNAMIC_TAGS] = ... - MIPS_RLD_VERSION: ClassVar[DYNAMIC_TAGS] = ... - MIPS_RWPLT: ClassVar[DYNAMIC_TAGS] = ... - MIPS_SYMBOL_LIB: ClassVar[DYNAMIC_TAGS] = ... - MIPS_SYMTABNO: ClassVar[DYNAMIC_TAGS] = ... - MIPS_TIME_STAMP: ClassVar[DYNAMIC_TAGS] = ... - MIPS_UNREFEXTNO: ClassVar[DYNAMIC_TAGS] = ... - NEEDED: ClassVar[DYNAMIC_TAGS] = ... - NULL: ClassVar[DYNAMIC_TAGS] = ... - PLTGOT: ClassVar[DYNAMIC_TAGS] = ... - PLTREL: ClassVar[DYNAMIC_TAGS] = ... - PLTRELSZ: ClassVar[DYNAMIC_TAGS] = ... - PREINIT_ARRAY: ClassVar[DYNAMIC_TAGS] = ... - PREINIT_ARRAYSZ: ClassVar[DYNAMIC_TAGS] = ... - REL: ClassVar[DYNAMIC_TAGS] = ... - RELA: ClassVar[DYNAMIC_TAGS] = ... - RELACOUNT: ClassVar[DYNAMIC_TAGS] = ... - RELAENT: ClassVar[DYNAMIC_TAGS] = ... - RELASZ: ClassVar[DYNAMIC_TAGS] = ... - RELCOUNT: ClassVar[DYNAMIC_TAGS] = ... - RELENT: ClassVar[DYNAMIC_TAGS] = ... - RELR: ClassVar[DYNAMIC_TAGS] = ... - RELRENT: ClassVar[DYNAMIC_TAGS] = ... - RELRSZ: ClassVar[DYNAMIC_TAGS] = ... - RELSZ: ClassVar[DYNAMIC_TAGS] = ... - RPATH: ClassVar[DYNAMIC_TAGS] = ... - RUNPATH: ClassVar[DYNAMIC_TAGS] = ... - SONAME: ClassVar[DYNAMIC_TAGS] = ... - STRSZ: ClassVar[DYNAMIC_TAGS] = ... - STRTAB: ClassVar[DYNAMIC_TAGS] = ... - SYMBOLIC: ClassVar[DYNAMIC_TAGS] = ... - SYMENT: ClassVar[DYNAMIC_TAGS] = ... - SYMTAB: ClassVar[DYNAMIC_TAGS] = ... - SYMTAB_SHNDX: ClassVar[DYNAMIC_TAGS] = ... - TEXTREL: ClassVar[DYNAMIC_TAGS] = ... - VERDEF: ClassVar[DYNAMIC_TAGS] = ... - VERDEFNUM: ClassVar[DYNAMIC_TAGS] = ... - VERNEED: ClassVar[DYNAMIC_TAGS] = ... - VERNEEDNUM: ClassVar[DYNAMIC_TAGS] = ... - VERSYM: ClassVar[DYNAMIC_TAGS] = ... - __name__: Any - def __init__(self, *args, **kwargs) -> None: ... - @staticmethod - def from_value(arg: int, /) -> lief.ELF.DYNAMIC_TAGS: ... - @property - def value(self) -> int: ... - class DYNSYM_COUNT_METHODS: AUTO: ClassVar[DYNSYM_COUNT_METHODS] = ... HASH: ClassVar[DYNSYM_COUNT_METHODS] = ... @@ -1084,23 +980,142 @@ class DYNSYM_COUNT_METHODS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.DYNSYM_COUNT_METHODS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... class DynamicEntry(lief.Object): - tag: lief.ELF.DYNAMIC_TAGS + class TAG: + ANDROID_REL: ClassVar[DynamicEntry.TAG] = ... + ANDROID_RELA: ClassVar[DynamicEntry.TAG] = ... + ANDROID_RELASZ: ClassVar[DynamicEntry.TAG] = ... + ANDROID_RELR: ClassVar[DynamicEntry.TAG] = ... + ANDROID_RELRCOUNT: ClassVar[DynamicEntry.TAG] = ... + ANDROID_RELRENT: ClassVar[DynamicEntry.TAG] = ... + ANDROID_RELRSZ: ClassVar[DynamicEntry.TAG] = ... + ANDROID_RELSZ: ClassVar[DynamicEntry.TAG] = ... + ANDROID_REL_OFFSET: ClassVar[DynamicEntry.TAG] = ... + ANDROID_REL_SIZE: ClassVar[DynamicEntry.TAG] = ... + BIND_NOW: ClassVar[DynamicEntry.TAG] = ... + DEBUG: ClassVar[DynamicEntry.TAG] = ... + FINI: ClassVar[DynamicEntry.TAG] = ... + FINI_ARRAY: ClassVar[DynamicEntry.TAG] = ... + FINI_ARRAYSZ: ClassVar[DynamicEntry.TAG] = ... + FLAGS: ClassVar[DynamicEntry.TAG] = ... + FLAGS_1: ClassVar[DynamicEntry.TAG] = ... + GNU_HASH: ClassVar[DynamicEntry.TAG] = ... + HASH: ClassVar[DynamicEntry.TAG] = ... + INIT: ClassVar[DynamicEntry.TAG] = ... + INIT_ARRAY: ClassVar[DynamicEntry.TAG] = ... + INIT_ARRAYSZ: ClassVar[DynamicEntry.TAG] = ... + JMPREL: ClassVar[DynamicEntry.TAG] = ... + MIPS_AUX_DYNAMIC: ClassVar[DynamicEntry.TAG] = ... + MIPS_BASE_ADDRESS: ClassVar[DynamicEntry.TAG] = ... + MIPS_COMPACT_SIZE: ClassVar[DynamicEntry.TAG] = ... + MIPS_CONFLICT: ClassVar[DynamicEntry.TAG] = ... + MIPS_CONFLICTNO: ClassVar[DynamicEntry.TAG] = ... + MIPS_CXX_FLAGS: ClassVar[DynamicEntry.TAG] = ... + MIPS_DELTA_CLASS: ClassVar[DynamicEntry.TAG] = ... + MIPS_DELTA_CLASSSYM: ClassVar[DynamicEntry.TAG] = ... + MIPS_DELTA_CLASSSYM_NO: ClassVar[DynamicEntry.TAG] = ... + MIPS_DELTA_CLASS_NO: ClassVar[DynamicEntry.TAG] = ... + MIPS_DELTA_INSTANCE: ClassVar[DynamicEntry.TAG] = ... + MIPS_DELTA_INSTANCE_NO: ClassVar[DynamicEntry.TAG] = ... + MIPS_DELTA_RELOC: ClassVar[DynamicEntry.TAG] = ... + MIPS_DELTA_RELOC_NO: ClassVar[DynamicEntry.TAG] = ... + MIPS_DELTA_SYM: ClassVar[DynamicEntry.TAG] = ... + MIPS_DELTA_SYM_NO: ClassVar[DynamicEntry.TAG] = ... + MIPS_DYNSTR_ALIGN: ClassVar[DynamicEntry.TAG] = ... + MIPS_FLAGS: ClassVar[DynamicEntry.TAG] = ... + MIPS_GOTSYM: ClassVar[DynamicEntry.TAG] = ... + MIPS_GP_VALUE: ClassVar[DynamicEntry.TAG] = ... + MIPS_HIDDEN_GOTIDX: ClassVar[DynamicEntry.TAG] = ... + MIPS_HIPAGENO: ClassVar[DynamicEntry.TAG] = ... + MIPS_ICHECKSUM: ClassVar[DynamicEntry.TAG] = ... + MIPS_INTERFACE: ClassVar[DynamicEntry.TAG] = ... + MIPS_INTERFACE_SIZE: ClassVar[DynamicEntry.TAG] = ... + MIPS_IVERSION: ClassVar[DynamicEntry.TAG] = ... + MIPS_LIBLIST: ClassVar[DynamicEntry.TAG] = ... + MIPS_LIBLISTNO: ClassVar[DynamicEntry.TAG] = ... + MIPS_LOCALPAGE_GOTIDX: ClassVar[DynamicEntry.TAG] = ... + MIPS_LOCAL_GOTIDX: ClassVar[DynamicEntry.TAG] = ... + MIPS_LOCAL_GOTNO: ClassVar[DynamicEntry.TAG] = ... + MIPS_MSYM: ClassVar[DynamicEntry.TAG] = ... + MIPS_OPTIONS: ClassVar[DynamicEntry.TAG] = ... + MIPS_PERF_SUFFIX: ClassVar[DynamicEntry.TAG] = ... + MIPS_PIXIE_INIT: ClassVar[DynamicEntry.TAG] = ... + MIPS_PLTGOT: ClassVar[DynamicEntry.TAG] = ... + MIPS_PROTECTED_GOTIDX: ClassVar[DynamicEntry.TAG] = ... + MIPS_RLD_MAP: ClassVar[DynamicEntry.TAG] = ... + MIPS_RLD_TEXT_RESOLVE_ADDR: ClassVar[DynamicEntry.TAG] = ... + MIPS_RLD_VERSION: ClassVar[DynamicEntry.TAG] = ... + MIPS_RWPLT: ClassVar[DynamicEntry.TAG] = ... + MIPS_SYMBOL_LIB: ClassVar[DynamicEntry.TAG] = ... + MIPS_SYMTABNO: ClassVar[DynamicEntry.TAG] = ... + MIPS_TIME_STAMP: ClassVar[DynamicEntry.TAG] = ... + MIPS_UNREFEXTNO: ClassVar[DynamicEntry.TAG] = ... + NEEDED: ClassVar[DynamicEntry.TAG] = ... + NULL: ClassVar[DynamicEntry.TAG] = ... + PLTGOT: ClassVar[DynamicEntry.TAG] = ... + PLTREL: ClassVar[DynamicEntry.TAG] = ... + PLTRELSZ: ClassVar[DynamicEntry.TAG] = ... + PREINIT_ARRAY: ClassVar[DynamicEntry.TAG] = ... + PREINIT_ARRAYSZ: ClassVar[DynamicEntry.TAG] = ... + REL: ClassVar[DynamicEntry.TAG] = ... + RELA: ClassVar[DynamicEntry.TAG] = ... + RELACOUNT: ClassVar[DynamicEntry.TAG] = ... + RELAENT: ClassVar[DynamicEntry.TAG] = ... + RELASZ: ClassVar[DynamicEntry.TAG] = ... + RELCOUNT: ClassVar[DynamicEntry.TAG] = ... + RELENT: ClassVar[DynamicEntry.TAG] = ... + RELR: ClassVar[DynamicEntry.TAG] = ... + RELRENT: ClassVar[DynamicEntry.TAG] = ... + RELRSZ: ClassVar[DynamicEntry.TAG] = ... + RELSZ: ClassVar[DynamicEntry.TAG] = ... + RPATH: ClassVar[DynamicEntry.TAG] = ... + RUNPATH: ClassVar[DynamicEntry.TAG] = ... + SONAME: ClassVar[DynamicEntry.TAG] = ... + STRSZ: ClassVar[DynamicEntry.TAG] = ... + STRTAB: ClassVar[DynamicEntry.TAG] = ... + SYMBOLIC: ClassVar[DynamicEntry.TAG] = ... + SYMENT: ClassVar[DynamicEntry.TAG] = ... + SYMTAB: ClassVar[DynamicEntry.TAG] = ... + SYMTAB_SHNDX: ClassVar[DynamicEntry.TAG] = ... + TEXTREL: ClassVar[DynamicEntry.TAG] = ... + VERDEF: ClassVar[DynamicEntry.TAG] = ... + VERDEFNUM: ClassVar[DynamicEntry.TAG] = ... + VERNEED: ClassVar[DynamicEntry.TAG] = ... + VERNEEDNUM: ClassVar[DynamicEntry.TAG] = ... + VERSYM: ClassVar[DynamicEntry.TAG] = ... + __name__: Any + def __init__(self, *args, **kwargs) -> None: ... + @staticmethod + def from_value(arg: int, /) -> lief.ELF.DynamicEntry.TAG: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... + @property + def value(self) -> int: ... + tag: lief.ELF.DynamicEntry.TAG value: int @overload def __init__(self) -> None: ... @overload - def __init__(self, tag: lief.ELF.DYNAMIC_TAGS, value: int) -> None: ... + def __init__(self, tag: lief.ELF.DynamicEntry.TAG, value: int) -> None: ... class DynamicEntryArray(DynamicEntry): array: list[int] - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, tag: lief.ELF.DYNAMIC_TAGS, value: int) -> None: ... + def __init__(self, tag: lief.ELF.DynamicEntry.TAG, array: list[int]) -> None: ... def append(self, function: int) -> lief.ELF.DynamicEntryArray: ... def insert(self, pos: int, function: int) -> lief.ELF.DynamicEntryArray: ... def remove(self, function: int) -> lief.ELF.DynamicEntryArray: ... @@ -1110,43 +1125,70 @@ class DynamicEntryArray(DynamicEntry): def __len__(self) -> int: ... class DynamicEntryFlags(DynamicEntry): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, tag: lief.ELF.DYNAMIC_TAGS, value: int) -> None: ... - @overload - def add(self, flag: lief.ELF.DYNAMIC_FLAGS) -> None: ... - @overload - def add(self, flag: lief.ELF.DYNAMIC_FLAGS_1) -> None: ... - @overload - def has(self, flag: lief.ELF.DYNAMIC_FLAGS) -> bool: ... - @overload - def has(self, flag: lief.ELF.DYNAMIC_FLAGS_1) -> bool: ... - @overload - def remove(self, flag: lief.ELF.DYNAMIC_FLAGS) -> None: ... - @overload - def remove(self, flag: lief.ELF.DYNAMIC_FLAGS_1) -> None: ... - @overload - def __contains__(self, arg: lief.ELF.DYNAMIC_FLAGS, /) -> bool: ... - @overload - def __contains__(self, arg: lief.ELF.DYNAMIC_FLAGS_1, /) -> bool: ... - @overload - def __iadd__(self, arg: lief.ELF.DYNAMIC_FLAGS, /) -> lief.ELF.DynamicEntryFlags: ... - @overload - def __iadd__(self, arg: lief.ELF.DYNAMIC_FLAGS_1, /) -> lief.ELF.DynamicEntryFlags: ... - @overload - def __isub__(self, arg: lief.ELF.DYNAMIC_FLAGS, /) -> lief.ELF.DynamicEntryFlags: ... - @overload - def __isub__(self, arg: lief.ELF.DYNAMIC_FLAGS_1, /) -> lief.ELF.DynamicEntryFlags: ... + class FLAG: + BIND_NOW: ClassVar[DynamicEntryFlags.FLAG] = ... + CONFALT: ClassVar[DynamicEntryFlags.FLAG] = ... + DIRECT: ClassVar[DynamicEntryFlags.FLAG] = ... + DISPRELDNE: ClassVar[DynamicEntryFlags.FLAG] = ... + DISPRELPND: ClassVar[DynamicEntryFlags.FLAG] = ... + EDITED: ClassVar[DynamicEntryFlags.FLAG] = ... + ENDFILTEE: ClassVar[DynamicEntryFlags.FLAG] = ... + GLOBAL: ClassVar[DynamicEntryFlags.FLAG] = ... + GLOBAUDIT: ClassVar[DynamicEntryFlags.FLAG] = ... + GROUP: ClassVar[DynamicEntryFlags.FLAG] = ... + HANDLE_ORIGIN: ClassVar[DynamicEntryFlags.FLAG] = ... + IGNMULDEF: ClassVar[DynamicEntryFlags.FLAG] = ... + INITFIRST: ClassVar[DynamicEntryFlags.FLAG] = ... + INTERPOSE: ClassVar[DynamicEntryFlags.FLAG] = ... + KMOD: ClassVar[DynamicEntryFlags.FLAG] = ... + LOADFLTR: ClassVar[DynamicEntryFlags.FLAG] = ... + NOCOMMON: ClassVar[DynamicEntryFlags.FLAG] = ... + NODEFLIB: ClassVar[DynamicEntryFlags.FLAG] = ... + NODELETE: ClassVar[DynamicEntryFlags.FLAG] = ... + NODIRECT: ClassVar[DynamicEntryFlags.FLAG] = ... + NODUMP: ClassVar[DynamicEntryFlags.FLAG] = ... + NOHDR: ClassVar[DynamicEntryFlags.FLAG] = ... + NOKSYMS: ClassVar[DynamicEntryFlags.FLAG] = ... + NOOPEN: ClassVar[DynamicEntryFlags.FLAG] = ... + NORELOC: ClassVar[DynamicEntryFlags.FLAG] = ... + NOW: ClassVar[DynamicEntryFlags.FLAG] = ... + ORIGIN: ClassVar[DynamicEntryFlags.FLAG] = ... + PIE: ClassVar[DynamicEntryFlags.FLAG] = ... + SINGLETON: ClassVar[DynamicEntryFlags.FLAG] = ... + STATIC_TLS: ClassVar[DynamicEntryFlags.FLAG] = ... + SYMBOLIC: ClassVar[DynamicEntryFlags.FLAG] = ... + SYMINTPOSE: ClassVar[DynamicEntryFlags.FLAG] = ... + TEXTREL: ClassVar[DynamicEntryFlags.FLAG] = ... + TRANS: ClassVar[DynamicEntryFlags.FLAG] = ... + WEAKFILTER: ClassVar[DynamicEntryFlags.FLAG] = ... + __name__: Any + def __init__(self, *args, **kwargs) -> None: ... + @staticmethod + def from_value(arg: int, /) -> lief.ELF.DynamicEntryFlags.FLAG: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... + @property + def value(self) -> int: ... + def __init__(self, *args, **kwargs) -> None: ... + def add(self, flag: lief.ELF.DynamicEntryFlags.FLAG) -> None: ... + def has(self, flag: lief.ELF.DynamicEntryFlags.FLAG) -> bool: ... + def remove(self, flag: lief.ELF.DynamicEntryFlags.FLAG) -> None: ... + def __contains__(self, arg: lief.ELF.DynamicEntryFlags.FLAG, /) -> bool: ... + def __iadd__(self, arg: lief.ELF.DynamicEntryFlags.FLAG, /) -> lief.ELF.DynamicEntryFlags: ... + def __isub__(self, arg: lief.ELF.DynamicEntryFlags.FLAG, /) -> lief.ELF.DynamicEntryFlags: ... @property - def flags(self) -> set[int]: ... + def flags(self) -> list[lief.ELF.DynamicEntryFlags.FLAG]: ... class DynamicEntryLibrary(DynamicEntry): name: Union[str,bytes] def __init__(self, library_name: str) -> None: ... class DynamicEntryRpath(DynamicEntry): - name: Union[str,bytes] paths: list[str] rpath: Union[str,bytes] @overload @@ -1160,7 +1202,6 @@ class DynamicEntryRpath(DynamicEntry): def __isub__(self, arg: str, /) -> lief.ELF.DynamicEntryRpath: ... class DynamicEntryRunPath(DynamicEntry): - name: Union[str,bytes] paths: list[str] runpath: Union[str,bytes] @overload @@ -1185,6 +1226,13 @@ class ELF_CLASS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.ELF_CLASS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1196,6 +1244,13 @@ class ELF_DATA: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.ELF_DATA: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1211,6 +1266,13 @@ class E_TYPE: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.E_TYPE: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1256,18 +1318,41 @@ class HEXAGON_EFLAGS: def from_value(arg: int, /) -> lief.ELF.HEXAGON_EFLAGS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.ELF.HEXAGON_EFLAGS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.ELF.HEXAGON_EFLAGS, /) -> lief.ELF.HEXAGON_EFLAGS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.ELF.HEXAGON_EFLAGS, /) -> int: ... @property def value(self) -> int: ... @@ -1329,6 +1414,13 @@ class IDENTITY: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.IDENTITY: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1342,18 +1434,41 @@ class LOONGARCH_EFLAGS: def from_value(arg: int, /) -> lief.ELF.LOONGARCH_EFLAGS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.ELF.LOONGARCH_EFLAGS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.ELF.LOONGARCH_EFLAGS, /) -> lief.ELF.LOONGARCH_EFLAGS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.ELF.LOONGARCH_EFLAGS, /) -> int: ... @property def value(self) -> int: ... @@ -1407,18 +1522,41 @@ class MIPS_EFLAGS: def from_value(arg: int, /) -> lief.ELF.MIPS_EFLAGS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.ELF.MIPS_EFLAGS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.ELF.MIPS_EFLAGS, /) -> lief.ELF.MIPS_EFLAGS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.ELF.MIPS_EFLAGS, /) -> int: ... @property def value(self) -> int: ... @@ -1471,6 +1609,13 @@ class Note(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.Note.TYPE: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... description: memoryview @@ -1506,6 +1651,13 @@ class NoteAbi(Note): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.NoteAbi.ABI: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... def __init__(self, *args, **kwargs) -> None: ... @@ -1529,6 +1681,13 @@ class NoteGnuProperty(Note): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.NoteGnuProperty.Property.TYPE: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... def __init__(self, *args, **kwargs) -> None: ... @@ -1570,6 +1729,13 @@ class OS_ABI: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.OS_ABI: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1581,18 +1747,41 @@ class PPC64_EFLAGS: def from_value(arg: int, /) -> lief.ELF.PPC64_EFLAGS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.ELF.PPC64_EFLAGS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.ELF.PPC64_EFLAGS, /) -> lief.ELF.PPC64_EFLAGS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.ELF.PPC64_EFLAGS, /) -> int: ... @property def value(self) -> int: ... @@ -1736,6 +1925,13 @@ class RELOCATION_AARCH64: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.RELOCATION_AARCH64: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1882,6 +2078,13 @@ class RELOCATION_ARM: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.RELOCATION_ARM: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1979,6 +2182,13 @@ class RELOCATION_LOONGARCH: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.RELOCATION_LOONGARCH: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2096,6 +2306,13 @@ class RELOCATION_MIPS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.RELOCATION_MIPS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2161,6 +2378,13 @@ class RELOCATION_PPC: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.RELOCATION_PPC: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2253,6 +2477,13 @@ class RELOCATION_PPC64: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.RELOCATION_PPC64: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2265,6 +2496,13 @@ class RELOCATION_PURPOSES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.RELOCATION_PURPOSES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2316,6 +2554,13 @@ class RELOCATION_X86_64: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.RELOCATION_X86_64: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2365,6 +2610,13 @@ class RELOCATION_i386: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.RELOCATION_i386: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2417,18 +2669,41 @@ class SECTION_FLAGS: def from_value(arg: int, /) -> lief.ELF.SECTION_FLAGS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.ELF.SECTION_FLAGS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.ELF.SECTION_FLAGS, /) -> lief.ELF.SECTION_FLAGS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.ELF.SECTION_FLAGS, /) -> int: ... @property def value(self) -> int: ... @@ -2474,6 +2749,13 @@ class SECTION_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.SECTION_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2488,18 +2770,41 @@ class SEGMENT_FLAGS: def from_value(arg: int, /) -> lief.ELF.SEGMENT_FLAGS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.ELF.SEGMENT_FLAGS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.ELF.SEGMENT_FLAGS, /) -> lief.ELF.SEGMENT_FLAGS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.ELF.SEGMENT_FLAGS, /) -> int: ... @property def value(self) -> int: ... @@ -2523,6 +2828,13 @@ class SEGMENT_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.SEGMENT_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2535,6 +2847,13 @@ class SYMBOL_BINDINGS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.SYMBOL_BINDINGS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2547,6 +2866,13 @@ class SYMBOL_SECTION_INDEX: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.SYMBOL_SECTION_INDEX: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2563,6 +2889,13 @@ class SYMBOL_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.SYMBOL_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2575,6 +2908,13 @@ class SYMBOL_VISIBILITY: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.SYMBOL_VISIBILITY: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2757,6 +3097,13 @@ class VERSION: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.VERSION: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2783,6 +3130,13 @@ class X86Features(NoteGnuProperty.Property): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.X86Features.FEATURE: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2794,6 +3148,13 @@ class X86Features(NoteGnuProperty.Property): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.X86Features.FLAG: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... def __init__(self, *args, **kwargs) -> None: ... @@ -2809,6 +3170,13 @@ class X86ISA(NoteGnuProperty.Property): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.X86ISA.FLAG: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2850,6 +3218,13 @@ class X86ISA(NoteGnuProperty.Property): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ELF.X86ISA.ISA: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... def __init__(self, *args, **kwargs) -> None: ... diff --git a/api/python/lief/MachO.pyi b/api/python/lief/MachO.pyi index 5ce9db8b51..e763bc9f14 100644 --- a/api/python/lief/MachO.pyi +++ b/api/python/lief/MachO.pyi @@ -33,6 +33,13 @@ class ARM64_RELOCATION: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.ARM64_RELOCATION: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -51,6 +58,13 @@ class ARM_RELOCATION: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.ARM_RELOCATION: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -63,6 +77,13 @@ class BINDING_CLASS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.BINDING_CLASS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -85,6 +106,13 @@ class BIND_OPCODES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.BIND_OPCODES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -96,6 +124,13 @@ class BIND_SPECIAL_DYLIB: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.BIND_SPECIAL_DYLIB: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -107,6 +142,13 @@ class BIND_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.BIND_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -400,6 +442,13 @@ class BuildToolVersion(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.BuildToolVersion.TOOLS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... def __init__(self, *args, **kwargs) -> None: ... @@ -419,6 +468,13 @@ class BuildVersion(LoadCommand): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.BuildVersion.PLATFORMS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... minos: list[int] @@ -461,6 +517,13 @@ class CPU_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.CPU_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -496,6 +559,13 @@ class DYLD_CHAINED_FORMAT: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.DYLD_CHAINED_FORMAT: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -516,6 +586,13 @@ class DYLD_CHAINED_PTR_FORMAT: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.DYLD_CHAINED_PTR_FORMAT: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -531,6 +608,13 @@ class DataCodeEntry(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.DataCodeEntry.TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... length: int @@ -727,6 +811,13 @@ class EXPORT_SYMBOL_FLAGS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.EXPORT_SYMBOL_FLAGS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -738,6 +829,13 @@ class EXPORT_SYMBOL_KINDS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.EXPORT_SYMBOL_KINDS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -783,6 +881,13 @@ class FILE_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.FILE_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -852,6 +957,13 @@ class HEADER_FLAGS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.HEADER_FLAGS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -933,6 +1045,13 @@ class LOAD_COMMAND_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.LOAD_COMMAND_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -964,6 +1083,13 @@ class MACHO_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.MACHO_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -993,6 +1119,13 @@ class PPC_RELOCATION: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.PPC_RELOCATION: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1022,6 +1155,13 @@ class REBASE_OPCODES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.REBASE_OPCODES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1033,6 +1173,13 @@ class REBASE_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.REBASE_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1045,6 +1192,13 @@ class RELOCATION_ORIGINS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.RELOCATION_ORIGINS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1076,6 +1230,10 @@ class Relocation(lief.Relocation): class RelocationDyld(Relocation): def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, arg: lief.MachO.RelocationDyld, /) -> bool: ... + def __gt__(self, arg: lief.MachO.RelocationDyld, /) -> bool: ... + def __le__(self, arg: lief.MachO.RelocationDyld, /) -> bool: ... + def __lt__(self, arg: lief.MachO.RelocationDyld, /) -> bool: ... class RelocationFixup(Relocation): target: int @@ -1102,6 +1260,13 @@ class SECTION_FLAGS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.SECTION_FLAGS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1132,6 +1297,13 @@ class SECTION_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.SECTION_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1143,6 +1315,13 @@ class SYMBOL_ORIGINS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.SYMBOL_ORIGINS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1251,6 +1430,13 @@ class Symbol(lief.Symbol): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.Symbol.CATEGORY: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... description: int @@ -1313,6 +1499,13 @@ class VM_PROTECTIONS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.VM_PROTECTIONS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1336,6 +1529,13 @@ class X86_64_RELOCATION: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.X86_64_RELOCATION: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1350,6 +1550,13 @@ class X86_RELOCATION: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MachO.X86_RELOCATION: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... diff --git a/api/python/lief/OAT.pyi b/api/python/lief/OAT.pyi index ad556e3746..485c1127e1 100644 --- a/api/python/lief/OAT.pyi +++ b/api/python/lief/OAT.pyi @@ -113,6 +113,13 @@ class HEADER_KEYS: PIC: ClassVar[HEADER_KEYS] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... class Header(lief.Object): class element_t: @@ -185,6 +192,13 @@ class INSTRUCTION_SETS: X86_64: ClassVar[INSTRUCTION_SETS] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... class Method(lief.Object): quick_code: list[int] @@ -218,6 +232,13 @@ class OAT_CLASS_STATUS: VERIFYING_AT_RUNTIME: ClassVar[OAT_CLASS_STATUS] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... class OAT_CLASS_TYPES: ALL_COMPILED: ClassVar[OAT_CLASS_TYPES] = ... @@ -225,6 +246,13 @@ class OAT_CLASS_TYPES: SOME_COMPILED: ClassVar[OAT_CLASS_TYPES] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... def android_version(arg: int, /) -> lief.Android.ANDROID_VERSIONS: ... @overload diff --git a/api/python/lief/PE.pyi b/api/python/lief/PE.pyi index 86d3351cee..456b508aee 100644 --- a/api/python/lief/PE.pyi +++ b/api/python/lief/PE.pyi @@ -44,18 +44,41 @@ class ACCELERATOR_FLAGS: def from_value(arg: int, /) -> lief.PE.ACCELERATOR_FLAGS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.PE.ACCELERATOR_FLAGS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.PE.ACCELERATOR_FLAGS, /) -> lief.PE.ACCELERATOR_FLAGS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.PE.ACCELERATOR_FLAGS, /) -> int: ... @property def value(self) -> int: ... @@ -238,6 +261,13 @@ class ACCELERATOR_VK_CODES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.ACCELERATOR_VK_CODES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -266,6 +296,13 @@ class ALGORITHMS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.ALGORITHMS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -286,6 +323,13 @@ class Attribute(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.Attribute.TYPE: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... def __init__(self, *args, **kwargs) -> None: ... @@ -609,6 +653,13 @@ class CODE_PAGES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.CODE_PAGES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -630,6 +681,13 @@ class CodeView(Debug): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.CodeView.SIGNATURES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @overload @@ -685,6 +743,13 @@ class DIALOG_BOX_STYLES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.DIALOG_BOX_STYLES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -711,6 +776,13 @@ class DataDirectory(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.DataDirectory.TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... rva: int @@ -748,6 +820,13 @@ class Debug(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.Debug.TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... addressof_rawdata: int @@ -843,6 +922,13 @@ class EXTENDED_WINDOW_STYLES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.EXTENDED_WINDOW_STYLES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -892,6 +978,13 @@ class FIXED_VERSION_FILE_FLAGS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.FIXED_VERSION_FILE_FLAGS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -915,6 +1008,13 @@ class FIXED_VERSION_FILE_SUB_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.FIXED_VERSION_FILE_SUB_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -930,6 +1030,13 @@ class FIXED_VERSION_FILE_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.FIXED_VERSION_FILE_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -952,6 +1059,13 @@ class FIXED_VERSION_OS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.FIXED_VERSION_OS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -988,18 +1102,41 @@ class Header(lief.Object): def from_value(arg: int, /) -> lief.PE.Header.CHARACTERISTICS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.PE.Header.CHARACTERISTICS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.PE.Header.CHARACTERISTICS, /) -> lief.PE.Header.CHARACTERISTICS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.PE.Header.CHARACTERISTICS, /) -> int: ... @property def value(self) -> int: ... @@ -1030,6 +1167,13 @@ class Header(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.Header.MACHINE_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... characteristics: int @@ -1057,6 +1201,13 @@ class IMPHASH_MODE: VT: ClassVar[IMPHASH_MODE] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... class Import(lief.Object): class it_entries: @@ -1142,6 +1293,13 @@ class LoadConfiguration(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.LoadConfiguration.VERSION: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... characteristics: int @@ -1199,18 +1357,41 @@ class LoadConfigurationV1(LoadConfigurationV0): def from_value(arg: int, /) -> lief.PE.LoadConfigurationV1.IMAGE_GUARD: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.PE.LoadConfigurationV1.IMAGE_GUARD, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.PE.LoadConfigurationV1.IMAGE_GUARD, /) -> lief.PE.LoadConfigurationV1.IMAGE_GUARD: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.PE.LoadConfigurationV1.IMAGE_GUARD, /) -> int: ... @property def value(self) -> int: ... guard_cf_check_function_pointer: int @@ -1318,18 +1499,41 @@ class OptionalHeader(lief.Object): def from_value(arg: int, /) -> lief.PE.OptionalHeader.DLL_CHARACTERISTICS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.PE.OptionalHeader.DLL_CHARACTERISTICS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.PE.OptionalHeader.DLL_CHARACTERISTICS, /) -> lief.PE.OptionalHeader.DLL_CHARACTERISTICS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.PE.OptionalHeader.DLL_CHARACTERISTICS, /) -> int: ... @property def value(self) -> int: ... @@ -1352,6 +1556,13 @@ class OptionalHeader(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.OptionalHeader.SUBSYSTEM: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... addressof_entrypoint: int @@ -1406,6 +1617,13 @@ class PE_TYPE: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.PE_TYPE: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1449,6 +1667,13 @@ class Pogo(Debug): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.Pogo.SIGNATURES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1579,6 +1804,13 @@ class RESOURCE_LANGS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.RESOURCE_LANGS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1623,6 +1855,13 @@ class RelocationEntry(lief.Relocation): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.RelocationEntry.BASE_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... data: int @@ -1861,6 +2100,13 @@ class ResourcesManager(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.ResourcesManager.TYPE: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -1996,6 +2242,13 @@ class SECTION_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.SECTION_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2020,6 +2273,13 @@ class SYMBOL_BASE_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.SYMBOL_BASE_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2033,6 +2293,13 @@ class SYMBOL_COMPLEX_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.SYMBOL_COMPLEX_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2044,6 +2311,13 @@ class SYMBOL_SECTION_NUMBER: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.SYMBOL_SECTION_NUMBER: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2076,6 +2350,13 @@ class SYMBOL_STORAGE_CLASS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.SYMBOL_STORAGE_CLASS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2122,18 +2403,41 @@ class Section(lief.Section): def from_value(arg: int, /) -> lief.PE.Section.CHARACTERISTICS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.PE.Section.CHARACTERISTICS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.PE.Section.CHARACTERISTICS, /) -> lief.PE.Section.CHARACTERISTICS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.PE.Section.CHARACTERISTICS, /) -> int: ... @property def value(self) -> int: ... characteristics: int @@ -2169,18 +2473,41 @@ class Signature(lief.Object): def from_value(arg: int, /) -> lief.PE.Signature.VERIFICATION_CHECKS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.PE.Signature.VERIFICATION_CHECKS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.PE.Signature.VERIFICATION_CHECKS, /) -> lief.PE.Signature.VERIFICATION_CHECKS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.PE.Signature.VERIFICATION_CHECKS, /) -> int: ... @property def value(self) -> int: ... @@ -2204,18 +2531,41 @@ class Signature(lief.Object): def from_value(arg: int, /) -> lief.PE.Signature.VERIFICATION_FLAGS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.PE.Signature.VERIFICATION_FLAGS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.PE.Signature.VERIFICATION_FLAGS, /) -> lief.PE.Signature.VERIFICATION_FLAGS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.PE.Signature.VERIFICATION_FLAGS, /) -> int: ... @property def value(self) -> int: ... @@ -2372,6 +2722,13 @@ class WINDOW_STYLES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.WINDOW_STYLES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2388,6 +2745,13 @@ class x509(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.x509.KEY_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2405,6 +2769,13 @@ class x509(lief.Object): def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PE.x509.KEY_USAGE: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -2436,18 +2807,41 @@ class x509(lief.Object): def from_value(arg: int, /) -> lief.PE.x509.VERIFICATION_FLAGS: ... def __abs__(self) -> Any: ... def __add__(self, other) -> Any: ... + @overload + def __and__(self, arg: int, /) -> int: ... + @overload + def __and__(self, arg: lief.PE.x509.VERIFICATION_FLAGS, /) -> int: ... def __floordiv__(self, other) -> Any: ... + def __ge__(self, arg: int, /) -> bool: ... + def __gt__(self, arg: int, /) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __invert__(self) -> int: ... + def __le__(self, arg: int, /) -> bool: ... def __lshift__(self, other) -> Any: ... + def __lt__(self, arg: int, /) -> bool: ... def __mul__(self, other) -> Any: ... def __neg__(self) -> Any: ... + @overload + def __or__(self, arg: int, /) -> int: ... + @overload + def __or__(self, arg: lief.PE.x509.VERIFICATION_FLAGS, /) -> lief.PE.x509.VERIFICATION_FLAGS: ... def __radd__(self, other) -> Any: ... + def __rand__(self, arg: int, /) -> int: ... def __rfloordiv__(self, other) -> Any: ... def __rlshift__(self, other) -> Any: ... def __rmul__(self, other) -> Any: ... + def __ror__(self, arg: int, /) -> int: ... def __rrshift__(self, other) -> Any: ... def __rshift__(self, other) -> Any: ... def __rsub__(self, other) -> Any: ... + def __rxor__(self, arg: int, /) -> int: ... def __sub__(self, other) -> Any: ... + @overload + def __xor__(self, arg: int, /) -> int: ... + @overload + def __xor__(self, arg: lief.PE.x509.VERIFICATION_FLAGS, /) -> int: ... @property def value(self) -> int: ... def __init__(self, *args, **kwargs) -> None: ... diff --git a/api/python/lief/__init__.pyi b/api/python/lief/__init__.pyi index d89e5dc3cb..d97c323703 100644 --- a/api/python/lief/__init__.pyi +++ b/api/python/lief/__init__.pyi @@ -27,6 +27,13 @@ class ARCHITECTURES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ARCHITECTURES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -39,6 +46,13 @@ class Binary(Object): UNKNOWN: ClassVar[Binary.FORMATS] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... class VA_TYPES: AUTO: ClassVar[Binary.VA_TYPES] = ... @@ -46,6 +60,13 @@ class Binary(Object): VA: ClassVar[Binary.VA_TYPES] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... class it_relocations: def __init__(self, *args, **kwargs) -> None: ... @@ -118,6 +139,13 @@ class ENDIANNESS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.ENDIANNESS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -130,6 +158,13 @@ class Function(Symbol): IMPORTED: ClassVar[Function.FLAGS] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... address: int @overload def __init__(self) -> None: ... @@ -176,6 +211,13 @@ class MODES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.MODES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -188,11 +230,19 @@ class OBJECT_TYPES: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.OBJECT_TYPES: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... class Object: def __init__(self, *args, **kwargs) -> None: ... + def __hash__(self) -> int: ... class PLATFORMS: ANDROID: ClassVar[PLATFORMS] = ... @@ -205,6 +255,13 @@ class PLATFORMS: def __init__(self, *args, **kwargs) -> None: ... @staticmethod def from_value(arg: int, /) -> lief.PLATFORMS: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... @property def value(self) -> int: ... @@ -257,6 +314,13 @@ class lief_errors: read_out_of_bound: ClassVar[lief_errors] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... class ok_error_t: def __init__(self, *args, **kwargs) -> None: ... diff --git a/api/python/lief/logging.pyi b/api/python/lief/logging.pyi index 3df1f4a528..eef04cb9f5 100644 --- a/api/python/lief/logging.pyi +++ b/api/python/lief/logging.pyi @@ -11,6 +11,13 @@ class LOGGING_LEVEL: WARNING: ClassVar[LOGGING_LEVEL] = ... __name__: Any def __init__(self, *args, **kwargs) -> None: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __hash__(self) -> int: ... + def __index__(self) -> Any: ... + def __int__(self) -> int: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... def disable() -> None: ... def enable() -> None: ... diff --git a/api/python/src/ELF/enums.cpp b/api/python/src/ELF/enums.cpp index c9a953dc54..9d47ea93e7 100644 --- a/api/python/src/ELF/enums.cpp +++ b/api/python/src/ELF/enums.cpp @@ -344,109 +344,6 @@ void init_enums(nb::module_& m) { .value(PY_ENUM(ELF_SEGMENT_FLAGS::PF_W)) .value(PY_ENUM(ELF_SEGMENT_FLAGS::PF_R)); - enum_(m, "DYNAMIC_TAGS") - .value(PY_ENUM(DYNAMIC_TAGS::DT_NULL)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_NEEDED)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_PLTRELSZ)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_PLTGOT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_HASH)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_STRTAB)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_SYMTAB)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_RELA)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_RELASZ)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_RELAENT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_STRSZ)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_SYMENT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_INIT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_FINI)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_SONAME)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_RPATH)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_SYMBOLIC)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_REL)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_RELSZ)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_RELENT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_PLTREL)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_DEBUG)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_TEXTREL)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_JMPREL)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_BIND_NOW)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_INIT_ARRAY)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_FINI_ARRAY)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_INIT_ARRAYSZ)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_FINI_ARRAYSZ)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_RUNPATH)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_FLAGS)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_PREINIT_ARRAY)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_PREINIT_ARRAYSZ)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_GNU_HASH)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_RELACOUNT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_RELCOUNT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_FLAGS_1)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_VERSYM)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_VERDEF)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_VERDEFNUM)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_VERNEED)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_VERNEEDNUM)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_SYMTAB_SHNDX)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_RELRSZ)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_RELR)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_RELRENT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_RLD_VERSION)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_TIME_STAMP)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_ICHECKSUM)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_IVERSION)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_FLAGS)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_BASE_ADDRESS)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_MSYM)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_CONFLICT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_LIBLIST)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_LOCAL_GOTNO)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_CONFLICTNO)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_LIBLISTNO)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_SYMTABNO)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_UNREFEXTNO)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_GOTSYM)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_HIPAGENO)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_RLD_MAP)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_DELTA_CLASS)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_DELTA_CLASS_NO)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_DELTA_INSTANCE)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_DELTA_INSTANCE_NO)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_DELTA_RELOC)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_DELTA_RELOC_NO)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_DELTA_SYM)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_DELTA_SYM_NO)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_DELTA_CLASSSYM)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_DELTA_CLASSSYM_NO)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_CXX_FLAGS)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_PIXIE_INIT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_SYMBOL_LIB)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_LOCALPAGE_GOTIDX)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_LOCAL_GOTIDX)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_HIDDEN_GOTIDX)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_PROTECTED_GOTIDX)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_OPTIONS)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_INTERFACE)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_DYNSTR_ALIGN)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_INTERFACE_SIZE)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_RLD_TEXT_RESOLVE_ADDR)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_PERF_SUFFIX)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_COMPACT_SIZE)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_GP_VALUE)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_AUX_DYNAMIC)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_PLTGOT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_RWPLT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_REL_OFFSET)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_REL_SIZE)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_REL)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_RELSZ)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_RELA)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_RELASZ)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_RELR)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_RELRSZ)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_RELRENT)) - .value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_RELRCOUNT)); - enum_(m, "SYMBOL_TYPES") .value(PY_ENUM(ELF_SYMBOL_TYPES::STT_NOTYPE)) @@ -1279,43 +1176,6 @@ void init_enums(nb::module_& m) { .value(PY_ENUM(SYMBOL_SECTION_INDEX::SHN_COMMON)) .value(PY_ENUM(SYMBOL_SECTION_INDEX::SHN_HIRESERVE)); - - enum_(m, "DYNAMIC_FLAGS", nb::is_arithmetic()) - .value(PY_ENUM(DYNAMIC_FLAGS::DF_ORIGIN)) - .value(PY_ENUM(DYNAMIC_FLAGS::DF_SYMBOLIC)) - .value(PY_ENUM(DYNAMIC_FLAGS::DF_TEXTREL)) - .value(PY_ENUM(DYNAMIC_FLAGS::DF_BIND_NOW)) - .value(PY_ENUM(DYNAMIC_FLAGS::DF_STATIC_TLS)); - - enum_(m, "DYNAMIC_FLAGS_1", nb::is_arithmetic()) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_NOW)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_GLOBAL)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_GROUP)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_NODELETE)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_LOADFLTR)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_INITFIRST)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_NOOPEN)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_ORIGIN)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_DIRECT)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_TRANS)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_INTERPOSE)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_NODEFLIB)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_NODUMP)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_CONFALT)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_ENDFILTEE)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_DISPRELDNE)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_DISPRELPND)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_NODIRECT)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_IGNMULDEF)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_NOKSYMS)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_NOHDR)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_EDITED)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_NORELOC)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_SYMINTPOSE)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_GLOBAUDIT)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_SINGLETON)) - .value(PY_ENUM(DYNAMIC_FLAGS_1::DF_1_PIE)); - enum_(m, "SYMBOL_VISIBILITY") .value(PY_ENUM(ELF_SYMBOL_VISIBILITY::STV_DEFAULT)) .value(PY_ENUM(ELF_SYMBOL_VISIBILITY::STV_HIDDEN)) diff --git a/api/python/src/ELF/objects/pyBinary.cpp b/api/python/src/ELF/objects/pyBinary.cpp index a33018d990..b07df41178 100644 --- a/api/python/src/ELF/objects/pyBinary.cpp +++ b/api/python/src/ELF/objects/pyBinary.cpp @@ -322,10 +322,10 @@ void create(nb::module_& m) { nb::rv_policy::reference_internal) .def("get", - nb::overload_cast(&Binary::get), + nb::overload_cast(&Binary::get), R"delim( Return the first binary's :class:`~lief.ELF.DynamicEntry` from the given - :class:`~lief.ELF.DYNAMIC_TAGS`. + :class:`~lief.ELF.DynamicEntry.TAG`. It returns None if the dynamic entry can't be found. )delim"_doc, @@ -366,10 +366,10 @@ void create(nb::module_& m) { nb::rv_policy::reference_internal) .def("has", - nb::overload_cast(&Binary::has, nb::const_), + nb::overload_cast(&Binary::has, nb::const_), R"delim( Check if it exists a :class:`~lief.ELF.DynamicEntry` with the given - :class:`~lief.ELF.DYNAMIC_TAGS` + :class:`~lief.ELF.DynamicEntry.TAG` )delim"_doc, "tag"_a) @@ -500,8 +500,8 @@ void create(nb::module_& m) { "dynamic_entry"_a) .def("remove", - nb::overload_cast(&Binary::remove), - "Remove **all** the " RST_CLASS_REF(lief.ELF.DynamicEntry) " with the given " RST_CLASS_REF(lief.ELF.DYNAMIC_TAGS) ""_doc, + nb::overload_cast(&Binary::remove), + "Remove **all** the " RST_CLASS_REF(lief.ELF.DynamicEntry) " with the given " RST_CLASS_REF(lief.ELF.DynamicEntry.TAG) ""_doc, "tag"_a) .def("remove", @@ -733,7 +733,7 @@ void create(nb::module_& m) { return &self; }, nb::rv_policy::reference_internal) .def(nb::self -= DynamicEntry(), nb::rv_policy::reference_internal) - .def(nb::self -= DYNAMIC_TAGS(), nb::rv_policy::reference_internal) + .def(nb::self -= DynamicEntry::TAG(), nb::rv_policy::reference_internal) .def("__isub__", [] (Binary& self, const Note& note) { self -= note; return &self; @@ -749,7 +749,7 @@ void create(nb::module_& m) { nb::rv_policy::reference_internal) .def("__getitem__", - nb::overload_cast(&Binary::operator[]), + nb::overload_cast(&Binary::operator[]), nb::rv_policy::reference_internal) .def("__getitem__", @@ -761,8 +761,8 @@ void create(nb::module_& m) { "Check if a " RST_CLASS_REF(lief.ELF.Segment) " of *type* (" RST_CLASS_REF(lief.ELF.SEGMENT_TYPES) ") exists"_doc) .def("__contains__", - nb::overload_cast(&Binary::has, nb::const_), - "Check if the " RST_CLASS_REF(lief.ELF.DynamicEntry) " associated with the given " RST_CLASS_REF(lief.ELF.DYNAMIC_TAGS) " exists"_doc) + nb::overload_cast(&Binary::has, nb::const_), + "Check if the " RST_CLASS_REF(lief.ELF.DynamicEntry) " associated with the given " RST_CLASS_REF(lief.ELF.DynamicEntry.TAG) " exists"_doc) .def("__contains__", nb::overload_cast(&Binary::has, nb::const_), diff --git a/api/python/src/ELF/objects/pyBuilder.cpp b/api/python/src/ELF/objects/pyBuilder.cpp index fc212141cb..cd9994f268 100644 --- a/api/python/src/ELF/objects/pyBuilder.cpp +++ b/api/python/src/ELF/objects/pyBuilder.cpp @@ -37,21 +37,21 @@ void create(nb::module_& m) { .def_rw("force_relocate", &Builder::config_t::force_relocate, "Force to relocate all the ELF structures that can be relocated (mostly for testing)"_doc) - .def_rw("dt_hash", &Builder::config_t::dt_hash, "Rebuild :attr:`~lief.ELF.DYNAMIC_TAGS.HASH`"_doc) - .def_rw("dyn_str", &Builder::config_t::dyn_str, "Rebuild :attr:`~lief.ELF.DYNAMIC_TAGS.STRTAB`"_doc) + .def_rw("dt_hash", &Builder::config_t::dt_hash, "Rebuild :attr:`~lief.ELF.DynamicEntry.TAG.HASH`"_doc) + .def_rw("dyn_str", &Builder::config_t::dyn_str, "Rebuild :attr:`~lief.ELF.DynamicEntry.TAG.STRTAB`"_doc) .def_rw("dynamic_section", &Builder::config_t::dynamic_section, "Rebuild the `PT_DYNAMIC` segment"_doc) - .def_rw("fini_array", &Builder::config_t::fini_array, "Rebuild :attr:`~lief.ELF.DYNAMIC_TAGS.FINI_ARRAY`"_doc) - .def_rw("init_array", &Builder::config_t::init_array, "Rebuild :attr:`~lief.ELF.DYNAMIC_TAGS.INIT_ARRAY`"_doc) + .def_rw("fini_array", &Builder::config_t::fini_array, "Rebuild :attr:`~lief.ELF.DynamicEntry.TAG.FINI_ARRAY`"_doc) + .def_rw("init_array", &Builder::config_t::init_array, "Rebuild :attr:`~lief.ELF.DynamicEntry.TAG.INIT_ARRAY`"_doc) .def_rw("interpreter", &Builder::config_t::interpreter, "Rebuild the `PT_INTERP` segment"_doc) - .def_rw("jmprel", &Builder::config_t::jmprel, "Rebuild :attr:`~lief.ELF.DYNAMIC_TAGS.JMPREL`"_doc) + .def_rw("jmprel", &Builder::config_t::jmprel, "Rebuild :attr:`~lief.ELF.DynamicEntry.TAG.JMPREL`"_doc) .def_rw("notes", &Builder::config_t::notes, "Rebuild `PT_NOTES` segment(s)"_doc) - .def_rw("preinit_array", &Builder::config_t::preinit_array, "Rebuild :attr:`~lief.ELF.DYNAMIC_TAGS.PREINIT_ARRAY`"_doc) - .def_rw("rela", &Builder::config_t::rela, "Rebuild :attr:`~lief.ELF.DYNAMIC_TAGS.RELA`"_doc) + .def_rw("preinit_array", &Builder::config_t::preinit_array, "Rebuild :attr:`~lief.ELF.DynamicEntry.TAG.PREINIT_ARRAY`"_doc) + .def_rw("rela", &Builder::config_t::rela, "Rebuild :attr:`~lief.ELF.DynamicEntry.TAG.RELA`"_doc) .def_rw("static_symtab", &Builder::config_t::static_symtab, "Rebuild `.symtab` section"_doc) - .def_rw("sym_verdef", &Builder::config_t::sym_verdef, "Rebuild :attr:`~lief.ELF.DYNAMIC_TAGS.VERDEF`"_doc) - .def_rw("sym_verneed", &Builder::config_t::sym_verneed, "Rebuild :attr:`~lief.ELF.DYNAMIC_TAGS.VERNEED`"_doc) - .def_rw("sym_versym", &Builder::config_t::sym_versym, "Rebuild :attr:`~lief.ELF.DYNAMIC_TAGS.VERSYM`"_doc) - .def_rw("symtab", &Builder::config_t::symtab, "Rebuild :attr:`~lief.ELF.DYNAMIC_TAGS.SYMTAB`"_doc); + .def_rw("sym_verdef", &Builder::config_t::sym_verdef, "Rebuild :attr:`~lief.ELF.DynamicEntry.TAG.VERDEF`"_doc) + .def_rw("sym_verneed", &Builder::config_t::sym_verneed, "Rebuild :attr:`~lief.ELF.DynamicEntry.TAG.VERNEED`"_doc) + .def_rw("sym_versym", &Builder::config_t::sym_versym, "Rebuild :attr:`~lief.ELF.DynamicEntry.TAG.VERSYM`"_doc) + .def_rw("symtab", &Builder::config_t::symtab, "Rebuild :attr:`~lief.ELF.DynamicEntry.TAG.SYMTAB`"_doc); builder .def(nb::init(), diff --git a/api/python/src/ELF/objects/pyDynamicEntry.cpp b/api/python/src/ELF/objects/pyDynamicEntry.cpp index 1b03d91584..b8f41f5e10 100644 --- a/api/python/src/ELF/objects/pyDynamicEntry.cpp +++ b/api/python/src/ELF/objects/pyDynamicEntry.cpp @@ -18,6 +18,7 @@ #include #include "ELF/pyELF.hpp" +#include "enums_wrapper.hpp" #include "LIEF/ELF/DynamicEntry.hpp" @@ -25,22 +26,130 @@ namespace LIEF::ELF::py { template<> void create(nb::module_& m) { - nb::class_(m, "DynamicEntry", + nb::class_ entry(m, "DynamicEntry", R"delim( Class which represents an entry in the dynamic table These entries are located in the ``.dynamic`` section or the ``PT_DYNAMIC`` segment - )delim"_doc) + )delim"_doc); + + #define ENTRY(X) .value(to_string(DynamicEntry::TAG::X), DynamicEntry::TAG::X) + enum_(entry, "TAG") + .value("NULL", DynamicEntry::TAG::DT_NULL) + ENTRY(NEEDED) + ENTRY(PLTRELSZ) + ENTRY(PLTGOT) + ENTRY(HASH) + ENTRY(STRTAB) + ENTRY(SYMTAB) + ENTRY(RELA) + ENTRY(RELASZ) + ENTRY(RELAENT) + ENTRY(STRSZ) + ENTRY(SYMENT) + ENTRY(INIT) + ENTRY(FINI) + ENTRY(SONAME) + ENTRY(RPATH) + ENTRY(SYMBOLIC) + ENTRY(REL) + ENTRY(RELSZ) + ENTRY(RELENT) + ENTRY(PLTREL) + ENTRY(DEBUG) + ENTRY(TEXTREL) + ENTRY(JMPREL) + ENTRY(BIND_NOW) + ENTRY(INIT_ARRAY) + ENTRY(FINI_ARRAY) + ENTRY(INIT_ARRAYSZ) + ENTRY(FINI_ARRAYSZ) + ENTRY(RUNPATH) + ENTRY(FLAGS) + ENTRY(PREINIT_ARRAY) + ENTRY(PREINIT_ARRAYSZ) + ENTRY(SYMTAB_SHNDX) + ENTRY(RELRSZ) + ENTRY(RELR) + ENTRY(RELRENT) + ENTRY(GNU_HASH) + ENTRY(RELACOUNT) + ENTRY(RELCOUNT) + ENTRY(FLAGS_1) + ENTRY(VERSYM) + ENTRY(VERDEF) + ENTRY(VERDEFNUM) + ENTRY(VERNEED) + ENTRY(VERNEEDNUM) + ENTRY(ANDROID_REL_OFFSET) + ENTRY(ANDROID_REL_SIZE) + ENTRY(ANDROID_REL) + ENTRY(ANDROID_RELSZ) + ENTRY(ANDROID_RELA) + ENTRY(ANDROID_RELASZ) + ENTRY(ANDROID_RELR) + ENTRY(ANDROID_RELRSZ) + ENTRY(ANDROID_RELRENT) + ENTRY(ANDROID_RELRCOUNT) + ENTRY(MIPS_RLD_VERSION) + ENTRY(MIPS_TIME_STAMP) + ENTRY(MIPS_ICHECKSUM) + ENTRY(MIPS_IVERSION) + ENTRY(MIPS_FLAGS) + ENTRY(MIPS_BASE_ADDRESS) + ENTRY(MIPS_MSYM) + ENTRY(MIPS_CONFLICT) + ENTRY(MIPS_LIBLIST) + ENTRY(MIPS_LOCAL_GOTNO) + ENTRY(MIPS_CONFLICTNO) + ENTRY(MIPS_LIBLISTNO) + ENTRY(MIPS_SYMTABNO) + ENTRY(MIPS_UNREFEXTNO) + ENTRY(MIPS_GOTSYM) + ENTRY(MIPS_HIPAGENO) + ENTRY(MIPS_RLD_MAP) + ENTRY(MIPS_DELTA_CLASS) + ENTRY(MIPS_DELTA_CLASS_NO) + ENTRY(MIPS_DELTA_INSTANCE) + ENTRY(MIPS_DELTA_INSTANCE_NO) + ENTRY(MIPS_DELTA_RELOC) + ENTRY(MIPS_DELTA_RELOC_NO) + ENTRY(MIPS_DELTA_SYM) + ENTRY(MIPS_DELTA_SYM_NO) + ENTRY(MIPS_DELTA_CLASSSYM) + ENTRY(MIPS_DELTA_CLASSSYM_NO) + ENTRY(MIPS_CXX_FLAGS) + ENTRY(MIPS_PIXIE_INIT) + ENTRY(MIPS_SYMBOL_LIB) + ENTRY(MIPS_LOCALPAGE_GOTIDX) + ENTRY(MIPS_LOCAL_GOTIDX) + ENTRY(MIPS_HIDDEN_GOTIDX) + ENTRY(MIPS_PROTECTED_GOTIDX) + ENTRY(MIPS_OPTIONS) + ENTRY(MIPS_INTERFACE) + ENTRY(MIPS_DYNSTR_ALIGN) + ENTRY(MIPS_INTERFACE_SIZE) + ENTRY(MIPS_RLD_TEXT_RESOLVE_ADDR) + ENTRY(MIPS_PERF_SUFFIX) + ENTRY(MIPS_COMPACT_SIZE) + ENTRY(MIPS_GP_VALUE) + ENTRY(MIPS_AUX_DYNAMIC) + ENTRY(MIPS_PLTGOT) + ENTRY(MIPS_RWPLT) + ; + #undef ENTRY + + entry .def(nb::init<>(), "Default constructor"_doc) - .def(nb::init(), - "Constructor from a " RST_CLASS_REF(lief.ELF.DYNAMIC_TAGS) " and value"_doc, + .def(nb::init(), + "Constructor from a " RST_CLASS_REF(lief.ELF.DynamicEntry.TAG) " and value"_doc, "tag"_a, "value"_a) .def_prop_rw("tag", nb::overload_cast<>(&DynamicEntry::tag, nb::const_), - nb::overload_cast(&DynamicEntry::tag), - "Return the entry's " RST_CLASS_REF(lief.ELF.DYNAMIC_TAGS) " which represent the entry type"_doc) + nb::overload_cast(&DynamicEntry::tag), + "Return the entry's " RST_CLASS_REF(lief.ELF.DynamicEntry.TAG) " which represent the entry type"_doc) .def_prop_rw("value", nb::overload_cast<>(&DynamicEntry::value, nb::const_), diff --git a/api/python/src/ELF/objects/pyDynamicEntryArray.cpp b/api/python/src/ELF/objects/pyDynamicEntryArray.cpp index 625c406523..4a633b4704 100644 --- a/api/python/src/ELF/objects/pyDynamicEntryArray.cpp +++ b/api/python/src/ELF/objects/pyDynamicEntryArray.cpp @@ -40,11 +40,9 @@ void create(nb::module_& m) { The underlying values are 64-bits integers to cover both: ELF32 and ELF64 binaries. )delim"_doc) - .def(nb::init<>()) - .def(nb::init(), - "Constructor with " RST_CLASS_REF(lief.ELF.DYNAMIC_TAGS) " and value"_doc, - "tag"_a, "value"_a) + .def(nb::init(), + "tag"_a, "array"_a) .def_prop_rw("array", nb::overload_cast<>(&DynamicEntryArray::array, nb::const_), @@ -70,7 +68,6 @@ void create(nb::module_& m) { "function"_a, nb::rv_policy::reference_internal) - .def(nb::self += uint64_t()) .def(nb::self -= uint64_t()) diff --git a/api/python/src/ELF/objects/pyDynamicEntryFlags.cpp b/api/python/src/ELF/objects/pyDynamicEntryFlags.cpp index 0b6e1dc9ad..25bc0e628c 100644 --- a/api/python/src/ELF/objects/pyDynamicEntryFlags.cpp +++ b/api/python/src/ELF/objects/pyDynamicEntryFlags.cpp @@ -18,9 +18,10 @@ #include #include -#include +#include #include "ELF/pyELF.hpp" +#include "enums_wrapper.hpp" #include "LIEF/ELF/DynamicEntryFlags.hpp" #include "LIEF/ELF/DynamicEntry.hpp" @@ -29,61 +30,76 @@ namespace LIEF::ELF::py { template<> void create(nb::module_& m) { - nb::class_(m, "DynamicEntryFlags") - .def(nb::init<>()) - - .def(nb::init(), - "Constructor with " RST_CLASS_REF(lief.ELF.DYNAMIC_TAGS) " and value"_doc, - "tag"_a, "value"_a) - + nb::class_ entry(m, "DynamicEntryFlags"); + + #define ENTRY(X) .value(to_string(DynamicEntryFlags::FLAG::X), DynamicEntryFlags::FLAG::X) + enum_(entry, "FLAG") + ENTRY(ORIGIN) + ENTRY(SYMBOLIC) + ENTRY(TEXTREL) + ENTRY(BIND_NOW) + ENTRY(STATIC_TLS) + ENTRY(NOW) + ENTRY(GLOBAL) + ENTRY(GROUP) + ENTRY(NODELETE) + ENTRY(LOADFLTR) + ENTRY(INITFIRST) + ENTRY(NOOPEN) + ENTRY(HANDLE_ORIGIN) + ENTRY(DIRECT) + ENTRY(TRANS) + ENTRY(INTERPOSE) + ENTRY(NODEFLIB) + ENTRY(NODUMP) + ENTRY(CONFALT) + ENTRY(ENDFILTEE) + ENTRY(DISPRELDNE) + ENTRY(DISPRELPND) + ENTRY(NODIRECT) + ENTRY(IGNMULDEF) + ENTRY(NOKSYMS) + ENTRY(NOHDR) + ENTRY(EDITED) + ENTRY(NORELOC) + ENTRY(SYMINTPOSE) + ENTRY(GLOBAUDIT) + ENTRY(SINGLETON) + ENTRY(PIE) + ENTRY(KMOD) + ENTRY(WEAKFILTER) + ENTRY(NOCOMMON) + ; + #undef ENTRY + + entry .def_prop_ro("flags", &DynamicEntryFlags::flags, - "Return list of " RST_CLASS_REF(lief.ELF.DYNAMIC_FLAGS) " or " RST_CLASS_REF(lief.ELF.DYNAMIC_FLAGS_1) " (integer)"_doc, + "Return list of :class:`~.FLAG`"_doc, nb::rv_policy::move) .def("has", - nb::overload_cast(&DynamicEntryFlags::has, nb::const_), - "Check if this entry contains the given " RST_CLASS_REF(lief.ELF.DYNAMIC_FLAGS) ""_doc, + nb::overload_cast(&DynamicEntryFlags::has, nb::const_), + "Check if this entry contains the given :class:`~.FLAG`"_doc, "flag"_a) - .def("has", - nb::overload_cast(&DynamicEntryFlags::has, nb::const_), - "Check if this entry contains the given " RST_CLASS_REF(lief.ELF.DYNAMIC_FLAGS_1) ""_doc, - "flag"_a) - - .def("add", - nb::overload_cast(&DynamicEntryFlags::add), - "Add the given " RST_CLASS_REF(lief.ELF.DYNAMIC_FLAGS) ""_doc, - "flag"_a) .def("add", - nb::overload_cast(&DynamicEntryFlags::add), - "Add the given " RST_CLASS_REF(lief.ELF.DYNAMIC_FLAGS_1) ""_doc, + nb::overload_cast(&DynamicEntryFlags::add), + "Add the given :class:`~.FLAG`"_doc, "flag"_a) .def("remove", - nb::overload_cast(&DynamicEntryFlags::remove), - "Remove the given " RST_CLASS_REF(lief.ELF.DYNAMIC_FLAGS) ""_doc, + nb::overload_cast(&DynamicEntryFlags::remove), + "Remove the given :class:`~.FLAG`"_doc, "flag"_a) - .def("remove", - nb::overload_cast(&DynamicEntryFlags::remove), - "Remove the given " RST_CLASS_REF(lief.ELF.DYNAMIC_FLAGS_1) ""_doc, - "flag"_a) - - .def(nb::self += DYNAMIC_FLAGS()) - .def(nb::self += DYNAMIC_FLAGS_1()) - - .def(nb::self -= DYNAMIC_FLAGS()) - .def(nb::self -= DYNAMIC_FLAGS_1()) - - .def("__contains__", - nb::overload_cast(&DynamicEntryFlags::has, nb::const_), - "Check if the given " RST_CLASS_REF(lief.ELF.DYNAMIC_FLAGS) " is present"_doc) + .def(nb::self += DynamicEntryFlags::FLAG()) + .def(nb::self -= DynamicEntryFlags::FLAG()) .def("__contains__", - nb::overload_cast(&DynamicEntryFlags::has, nb::const_), - "Check if the given " RST_CLASS_REF(lief.ELF.DYNAMIC_FLAGS_1) " is present"_doc) + nb::overload_cast(&DynamicEntryFlags::has, nb::const_), + "Check if the given :class:`~.FLAG` is present"_doc) LIEF_DEFAULT_STR(DynamicEntryFlags); } diff --git a/api/python/src/ELF/objects/pyDynamicEntryLibrary.cpp b/api/python/src/ELF/objects/pyDynamicEntryLibrary.cpp index 7ccc616b72..2bb80fd7c9 100644 --- a/api/python/src/ELF/objects/pyDynamicEntryLibrary.cpp +++ b/api/python/src/ELF/objects/pyDynamicEntryLibrary.cpp @@ -42,7 +42,7 @@ void create(nb::module_& m) { [] (const DynamicEntryLibrary& obj) { return LIEF::py::safe_string(obj.name()); }, - nb::overload_cast(&DynamicEntryLibrary::name), + nb::overload_cast(&DynamicEntryLibrary::name), "Library associated with this entry (e.g. ``libc.so.6``)"_doc) LIEF_DEFAULT_STR(DynamicEntryLibrary); diff --git a/api/python/src/ELF/objects/pyDynamicEntryRpath.cpp b/api/python/src/ELF/objects/pyDynamicEntryRpath.cpp index 891438a888..2a4f554683 100644 --- a/api/python/src/ELF/objects/pyDynamicEntryRpath.cpp +++ b/api/python/src/ELF/objects/pyDynamicEntryRpath.cpp @@ -44,13 +44,6 @@ void create(nb::module_& m) { "Constructor from a list of paths"_doc, "paths"_a) - .def_prop_rw("name", - [] (const DynamicEntryRpath& obj) { - return LIEF::py::safe_string(obj.name()); - }, - nb::overload_cast(&DynamicEntryRpath::name), - "The actual rpath as a string"_doc) - .def_prop_rw("rpath", [] (const DynamicEntryRpath& obj) { return LIEF::py::safe_string(obj.rpath()); diff --git a/api/python/src/ELF/objects/pyDynamicEntryRunPath.cpp b/api/python/src/ELF/objects/pyDynamicEntryRunPath.cpp index 63c6c1496c..81fdc5034d 100644 --- a/api/python/src/ELF/objects/pyDynamicEntryRunPath.cpp +++ b/api/python/src/ELF/objects/pyDynamicEntryRunPath.cpp @@ -44,18 +44,11 @@ void create(nb::module_& m) { "Constructor from a list of paths"_doc, "paths"_a) - .def_prop_rw("name", - [] (const DynamicEntryRunPath& obj) { - return LIEF::py::safe_string(obj.name()); - }, - nb::overload_cast(&DynamicEntryRunPath::name), - "Runpath raw value"_doc) - .def_prop_rw("runpath", [] (const DynamicEntryRunPath& obj) { return LIEF::py::safe_string(obj.runpath()); }, - nb::overload_cast(&DynamicEntryRunPath::runpath), + nb::overload_cast(&DynamicEntryRunPath::runpath), "Runpath raw value"_doc) .def_prop_rw("paths", diff --git a/api/python/src/ELF/objects/pyDynamicSharedObject.cpp b/api/python/src/ELF/objects/pyDynamicSharedObject.cpp index 437af6320b..8ee433d923 100644 --- a/api/python/src/ELF/objects/pyDynamicSharedObject.cpp +++ b/api/python/src/ELF/objects/pyDynamicSharedObject.cpp @@ -43,7 +43,7 @@ void create(nb::module_& m) { [] (const DynamicSharedObject& obj) { return LIEF::py::safe_string(obj.name()); }, - nb::overload_cast(&DynamicSharedObject::name), + nb::overload_cast(&DynamicSharedObject::name), "Return the library name"_doc) LIEF_DEFAULT_STR(DynamicSharedObject); diff --git a/doc/sphinx/api/cpp/elf.rst b/doc/sphinx/api/cpp/elf.rst index 63d6a0225c..c439487806 100644 --- a/doc/sphinx/api/cpp/elf.rst +++ b/doc/sphinx/api/cpp/elf.rst @@ -387,24 +387,6 @@ Segment flags ---------- -Dynamic tags -~~~~~~~~~~~~ - -.. doxygenenum:: LIEF::ELF::DYNAMIC_TAGS - ----------- - -Dynamic flags -~~~~~~~~~~~~~ -.. doxygenenum:: LIEF::ELF::DYNAMIC_FLAGS - ----------- - -Dynamic flags 1 -~~~~~~~~~~~~~~~ -.. doxygenenum:: LIEF::ELF::DYNAMIC_FLAGS_1 - ----------- Dynamic symbols counting ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/sphinx/api/python/elf.rst b/doc/sphinx/api/python/elf.rst index 29f3c953fe..99ed69b784 100644 --- a/doc/sphinx/api/python/elf.rst +++ b/doc/sphinx/api/python/elf.rst @@ -350,28 +350,6 @@ Version ---------- -Dynamic tags -~~~~~~~~~~~~ - -.. autoclass:: lief.ELF.DYNAMIC_TAGS - ----------- - -Dynamic flags -~~~~~~~~~~~~~ - -.. autoclass:: lief.ELF.DYNAMIC_FLAGS - ----------- - - -Dynamic flags 1 -~~~~~~~~~~~~~~~ - -.. autoclass:: lief.ELF.DYNAMIC_FLAGS_1 - ----------- - Symbol types ~~~~~~~~~~~~ diff --git a/doc/sphinx/tutorials/08_elf_bin2lib.rst b/doc/sphinx/tutorials/08_elf_bin2lib.rst index 6077d18f0c..a4ff11e400 100644 --- a/doc/sphinx/tutorials/08_elf_bin2lib.rst +++ b/doc/sphinx/tutorials/08_elf_bin2lib.rst @@ -240,7 +240,7 @@ In order to circumvent this test, LIEF can be used to remove this ``DF_1_PIE`` f import sys path = sys.argv[1] bin_ = lief.parse(path) - bin_[lief.ELF.DYNAMIC_TAGS.FLAGS_1].remove(lief.ELF.DYNAMIC_FLAGS_1.PIE) + bin_[lief.ELF.DynamicEntry.TAG.FLAGS_1].remove(lief.ELF.DynamicEntryFlags.FLAG.PIE) bin_.write(path + ".patched") diff --git a/doc/sphinx/tutorials/09_frida_lief.rst b/doc/sphinx/tutorials/09_frida_lief.rst index b0f0b711fc..312e1a34e9 100644 --- a/doc/sphinx/tutorials/09_frida_lief.rst +++ b/doc/sphinx/tutorials/09_frida_lief.rst @@ -276,11 +276,11 @@ Here is a quick summary of advantages/disadvantages of this technique .. rubric:: Notes -.. [1] Note that LIEF **does not** modify the :attr:`~lief.ELF.DYNAMIC_TAGS.DEBUG` entry ... +.. [1] Note that LIEF **does not** modify the :attr:`~lief.ELF.DynamicEntry.TAG.DEBUG` entry ... .. [2] Modification of the ELF Dynamic section is not as easy as the API looks like. -.. [3] In the ELF format they are located in the :attr:`~lief.ELF.DYNAMIC_TAGS.INIT_ARRAY` or :attr:`~lief.ELF.DYNAMIC_TAGS.INIT` entries +.. [3] In the ELF format they are located in the :attr:`~lief.ELF.DynamicEntry.TAG.INIT_ARRAY` or :attr:`~lief.ELF.DynamicEntry.TAG.INIT` entries .. [4] For those who are interested, checks are done in the ``framework_base/core/jni/com_android_internal_content_NativeLibraryHelper.cpp`` file. Actually these checks on the prefix and suffix are only done if the application is not *debuggable*. diff --git a/examples/c/elf_reader.c b/examples/c/elf_reader.c index 052077d1f9..f8c7ab4aca 100644 --- a/examples/c/elf_reader.c +++ b/examples/c/elf_reader.c @@ -247,11 +247,6 @@ int main(int argc, char **argv) { DYNAMIC_TAGS_to_string(e->tag), e->value); - enum LIEF_ELF_DYNAMIC_FLAGS* flags = e->flags; - for (j = 0; flags[j] != 0; ++j) { - fprintf(stdout, "%s ", DYNAMIC_FLAGS_to_string(flags[j])); - } - fprintf(stdout, "\n"); break; } @@ -264,12 +259,6 @@ int main(int argc, char **argv) { "0x%010" PRIx64 " ", DYNAMIC_TAGS_to_string(e->tag), e->value); - - enum LIEF_ELF_DYNAMIC_FLAGS_1* flags = e->flags_1; - for (j = 0; flags[j] != 0; ++j) { - fprintf(stdout, "%s ", DYNAMIC_FLAGS_1_to_string(flags[j])); - } - fprintf(stdout, "\n"); break; } diff --git a/include/LIEF/ELF/Binary.hpp b/include/LIEF/ELF/Binary.hpp index 85da9c5be7..a88fb746bc 100644 --- a/include/LIEF/ELF/Binary.hpp +++ b/include/LIEF/ELF/Binary.hpp @@ -26,6 +26,7 @@ #include "LIEF/Abstract/Binary.hpp" #include "LIEF/ELF/Note.hpp" +#include "LIEF/ELF/DynamicEntry.hpp" #include "LIEF/ELF/Header.hpp" #include "LIEF/ELF/Builder.hpp" @@ -36,7 +37,6 @@ namespace DataHandler { class Handler; } -class DynamicEntry; class ExeLayout; class GnuHash; class Layout; @@ -268,7 +268,7 @@ class LIEF_API Binary : public LIEF::Binary { void remove(const DynamicEntry& entry); //! Remove **all** dynamic entries with the given tag - void remove(DYNAMIC_TAGS tag); + void remove(DynamicEntry::TAG tag); //! Remove the given section. The ``clear`` parameter //! can be used to zeroize the original content beforehand @@ -371,20 +371,28 @@ class LIEF_API Binary : public LIEF::Binary { //! ``true`` if GNU hash is used //! //! @see gnu_hash and use_sysv_hash - bool use_gnu_hash() const; + bool use_gnu_hash() const { + return gnu_hash_ != nullptr && has(DynamicEntry::TAG::GNU_HASH); + } //! Return the GnuHash object in **readonly** //! If the ELF binary does not use the GNU hash table, return a nullptr - const GnuHash* gnu_hash() const; + const GnuHash* gnu_hash() const { + return use_gnu_hash() ? gnu_hash_.get() : nullptr; + } //! ``true`` if SYSV hash is used //! //! @see sysv_hash and use_gnu_hash - bool use_sysv_hash() const; + bool use_sysv_hash() const { + return sysv_hash_ != nullptr && has(DynamicEntry::TAG::HASH); + } //! Return the SysvHash object as a **read-only** object //! If the ELF binary does not use the legacy sysv hash table, return a nullptr - const SysvHash* sysv_hash() const; + const SysvHash* sysv_hash() const { + return use_sysv_hash() ? sysv_hash_.get() : nullptr; + } //! Check if a section with the given name exists in the binary bool has_section(const std::string& name) const; @@ -682,8 +690,10 @@ class LIEF_API Binary : public LIEF::Binary { //! Return the **first** ELF::DynamicEntry associated with the given tag //! If the tag can't be found, it returns a nullptr - const DynamicEntry* get(DYNAMIC_TAGS tag) const; - DynamicEntry* get(DYNAMIC_TAGS tag); + const DynamicEntry* get(DynamicEntry::TAG tag) const; + DynamicEntry* get(DynamicEntry::TAG tag) { + return const_cast(static_cast(this)->get(tag)); + } //! Return the **first** ELF::Segment associated with the given type. //! If a segment can't be found, it returns a nullptr. @@ -701,7 +711,9 @@ class LIEF_API Binary : public LIEF::Binary { Section* get(ELF_SECTION_TYPES type); //! Check if an ELF::DynamicEntry associated with the given tag exists. - bool has(DYNAMIC_TAGS tag) const; + bool has(DynamicEntry::TAG tag) const { + return get(tag) != nullptr; + } //! Check if ELF::Segment associated with the given type exists. bool has(SEGMENT_TYPES type) const; @@ -777,28 +789,76 @@ class LIEF_API Binary : public LIEF::Binary { std::ostream& print(std::ostream& os) const override; - Binary& operator+=(const DynamicEntry& entry); - Binary& operator+=(const Section& section); - Binary& operator+=(const Segment& segment); - Binary& operator+=(const Note& note); + Binary& operator+=(const DynamicEntry& entry) { + add(entry); + return *this; + } + Binary& operator+=(const Section& section) { + add(section); + return *this; + } + + Binary& operator+=(const Segment& segment) { + add(segment); + return *this; + } + + Binary& operator+=(const Note& note) { + add(note); + return *this; + } + + Binary& operator-=(const DynamicEntry& entry) { + remove(entry); + return *this; + } + + Binary& operator-=(DynamicEntry::TAG tag) { + remove(tag); + return *this; + } + + Binary& operator-=(const Note& note) { + remove(note); + return *this; + } - Binary& operator-=(const DynamicEntry& entry); - Binary& operator-=(DYNAMIC_TAGS tag); + Binary& operator-=(Note::TYPE type) { + remove(type); + return *this; + } - Binary& operator-=(const Note& note); - Binary& operator-=(Note::TYPE type); + Segment* operator[](SEGMENT_TYPES type) { + return get(type); + } - Segment* operator[](SEGMENT_TYPES type); - const Segment* operator[](SEGMENT_TYPES type) const; + const Segment* operator[](SEGMENT_TYPES type) const { + return get(type); + } - DynamicEntry* operator[](DYNAMIC_TAGS tag); - const DynamicEntry* operator[](DYNAMIC_TAGS tag) const; + DynamicEntry* operator[](DynamicEntry::TAG tag) { + return get(tag); + } - Note* operator[](Note::TYPE type); - const Note* operator[](Note::TYPE type) const; + const DynamicEntry* operator[](DynamicEntry::TAG tag) const { + return get(tag); + } - Section* operator[](ELF_SECTION_TYPES type); - const Section* operator[](ELF_SECTION_TYPES type) const; + Note* operator[](Note::TYPE type) { + return get(type); + } + + const Note* operator[](Note::TYPE type) const { + return get(type); + } + + Section* operator[](ELF_SECTION_TYPES type) { + return get(type); + } + + const Section* operator[](ELF_SECTION_TYPES type) const { + return get(type); + } protected: struct phdr_relocation_info_t { @@ -859,7 +919,7 @@ class LIEF_API Binary : public LIEF::Binary { std::string shstrtab_name() const; Section* add_frame_section(const Section& sec); - LIEF::Binary::functions_t tor_functions(DYNAMIC_TAGS tag) const; + LIEF::Binary::functions_t tor_functions(DynamicEntry::TAG tag) const; ELF_CLASS type_ = ELF_CLASS::ELFCLASSNONE; Header header_; diff --git a/include/LIEF/ELF/DynamicEntry.hpp b/include/LIEF/ELF/DynamicEntry.hpp index a2e00b13e8..dd13a89725 100644 --- a/include/LIEF/ELF/DynamicEntry.hpp +++ b/include/LIEF/ELF/DynamicEntry.hpp @@ -17,14 +17,13 @@ #define LIEF_ELF_DYNAMIC_ENTRY_H #include -#include #include +#include +#include #include "LIEF/visibility.h" #include "LIEF/Object.hpp" -#include "LIEF/ELF/enums.hpp" - namespace LIEF { namespace ELF { namespace details { @@ -36,40 +35,174 @@ struct Elf32_Dyn; //! These entries are located in the ``.dynamic`` section or the ``PT_DYNAMIC`` segment class LIEF_API DynamicEntry : public Object { public: + enum class TAG { + DT_NULL = 0, /**< Marks end of dynamic array. */ + NEEDED = 1, /**< String table offset of needed library. */ + PLTRELSZ = 2, /**< Size of relocation entries in PLT. */ + PLTGOT = 3, /**< Address associated with linkage table. */ + HASH = 4, /**< Address of symbolic hash table. */ + STRTAB = 5, /**< Address of dynamic string table. */ + SYMTAB = 6, /**< Address of dynamic symbol table. */ + RELA = 7, /**< Address of relocation table (Rela entries). */ + RELASZ = 8, /**< Size of Rela relocation table. */ + RELAENT = 9, /**< Size of a Rela relocation entry. */ + STRSZ = 10,/**< Total size of the string table. */ + SYMENT = 11,/**< Size of a symbol table entry. */ + INIT = 12,/**< Address of initialization function. */ + FINI = 13,/**< Address of termination function. */ + SONAME = 14,/**< String table offset of a shared objects name. */ + RPATH = 15,/**< String table offset of library search path. */ + SYMBOLIC = 16,/**< Changes symbol resolution algorithm. */ + REL = 17,/**< Address of relocation table (Rel entries). */ + RELSZ = 18,/**< Size of Rel relocation table. */ + RELENT = 19,/**< Size of a Rel relocation entry. */ + PLTREL = 20,/**< Type of relocation entry used for linking. */ + DEBUG = 21,/**< Reserved for debugger. */ + TEXTREL = 22,/**< Relocations exist for non-writable segments. */ + JMPREL = 23,/**< Address of relocations associated with PLT. */ + BIND_NOW = 24,/**< Process all relocations before execution. */ + INIT_ARRAY = 25,/**< Pointer to array of initialization functions. */ + FINI_ARRAY = 26,/**< Pointer to array of termination functions. */ + INIT_ARRAYSZ = 27,/**< Size of DT_INIT_ARRAY. */ + FINI_ARRAYSZ = 28,/**< Size of DT_FINI_ARRAY. */ + RUNPATH = 29,/**< String table offset of lib search path. */ + FLAGS = 30,/**< Flags. */ + PREINIT_ARRAY = 32,/**< Pointer to array of preinit functions. */ + PREINIT_ARRAYSZ = 33,/**< Size of the DT_PREINIT_ARRAY array. */ + SYMTAB_SHNDX = 34,/**< Address of SYMTAB_SHNDX section */ + RELRSZ = 35,/**< Total size of RELR relative relocations */ + RELR = 36,/**< Address of RELR relative relocations */ + RELRENT = 37,/**< Size of one RELR relative relocaction */ + + // GNU Extensions + GNU_HASH = 0x6FFFFEF5, /**< Reference to the GNU hash table. */ + RELACOUNT = 0x6FFFFFF9, /**< ELF32_Rela count. */ + RELCOUNT = 0x6FFFFFFA, /**< ELF32_Rel count. */ + FLAGS_1 = 0x6FFFFFFB, /**< Flags_1. */ + VERSYM = 0x6FFFFFF0, /**< The address of .gnu.version section. */ + VERDEF = 0x6FFFFFFC, /**< The address of the version definition table. */ + VERDEFNUM = 0x6FFFFFFD, /**< The number of entries in DT_VERDEF. */ + VERNEED = 0x6FFFFFFE, /**< The address of the version Dependency table. */ + VERNEEDNUM = 0x6FFFFFFF, /**< The number of entries in DT_VERNEED. */ + + // Android Extensions + ANDROID_REL_OFFSET = 0x6000000D, /**< The offset of packed relocation data (older version < M) (Android specific). */ + ANDROID_REL_SIZE = 0x6000000E, /**< The size of packed relocation data in bytes (older version < M) (Android specific). */ + ANDROID_REL = 0x6000000F, /**< The offset of packed relocation data (Android specific). */ + ANDROID_RELSZ = 0x60000010, /**< The size of packed relocation data in bytes (Android specific). */ + ANDROID_RELA = 0x60000011, /**< The offset of packed relocation data (Android specific). */ + ANDROID_RELASZ = 0x60000012, /**< The size of packed relocation data in bytes (Android specific). */ + ANDROID_RELR = 0x6FFFE000, /**< The offset of new relr relocation data (Android specific). */ + ANDROID_RELRSZ = 0x6FFFE001, /**< The size of nre relr relocation data in bytes (Android specific). */ + ANDROID_RELRENT = 0x6FFFE003, /**< The size of a new relr relocation entry (Android specific). */ + ANDROID_RELRCOUNT = 0x6FFFE005, /**< Specifies the relative count of new relr relocation entries (Android specific). */ + /* Mips specific dynamic table entry tags. */ + MIPS_RLD_VERSION = 0x70000001, /**< 32 bit version number for runtime linker interface. */ + MIPS_TIME_STAMP = 0x70000002, /**< Time stamp. */ + MIPS_ICHECKSUM = 0x70000003, /**< Checksum of external strings and common sizes. */ + MIPS_IVERSION = 0x70000004, /**< Index of version string in string table. */ + MIPS_FLAGS = 0x70000005, /**< 32 bits of flags. */ + MIPS_BASE_ADDRESS = 0x70000006, /**< Base address of the segment. */ + MIPS_MSYM = 0x70000007, /**< Address of .msym section. */ + MIPS_CONFLICT = 0x70000008, /**< Address of .conflict section. */ + MIPS_LIBLIST = 0x70000009, /**< Address of .liblist section. */ + MIPS_LOCAL_GOTNO = 0x7000000a, /**< Number of local global offset table entries. */ + MIPS_CONFLICTNO = 0x7000000b, /**< Number of entries in the .conflict section. */ + MIPS_LIBLISTNO = 0x70000010, /**< Number of entries in the .liblist section. */ + MIPS_SYMTABNO = 0x70000011, /**< Number of entries in the .dynsym section. */ + MIPS_UNREFEXTNO = 0x70000012, /**< Index of first external dynamic symbol not referenced locally. */ + MIPS_GOTSYM = 0x70000013, /**< Index of first dynamic symbol in global offset table. */ + MIPS_HIPAGENO = 0x70000014, /**< Number of page table entries in global offset table. */ + MIPS_RLD_MAP = 0x70000016, /**< Address of run time loader map, used for debugging. */ + MIPS_DELTA_CLASS = 0x70000017, /**< Delta C++ class definition. */ + MIPS_DELTA_CLASS_NO = 0x70000018, /**< Number of entries in DT_MIPS_DELTA_CLASS. */ + MIPS_DELTA_INSTANCE = 0x70000019, /**< Delta C++ class instances. */ + MIPS_DELTA_INSTANCE_NO = 0x7000001A, /**< Number of entries in DT_MIPS_DELTA_INSTANCE. */ + MIPS_DELTA_RELOC = 0x7000001B, /**< Delta relocations. */ + MIPS_DELTA_RELOC_NO = 0x7000001C, /**< Number of entries in DT_MIPS_DELTA_RELOC. */ + MIPS_DELTA_SYM = 0x7000001D, /**< Delta symbols that Delta relocations refer to. */ + MIPS_DELTA_SYM_NO = 0x7000001E, /**< Number of entries in DT_MIPS_DELTA_SYM. */ + MIPS_DELTA_CLASSSYM = 0x70000020, /**< Delta symbols that hold class declarations. */ + MIPS_DELTA_CLASSSYM_NO = 0x70000021, /**< Number of entries in DT_MIPS_DELTA_CLASSSYM. */ + MIPS_CXX_FLAGS = 0x70000022, /**< Flags indicating information about C++ flavor. */ + MIPS_PIXIE_INIT = 0x70000023, /**< Pixie information. */ + MIPS_SYMBOL_LIB = 0x70000024, /**< Address of .MIPS.symlib */ + MIPS_LOCALPAGE_GOTIDX = 0x70000025, /**< The GOT index of the first PTE for a segment */ + MIPS_LOCAL_GOTIDX = 0x70000026, /**< The GOT index of the first PTE for a local symbol */ + MIPS_HIDDEN_GOTIDX = 0x70000027, /**< The GOT index of the first PTE for a hidden symbol */ + MIPS_PROTECTED_GOTIDX = 0x70000028, /**< The GOT index of the first PTE for a protected symbol */ + MIPS_OPTIONS = 0x70000029, /**< Address of `.MIPS.options'. */ + MIPS_INTERFACE = 0x7000002A, /**< Address of `.interface'. */ + MIPS_DYNSTR_ALIGN = 0x7000002B, /**< Unknown. */ + MIPS_INTERFACE_SIZE = 0x7000002C, /**< Size of the .interface section. */ + MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002D, /**< Size of rld_text_resolve function stored in the GOT. */ + MIPS_PERF_SUFFIX = 0x7000002E, /**< Default suffix of DSO to be added by rld on dlopen() calls. */ + MIPS_COMPACT_SIZE = 0x7000002F, /**< Size of compact relocation section (O32). */ + MIPS_GP_VALUE = 0x70000030, /**< GP value for auxiliary GOTs. */ + MIPS_AUX_DYNAMIC = 0x70000031, /**< Address of auxiliary .dynamic. */ + MIPS_PLTGOT = 0x70000032, /**< Address of the base of the PLTGOT. */ + MIPS_RWPLT = 0x70000034, /**< Points to the base of a writable PLT. */ + }; + static DynamicEntry::TAG from_value(uint64_t value) { + // The current implementation keeps the original enum value so the mapping + // is 1<->1 + return DynamicEntry::TAG(value); + } + DynamicEntry() = default; DynamicEntry(const details::Elf64_Dyn& header); DynamicEntry(const details::Elf32_Dyn& header); - DynamicEntry(); - DynamicEntry(DYNAMIC_TAGS tag, uint64_t value); - DynamicEntry& operator=(const DynamicEntry&); - DynamicEntry(const DynamicEntry&); - ~DynamicEntry() override; + DynamicEntry(TAG tag, uint64_t value) : + tag_(tag), value_(value) + {} + + DynamicEntry& operator=(const DynamicEntry&) = default; + DynamicEntry(const DynamicEntry&) = default; + ~DynamicEntry() override = default; + + virtual std::unique_ptr clone() const { + return std::unique_ptr(new DynamicEntry(*this)); + } //! Tag of the current entry. The most common tags are: //! DT_NEEDED, DT_INIT, ... - DYNAMIC_TAGS tag() const; + TAG tag() const { + return tag_; + } //! Return the entry's value //! //! The meaning of the value strongly depends on the tag. //! It can be an offset, an index, a flag, ... - uint64_t value() const; + uint64_t value() const { + return value_; + } - void tag(DYNAMIC_TAGS tag); - void value(uint64_t value); + void tag(TAG tag) { + tag_ = tag; + } + + void value(uint64_t value) { + value_ = value; + } void accept(Visitor& visitor) const override; virtual std::ostream& print(std::ostream& os) const; - - LIEF_API friend std::ostream& operator<<(std::ostream& os, const DynamicEntry& entry); + LIEF_API friend + std::ostream& operator<<(std::ostream& os, const DynamicEntry& entry) { + return entry.print(os); + } protected: - DYNAMIC_TAGS tag_; - uint64_t value_; + TAG tag_ = TAG::DT_NULL; + uint64_t value_ = 0; }; + +LIEF_API const char* to_string(DynamicEntry::TAG e); + } } #endif diff --git a/include/LIEF/ELF/DynamicEntryArray.hpp b/include/LIEF/ELF/DynamicEntryArray.hpp index df003024b5..9f64a99538 100644 --- a/include/LIEF/ELF/DynamicEntryArray.hpp +++ b/include/LIEF/ELF/DynamicEntryArray.hpp @@ -19,6 +19,8 @@ #include "LIEF/visibility.h" #include "LIEF/ELF/DynamicEntry.hpp" +#include + namespace LIEF { namespace ELF { @@ -33,36 +35,57 @@ namespace ELF { class LIEF_API DynamicEntryArray : public DynamicEntry { public: using array_t = std::vector; - - public: using DynamicEntry::DynamicEntry; - DynamicEntryArray(); - DynamicEntryArray(DYNAMIC_TAGS tag, array_t array); + DynamicEntryArray() = delete; + DynamicEntryArray(DynamicEntry::TAG tag, array_t array) : + DynamicEntry(tag, 0), + array_(std::move(array)) + {} - DynamicEntryArray& operator=(const DynamicEntryArray&); - DynamicEntryArray(const DynamicEntryArray&); + DynamicEntryArray& operator=(const DynamicEntryArray&) = default; + DynamicEntryArray(const DynamicEntryArray&) = default; - //! Return the array values (list of pointer) - array_t& array(); + std::unique_ptr clone() const override { + return std::unique_ptr(new DynamicEntryArray(*this)); + } - const array_t& array() const; - void array(const array_t& array); + //! Return the array values (list of pointers) + array_t& array() { + return array_; + } + + const array_t& array() const { + return array_; + } + void array(const array_t& array) { + array_ = array; + } //! Insert the given function at ``pos`` DynamicEntryArray& insert(size_t pos, uint64_t function); //! Append the given function - DynamicEntryArray& append(uint64_t function); + DynamicEntryArray& append(uint64_t function) { + array_.push_back(function); + return *this; + } //! Remove the given function DynamicEntryArray& remove(uint64_t function); //! Number of function registred in this array - size_t size() const; + size_t size() const { + return array_.size(); + } + + DynamicEntryArray& operator+=(uint64_t value) { + return append(value); + } - DynamicEntryArray& operator+=(uint64_t value); - DynamicEntryArray& operator-=(uint64_t value); + DynamicEntryArray& operator-=(uint64_t value) { + return remove(value); + } const uint64_t& operator[](size_t idx) const; uint64_t& operator[](size_t idx); @@ -71,13 +94,17 @@ class LIEF_API DynamicEntryArray : public DynamicEntry { std::ostream& print(std::ostream& os) const override; - ~DynamicEntryArray() override; + ~DynamicEntryArray() override = default; - static bool classof(const DynamicEntry* entry); + static bool classof(const DynamicEntry* entry) { + const DynamicEntry::TAG tag = entry->tag(); + return tag == DynamicEntry::TAG::INIT_ARRAY || + tag == DynamicEntry::TAG::FINI_ARRAY || + tag == DynamicEntry::TAG::PREINIT_ARRAY; + } private: array_t array_; - }; } } diff --git a/include/LIEF/ELF/DynamicEntryFlags.hpp b/include/LIEF/ELF/DynamicEntryFlags.hpp index 5aff1c25ff..3c80c5b3fe 100644 --- a/include/LIEF/ELF/DynamicEntryFlags.hpp +++ b/include/LIEF/ELF/DynamicEntryFlags.hpp @@ -16,7 +16,7 @@ #ifndef LIEF_ELF_DYNAMIC_ENTRY_FLAGS_H #define LIEF_ELF_DYNAMIC_ENTRY_FLAGS_H -#include +#include #include #include "LIEF/visibility.h" @@ -26,51 +26,109 @@ namespace LIEF { namespace ELF { class LIEF_API DynamicEntryFlags : public DynamicEntry { - public: - using flags_list_t = std::set; + static constexpr uint64_t BASE = 0x100000000; + + enum class FLAG : uint64_t { + ORIGIN = 0x00000001, /**< The object may reference $ORIGIN. */ + SYMBOLIC = 0x00000002, /**< Search the shared lib before searching the exe. */ + TEXTREL = 0x00000004, /**< Relocations may modify a non-writable segment. */ + BIND_NOW = 0x00000008, /**< Process all relocations on load. */ + STATIC_TLS = 0x00000010, /**< Reject attempts to load dynamically. */ + + NOW = BASE + 0x000000001, /**< Set RTLD_NOW for this object. */ + GLOBAL = BASE + 0x000000002, /**< Set RTLD_GLOBAL for this object. */ + GROUP = BASE + 0x000000004, /**< Set RTLD_GROUP for this object. */ + NODELETE = BASE + 0x000000008, /**< Set RTLD_NODELETE for this object. */ + LOADFLTR = BASE + 0x000000010, /**< Trigger filtee loading at runtime. */ + INITFIRST = BASE + 0x000000020, /**< Set RTLD_INITFIRST for this object. */ + NOOPEN = BASE + 0x000000040, /**< Set RTLD_NOOPEN for this object. */ + HANDLE_ORIGIN = BASE + 0x000000080, /**< $ORIGIN must be handled. */ + DIRECT = BASE + 0x000000100, /**< Direct binding enabled. */ + TRANS = BASE + 0x000000200, + INTERPOSE = BASE + 0x000000400, /**< Object is used to interpose. */ + NODEFLIB = BASE + 0x000000800, /**< Ignore default lib search path. */ + NODUMP = BASE + 0x000001000, /**< Object can't be dldump'ed. */ + CONFALT = BASE + 0x000002000, /**< Configuration alternative created. */ + ENDFILTEE = BASE + 0x000004000, /**< Filtee terminates filters search. */ + DISPRELDNE = BASE + 0x000008000, /**< Disp reloc applied at build time. */ + DISPRELPND = BASE + 0x000010000, /**< Disp reloc applied at run-time. */ + NODIRECT = BASE + 0x000020000, /**< Object has no-direct binding. */ + IGNMULDEF = BASE + 0x000040000, + NOKSYMS = BASE + 0x000080000, + NOHDR = BASE + 0x000100000, + EDITED = BASE + 0x000200000, /**< Object is modified after built. */ + NORELOC = BASE + 0x000400000, + SYMINTPOSE = BASE + 0x000800000, /**< Object has individual interposers. */ + GLOBAUDIT = BASE + 0x001000000, /**< Global auditing required. */ + SINGLETON = BASE + 0x002000000, /**< Singleton symbols are used. */ + PIE = BASE + 0x008000000, /**< Singleton symbols are used. */ + KMOD = BASE + 0x010000000, + WEAKFILTER = BASE + 0x020000000, + NOCOMMON = BASE + 0x040000000, + }; + + using flags_list_t = std::vector; public: using DynamicEntry::DynamicEntry; - DynamicEntryFlags(); + DynamicEntryFlags() = delete; - DynamicEntryFlags& operator=(const DynamicEntryFlags&); - DynamicEntryFlags(const DynamicEntryFlags&); + static DynamicEntryFlags create_dt_flag(uint64_t value) { + return DynamicEntryFlags(DynamicEntry::TAG::FLAGS, value); + } - //! If the current entry has the given DYNAMIC_FLAGS - bool has(DYNAMIC_FLAGS f) const; + static DynamicEntryFlags create_dt_flag_1(uint64_t value) { + return DynamicEntryFlags(DynamicEntry::TAG::FLAGS_1, value); + } - //! If the current entry has the given DYNAMIC_FLAGS_1 - bool has(DYNAMIC_FLAGS_1 f) const; + DynamicEntryFlags& operator=(const DynamicEntryFlags&) = default; + DynamicEntryFlags(const DynamicEntryFlags&) = default; - //! Return flags as a list of integers - flags_list_t flags() const; + std::unique_ptr clone() const override { + return std::unique_ptr(new DynamicEntryFlags(*this)); + } - //! Add the given DYNAMIC_FLAGS - void add(DYNAMIC_FLAGS f); + //! If the current entry has the given FLAG + bool has(FLAG f) const; - //! Add the given DYNAMIC_FLAGS_1 - void add(DYNAMIC_FLAGS_1 f); + //! Return flags as a list of integers + flags_list_t flags() const; - //! Remove the given DYNAMIC_FLAGS - void remove(DYNAMIC_FLAGS f); + //! Add the given FLAG + void add(FLAG f); - //! Remove the given DYNAMIC_FLAGS_1 - void remove(DYNAMIC_FLAGS_1 f); + //! Remove the given FLAG + void remove(FLAG f); - DynamicEntryFlags& operator+=(DYNAMIC_FLAGS f); - DynamicEntryFlags& operator+=(DYNAMIC_FLAGS_1 f); + DynamicEntryFlags& operator+=(FLAG f) { + add(f); + return *this; + } - DynamicEntryFlags& operator-=(DYNAMIC_FLAGS f); - DynamicEntryFlags& operator-=(DYNAMIC_FLAGS_1 f); + DynamicEntryFlags& operator-=(FLAG f) { + remove(f); + return *this; + } - //! Method so that the ``visitor`` can visit us void accept(Visitor& visitor) const override; - static bool classof(const DynamicEntry* entry); + static bool classof(const DynamicEntry* entry) { + return entry->tag() == DynamicEntry::TAG::FLAGS || + entry->tag() == DynamicEntry::TAG::FLAGS_1; + } + + ~DynamicEntryFlags() = default; std::ostream& print(std::ostream& os) const override; + private: + DynamicEntryFlags(DynamicEntry::TAG tag, uint64_t flags) : + DynamicEntry(tag, flags) + {} }; + +LIEF_API const char* to_string(DynamicEntryFlags::FLAG e); + } } diff --git a/include/LIEF/ELF/DynamicEntryLibrary.hpp b/include/LIEF/ELF/DynamicEntryLibrary.hpp index 080ab9ec96..a0940e504a 100644 --- a/include/LIEF/ELF/DynamicEntryLibrary.hpp +++ b/include/LIEF/ELF/DynamicEntryLibrary.hpp @@ -17,10 +17,7 @@ #define LIEF_ELF_DYNAMIC_ENTRY_LIBRARY_H #include -#include - #include "LIEF/visibility.h" - #include "LIEF/ELF/DynamicEntry.hpp" namespace LIEF { @@ -34,17 +31,34 @@ class LIEF_API DynamicEntryLibrary : public DynamicEntry { public: using DynamicEntry::DynamicEntry; - DynamicEntryLibrary(); - DynamicEntryLibrary(std::string name); + DynamicEntryLibrary() : + DynamicEntry::DynamicEntry{DynamicEntry::TAG::NEEDED, 0} + {} + + DynamicEntryLibrary(std::string name) : + DynamicEntry::DynamicEntry{DynamicEntry::TAG::NEEDED, 0}, + libname_(std::move(name)) + {} - DynamicEntryLibrary& operator=(const DynamicEntryLibrary&); - DynamicEntryLibrary(const DynamicEntryLibrary&); + DynamicEntryLibrary& operator=(const DynamicEntryLibrary&) = default; + DynamicEntryLibrary(const DynamicEntryLibrary&) = default; + + std::unique_ptr clone() const override { + return std::unique_ptr(new DynamicEntryLibrary{*this}); + } //! Return the library associated with this entry (e.g. ``libc.so.6``) - const std::string& name() const; - void name(const std::string& name); + const std::string& name() const { + return libname_; + } + + void name(std::string name) { + libname_ = std::move(name); + } - static bool classof(const DynamicEntry* entry); + static bool classof(const DynamicEntry* entry) { + return entry->tag() == DynamicEntry::TAG::NEEDED; + } void accept(Visitor& visitor) const override; diff --git a/include/LIEF/ELF/DynamicEntryRpath.hpp b/include/LIEF/ELF/DynamicEntryRpath.hpp index 9887271286..9e4d544756 100644 --- a/include/LIEF/ELF/DynamicEntryRpath.hpp +++ b/include/LIEF/ELF/DynamicEntryRpath.hpp @@ -17,9 +17,9 @@ #define LIEF_ELF_DYNAMIC_ENTRY_RPATH_H #include +#include #include "LIEF/visibility.h" - #include "LIEF/ELF/DynamicEntry.hpp" namespace LIEF { @@ -28,27 +28,40 @@ namespace ELF { //! Class which represents a ``DT_RPATH`` entry. This attribute is //! deprecated (cf. ``man ld``) in favour of ``DT_RUNPATH`` (See DynamicRunPath) class LIEF_API DynamicEntryRpath : public DynamicEntry { - public: static constexpr char delimiter = ':'; using DynamicEntry::DynamicEntry; - DynamicEntryRpath(); + DynamicEntryRpath() : + DynamicEntry::DynamicEntry(DynamicEntry::TAG::RPATH, 0) + {} - DynamicEntryRpath(std::string rpath); + DynamicEntryRpath(std::string rpath) : + DynamicEntry::DynamicEntry(DynamicEntry::TAG::RPATH, 0), + rpath_(std::move(rpath)) + {} //! Constructor from a list of paths - DynamicEntryRpath(const std::vector& paths); + DynamicEntryRpath(const std::vector& paths) : + DynamicEntry::DynamicEntry(DynamicEntry::TAG::RPATH, 0) + { + this->paths(paths); + } - DynamicEntryRpath& operator=(const DynamicEntryRpath&); - DynamicEntryRpath(const DynamicEntryRpath&); + DynamicEntryRpath& operator=(const DynamicEntryRpath&) = default; + DynamicEntryRpath(const DynamicEntryRpath&) = default; - //! The actual rpath as a string - const std::string& name() const; - void name(const std::string& name); + std::unique_ptr clone() const override { + return std::unique_ptr(new DynamicEntryRpath(*this)); + } //! The actual rpath as a string - const std::string& rpath() const; - void rpath(const std::string& name); + const std::string& rpath() const { + return rpath_; + } + + void rpath(const std::string& name) { + rpath_ = std::move(name); + } //! Paths as a list std::vector paths() const; @@ -63,15 +76,24 @@ class LIEF_API DynamicEntryRpath : public DynamicEntry { //! Remove the given ``path`` DynamicEntryRpath& remove(const std::string& path); - DynamicEntryRpath& operator+=(const std::string& path); - DynamicEntryRpath& operator-=(const std::string& path); + DynamicEntryRpath& operator+=(std::string path) { + return append(std::move(path)); + } + + DynamicEntryRpath& operator-=(const std::string& path) { + return remove(path); + } - static bool classof(const DynamicEntry* entry); + static bool classof(const DynamicEntry* entry) { + return entry->tag() == DynamicEntry::TAG::RPATH; + } void accept(Visitor& visitor) const override; std::ostream& print(std::ostream& os) const override; + ~DynamicEntryRpath() = default; + private: std::string rpath_; }; diff --git a/include/LIEF/ELF/DynamicEntryRunPath.hpp b/include/LIEF/ELF/DynamicEntryRunPath.hpp index 4f881be28c..f1661caa74 100644 --- a/include/LIEF/ELF/DynamicEntryRunPath.hpp +++ b/include/LIEF/ELF/DynamicEntryRunPath.hpp @@ -17,9 +17,9 @@ #define LIEF_ELF_DYNAMIC_ENTRY_RUNPATH_H #include +#include #include "LIEF/visibility.h" - #include "LIEF/ELF/DynamicEntry.hpp" namespace LIEF { @@ -33,24 +33,38 @@ class LIEF_API DynamicEntryRunPath : public DynamicEntry { static constexpr char delimiter = ':'; using DynamicEntry::DynamicEntry; - DynamicEntryRunPath(); + DynamicEntryRunPath() : + DynamicEntry::DynamicEntry(DynamicEntry::TAG::RUNPATH, 0) + {} //! Constructor from (run)path - DynamicEntryRunPath(std::string runpath); + DynamicEntryRunPath(std::string runpath) : + DynamicEntry::DynamicEntry(DynamicEntry::TAG::RUNPATH, 0), + runpath_(std::move(runpath)) + {} //! Constructor from a list of paths - DynamicEntryRunPath(const std::vector& paths); + DynamicEntryRunPath(const std::vector& paths) : + DynamicEntry::DynamicEntry(DynamicEntry::TAG::RUNPATH, 0) + { + this->paths(paths); + } - DynamicEntryRunPath& operator=(const DynamicEntryRunPath&); - DynamicEntryRunPath(const DynamicEntryRunPath&); + DynamicEntryRunPath& operator=(const DynamicEntryRunPath&) = default; + DynamicEntryRunPath(const DynamicEntryRunPath&) = default; - //! Runpath raw value - const std::string& name() const; - void name(const std::string& name); + std::unique_ptr clone() const override { + return std::unique_ptr(new DynamicEntryRunPath(*this)); + } //! Runpath raw value - const std::string& runpath() const; - void runpath(const std::string& runpath); + const std::string& runpath() const { + return runpath_; + } + + void runpath(std::string runpath) { + runpath_ = std::move(runpath); + } //! Paths as a list std::vector paths() const; @@ -65,15 +79,24 @@ class LIEF_API DynamicEntryRunPath : public DynamicEntry { //! Remove the given ``path`` DynamicEntryRunPath& remove(const std::string& path); - DynamicEntryRunPath& operator+=(const std::string& path); - DynamicEntryRunPath& operator-=(const std::string& path); + DynamicEntryRunPath& operator+=(std::string path) { + return append(std::move(path)); + } + + DynamicEntryRunPath& operator-=(const std::string& path) { + return remove(path); + } void accept(Visitor& visitor) const override; - static bool classof(const DynamicEntry* entry); + static bool classof(const DynamicEntry* entry) { + return entry->tag() == DynamicEntry::TAG::RUNPATH; + } std::ostream& print(std::ostream& os) const override; + ~DynamicEntryRunPath() = default; + private: std::string runpath_; }; diff --git a/include/LIEF/ELF/DynamicSharedObject.hpp b/include/LIEF/ELF/DynamicSharedObject.hpp index 91d2e50366..068b9f0c56 100644 --- a/include/LIEF/ELF/DynamicSharedObject.hpp +++ b/include/LIEF/ELF/DynamicSharedObject.hpp @@ -19,35 +19,53 @@ #include #include "LIEF/visibility.h" - #include "LIEF/ELF/DynamicEntry.hpp" namespace LIEF { namespace ELF { //! Class which represents a ``DT_SONAME`` entry in the dynamic table -//! This kind of entry is usually used no name the original library. +//! This kind of entry is usually used to name the original library. //! //! This entry is not present for executable. class LIEF_API DynamicSharedObject : public DynamicEntry { public: using DynamicEntry::DynamicEntry; - DynamicSharedObject(); - DynamicSharedObject(std::string name); + DynamicSharedObject() : + DynamicEntry(DynamicEntry::TAG::SONAME, 0) + {} + + DynamicSharedObject(std::string name) : + DynamicEntry(DynamicEntry::TAG::SONAME, 0), + name_(std::move(name)) + {} + + DynamicSharedObject& operator=(const DynamicSharedObject&) = default; + DynamicSharedObject(const DynamicSharedObject&) = default; - DynamicSharedObject& operator=(const DynamicSharedObject&); - DynamicSharedObject(const DynamicSharedObject&); + std::unique_ptr clone() const override { + return std::unique_ptr(new DynamicSharedObject(*this)); + } //! The actual name (e.g. ``libMyLib.so``) - const std::string& name() const; - void name(const std::string& name); + const std::string& name() const { + return name_; + } + + void name(std::string name) { + name_ = std::move(name); + } void accept(Visitor& visitor) const override; std::ostream& print(std::ostream& os) const override; - static bool classof(const DynamicEntry* entry); + static bool classof(const DynamicEntry* entry) { + return entry->tag() == DynamicEntry::TAG::SONAME; + } + + ~DynamicSharedObject() override = default; private: std::string name_; diff --git a/include/LIEF/ELF/EnumToString.hpp b/include/LIEF/ELF/EnumToString.hpp index 6c30fc0fc4..dcf0580350 100644 --- a/include/LIEF/ELF/EnumToString.hpp +++ b/include/LIEF/ELF/EnumToString.hpp @@ -25,7 +25,6 @@ LIEF_API const char* to_string(E_TYPE e); LIEF_API const char* to_string(VERSION e); LIEF_API const char* to_string(ARCH e); LIEF_API const char* to_string(SEGMENT_TYPES e); -LIEF_API const char* to_string(DYNAMIC_TAGS e); LIEF_API const char* to_string(ELF_SECTION_TYPES e); LIEF_API const char* to_string(ELF_SECTION_FLAGS e); LIEF_API const char* to_string(ELF_SYMBOL_TYPES e); @@ -43,8 +42,6 @@ LIEF_API const char* to_string(DYNSYM_COUNT_METHODS e); LIEF_API const char* to_string(RELOCATION_PURPOSES e); LIEF_API const char* to_string(IDENTITY e); LIEF_API const char* to_string(SYMBOL_SECTION_INDEX e); -LIEF_API const char* to_string(DYNAMIC_FLAGS e); -LIEF_API const char* to_string(DYNAMIC_FLAGS_1 e); LIEF_API const char* to_string(ELF_SEGMENT_FLAGS e); LIEF_API const char* to_string(ELF_SYMBOL_VISIBILITY e); diff --git a/include/LIEF/ELF/Parser.hpp b/include/LIEF/ELF/Parser.hpp index f4f4bddf55..bb54c4d50e 100644 --- a/include/LIEF/ELF/Parser.hpp +++ b/include/LIEF/ELF/Parser.hpp @@ -192,8 +192,8 @@ class LIEF_API Parser : public LIEF::Parser { //! Parse SymbolVersionRequirement //! //! We use the virtual address stored in the - //! DYNAMIC_TAGS::DT_VERNEED entry to get the offset. - //! and DYNAMIC_TAGS::DT_VERNEEDNUM to get the number of entries + //! DynamicEntry::TAG::VERNEED entry to get the offset. + //! and DynamicEntry::TAG::VERNEEDNUM to get the number of entries template ok_error_t parse_symbol_version_requirement(uint64_t offset, uint32_t nb_entries); @@ -201,8 +201,8 @@ class LIEF_API Parser : public LIEF::Parser { //! Parse SymbolVersionDefinition. //! //! We use the virtual address stored in - //! the DYNAMIC_TAGS::DT_VERDEF DT_VERDEF entry to get the offset. - //! DYNAMIC_TAGS::DT_VERDEFNUM gives the number of entries + //! the DynamicEntry::TAG::VERDEF DT_VERDEF entry to get the offset. + //! DynamicEntry::TAG::VERDEFNUM gives the number of entries template ok_error_t parse_symbol_version_definition(uint64_t offset, uint32_t nb_entries); @@ -210,7 +210,7 @@ class LIEF_API Parser : public LIEF::Parser { //! Parse @link SymbolVersion Symbol version @endlink. //! //! We use the virtual address stored in the - //! DYNAMIC_TAGS::DT_VERSYM entry to parse it. + //! DynamicEntry::TAG::VERSYM entry to parse it. //! //! @see http://dev.gentoo.org/~solar/elf/symbol-versioning ok_error_t parse_symbol_version(uint64_t symbol_version_offset); diff --git a/include/LIEF/ELF/enums.hpp b/include/LIEF/ELF/enums.hpp index a291b7ddb8..2f41625b8a 100644 --- a/include/LIEF/ELF/enums.hpp +++ b/include/LIEF/ELF/enums.hpp @@ -675,164 +675,6 @@ enum class ELF_SEGMENT_FLAGS: size_t { PF_MASKPROC = 0xf0000000 /**< Bits for processor-specific semantics. */ }; - -/** Dynamic table entry tags. */ -enum class DYNAMIC_TAGS: size_t { - DT_NULL = 0, /**< Marks end of dynamic array. */ - DT_NEEDED = 1, /**< String table offset of needed library. */ - DT_PLTRELSZ = 2, /**< Size of relocation entries in PLT. */ - DT_PLTGOT = 3, /**< Address associated with linkage table. */ - DT_HASH = 4, /**< Address of symbolic hash table. */ - DT_STRTAB = 5, /**< Address of dynamic string table. */ - DT_SYMTAB = 6, /**< Address of dynamic symbol table. */ - DT_RELA = 7, /**< Address of relocation table (Rela entries). */ - DT_RELASZ = 8, /**< Size of Rela relocation table. */ - DT_RELAENT = 9, /**< Size of a Rela relocation entry. */ - DT_STRSZ = 10, /**< Total size of the string table. */ - DT_SYMENT = 11, /**< Size of a symbol table entry. */ - DT_INIT = 12, /**< Address of initialization function. */ - DT_FINI = 13, /**< Address of termination function. */ - DT_SONAME = 14, /**< String table offset of a shared objects name. */ - DT_RPATH = 15, /**< String table offset of library search path. */ - DT_SYMBOLIC = 16, /**< Changes symbol resolution algorithm. */ - DT_REL = 17, /**< Address of relocation table (Rel entries). */ - DT_RELSZ = 18, /**< Size of Rel relocation table. */ - DT_RELENT = 19, /**< Size of a Rel relocation entry. */ - DT_PLTREL = 20, /**< Type of relocation entry used for linking. */ - DT_DEBUG = 21, /**< Reserved for debugger. */ - DT_TEXTREL = 22, /**< Relocations exist for non-writable segments. */ - DT_JMPREL = 23, /**< Address of relocations associated with PLT. */ - DT_BIND_NOW = 24, /**< Process all relocations before execution. */ - DT_INIT_ARRAY = 25, /**< Pointer to array of initialization functions. */ - DT_FINI_ARRAY = 26, /**< Pointer to array of termination functions. */ - DT_INIT_ARRAYSZ = 27, /**< Size of DT_INIT_ARRAY. */ - DT_FINI_ARRAYSZ = 28, /**< Size of DT_FINI_ARRAY. */ - DT_RUNPATH = 29, /**< String table offset of lib search path. */ - DT_FLAGS = 30, /**< Flags. */ - DT_ENCODING = 32, /**< Values from here to DT_LOOS follow the rules for the interpretation of the d_un union. */ - - DT_PREINIT_ARRAY = 32, /**< Pointer to array of preinit functions. */ - DT_PREINIT_ARRAYSZ = 33, /**< Size of the DT_PREINIT_ARRAY array. */ - DT_SYMTAB_SHNDX = 34, /**< Address of SYMTAB_SHNDX section */ - DT_RELRSZ = 35, /**< Total size of RELR relative relocations */ - DT_RELR = 36, /**< Address of RELR relative relocations */ - DT_RELRENT = 37, /**< Size of one RELR relative relocaction */ - - DT_LOOS = 0x60000000, /**< Start of environment specific tags. */ - DT_HIOS = 0x6FFFFFFF, /**< End of environment specific tags. */ - DT_LOPROC = 0x70000000, /**< Start of processor specific tags. */ - DT_HIPROC = 0x7FFFFFFF, /**< End of processor specific tags. */ - - DT_GNU_HASH = 0x6FFFFEF5, /**< Reference to the GNU hash table. */ - DT_RELACOUNT = 0x6FFFFFF9, /**< ELF32_Rela count. */ - DT_RELCOUNT = 0x6FFFFFFA, /**< ELF32_Rel count. */ - - DT_FLAGS_1 = 0x6FFFFFFB, /**< Flags_1. */ - DT_VERSYM = 0x6FFFFFF0, /**< The address of .gnu.version section. */ - DT_VERDEF = 0x6FFFFFFC, /**< The address of the version definition table. */ - DT_VERDEFNUM = 0x6FFFFFFD, /**< The number of entries in DT_VERDEF. */ - DT_VERNEED = 0x6FFFFFFE, /**< The address of the version Dependency table. */ - DT_VERNEEDNUM = 0x6FFFFFFF, /**< The number of entries in DT_VERNEED. */ - - /* Mips specific dynamic table entry tags. */ - DT_MIPS_RLD_VERSION = 0x70000001, /**< 32 bit version number for runtime linker interface. */ - DT_MIPS_TIME_STAMP = 0x70000002, /**< Time stamp. */ - DT_MIPS_ICHECKSUM = 0x70000003, /**< Checksum of external strings and common sizes. */ - DT_MIPS_IVERSION = 0x70000004, /**< Index of version string in string table. */ - DT_MIPS_FLAGS = 0x70000005, /**< 32 bits of flags. */ - DT_MIPS_BASE_ADDRESS = 0x70000006, /**< Base address of the segment. */ - DT_MIPS_MSYM = 0x70000007, /**< Address of .msym section. */ - DT_MIPS_CONFLICT = 0x70000008, /**< Address of .conflict section. */ - DT_MIPS_LIBLIST = 0x70000009, /**< Address of .liblist section. */ - DT_MIPS_LOCAL_GOTNO = 0x7000000a, /**< Number of local global offset table entries. */ - DT_MIPS_CONFLICTNO = 0x7000000b, /**< Number of entries in the .conflict section. */ - DT_MIPS_LIBLISTNO = 0x70000010, /**< Number of entries in the .liblist section. */ - DT_MIPS_SYMTABNO = 0x70000011, /**< Number of entries in the .dynsym section. */ - DT_MIPS_UNREFEXTNO = 0x70000012, /**< Index of first external dynamic symbol not referenced locally. */ - DT_MIPS_GOTSYM = 0x70000013, /**< Index of first dynamic symbol in global offset table. */ - DT_MIPS_HIPAGENO = 0x70000014, /**< Number of page table entries in global offset table. */ - DT_MIPS_RLD_MAP = 0x70000016, /**< Address of run time loader map, used for debugging. */ - DT_MIPS_DELTA_CLASS = 0x70000017, /**< Delta C++ class definition. */ - DT_MIPS_DELTA_CLASS_NO = 0x70000018, /**< Number of entries in DT_MIPS_DELTA_CLASS. */ - DT_MIPS_DELTA_INSTANCE = 0x70000019, /**< Delta C++ class instances. */ - DT_MIPS_DELTA_INSTANCE_NO = 0x7000001A, /**< Number of entries in DT_MIPS_DELTA_INSTANCE. */ - DT_MIPS_DELTA_RELOC = 0x7000001B, /**< Delta relocations. */ - DT_MIPS_DELTA_RELOC_NO = 0x7000001C, /**< Number of entries in DT_MIPS_DELTA_RELOC. */ - DT_MIPS_DELTA_SYM = 0x7000001D, /**< Delta symbols that Delta relocations refer to. */ - DT_MIPS_DELTA_SYM_NO = 0x7000001E, /**< Number of entries in DT_MIPS_DELTA_SYM. */ - DT_MIPS_DELTA_CLASSSYM = 0x70000020, /**< Delta symbols that hold class declarations. */ - DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021, /**< Number of entries in DT_MIPS_DELTA_CLASSSYM. */ - DT_MIPS_CXX_FLAGS = 0x70000022, /**< Flags indicating information about C++ flavor. */ - DT_MIPS_PIXIE_INIT = 0x70000023, /**< Pixie information. */ - DT_MIPS_SYMBOL_LIB = 0x70000024, /**< Address of .MIPS.symlib */ - DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025, /**< The GOT index of the first PTE for a segment */ - DT_MIPS_LOCAL_GOTIDX = 0x70000026, /**< The GOT index of the first PTE for a local symbol */ - DT_MIPS_HIDDEN_GOTIDX = 0x70000027, /**< The GOT index of the first PTE for a hidden symbol */ - DT_MIPS_PROTECTED_GOTIDX = 0x70000028, /**< The GOT index of the first PTE for a protected symbol */ - DT_MIPS_OPTIONS = 0x70000029, /**< Address of `.MIPS.options'. */ - DT_MIPS_INTERFACE = 0x7000002A, /**< Address of `.interface'. */ - DT_MIPS_DYNSTR_ALIGN = 0x7000002B, /**< Unknown. */ - DT_MIPS_INTERFACE_SIZE = 0x7000002C, /**< Size of the .interface section. */ - DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002D, /**< Size of rld_text_resolve function stored in the GOT. */ - DT_MIPS_PERF_SUFFIX = 0x7000002E, /**< Default suffix of DSO to be added by rld on dlopen() calls. */ - DT_MIPS_COMPACT_SIZE = 0x7000002F, /**< Size of compact relocation section (O32). */ - DT_MIPS_GP_VALUE = 0x70000030, /**< GP value for auxiliary GOTs. */ - DT_MIPS_AUX_DYNAMIC = 0x70000031, /**< Address of auxiliary .dynamic. */ - DT_MIPS_PLTGOT = 0x70000032, /**< Address of the base of the PLTGOT. */ - DT_MIPS_RWPLT = 0x70000034, /**< Points to the base of a writable PLT. */ - - /* Android specific dynamic table entry tags. */ - DT_ANDROID_REL_OFFSET = 0x6000000D, /**< The offset of packed relocation data (older version < M) (Android specific). */ - DT_ANDROID_REL_SIZE = 0x6000000E, /**< The size of packed relocation data in bytes (older version < M) (Android specific). */ - DT_ANDROID_REL = 0x6000000F, /**< The offset of packed relocation data (Android specific). */ - DT_ANDROID_RELSZ = 0x60000010, /**< The size of packed relocation data in bytes (Android specific). */ - DT_ANDROID_RELA = 0x60000011, /**< The offset of packed relocation data (Android specific). */ - DT_ANDROID_RELASZ = 0x60000012, /**< The size of packed relocation data in bytes (Android specific). */ - DT_ANDROID_RELR = 0x6FFFE000, /**< The offset of new relr relocation data (Android specific). */ - DT_ANDROID_RELRSZ = 0x6FFFE001, /**< The size of nre relr relocation data in bytes (Android specific). */ - DT_ANDROID_RELRENT = 0x6FFFE003, /**< The size of a new relr relocation entry (Android specific). */ - DT_ANDROID_RELRCOUNT = 0x6FFFE005 /**< Specifies the relative count of new relr relocation entries (Android specific). */ -}; - -/** DT_FLAGS and DT_FLAGS_1 values. */ -enum class DYNAMIC_FLAGS: size_t { - DF_ORIGIN = 0x00000001, /**< The object may reference $ORIGIN. */ - DF_SYMBOLIC = 0x00000002, /**< Search the shared lib before searching the exe. */ - DF_TEXTREL = 0x00000004, /**< Relocations may modify a non-writable segment. */ - DF_BIND_NOW = 0x00000008, /**< Process all relocations on load. */ - DF_STATIC_TLS = 0x00000010, /**< Reject attempts to load dynamically. */ -}; - -enum class DYNAMIC_FLAGS_1: size_t { - DF_1_NOW = 0x00000001, /**< Set RTLD_NOW for this object. */ - DF_1_GLOBAL = 0x00000002, /**< Set RTLD_GLOBAL for this object. */ - DF_1_GROUP = 0x00000004, /**< Set RTLD_GROUP for this object. */ - DF_1_NODELETE = 0x00000008, /**< Set RTLD_NODELETE for this object. */ - DF_1_LOADFLTR = 0x00000010, /**< Trigger filtee loading at runtime. */ - DF_1_INITFIRST = 0x00000020, /**< Set RTLD_INITFIRST for this object. */ - DF_1_NOOPEN = 0x00000040, /**< Set RTLD_NOOPEN for this object. */ - DF_1_ORIGIN = 0x00000080, /**< $ORIGIN must be handled. */ - DF_1_DIRECT = 0x00000100, /**< Direct binding enabled. */ - DF_1_TRANS = 0x00000200, - DF_1_INTERPOSE = 0x00000400, /**< Object is used to interpose. */ - DF_1_NODEFLIB = 0x00000800, /**< Ignore default lib search path. */ - DF_1_NODUMP = 0x00001000, /**< Object can't be dldump'ed. */ - DF_1_CONFALT = 0x00002000, /**< Configuration alternative created. */ - DF_1_ENDFILTEE = 0x00004000, /**< Filtee terminates filters search. */ - DF_1_DISPRELDNE = 0x00008000, /**< Disp reloc applied at build time. */ - DF_1_DISPRELPND = 0x00010000, /**< Disp reloc applied at run-time. */ - DF_1_NODIRECT = 0x00020000, /**< Object has no-direct binding. */ - DF_1_IGNMULDEF = 0x00040000, - DF_1_NOKSYMS = 0x00080000, - DF_1_NOHDR = 0x00100000, - DF_1_EDITED = 0x00200000, /**< Object is modified after built. */ - DF_1_NORELOC = 0x00400000, - DF_1_SYMINTPOSE = 0x00800000, /**< Object has individual interposers. */ - DF_1_GLOBAUDIT = 0x01000000, /**< Global auditing required. */ - DF_1_SINGLETON = 0x02000000, /**< Singleton symbols are used. */ - DF_1_PIE = 0x08000000 /**< Singleton symbols are used. */ -}; - /* DT_MIPS_FLAGS values. */ enum { RHF_NONE = 0x00000000, /* No flags. */ @@ -910,7 +752,5 @@ ENABLE_BITMASK_OPERATORS(LIEF::ELF::MIPS_EFLAGS) ENABLE_BITMASK_OPERATORS(LIEF::ELF::HEXAGON_EFLAGS) ENABLE_BITMASK_OPERATORS(LIEF::ELF::LOONGARCH_EFLAGS) ENABLE_BITMASK_OPERATORS(LIEF::ELF::ELF_SECTION_FLAGS) -ENABLE_BITMASK_OPERATORS(LIEF::ELF::DYNAMIC_FLAGS) -ENABLE_BITMASK_OPERATORS(LIEF::ELF::DYNAMIC_FLAGS_1) #endif diff --git a/src/ELF/Binary.cpp b/src/ELF/Binary.cpp index 6893f1ec0f..077f206352 100644 --- a/src/ELF/Binary.cpp +++ b/src/ELF/Binary.cpp @@ -183,34 +183,11 @@ Binary::it_const_dynamic_entries Binary::dynamic_entries() const { DynamicEntry& Binary::add(const DynamicEntry& entry) { - - std::unique_ptr new_one; - - if (DynamicEntryLibrary::classof(&entry)) { - new_one = std::make_unique(*entry.as()); - } - else if (DynamicSharedObject::classof(&entry)) { - new_one = std::make_unique(*entry.as()); - } - else if (DynamicEntryRpath::classof(&entry)) { - new_one = std::make_unique(*entry.as()); - } - else if (DynamicEntryRunPath::classof(&entry)) { - new_one = std::make_unique(*entry.as()); - } - else if (DynamicEntryFlags::classof(&entry)) { - new_one = std::make_unique(*entry.as()); - } - else if (DynamicEntryArray::classof(&entry)) { - new_one = std::make_unique(*entry.as()); - } - else { - new_one = std::make_unique(entry); - } + std::unique_ptr new_one = entry.clone(); const auto it_new_place = std::find_if(std::begin(dynamic_entries_), std::end(dynamic_entries_), [&new_one] (const std::unique_ptr& e) { - return e->tag() == new_one->tag() || e->tag() == DYNAMIC_TAGS::DT_NULL; + return e->tag() == new_one->tag() || e->tag() == DynamicEntry::TAG::DT_NULL; }); auto* ptr = new_one.get(); @@ -240,7 +217,7 @@ void Binary::remove(const DynamicEntry& entry) { } -void Binary::remove(DYNAMIC_TAGS tag) { +void Binary::remove(DynamicEntry::TAG tag) { for (auto it = std::begin(dynamic_entries_); it != std::end(dynamic_entries_);) { if ((*it)->tag() == tag) { it = dynamic_entries_.erase(it); @@ -744,13 +721,13 @@ void Binary::remove_dynamic_symbol(Symbol* symbol) { if (it_relocation != std::end(relocations_)) { const size_t rel_sizeof = get_relocation_sizeof(*this, **it_relocation); - if (auto* DT = get(DYNAMIC_TAGS::DT_RELASZ)) { + if (auto* DT = get(DynamicEntry::TAG::RELASZ)) { const uint64_t sizes = DT->value(); if (sizes >= rel_sizeof) { DT->value(sizes - rel_sizeof); } } - else if (auto* DT = get(DYNAMIC_TAGS::DT_RELSZ)) { + else if (auto* DT = get(DynamicEntry::TAG::RELSZ)) { const uint64_t sizes = DT->value(); if (sizes >= rel_sizeof) { DT->value(sizes - rel_sizeof); @@ -817,8 +794,11 @@ Relocation& Binary::add_dynamic_relocation(const Relocation& relocation) { // Update the Dynamic Section (Thanks to @yd0b0N) bool is_rela = relocation.is_rela(); - DYNAMIC_TAGS tag_sz = is_rela ? DYNAMIC_TAGS::DT_RELASZ : DYNAMIC_TAGS::DT_RELSZ; - DYNAMIC_TAGS tag_ent = is_rela ? DYNAMIC_TAGS::DT_RELAENT : DYNAMIC_TAGS::DT_RELENT; + auto tag_sz = is_rela ? DynamicEntry::TAG::RELASZ : + DynamicEntry::TAG::RELSZ; + + auto tag_ent = is_rela ? DynamicEntry::TAG::RELAENT : + DynamicEntry::TAG::RELENT; DynamicEntry* dt_sz = get(tag_sz); DynamicEntry* dt_ent = get(tag_ent); @@ -855,8 +835,8 @@ Relocation& Binary::add_pltgot_relocation(const Relocation& relocation) { // Update the Dynamic Section size_t reloc_size = get_relocation_sizeof(*this, relocation); - DynamicEntry* dt_sz = get(DYNAMIC_TAGS::DT_PLTRELSZ); - if (dt_sz != nullptr && has(DYNAMIC_TAGS::DT_JMPREL)) { + DynamicEntry* dt_sz = get(DynamicEntry::TAG::PLTRELSZ); + if (dt_sz != nullptr && has(DynamicEntry::TAG::JMPREL)) { dt_sz->value(dt_sz->value() + reloc_size); } @@ -1135,8 +1115,8 @@ bool Binary::is_pie() const { if (has(SEGMENT_TYPES::PT_DYNAMIC)) { - if (const auto* flag = static_cast(get(DYNAMIC_TAGS::DT_FLAGS_1))) { - return flag->has(DYNAMIC_FLAGS_1::DF_1_PIE); + if (const auto* flag = static_cast(get(DynamicEntry::TAG::FLAGS_1))) { + return flag->has(DynamicEntryFlags::FLAG::PIE); } } @@ -1828,7 +1808,7 @@ span Binary::get_content_from_virtual_address(uint64_t virtual_ad } -const DynamicEntry* Binary::get(DYNAMIC_TAGS tag) const { +const DynamicEntry* Binary::get(DynamicEntry::TAG tag) const { const auto it_entry = std::find_if(std::begin(dynamic_entries_), std::end(dynamic_entries_), [tag] (const std::unique_ptr& entry) { return entry->tag() == tag; @@ -1839,15 +1819,6 @@ const DynamicEntry* Binary::get(DYNAMIC_TAGS tag) const { return it_entry->get(); } -DynamicEntry* Binary::get(DYNAMIC_TAGS tag) { - return const_cast(static_cast(this)->get(tag)); -} - - -bool Binary::has(DYNAMIC_TAGS tag) const { - return get(tag) != nullptr; -} - const Segment* Binary::get(SEGMENT_TYPES type) const { const auto it_segment = std::find_if(std::begin(segments_), std::end(segments_), [type] (const std::unique_ptr& segment) { @@ -1974,31 +1945,6 @@ void Binary::accept(LIEF::Visitor& visitor) const { visitor.visit(*this); } -bool Binary::use_gnu_hash() const { - return gnu_hash_ != nullptr && has(DYNAMIC_TAGS::DT_GNU_HASH); -} - - -const GnuHash* Binary::gnu_hash() const { - if (!use_gnu_hash()) { - return nullptr; - } - return gnu_hash_.get(); -} - - -bool Binary::use_sysv_hash() const { - return sysv_hash_ != nullptr && has(DYNAMIC_TAGS::DT_HASH); -} - -const SysvHash* Binary::sysv_hash() const { - if (!use_sysv_hash()) { - return nullptr; - } - return sysv_hash_.get(); -} - - void Binary::shift_sections(uint64_t from, uint64_t shift) { LIEF_DEBUG("[+] Shift Sections"); for (std::unique_ptr
& section : sections_) { @@ -2037,19 +1983,19 @@ void Binary::shift_dynamic_entries(uint64_t from, uint64_t shift) { for (std::unique_ptr& entry : dynamic_entries_) { LIEF_DEBUG("[BEFORE] {}", *entry); switch (entry->tag()) { - case DYNAMIC_TAGS::DT_PLTGOT: - case DYNAMIC_TAGS::DT_HASH: - case DYNAMIC_TAGS::DT_GNU_HASH: - case DYNAMIC_TAGS::DT_STRTAB: - case DYNAMIC_TAGS::DT_SYMTAB: - case DYNAMIC_TAGS::DT_RELA: - case DYNAMIC_TAGS::DT_REL: - case DYNAMIC_TAGS::DT_JMPREL: - case DYNAMIC_TAGS::DT_INIT: - case DYNAMIC_TAGS::DT_FINI: - case DYNAMIC_TAGS::DT_VERSYM: - case DYNAMIC_TAGS::DT_VERDEF: - case DYNAMIC_TAGS::DT_VERNEED: + case DynamicEntry::TAG::PLTGOT: + case DynamicEntry::TAG::HASH: + case DynamicEntry::TAG::GNU_HASH: + case DynamicEntry::TAG::STRTAB: + case DynamicEntry::TAG::SYMTAB: + case DynamicEntry::TAG::RELA: + case DynamicEntry::TAG::REL: + case DynamicEntry::TAG::JMPREL: + case DynamicEntry::TAG::INIT: + case DynamicEntry::TAG::FINI: + case DynamicEntry::TAG::VERSYM: + case DynamicEntry::TAG::VERDEF: + case DynamicEntry::TAG::VERNEED: { if (entry->value() >= from) { @@ -2058,9 +2004,9 @@ void Binary::shift_dynamic_entries(uint64_t from, uint64_t shift) { break; } - case DYNAMIC_TAGS::DT_INIT_ARRAY: - case DYNAMIC_TAGS::DT_FINI_ARRAY: - case DYNAMIC_TAGS::DT_PREINIT_ARRAY: + case DynamicEntry::TAG::INIT_ARRAY: + case DynamicEntry::TAG::FINI_ARRAY: + case DynamicEntry::TAG::PREINIT_ARRAY: { DynamicEntryArray::array_t& array = entry->as()->array(); for (uint64_t& address : array) { @@ -2232,7 +2178,7 @@ bool Binary::has_library(const std::string& name) const { } -LIEF::Binary::functions_t Binary::tor_functions(DYNAMIC_TAGS tag) const { +LIEF::Binary::functions_t Binary::tor_functions(DynamicEntry::TAG tag) const { LIEF::Binary::functions_t functions; const DynamicEntry* entry = get(tag); if (entry == nullptr || !DynamicEntryArray::classof(entry)) { @@ -2256,7 +2202,7 @@ LIEF::Binary::functions_t Binary::tor_functions(DYNAMIC_TAGS tag) const { LIEF::Binary::functions_t Binary::ctor_functions() const { LIEF::Binary::functions_t functions; - LIEF::Binary::functions_t init = tor_functions(DYNAMIC_TAGS::DT_INIT_ARRAY); + LIEF::Binary::functions_t init = tor_functions(DynamicEntry::TAG::INIT_ARRAY); std::transform( std::make_move_iterator(std::begin(init)), std::make_move_iterator(std::end(init)), std::back_inserter(functions), @@ -2266,7 +2212,7 @@ LIEF::Binary::functions_t Binary::ctor_functions() const { return f; }); - LIEF::Binary::functions_t preinit = tor_functions(DYNAMIC_TAGS::DT_PREINIT_ARRAY); + LIEF::Binary::functions_t preinit = tor_functions(DynamicEntry::TAG::PREINIT_ARRAY); std::transform( std::make_move_iterator(std::begin(preinit)), std::make_move_iterator(std::end(preinit)), @@ -2277,7 +2223,7 @@ LIEF::Binary::functions_t Binary::ctor_functions() const { return f; }); - const DynamicEntry* dt_init = get(DYNAMIC_TAGS::DT_INIT); + const DynamicEntry* dt_init = get(DynamicEntry::TAG::INIT); if (dt_init != nullptr) { functions.emplace_back("__dt_init", dt_init->value(), Function::flags_list_t{Function::FLAGS::CONSTRUCTOR}); @@ -2290,7 +2236,7 @@ LIEF::Binary::functions_t Binary::dtor_functions() const { LIEF::Binary::functions_t functions; - LIEF::Binary::functions_t fini = tor_functions(DYNAMIC_TAGS::DT_FINI_ARRAY); + LIEF::Binary::functions_t fini = tor_functions(DynamicEntry::TAG::FINI_ARRAY); std::transform( std::make_move_iterator(std::begin(fini)), std::make_move_iterator(std::end(fini)), std::back_inserter(functions), @@ -2300,7 +2246,7 @@ LIEF::Binary::functions_t Binary::dtor_functions() const { return f; }); - const DynamicEntry* dt_fini = get(DYNAMIC_TAGS::DT_FINI); + const DynamicEntry* dt_fini = get(DynamicEntry::TAG::FINI); if (dt_fini != nullptr) { functions.emplace_back("__dt_fini", dt_fini->value(), Function::flags_list_t{Function::FLAGS::DESTRUCTOR}); @@ -3307,89 +3253,6 @@ uint64_t Binary::relocate_phdr_table_v1() { return phdr_reloc_info_.new_offset; } -// Operator+= -// ========== -Binary& Binary::operator+=(const DynamicEntry& entry) { - add(entry); - return *this; -} - -Binary& Binary::operator+=(const Section& section) { - add(section); - return *this; -} - -Binary& Binary::operator+=(const Segment& segment) { - add(segment); - return *this; -} - -Binary& Binary::operator+=(const Note& note) { - add(note); - return *this; -} - -// Operator -= -// =========== -Binary& Binary::operator-=(const DynamicEntry& entry) { - remove(entry); - return *this; -} - -Binary& Binary::operator-=(DYNAMIC_TAGS tag) { - remove(tag); - return *this; -} - - -Binary& Binary::operator-=(const Note& note) { - remove(note); - return *this; -} - -Binary& Binary::operator-=(Note::TYPE type) { - remove(type); - return *this; -} - -// Operator[] -// ========== -Segment* Binary::operator[](SEGMENT_TYPES type) { - return get(type); -} - -const Segment* Binary::operator[](SEGMENT_TYPES type) const { - return get(type); -} - -DynamicEntry* Binary::operator[](DYNAMIC_TAGS tag) { - return get(tag); -} - -const DynamicEntry* Binary::operator[](DYNAMIC_TAGS tag) const { - return get(tag); -} - -Note* Binary::operator[](Note::TYPE type) { - return get(type); -} - -const Note* Binary::operator[](Note::TYPE type) const { - return get(type); -} - -Section* Binary::operator[](ELF_SECTION_TYPES type) { - return get(type); -} - -const Section* Binary::operator[](ELF_SECTION_TYPES type) const { - return get(type); -} - - - - - std::ostream& Binary::print(std::ostream& os) const { os << "Header" << std::endl; diff --git a/src/ELF/Binary.tcc b/src/ELF/Binary.tcc index 05ca73ae68..7ae0393a40 100644 --- a/src/ELF/Binary.tcc +++ b/src/ELF/Binary.tcc @@ -625,7 +625,7 @@ template void Binary::fix_got_entries(uint64_t from, uint64_t shift) { using ptr_t = typename ELF_T::Elf_Addr; - DynamicEntry* dt_pltgot = get(DYNAMIC_TAGS::DT_PLTGOT); + DynamicEntry* dt_pltgot = get(DynamicEntry::TAG::PLTGOT); if (dt_pltgot == nullptr) { return; } diff --git a/src/ELF/Builder.tcc b/src/ELF/Builder.tcc index 2e182fb112..f967d92d55 100644 --- a/src/ELF/Builder.tcc +++ b/src/ELF/Builder.tcc @@ -151,7 +151,7 @@ ok_error_t Builder::build_exe_lib() { } else { /*LIEF_DEBUG(".notes: -0x{:x} bytes", note_segment.physical_size() - notes_size);*/ } } - if (binary_->has(DYNAMIC_TAGS::DT_GNU_HASH) && config_.gnu_hash) { + if (binary_->has(DynamicEntry::TAG::GNU_HASH) && config_.gnu_hash) { const size_t needed_size = layout->symbol_gnu_hash_size(); const uint64_t osize = binary_->sizing_info_->gnu_hash; const bool should_relocate = needed_size > osize || config_.force_relocate; @@ -161,7 +161,7 @@ ok_error_t Builder::build_exe_lib() { } else { LIEF_DEBUG("DT_GNU_HASH: -0x{:x} bytes", osize - needed_size); } } - if (binary_->has(DYNAMIC_TAGS::DT_HASH) && config_.dt_hash) { + if (binary_->has(DynamicEntry::TAG::HASH) && config_.dt_hash) { const size_t needed_size = layout->symbol_sysv_hash_size(); const uint64_t osize = binary_->sizing_info_->hash; const bool should_relocate = needed_size > osize || config_.force_relocate; @@ -181,7 +181,7 @@ ok_error_t Builder::build_exe_lib() { } else { LIEF_DEBUG("PT_DYNAMIC: -0x{:x} bytes", osize - dynamic_needed_size); } } - if (binary_->has(DYNAMIC_TAGS::DT_RELA) || binary_->has(DYNAMIC_TAGS::DT_REL)) { + if (binary_->has(DynamicEntry::TAG::RELA) || binary_->has(DynamicEntry::TAG::REL)) { const size_t dyn_reloc_needed_size = layout->dynamic_relocations_size(); if (config_.rela) { const uint64_t osize = binary_->sizing_info_->rela; @@ -193,7 +193,7 @@ ok_error_t Builder::build_exe_lib() { } } - if (config_.jmprel && binary_->has(DYNAMIC_TAGS::DT_JMPREL)) { + if (config_.jmprel && binary_->has(DynamicEntry::TAG::JMPREL)) { const size_t plt_reloc_needed_size = layout->pltgot_relocations_size(); const uint64_t osize = binary_->sizing_info_->jmprel; const bool should_relocate = plt_reloc_needed_size > osize || config_.force_relocate; @@ -203,7 +203,7 @@ ok_error_t Builder::build_exe_lib() { } else { LIEF_DEBUG("DT_JMPREL: -0x{:x} bytes", osize - plt_reloc_needed_size); } } - if (config_.dyn_str && binary_->has(DYNAMIC_TAGS::DT_STRTAB)) { + if (config_.dyn_str && binary_->has(DynamicEntry::TAG::STRTAB)) { const size_t needed_size = layout->dynstr_size(); const uint64_t osize = binary_->sizing_info_->dynstr; const bool should_relocate = needed_size > osize || config_.force_relocate; @@ -213,7 +213,7 @@ ok_error_t Builder::build_exe_lib() { } else { LIEF_DEBUG("DT_STRTAB: -0x{:x} bytes", osize - needed_size); } } - if (config_.symtab && binary_->has(DYNAMIC_TAGS::DT_SYMTAB)) { + if (config_.symtab && binary_->has(DynamicEntry::TAG::SYMTAB)) { const size_t dynsym_needed_size = layout->dynsym_size(); const uint64_t osize = binary_->sizing_info_->dynsym; const bool should_relocate = dynsym_needed_size > osize || config_.force_relocate; @@ -223,10 +223,10 @@ ok_error_t Builder::build_exe_lib() { } else { LIEF_DEBUG("DT_SYMTAB: -0x{:x} bytes", osize - dynsym_needed_size); } } - if (binary_->has(DYNAMIC_TAGS::DT_INIT_ARRAY) && binary_->has(DYNAMIC_TAGS::DT_INIT_ARRAYSZ) && + if (binary_->has(DynamicEntry::TAG::INIT_ARRAY) && binary_->has(DynamicEntry::TAG::INIT_ARRAYSZ) && config_.init_array) { - const size_t needed_size = layout->dynamic_arraysize(DYNAMIC_TAGS::DT_INIT_ARRAY); + const size_t needed_size = layout->dynamic_arraysize(DynamicEntry::TAG::INIT_ARRAY); const uint64_t osize = binary_->sizing_info_->init_array; const bool should_relocate = needed_size > osize; if (should_relocate) { @@ -238,10 +238,10 @@ ok_error_t Builder::build_exe_lib() { } else { LIEF_DEBUG("DT_INIT_ARRAY: -0x{:x} bytes", osize - needed_size); } } - if (binary_->has(DYNAMIC_TAGS::DT_PREINIT_ARRAY) && binary_->has(DYNAMIC_TAGS::DT_PREINIT_ARRAYSZ) && + if (binary_->has(DynamicEntry::TAG::PREINIT_ARRAY) && binary_->has(DynamicEntry::TAG::PREINIT_ARRAYSZ) && config_.preinit_array) { - const size_t needed_size = layout->dynamic_arraysize(DYNAMIC_TAGS::DT_PREINIT_ARRAY); + const size_t needed_size = layout->dynamic_arraysize(DynamicEntry::TAG::PREINIT_ARRAY); const uint64_t osize = binary_->sizing_info_->preinit_array; const bool should_relocate = needed_size > osize; if (should_relocate) { @@ -250,10 +250,10 @@ ok_error_t Builder::build_exe_lib() { } else { LIEF_DEBUG("DT_PREINIT_ARRAY: -0x{:x} bytes", osize - needed_size); } } - if (binary_->has(DYNAMIC_TAGS::DT_FINI_ARRAY) && binary_->has(DYNAMIC_TAGS::DT_FINI_ARRAYSZ) && + if (binary_->has(DynamicEntry::TAG::FINI_ARRAY) && binary_->has(DynamicEntry::TAG::FINI_ARRAYSZ) && config_.fini_array) { - const size_t needed_size = layout->dynamic_arraysize(DYNAMIC_TAGS::DT_FINI_ARRAY); + const size_t needed_size = layout->dynamic_arraysize(DynamicEntry::TAG::FINI_ARRAY); const uint64_t osize = binary_->sizing_info_->fini_array; const bool should_relocate = needed_size > osize; if (should_relocate) { @@ -265,7 +265,7 @@ ok_error_t Builder::build_exe_lib() { } else { LIEF_DEBUG("DT_FINI_ARRAY: -0x{:x} bytes", osize - needed_size); } } - if (binary_->has(DYNAMIC_TAGS::DT_VERSYM) && config_.sym_versym) { + if (binary_->has(DynamicEntry::TAG::VERSYM) && config_.sym_versym) { const size_t symver_needed_size = layout->symbol_version(); const uint64_t osize = binary_->sizing_info_->versym; const bool should_relocate = symver_needed_size > osize || config_.force_relocate; @@ -275,7 +275,7 @@ ok_error_t Builder::build_exe_lib() { } else { LIEF_DEBUG("DT_VERSYM: -0x{:x} bytes", osize - symver_needed_size); } } - if (binary_->has(DYNAMIC_TAGS::DT_VERDEF) && config_.sym_verdef) { + if (binary_->has(DynamicEntry::TAG::VERDEF) && config_.sym_verdef) { const size_t symvdef_needed_size = layout->symbol_vdef_size(); const uint64_t osize = binary_->sizing_info_->verdef; const bool should_relocate = symvdef_needed_size > osize || config_.force_relocate; @@ -285,7 +285,7 @@ ok_error_t Builder::build_exe_lib() { } else { LIEF_DEBUG("DT_VERDEF: -0x{:x} bytes", osize - symvdef_needed_size); } } - if (binary_->has(DYNAMIC_TAGS::DT_VERNEED) && config_.sym_verneed) { + if (binary_->has(DynamicEntry::TAG::VERNEED) && config_.sym_verneed) { const size_t symvreq_needed_size = layout->symbol_vreq_size(); const uint64_t osize = binary_->sizing_info_->verneed; const bool should_relocate = symvreq_needed_size > osize || config_.force_relocate; @@ -371,7 +371,7 @@ ok_error_t Builder::build_exe_lib() { } if (config_.dyn_str) { - if (DynamicEntry* dt_strtab = binary_->get(DYNAMIC_TAGS::DT_STRTAB)) { + if (DynamicEntry* dt_strtab = binary_->get(DynamicEntry::TAG::STRTAB)) { binary_->patch_address(dt_strtab->value(), layout->raw_dynstr()); } } @@ -388,19 +388,19 @@ ok_error_t Builder::build_exe_lib() { build_dynamic_section(); } - if (config_.symtab && binary_->has(DYNAMIC_TAGS::DT_SYMTAB)) { + if (config_.symtab && binary_->has(DynamicEntry::TAG::SYMTAB)) { build_dynamic_symbols(); } - if (config_.sym_versym && binary_->has(DYNAMIC_TAGS::DT_VERSYM)) { + if (config_.sym_versym && binary_->has(DynamicEntry::TAG::VERSYM)) { build_symbol_version(); } - if (config_.sym_verdef && binary_->has(DYNAMIC_TAGS::DT_VERDEF)) { + if (config_.sym_verdef && binary_->has(DynamicEntry::TAG::VERDEF)) { build_symbol_definition(); } - if (config_.sym_verneed && binary_->has(DYNAMIC_TAGS::DT_VERNEED)) { + if (config_.sym_verneed && binary_->has(DynamicEntry::TAG::VERNEED)) { build_symbol_requirement(); } @@ -853,7 +853,7 @@ ok_error_t Builder::build_dynamic_section() { for (std::unique_ptr& entry : binary_->dynamic_entries_) { switch (entry->tag()) { - case DYNAMIC_TAGS::DT_NEEDED: + case DynamicEntry::TAG::NEEDED: { const std::string& name = entry->as()->name(); const auto& it = dynstr_map.find(name); @@ -865,7 +865,7 @@ ok_error_t Builder::build_dynamic_section() { break; } - case DYNAMIC_TAGS::DT_SONAME: + case DynamicEntry::TAG::SONAME: { const std::string& name = entry->as()->name(); const auto& it = dynstr_map.find(name); @@ -877,9 +877,9 @@ ok_error_t Builder::build_dynamic_section() { break; } - case DYNAMIC_TAGS::DT_RPATH: + case DynamicEntry::TAG::RPATH: { - const std::string& name = entry->as()->name(); + const std::string& name = entry->as()->rpath(); const auto& it = dynstr_map.find(name); if (it == std::end(dynstr_map)) { LIEF_ERR("Can't find string offset in .dynstr for {}", name); @@ -889,9 +889,9 @@ ok_error_t Builder::build_dynamic_section() { break; } - case DYNAMIC_TAGS::DT_RUNPATH: + case DynamicEntry::TAG::RUNPATH: { - const std::string& name = entry->as()->name(); + const std::string& name = entry->as()->runpath(); const auto& it = dynstr_map.find(name); if (it == std::end(dynstr_map)) { LIEF_ERR("Can't find string offset in .dynstr for {}", name); @@ -901,10 +901,10 @@ ok_error_t Builder::build_dynamic_section() { break; } - case DYNAMIC_TAGS::DT_INIT_ARRAY: + case DynamicEntry::TAG::INIT_ARRAY: { if (config_.init_array) { - DynamicEntry* dt_array_size = binary_->get(DYNAMIC_TAGS::DT_INIT_ARRAYSZ); + DynamicEntry* dt_array_size = binary_->get(DynamicEntry::TAG::INIT_ARRAYSZ); if (dt_array_size == nullptr) { LIEF_ERR("Can't find the DT_INIT_ARRAYSZ / .init_array"); break; @@ -923,10 +923,10 @@ ok_error_t Builder::build_dynamic_section() { break; } - case DYNAMIC_TAGS::DT_FINI_ARRAY: + case DynamicEntry::TAG::FINI_ARRAY: { if (config_.fini_array) { - DynamicEntry* dt_array_size = binary_->get(DYNAMIC_TAGS::DT_FINI_ARRAYSZ); + DynamicEntry* dt_array_size = binary_->get(DynamicEntry::TAG::FINI_ARRAYSZ); if (dt_array_size == nullptr) { LIEF_ERR("Can't find the DT_FINI_ARRAYSZ / .fini_array"); break; @@ -946,10 +946,10 @@ ok_error_t Builder::build_dynamic_section() { break; } - case DYNAMIC_TAGS::DT_PREINIT_ARRAY: + case DynamicEntry::TAG::PREINIT_ARRAY: { if (config_.fini_array) { - DynamicEntry* dt_array_size = binary_->get(DYNAMIC_TAGS::DT_PREINIT_ARRAYSZ); + DynamicEntry* dt_array_size = binary_->get(DynamicEntry::TAG::PREINIT_ARRAYSZ); if (dt_array_size == nullptr) { LIEF_ERR("Can't find the DT_PREINIT_ARRAYSZ / .preinit_array"); break; @@ -1008,7 +1008,7 @@ ok_error_t Builder::build_dynamic_section() { template ok_error_t Builder::build_symbol_hash() { LIEF_DEBUG("== Build SYSV Hash =="); - DynamicEntry* dt_hash = binary_->get(DYNAMIC_TAGS::DT_HASH); + DynamicEntry* dt_hash = binary_->get(DynamicEntry::TAG::HASH); if (dt_hash == nullptr) { LIEF_ERR("Can't find the SYSV hash section"); @@ -1082,7 +1082,7 @@ ok_error_t Builder::build_hash_table() { LIEF_DEBUG("== Build hash table =="); bool has_error = false; - if (config_.dt_hash && binary_->has(DYNAMIC_TAGS::DT_HASH)) { + if (config_.dt_hash && binary_->has(DynamicEntry::TAG::HASH)) { if (!build_symbol_hash()) { LIEF_ERR("Building the new SYSV Hash section failed"); has_error = true; @@ -1090,7 +1090,7 @@ ok_error_t Builder::build_hash_table() { } if (config_.gnu_hash) { - if (const DynamicEntry* entry = binary_->get(DYNAMIC_TAGS::DT_GNU_HASH)) { + if (const DynamicEntry* entry = binary_->get(DynamicEntry::TAG::GNU_HASH)) { binary_->patch_address(entry->value(), static_cast(layout_.get())->raw_gnuhash()); } } @@ -1168,7 +1168,7 @@ ok_error_t Builder::build_dynamic_symbols() { // Find useful sections // ==================== - DynamicEntry* dt_symtab = binary_->get(DYNAMIC_TAGS::DT_SYMTAB); + DynamicEntry* dt_symtab = binary_->get(DynamicEntry::TAG::SYMTAB); if (dt_symtab == nullptr) { LIEF_ERR("Can't find the DT_SYMTAB entry"); return make_error_code(lief_errors::not_found); @@ -1297,12 +1297,12 @@ ok_error_t Builder::build_dynamic_relocations() { Binary::it_dynamic_relocations dynamic_relocations = binary_->dynamic_relocations(); if (dynamic_relocations.empty()) { - if (auto* DT = binary_->get(DYNAMIC_TAGS::DT_REL)) { + if (auto* DT = binary_->get(DynamicEntry::TAG::REL)) { if (auto* sec = binary_->section_from_virtual_address(DT->value())) { sec->size(0); } } - if (auto* DT = binary_->get(DYNAMIC_TAGS::DT_RELA)) { + if (auto* DT = binary_->get(DynamicEntry::TAG::RELA)) { if (auto* sec = binary_->section_from_virtual_address(DT->value())) { sec->size(0); } @@ -1314,16 +1314,16 @@ ok_error_t Builder::build_dynamic_relocations() { DynamicEntry* dt_reloc = nullptr; DynamicEntry* dt_relocsz = nullptr; - DynamicEntry* dt_rela = binary_->get(DYNAMIC_TAGS::DT_RELA); + DynamicEntry* dt_rela = binary_->get(DynamicEntry::TAG::RELA); const bool is_rela = dt_rela != nullptr; if (dt_rela != nullptr) { dt_reloc = dt_rela; - dt_relocsz = binary_->get(DYNAMIC_TAGS::DT_RELASZ); + dt_relocsz = binary_->get(DynamicEntry::TAG::RELASZ); } else { // Fallback on relation type REL - dt_reloc = binary_->get(DYNAMIC_TAGS::DT_REL); - dt_relocsz = binary_->get(DYNAMIC_TAGS::DT_RELSZ); + dt_reloc = binary_->get(DynamicEntry::TAG::REL); + dt_relocsz = binary_->get(DynamicEntry::TAG::RELSZ); } @@ -1404,7 +1404,7 @@ ok_error_t Builder::build_pltgot_relocations() { Binary::it_pltgot_relocations pltgot_relocations = binary_->pltgot_relocations(); if (pltgot_relocations.empty()) { - if (auto* DT = binary_->get(DYNAMIC_TAGS::DT_JMPREL)) { + if (auto* DT = binary_->get(DynamicEntry::TAG::JMPREL)) { if (auto* sec = binary_->section_from_virtual_address(DT->value())) { sec->size(0); } @@ -1415,12 +1415,12 @@ ok_error_t Builder::build_pltgot_relocations() { LIEF_DEBUG("[+] Building .plt.got relocations"); bool is_rela = false; - DynamicEntry* dt_pltrel = binary_->get(DYNAMIC_TAGS::DT_PLTREL); + DynamicEntry* dt_pltrel = binary_->get(DynamicEntry::TAG::PLTREL); if (dt_pltrel != nullptr) { - is_rela = dt_pltrel->value() == static_cast(DYNAMIC_TAGS::DT_RELA); + is_rela = dt_pltrel->value() == static_cast(DynamicEntry::TAG::RELA); } - DynamicEntry* dt_jmprel = binary_->get(DYNAMIC_TAGS::DT_JMPREL); - DynamicEntry* dt_pltrelsz = binary_->get(DYNAMIC_TAGS::DT_PLTRELSZ); + DynamicEntry* dt_jmprel = binary_->get(DynamicEntry::TAG::JMPREL); + DynamicEntry* dt_pltrelsz = binary_->get(DynamicEntry::TAG::PLTRELSZ); if (dt_jmprel == nullptr) { LIEF_ERR("Unable to find the DT_JMPREL entry"); return make_error_code(lief_errors::not_found); @@ -1491,13 +1491,13 @@ ok_error_t Builder::build_symbol_requirement() { using Elf_Vernaux = typename ELF_T::Elf_Vernaux; LIEF_DEBUG("[+] Building symbol requirement"); - DynamicEntry* dt_verneed = binary_->get(DYNAMIC_TAGS::DT_VERNEED); + DynamicEntry* dt_verneed = binary_->get(DynamicEntry::TAG::VERNEED); if (dt_verneed == nullptr) { LIEF_ERR("Can't find DT_VERNEED"); return make_error_code(lief_errors::not_found); } - DynamicEntry* dt_verneednum = binary_->get(DYNAMIC_TAGS::DT_VERNEEDNUM); + DynamicEntry* dt_verneednum = binary_->get(DynamicEntry::TAG::VERNEEDNUM); if (dt_verneednum == nullptr) { LIEF_ERR("Can't find DT_VERNEEDNUM"); return make_error_code(lief_errors::not_found); @@ -1595,13 +1595,13 @@ ok_error_t Builder::build_symbol_definition() { using Elf_Verdaux = typename ELF_T::Elf_Verdaux; LIEF_DEBUG("[+] Building symbol definition"); - DynamicEntry* dt_verdef = binary_->get(DYNAMIC_TAGS::DT_VERDEF); + DynamicEntry* dt_verdef = binary_->get(DynamicEntry::TAG::VERDEF); if (dt_verdef == nullptr) { LIEF_ERR("Can't find DT_VERDEF"); return make_error_code(lief_errors::not_found); } - DynamicEntry* dt_verdefnum = binary_->get(DYNAMIC_TAGS::DT_VERDEFNUM); + DynamicEntry* dt_verdefnum = binary_->get(DynamicEntry::TAG::VERDEFNUM); if (dt_verdef == nullptr) { LIEF_ERR("Can't find DT_VERDEFNUM"); return make_error_code(lief_errors::not_found); @@ -1743,7 +1743,7 @@ ok_error_t Builder::build_symbol_version() { binary_->symbol_version_table_.size(), binary_->dynamic_symbols_.size()); } - DynamicEntry* dt_versym = binary_->get(DYNAMIC_TAGS::DT_VERSYM); + DynamicEntry* dt_versym = binary_->get(DynamicEntry::TAG::VERSYM); if (dt_versym == nullptr) { LIEF_ERR("Can't find DT_VERSYM entry"); return make_error_code(lief_errors::not_found); diff --git a/src/ELF/DynamicEntry.cpp b/src/ELF/DynamicEntry.cpp index dd837d340a..26c4b8f319 100644 --- a/src/ELF/DynamicEntry.cpp +++ b/src/ELF/DynamicEntry.cpp @@ -13,82 +13,150 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include - #include "LIEF/Visitor.hpp" -#include "LIEF/ELF/hash.hpp" #include "LIEF/ELF/DynamicEntry.hpp" -#include "LIEF/ELF/EnumToString.hpp" #include "ELF/Structures.hpp" -namespace LIEF { -namespace ELF { - -DynamicEntry::DynamicEntry() = default; +#include -DynamicEntry& DynamicEntry::operator=(const DynamicEntry&) = default; +#include "frozen.hpp" -DynamicEntry::DynamicEntry(const DynamicEntry&) = default; - -DynamicEntry::~DynamicEntry() = default; +namespace LIEF { +namespace ELF { DynamicEntry::DynamicEntry(const details::Elf64_Dyn& header) : - tag_{static_cast(header.d_tag)}, + tag_{DynamicEntry::from_value(header.d_tag)}, value_{header.d_un.d_val} {} - DynamicEntry::DynamicEntry(const details::Elf32_Dyn& header) : - tag_{static_cast(header.d_tag)}, + tag_{DynamicEntry::from_value(header.d_tag)}, value_{header.d_un.d_val} {} - -DynamicEntry::DynamicEntry(DYNAMIC_TAGS tag, uint64_t value) : - tag_{tag}, - value_{value} -{} - - -DYNAMIC_TAGS DynamicEntry::tag() const { - return tag_; -} - - -uint64_t DynamicEntry::value() const { - return value_; -} - -void DynamicEntry::tag(DYNAMIC_TAGS tag) { - tag_ = tag; -} - - -void DynamicEntry::value(uint64_t value) { - value_ = value; -} - void DynamicEntry::accept(Visitor& visitor) const { visitor.visit(*this); } - - - - - std::ostream& DynamicEntry::print(std::ostream& os) const { - os << std::hex; - os << std::left - << std::setw(20) << to_string(tag()) - << std::setw(10) << value(); + os << fmt::format("{:<20}: {}", to_string(tag()), value()); return os; } - -std::ostream& operator<<(std::ostream& os, const DynamicEntry& entry) { - return entry.print(os); +const char* to_string(DynamicEntry::TAG tag) { + #define ENTRY(X) std::pair(DynamicEntry::TAG::X, #X) + STRING_MAP enums2str { + ENTRY(DT_NULL), + ENTRY(NEEDED), + ENTRY(PLTRELSZ), + ENTRY(PLTGOT), + ENTRY(HASH), + ENTRY(STRTAB), + ENTRY(SYMTAB), + ENTRY(RELA), + ENTRY(RELASZ), + ENTRY(RELAENT), + ENTRY(STRSZ), + ENTRY(SYMENT), + ENTRY(INIT), + ENTRY(FINI), + ENTRY(SONAME), + ENTRY(RPATH), + ENTRY(SYMBOLIC), + ENTRY(REL), + ENTRY(RELSZ), + ENTRY(RELENT), + ENTRY(PLTREL), + ENTRY(DEBUG), + ENTRY(TEXTREL), + ENTRY(JMPREL), + ENTRY(BIND_NOW), + ENTRY(INIT_ARRAY), + ENTRY(FINI_ARRAY), + ENTRY(INIT_ARRAYSZ), + ENTRY(FINI_ARRAYSZ), + ENTRY(RUNPATH), + ENTRY(FLAGS), + ENTRY(PREINIT_ARRAY), + ENTRY(PREINIT_ARRAYSZ), + ENTRY(SYMTAB_SHNDX), + ENTRY(RELRSZ), + ENTRY(RELR), + ENTRY(RELRENT), + ENTRY(GNU_HASH), + ENTRY(RELACOUNT), + ENTRY(RELCOUNT), + ENTRY(FLAGS_1), + ENTRY(VERSYM), + ENTRY(VERDEF), + ENTRY(VERDEFNUM), + ENTRY(VERNEED), + ENTRY(VERNEEDNUM), + ENTRY(ANDROID_REL_OFFSET), + ENTRY(ANDROID_REL_SIZE), + ENTRY(ANDROID_REL), + ENTRY(ANDROID_RELSZ), + ENTRY(ANDROID_RELA), + ENTRY(ANDROID_RELASZ), + ENTRY(ANDROID_RELR), + ENTRY(ANDROID_RELRSZ), + ENTRY(ANDROID_RELRENT), + ENTRY(ANDROID_RELRCOUNT), + ENTRY(MIPS_RLD_VERSION), + ENTRY(MIPS_TIME_STAMP), + ENTRY(MIPS_ICHECKSUM), + ENTRY(MIPS_IVERSION), + ENTRY(MIPS_FLAGS), + ENTRY(MIPS_BASE_ADDRESS), + ENTRY(MIPS_MSYM), + ENTRY(MIPS_CONFLICT), + ENTRY(MIPS_LIBLIST), + ENTRY(MIPS_LOCAL_GOTNO), + ENTRY(MIPS_CONFLICTNO), + ENTRY(MIPS_LIBLISTNO), + ENTRY(MIPS_SYMTABNO), + ENTRY(MIPS_UNREFEXTNO), + ENTRY(MIPS_GOTSYM), + ENTRY(MIPS_HIPAGENO), + ENTRY(MIPS_RLD_MAP), + ENTRY(MIPS_DELTA_CLASS), + ENTRY(MIPS_DELTA_CLASS_NO), + ENTRY(MIPS_DELTA_INSTANCE), + ENTRY(MIPS_DELTA_INSTANCE_NO), + ENTRY(MIPS_DELTA_RELOC), + ENTRY(MIPS_DELTA_RELOC_NO), + ENTRY(MIPS_DELTA_SYM), + ENTRY(MIPS_DELTA_SYM_NO), + ENTRY(MIPS_DELTA_CLASSSYM), + ENTRY(MIPS_DELTA_CLASSSYM_NO), + ENTRY(MIPS_CXX_FLAGS), + ENTRY(MIPS_PIXIE_INIT), + ENTRY(MIPS_SYMBOL_LIB), + ENTRY(MIPS_LOCALPAGE_GOTIDX), + ENTRY(MIPS_LOCAL_GOTIDX), + ENTRY(MIPS_HIDDEN_GOTIDX), + ENTRY(MIPS_PROTECTED_GOTIDX), + ENTRY(MIPS_OPTIONS), + ENTRY(MIPS_INTERFACE), + ENTRY(MIPS_DYNSTR_ALIGN), + ENTRY(MIPS_INTERFACE_SIZE), + ENTRY(MIPS_RLD_TEXT_RESOLVE_ADDR), + ENTRY(MIPS_PERF_SUFFIX), + ENTRY(MIPS_COMPACT_SIZE), + ENTRY(MIPS_GP_VALUE), + ENTRY(MIPS_AUX_DYNAMIC), + ENTRY(MIPS_PLTGOT), + ENTRY(MIPS_RWPLT), + }; + #undef ENTRY + + if (auto it = enums2str.find(tag); it != enums2str.end()) { + return it->second; + } + + return "UNKNOWN"; } + } } diff --git a/src/ELF/DynamicEntryArray.cpp b/src/ELF/DynamicEntryArray.cpp index 38b3b8c1dd..9782c2a6d0 100644 --- a/src/ELF/DynamicEntryArray.cpp +++ b/src/ELF/DynamicEntryArray.cpp @@ -18,43 +18,9 @@ #include "logging.hpp" -#include -#include -#include -#include - namespace LIEF { namespace ELF { -DynamicEntryArray::DynamicEntryArray() = default; -DynamicEntryArray& DynamicEntryArray::operator=(const DynamicEntryArray&) = default; -DynamicEntryArray::DynamicEntryArray(const DynamicEntryArray&) = default; - - -DynamicEntryArray::DynamicEntryArray(DYNAMIC_TAGS tag, array_t array) : - DynamicEntry::DynamicEntry{tag, 0}, - array_{std::move(array)} -{} - - -DynamicEntryArray::array_t& DynamicEntryArray::array() { - return const_cast(static_cast(this)->array()); -} - - -const DynamicEntryArray::array_t& DynamicEntryArray::array() const { - return array_; -} - -void DynamicEntryArray::array(const DynamicEntryArray::array_t& array) { - array_ = array; -} - -DynamicEntryArray& DynamicEntryArray::append(uint64_t function) { - array_.push_back(function); - return *this; -} - DynamicEntryArray& DynamicEntryArray::remove(uint64_t function) { array_.erase(std::remove_if(std::begin(array_), std::end(array_), [function] (uint64_t v) { return v == function; }), @@ -76,21 +42,8 @@ DynamicEntryArray& DynamicEntryArray::insert(size_t pos, uint64_t function) { return *this; } - -size_t DynamicEntryArray::size() const { - return array_.size(); -} - -DynamicEntryArray& DynamicEntryArray::operator+=(uint64_t value) { - return append(value); -} - -DynamicEntryArray& DynamicEntryArray::operator-=(uint64_t value) { - return remove(value); -} - const uint64_t& DynamicEntryArray::operator[](size_t idx) const { - static uint64_t GARBAGE; + static uint64_t GARBAGE = 0; if (idx >= array_.size()) { LIEF_WARN("DynamicEntryArray[{}] is out-of-range", idx); return GARBAGE; @@ -106,34 +59,13 @@ void DynamicEntryArray::accept(Visitor& visitor) const { visitor.visit(*this); } -bool DynamicEntryArray::classof(const DynamicEntry* entry) { - const DYNAMIC_TAGS tag = entry->tag(); - return tag == DYNAMIC_TAGS::DT_INIT_ARRAY || - tag == DYNAMIC_TAGS::DT_FINI_ARRAY || - tag == DYNAMIC_TAGS::DT_PREINIT_ARRAY; -} - std::ostream& DynamicEntryArray::print(std::ostream& os) const { - const DynamicEntryArray::array_t& array = this->array(); + const array_t& array = this->array(); DynamicEntry::print(os); - os << std::hex - << std::left - << "[" - << std::accumulate(std::begin(array), std::end(array), std::string(), - [] (std::string& s, uint64_t x) { - std::stringstream ss; - ss << "0x" << std::hex << x; - return s.empty() ? ss.str() : s + ", " + ss.str(); - }) - << "]"; - - + os << fmt::format("0x{:04x}", fmt::join(array, ", ")); return os; } - -DynamicEntryArray::~DynamicEntryArray() = default; - } } diff --git a/src/ELF/DynamicEntryFlags.cpp b/src/ELF/DynamicEntryFlags.cpp index 268a7822ab..54a39b0483 100644 --- a/src/ELF/DynamicEntryFlags.cpp +++ b/src/ELF/DynamicEntryFlags.cpp @@ -13,150 +13,202 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include #include "LIEF/Visitor.hpp" - #include "LIEF/ELF/DynamicEntryFlags.hpp" -#include "LIEF/ELF/EnumToString.hpp" -#include "ELF/Structures.hpp" + +#include "frozen.hpp" +#include "logging.hpp" +#include "fmt_formatter.hpp" + +FMT_FORMATTER(LIEF::ELF::DynamicEntryFlags::FLAG, LIEF::ELF::to_string); namespace LIEF { namespace ELF { -DynamicEntryFlags::DynamicEntryFlags() = default; -DynamicEntryFlags& DynamicEntryFlags::operator=(const DynamicEntryFlags&) = default; -DynamicEntryFlags::DynamicEntryFlags(const DynamicEntryFlags&) = default; +static constexpr auto DF_FLAGS = { + DynamicEntryFlags::FLAG::ORIGIN, DynamicEntryFlags::FLAG::SYMBOLIC, + DynamicEntryFlags::FLAG::TEXTREL, DynamicEntryFlags::FLAG::BIND_NOW, + DynamicEntryFlags::FLAG::STATIC_TLS, +}; + +static constexpr auto DF_FLAGS_1 = { + DynamicEntryFlags::FLAG::NOW, + DynamicEntryFlags::FLAG::GLOBAL, + DynamicEntryFlags::FLAG::GROUP, + DynamicEntryFlags::FLAG::NODELETE, + DynamicEntryFlags::FLAG::LOADFLTR, + DynamicEntryFlags::FLAG::INITFIRST, + DynamicEntryFlags::FLAG::NOOPEN, + DynamicEntryFlags::FLAG::HANDLE_ORIGIN, + DynamicEntryFlags::FLAG::DIRECT, + DynamicEntryFlags::FLAG::TRANS, + DynamicEntryFlags::FLAG::INTERPOSE, + DynamicEntryFlags::FLAG::NODEFLIB, + DynamicEntryFlags::FLAG::NODUMP, + DynamicEntryFlags::FLAG::CONFALT, + DynamicEntryFlags::FLAG::ENDFILTEE, + DynamicEntryFlags::FLAG::DISPRELDNE, + DynamicEntryFlags::FLAG::DISPRELPND, + DynamicEntryFlags::FLAG::NODIRECT, + DynamicEntryFlags::FLAG::IGNMULDEF, + DynamicEntryFlags::FLAG::NOKSYMS, + DynamicEntryFlags::FLAG::NOHDR, + DynamicEntryFlags::FLAG::EDITED, + DynamicEntryFlags::FLAG::NORELOC, + DynamicEntryFlags::FLAG::SYMINTPOSE, + DynamicEntryFlags::FLAG::GLOBAUDIT, + DynamicEntryFlags::FLAG::SINGLETON, + DynamicEntryFlags::FLAG::PIE, + DynamicEntryFlags::FLAG::KMOD, + DynamicEntryFlags::FLAG::WEAKFILTER, + DynamicEntryFlags::FLAG::NOCOMMON, +}; + +bool DynamicEntryFlags::has(DynamicEntryFlags::FLAG f) const { + if (tag() == DynamicEntry::TAG::FLAGS) { + auto raw = static_cast(f); + if (BASE <= raw) { + return false; + } + return (value() & raw) > 0; + } -bool DynamicEntryFlags::has(DYNAMIC_FLAGS f) const { - if (tag() != DYNAMIC_TAGS::DT_FLAGS) { - return false; + if (tag() == DynamicEntry::TAG::FLAGS_1) { + auto raw = static_cast(f); + if (raw < BASE) { + return false; + } + raw -= BASE; + return (value() & raw) > 0; } - return (static_cast(f) & value()) > 0; + return false; } -bool DynamicEntryFlags::has(DYNAMIC_FLAGS_1 f) const { - if (tag() != DYNAMIC_TAGS::DT_FLAGS_1) { - return false; - } - return (static_cast(f) & value()) > 0; -} - DynamicEntryFlags::flags_list_t DynamicEntryFlags::flags() const { - DynamicEntryFlags::flags_list_t flags; + flags_list_t flags; - - if (tag() == DYNAMIC_TAGS::DT_FLAGS) { - for (DYNAMIC_FLAGS f : details::dynamic_flags_array) { + if (tag() == DynamicEntry::TAG::FLAGS) { + for (DynamicEntryFlags::FLAG f : DF_FLAGS) { if (has(f)) { - flags.insert(static_cast(f)); + flags.push_back(f); } } + return flags; } - if (tag() == DYNAMIC_TAGS::DT_FLAGS_1) { - for (DYNAMIC_FLAGS_1 f : details::dynamic_flags_1_array) { + if (tag() == DynamicEntry::TAG::FLAGS_1) { + for (DynamicEntryFlags::FLAG f : DF_FLAGS_1) { if (has(f)) { - flags.insert(static_cast(f)); + flags.push_back(f); } } + return flags; } return flags; } -void DynamicEntryFlags::add(DYNAMIC_FLAGS f) { - if (tag() != DYNAMIC_TAGS::DT_FLAGS) { +void DynamicEntryFlags::add(DynamicEntryFlags::FLAG f) { + if (tag() == DynamicEntry::TAG::FLAGS) { + auto raw = static_cast(f); + if (BASE <= raw) { + return; + } + value(value() | raw); return; } - value(value() | static_cast(f)); -} - -void DynamicEntryFlags::add(DYNAMIC_FLAGS_1 f) { - if (tag() != DYNAMIC_TAGS::DT_FLAGS_1) { + if (tag() == DynamicEntry::TAG::FLAGS_1) { + auto raw = static_cast(f); + if (raw < BASE) { + return; + } + raw -= BASE; + value(value() | raw); return; } - - value(value() | static_cast(f)); + return; } -void DynamicEntryFlags::remove(DYNAMIC_FLAGS f) { - if (tag() != DYNAMIC_TAGS::DT_FLAGS) { - return; +void DynamicEntryFlags::remove(DynamicEntryFlags::FLAG f) { + if (tag() == DynamicEntry::TAG::FLAGS) { + auto raw = static_cast(f); + if (BASE <= raw) { + return; + } + value(value() & ~raw); } - value(value() & (~ static_cast(f))); -} - -void DynamicEntryFlags::remove(DYNAMIC_FLAGS_1 f) { - if (tag() != DYNAMIC_TAGS::DT_FLAGS_1) { - return; + if (tag() == DynamicEntry::TAG::FLAGS_1) { + auto raw = static_cast(f); + if (raw < BASE) { + return; + } + raw -= BASE; + value(value() & ~raw); } - - value(value() & (~ static_cast(f))); -} - - -DynamicEntryFlags& DynamicEntryFlags::operator+=(DYNAMIC_FLAGS f) { - add(f); - return *this; -} - -DynamicEntryFlags& DynamicEntryFlags::operator+=(DYNAMIC_FLAGS_1 f) { - add(f); - return *this; -} - -DynamicEntryFlags& DynamicEntryFlags::operator-=(DYNAMIC_FLAGS f) { - remove(f); - return *this; -} - -DynamicEntryFlags& DynamicEntryFlags::operator-=(DYNAMIC_FLAGS_1 f) { - remove(f); - return *this; } void DynamicEntryFlags::accept(Visitor& visitor) const { visitor.visit(*this); } -bool DynamicEntryFlags::classof(const DynamicEntry* entry) { - const DYNAMIC_TAGS tag = entry->tag(); - return tag == DYNAMIC_TAGS::DT_FLAGS_1 || - tag == DYNAMIC_TAGS::DT_FLAGS; -} - std::ostream& DynamicEntryFlags::print(std::ostream& os) const { DynamicEntry::print(os); + os << " " << fmt::to_string(flags()); + return os; +} - const flags_list_t& flags = this->flags(); - std::string flags_str; - - if (tag() == DYNAMIC_TAGS::DT_FLAGS) { - flags_str = std::accumulate(std::begin(flags), std::end(flags), std::string{}, - [] (const std::string& a, const uint32_t flag) { - auto f = static_cast(flag); - return a.empty() ? to_string(f) : a + " - " + to_string(f); - }); - } - - if (tag() == DYNAMIC_TAGS::DT_FLAGS_1) { - flags_str = std::accumulate(std::begin(flags), std::end(flags), std::string{}, - [] (const std::string& a, const uint32_t flag) { - auto f = static_cast(flag); - return a.empty() ? to_string(f) : a + " - " + to_string(f); - }); +const char* to_string(DynamicEntryFlags::FLAG flag) { + #define ENTRY(X) std::pair(DynamicEntryFlags::FLAG::X, #X) + STRING_MAP enums2str { + ENTRY(ORIGIN), + ENTRY(SYMBOLIC), + ENTRY(TEXTREL), + ENTRY(BIND_NOW), + ENTRY(STATIC_TLS), + ENTRY(NOW), + ENTRY(GLOBAL), + ENTRY(GROUP), + ENTRY(NODELETE), + ENTRY(LOADFLTR), + ENTRY(INITFIRST), + ENTRY(NOOPEN), + ENTRY(HANDLE_ORIGIN), + ENTRY(DIRECT), + ENTRY(TRANS), + ENTRY(INTERPOSE), + ENTRY(NODEFLIB), + ENTRY(NODUMP), + ENTRY(CONFALT), + ENTRY(ENDFILTEE), + ENTRY(DISPRELDNE), + ENTRY(DISPRELPND), + ENTRY(NODIRECT), + ENTRY(IGNMULDEF), + ENTRY(NOKSYMS), + ENTRY(NOHDR), + ENTRY(EDITED), + ENTRY(NORELOC), + ENTRY(SYMINTPOSE), + ENTRY(GLOBAUDIT), + ENTRY(SINGLETON), + ENTRY(PIE), + ENTRY(KMOD), + ENTRY(WEAKFILTER), + ENTRY(NOCOMMON), + }; + #undef ENTRY + if (auto it = enums2str.find(flag); it != enums2str.end()) { + return it->second; } - os << " " << flags_str; - - return os; + return "UNKNOWN"; } + } } diff --git a/src/ELF/DynamicEntryLibrary.cpp b/src/ELF/DynamicEntryLibrary.cpp index afdccd30fd..3b1a19544b 100644 --- a/src/ELF/DynamicEntryLibrary.cpp +++ b/src/ELF/DynamicEntryLibrary.cpp @@ -16,52 +16,21 @@ #include "LIEF/ELF/DynamicEntryLibrary.hpp" #include "LIEF/Visitor.hpp" -#include -#include +#include namespace LIEF { namespace ELF { -DynamicEntryLibrary& DynamicEntryLibrary::operator=(const DynamicEntryLibrary&) = default; -DynamicEntryLibrary::DynamicEntryLibrary(const DynamicEntryLibrary&) = default; - -DynamicEntryLibrary::DynamicEntryLibrary() : - DynamicEntry::DynamicEntry{DYNAMIC_TAGS::DT_NEEDED, 0} -{} - -DynamicEntryLibrary::DynamicEntryLibrary(std::string name) : - DynamicEntry::DynamicEntry{DYNAMIC_TAGS::DT_NEEDED, 0}, - libname_{std::move(name)} -{} - -const std::string& DynamicEntryLibrary::name() const { - return libname_; -} - - -void DynamicEntryLibrary::name(const std::string& name) { - libname_ = name; -} - - void DynamicEntryLibrary::accept(Visitor& visitor) const { visitor.visit(*this); } -bool DynamicEntryLibrary::classof(const DynamicEntry* entry) { - const DYNAMIC_TAGS tag = entry->tag(); - return tag == DYNAMIC_TAGS::DT_NEEDED; -} - std::ostream& DynamicEntryLibrary::print(std::ostream& os) const { - DynamicEntry::print(os); - os << std::hex - << std::left - << std::setw(10) << name(); + os << fmt::format("{:<10}", name()); return os; - } + } } diff --git a/src/ELF/DynamicEntryRpath.cpp b/src/ELF/DynamicEntryRpath.cpp index a93df3a724..fd6220d298 100644 --- a/src/ELF/DynamicEntryRpath.cpp +++ b/src/ELF/DynamicEntryRpath.cpp @@ -26,45 +26,6 @@ namespace LIEF { namespace ELF { -DynamicEntryRpath::DynamicEntryRpath() : - DynamicEntry::DynamicEntry{DYNAMIC_TAGS::DT_RPATH, 0} -{} - -DynamicEntryRpath& DynamicEntryRpath::operator=(const DynamicEntryRpath&) = default; -DynamicEntryRpath::DynamicEntryRpath(const DynamicEntryRpath&) = default; - - -DynamicEntryRpath::DynamicEntryRpath(std::string rpath) : - DynamicEntry::DynamicEntry{DYNAMIC_TAGS::DT_RPATH, 0}, - rpath_{std::move(rpath)} -{} - - -DynamicEntryRpath::DynamicEntryRpath(const std::vector& paths) : - DynamicEntry::DynamicEntry{DYNAMIC_TAGS::DT_RPATH, 0} -{ - this->paths(paths); -} - -const std::string& DynamicEntryRpath::name() const { - return rpath_; -} - - -void DynamicEntryRpath::name(const std::string& name) { - rpath_ = name; -} - -const std::string& DynamicEntryRpath::rpath() const { - return name(); -} - - -void DynamicEntryRpath::rpath(const std::string& rpath) { - name(rpath); -} - - std::vector DynamicEntryRpath::paths() const { std::stringstream ss; ss.str(rpath()); @@ -117,33 +78,18 @@ DynamicEntryRpath& DynamicEntryRpath::insert(size_t pos, const std::string& path return *this; } -DynamicEntryRpath& DynamicEntryRpath::operator+=(const std::string& path) { - return append(path); -} - -DynamicEntryRpath& DynamicEntryRpath::operator-=(const std::string& path) { - return remove(path); -} void DynamicEntryRpath::accept(Visitor& visitor) const { visitor.visit(*this); } -bool DynamicEntryRpath::classof(const DynamicEntry* entry) { - const DYNAMIC_TAGS tag = entry->tag(); - return tag == DYNAMIC_TAGS::DT_RPATH; -} - std::ostream& DynamicEntryRpath::print(std::ostream& os) const { - DynamicEntry::print(os); - os << std::hex - << std::left - << std::setw(10) << rpath(); + os << fmt::format("{:<10}", rpath()); return os; - } + } } diff --git a/src/ELF/DynamicEntryRunPath.cpp b/src/ELF/DynamicEntryRunPath.cpp index 3555f95e00..f7330b574b 100644 --- a/src/ELF/DynamicEntryRunPath.cpp +++ b/src/ELF/DynamicEntryRunPath.cpp @@ -17,55 +17,12 @@ #include "LIEF/Visitor.hpp" #include "logging.hpp" -#include -#include #include #include -#include namespace LIEF { namespace ELF { - -DynamicEntryRunPath& DynamicEntryRunPath::operator=(const DynamicEntryRunPath&) = default; -DynamicEntryRunPath::DynamicEntryRunPath(const DynamicEntryRunPath&) = default; - -DynamicEntryRunPath::DynamicEntryRunPath() : - DynamicEntry::DynamicEntry{DYNAMIC_TAGS::DT_RUNPATH, 0} -{} - -DynamicEntryRunPath::DynamicEntryRunPath(std::string runpath) : - DynamicEntry::DynamicEntry{DYNAMIC_TAGS::DT_RUNPATH, 0}, - runpath_{std::move(runpath)} -{} - - -DynamicEntryRunPath::DynamicEntryRunPath(const std::vector& paths) : - DynamicEntry::DynamicEntry{DYNAMIC_TAGS::DT_RUNPATH, 0} -{ - this->paths(paths); -} - - - -const std::string& DynamicEntryRunPath::name() const { - return runpath_; -} - - -void DynamicEntryRunPath::name(const std::string& name) { - runpath_ = name; -} - -const std::string& DynamicEntryRunPath::runpath() const { - return name(); -} - -void DynamicEntryRunPath::runpath(const std::string& runpath) { - name(runpath); -} - - std::vector DynamicEntryRunPath::paths() const { std::stringstream ss; ss.str(runpath()); @@ -119,28 +76,14 @@ DynamicEntryRunPath& DynamicEntryRunPath::insert(size_t pos, const std::string& return *this; } -DynamicEntryRunPath& DynamicEntryRunPath::operator+=(const std::string& path) { - return append(path); -} - -DynamicEntryRunPath& DynamicEntryRunPath::operator-=(const std::string& path) { - return remove(path); -} - void DynamicEntryRunPath::accept(Visitor& visitor) const { visitor.visit(*this); } -bool DynamicEntryRunPath::classof(const DynamicEntry* entry) { - const DYNAMIC_TAGS tag = entry->tag(); - return tag == DYNAMIC_TAGS::DT_RUNPATH; -} std::ostream& DynamicEntryRunPath::print(std::ostream& os) const { DynamicEntry::print(os); - os << std::hex - << std::left - << std::setw(10) << name(); + os << fmt::format("{:<10}", runpath()); return os; } } diff --git a/src/ELF/DynamicSharedObject.cpp b/src/ELF/DynamicSharedObject.cpp index 1a7e9aa2b8..24242924c3 100644 --- a/src/ELF/DynamicSharedObject.cpp +++ b/src/ELF/DynamicSharedObject.cpp @@ -16,52 +16,21 @@ #include "LIEF/ELF/DynamicSharedObject.hpp" #include "LIEF/Visitor.hpp" -#include -#include +#include namespace LIEF { namespace ELF { -DynamicSharedObject::DynamicSharedObject() : - DynamicEntry::DynamicEntry{DYNAMIC_TAGS::DT_SONAME, 0} -{} - -DynamicSharedObject& DynamicSharedObject::operator=(const DynamicSharedObject&) = default; - -DynamicSharedObject::DynamicSharedObject(const DynamicSharedObject&) = default; - -DynamicSharedObject::DynamicSharedObject(std::string name) : - DynamicEntry::DynamicEntry{DYNAMIC_TAGS::DT_SONAME, 0}, - name_{std::move(name)} -{} - - -const std::string& DynamicSharedObject::name() const { - return name_; -} - - -void DynamicSharedObject::name(const std::string& name) { - name_ = name; -} void DynamicSharedObject::accept(Visitor& visitor) const { visitor.visit(*this); } -bool DynamicSharedObject::classof(const DynamicEntry* entry) { - const DYNAMIC_TAGS tag = entry->tag(); - return tag == DYNAMIC_TAGS::DT_SONAME; -} - - std::ostream& DynamicSharedObject::print(std::ostream& os) const { DynamicEntry::print(os); - os << std::hex - << std::left - << std::setw(10) << name(); + os << fmt::format("{:<10}", name()); return os; - } + } } diff --git a/src/ELF/EnumToString.cpp b/src/ELF/EnumToString.cpp index 1fc9fea9b2..ea44255c62 100644 --- a/src/ELF/EnumToString.cpp +++ b/src/ELF/EnumToString.cpp @@ -274,116 +274,6 @@ const char* to_string(SEGMENT_TYPES e) { return it == enumStrings.end() ? "UNDEFINED" : it->second; } -const char* to_string(DYNAMIC_TAGS e) { - CONST_MAP(DYNAMIC_TAGS, const char*, 101) enumStrings { - { DYNAMIC_TAGS::DT_NULL, "NULL"}, - { DYNAMIC_TAGS::DT_NEEDED, "NEEDED"}, - { DYNAMIC_TAGS::DT_PLTRELSZ, "PLTRELSZ"}, - { DYNAMIC_TAGS::DT_PLTGOT, "PLTGOT"}, - { DYNAMIC_TAGS::DT_HASH, "HASH"}, - { DYNAMIC_TAGS::DT_STRTAB, "STRTAB"}, - { DYNAMIC_TAGS::DT_SYMTAB, "SYMTAB"}, - { DYNAMIC_TAGS::DT_RELA, "RELA"}, - { DYNAMIC_TAGS::DT_RELASZ, "RELASZ"}, - { DYNAMIC_TAGS::DT_RELAENT, "RELAENT"}, - { DYNAMIC_TAGS::DT_STRSZ, "STRSZ"}, - { DYNAMIC_TAGS::DT_SYMENT, "SYMENT"}, - { DYNAMIC_TAGS::DT_INIT, "INIT"}, - { DYNAMIC_TAGS::DT_FINI, "FINI"}, - { DYNAMIC_TAGS::DT_SONAME, "SONAME"}, - { DYNAMIC_TAGS::DT_RPATH, "RPATH"}, - { DYNAMIC_TAGS::DT_SYMBOLIC, "SYMBOLIC"}, - { DYNAMIC_TAGS::DT_REL, "REL"}, - { DYNAMIC_TAGS::DT_RELSZ, "RELSZ"}, - { DYNAMIC_TAGS::DT_RELENT, "RELENT"}, - { DYNAMIC_TAGS::DT_PLTREL, "PLTREL"}, - { DYNAMIC_TAGS::DT_DEBUG, "DEBUG"}, - { DYNAMIC_TAGS::DT_TEXTREL, "TEXTREL"}, - { DYNAMIC_TAGS::DT_JMPREL, "JMPREL"}, - { DYNAMIC_TAGS::DT_BIND_NOW, "BIND_NOW"}, - { DYNAMIC_TAGS::DT_INIT_ARRAY, "INIT_ARRAY"}, - { DYNAMIC_TAGS::DT_FINI_ARRAY, "FINI_ARRAY"}, - { DYNAMIC_TAGS::DT_INIT_ARRAYSZ, "INIT_ARRAYSZ"}, - { DYNAMIC_TAGS::DT_FINI_ARRAYSZ, "FINI_ARRAYSZ"}, - { DYNAMIC_TAGS::DT_RUNPATH, "RUNPATH"}, - { DYNAMIC_TAGS::DT_FLAGS, "FLAGS"}, - //{ DYNAMIC_TAGS::DT_ENCODING, "ENCODING"}, // SKIPED - { DYNAMIC_TAGS::DT_PREINIT_ARRAY, "PREINIT_ARRAY"}, - { DYNAMIC_TAGS::DT_PREINIT_ARRAYSZ, "PREINIT_ARRAYSZ"}, - { DYNAMIC_TAGS::DT_GNU_HASH, "GNU_HASH"}, - { DYNAMIC_TAGS::DT_RELACOUNT, "RELACOUNT"}, - { DYNAMIC_TAGS::DT_RELCOUNT, "RELCOUNT"}, - { DYNAMIC_TAGS::DT_FLAGS_1, "FLAGS_1"}, - { DYNAMIC_TAGS::DT_VERSYM, "VERSYM"}, - { DYNAMIC_TAGS::DT_VERDEF, "VERDEF"}, - { DYNAMIC_TAGS::DT_VERDEFNUM, "VERDEFNUM"}, - { DYNAMIC_TAGS::DT_VERNEED, "VERNEED"}, - { DYNAMIC_TAGS::DT_VERNEEDNUM, "VERNEEDNUM"}, - { DYNAMIC_TAGS::DT_SYMTAB_SHNDX, "SYMTAB_SHNDX"}, - { DYNAMIC_TAGS::DT_RELRSZ, "RELRSZ"}, - { DYNAMIC_TAGS::DT_RELR, "RELR"}, - { DYNAMIC_TAGS::DT_RELRENT, "RELRENT"}, - { DYNAMIC_TAGS::DT_MIPS_RLD_VERSION, "MIPS_RLD_VERSION"}, - { DYNAMIC_TAGS::DT_MIPS_TIME_STAMP, "MIPS_TIME_STAMP"}, - { DYNAMIC_TAGS::DT_MIPS_ICHECKSUM, "MIPS_ICHECKSUM"}, - { DYNAMIC_TAGS::DT_MIPS_IVERSION, "MIPS_IVERSION"}, - { DYNAMIC_TAGS::DT_MIPS_FLAGS, "MIPS_FLAGS"}, - { DYNAMIC_TAGS::DT_MIPS_BASE_ADDRESS, "MIPS_BASE_ADDRESS"}, - { DYNAMIC_TAGS::DT_MIPS_MSYM, "MIPS_MSYM"}, - { DYNAMIC_TAGS::DT_MIPS_CONFLICT, "MIPS_CONFLICT"}, - { DYNAMIC_TAGS::DT_MIPS_LIBLIST, "MIPS_LIBLIST"}, - { DYNAMIC_TAGS::DT_MIPS_LOCAL_GOTNO, "MIPS_LOCAL_GOTNO"}, - { DYNAMIC_TAGS::DT_MIPS_CONFLICTNO, "MIPS_CONFLICTNO"}, - { DYNAMIC_TAGS::DT_MIPS_LIBLISTNO, "MIPS_LIBLISTNO"}, - { DYNAMIC_TAGS::DT_MIPS_SYMTABNO, "MIPS_SYMTABNO"}, - { DYNAMIC_TAGS::DT_MIPS_UNREFEXTNO, "MIPS_UNREFEXTNO"}, - { DYNAMIC_TAGS::DT_MIPS_GOTSYM, "MIPS_GOTSYM"}, - { DYNAMIC_TAGS::DT_MIPS_HIPAGENO, "MIPS_HIPAGENO"}, - { DYNAMIC_TAGS::DT_MIPS_RLD_MAP, "MIPS_RLD_MAP"}, - { DYNAMIC_TAGS::DT_MIPS_DELTA_CLASS, "MIPS_DELTA_CLASS"}, - { DYNAMIC_TAGS::DT_MIPS_DELTA_CLASS_NO, "MIPS_DELTA_CLASS_NO"}, - { DYNAMIC_TAGS::DT_MIPS_DELTA_INSTANCE, "MIPS_DELTA_INSTANCE"}, - { DYNAMIC_TAGS::DT_MIPS_DELTA_INSTANCE_NO, "MIPS_DELTA_INSTANCE_NO"}, - { DYNAMIC_TAGS::DT_MIPS_DELTA_RELOC, "MIPS_DELTA_RELOC"}, - { DYNAMIC_TAGS::DT_MIPS_DELTA_RELOC_NO, "MIPS_DELTA_RELOC_NO"}, - { DYNAMIC_TAGS::DT_MIPS_DELTA_SYM, "MIPS_DELTA_SYM"}, - { DYNAMIC_TAGS::DT_MIPS_DELTA_SYM_NO, "MIPS_DELTA_SYM_NO"}, - { DYNAMIC_TAGS::DT_MIPS_DELTA_CLASSSYM, "MIPS_DELTA_CLASSSYM"}, - { DYNAMIC_TAGS::DT_MIPS_DELTA_CLASSSYM_NO, "MIPS_DELTA_CLASSSYM_NO"}, - { DYNAMIC_TAGS::DT_MIPS_CXX_FLAGS, "MIPS_CXX_FLAGS"}, - { DYNAMIC_TAGS::DT_MIPS_PIXIE_INIT, "MIPS_PIXIE_INIT"}, - { DYNAMIC_TAGS::DT_MIPS_SYMBOL_LIB, "MIPS_SYMBOL_LIB"}, - { DYNAMIC_TAGS::DT_MIPS_LOCALPAGE_GOTIDX, "MIPS_LOCALPAGE_GOTIDX"}, - { DYNAMIC_TAGS::DT_MIPS_LOCAL_GOTIDX, "MIPS_LOCAL_GOTIDX"}, - { DYNAMIC_TAGS::DT_MIPS_HIDDEN_GOTIDX, "MIPS_HIDDEN_GOTIDX"}, - { DYNAMIC_TAGS::DT_MIPS_PROTECTED_GOTIDX, "MIPS_PROTECTED_GOTIDX"}, - { DYNAMIC_TAGS::DT_MIPS_OPTIONS, "MIPS_OPTIONS"}, - { DYNAMIC_TAGS::DT_MIPS_INTERFACE, "MIPS_INTERFACE"}, - { DYNAMIC_TAGS::DT_MIPS_DYNSTR_ALIGN, "MIPS_DYNSTR_ALIGN"}, - { DYNAMIC_TAGS::DT_MIPS_INTERFACE_SIZE, "MIPS_INTERFACE_SIZE"}, - { DYNAMIC_TAGS::DT_MIPS_RLD_TEXT_RESOLVE_ADDR, "MIPS_RLD_TEXT_RESOLVE_ADDR"}, - { DYNAMIC_TAGS::DT_MIPS_PERF_SUFFIX, "MIPS_PERF_SUFFIX"}, - { DYNAMIC_TAGS::DT_MIPS_COMPACT_SIZE, "MIPS_COMPACT_SIZE"}, - { DYNAMIC_TAGS::DT_MIPS_GP_VALUE, "MIPS_GP_VALUE"}, - { DYNAMIC_TAGS::DT_MIPS_AUX_DYNAMIC, "MIPS_AUX_DYNAMIC"}, - { DYNAMIC_TAGS::DT_MIPS_PLTGOT, "MIPS_PLTGOT"}, - { DYNAMIC_TAGS::DT_MIPS_RWPLT, "MIPS_RWPLT"}, - { DYNAMIC_TAGS::DT_ANDROID_REL_OFFSET, "ANDROID_REL_OFFSET"}, - { DYNAMIC_TAGS::DT_ANDROID_REL_SIZE, "ANDROID_REL_SIZE"}, - { DYNAMIC_TAGS::DT_ANDROID_REL, "ANDROID_REL"}, - { DYNAMIC_TAGS::DT_ANDROID_RELSZ, "ANDROID_RELSZ"}, - { DYNAMIC_TAGS::DT_ANDROID_RELA, "ANDROID_RELA"}, - { DYNAMIC_TAGS::DT_ANDROID_RELASZ, "ANDROID_RELASZ"}, - { DYNAMIC_TAGS::DT_ANDROID_RELR, "ANDROID_RELR"}, - { DYNAMIC_TAGS::DT_ANDROID_RELRSZ, "ANDROID_RELRSZ"}, - { DYNAMIC_TAGS::DT_ANDROID_RELRENT, "ANDROID_RELRENT"}, - { DYNAMIC_TAGS::DT_ANDROID_RELRCOUNT, "ANDROID_RELRCOUNT"} - }; - const auto it = enumStrings.find(e); - return it == enumStrings.end() ? "UNDEFINED" : it->second; -} - - const char* to_string(ELF_SECTION_TYPES e) { CONST_MAP(ELF_SECTION_TYPES, const char*, 39) enumStrings { { ELF_SECTION_TYPES::SHT_NULL, "NULL"}, @@ -1456,54 +1346,6 @@ const char* to_string(SYMBOL_SECTION_INDEX e) { } -const char* to_string(DYNAMIC_FLAGS e) { - CONST_MAP(DYNAMIC_FLAGS, const char*, 5) enum_strings { - { DYNAMIC_FLAGS::DF_ORIGIN, "ORIGIN" }, - { DYNAMIC_FLAGS::DF_SYMBOLIC, "SYMBOLIC" }, - { DYNAMIC_FLAGS::DF_TEXTREL, "TEXTREL" }, - { DYNAMIC_FLAGS::DF_BIND_NOW, "BIND_NOW" }, - { DYNAMIC_FLAGS::DF_STATIC_TLS, "STATIC_TLS" }, - }; - - const auto it = enum_strings.find(e); - return it == enum_strings.end() ? "UNDEFINED" : it->second; -} - -const char* to_string(DYNAMIC_FLAGS_1 e) { - CONST_MAP(DYNAMIC_FLAGS_1, const char*, 27) enum_strings_flags1 { - { DYNAMIC_FLAGS_1::DF_1_NOW, "NOW" }, - { DYNAMIC_FLAGS_1::DF_1_GLOBAL, "GLOBAL" }, - { DYNAMIC_FLAGS_1::DF_1_GROUP, "GROUP" }, - { DYNAMIC_FLAGS_1::DF_1_NODELETE, "NODELETE" }, - { DYNAMIC_FLAGS_1::DF_1_LOADFLTR, "LOADFLTR" }, - { DYNAMIC_FLAGS_1::DF_1_INITFIRST, "INITFIRST" }, - { DYNAMIC_FLAGS_1::DF_1_NOOPEN, "NOOPEN" }, - { DYNAMIC_FLAGS_1::DF_1_ORIGIN, "ORIGIN" }, - { DYNAMIC_FLAGS_1::DF_1_DIRECT, "DIRECT" }, - { DYNAMIC_FLAGS_1::DF_1_TRANS, "TRANS" }, - { DYNAMIC_FLAGS_1::DF_1_INTERPOSE, "INTERPOSE" }, - { DYNAMIC_FLAGS_1::DF_1_NODEFLIB, "NODEFLIB" }, - { DYNAMIC_FLAGS_1::DF_1_NODUMP, "NODUMP" }, - { DYNAMIC_FLAGS_1::DF_1_CONFALT, "CONFALT" }, - { DYNAMIC_FLAGS_1::DF_1_ENDFILTEE, "ENDFILTEE" }, - { DYNAMIC_FLAGS_1::DF_1_DISPRELDNE, "DISPRELDNE" }, - { DYNAMIC_FLAGS_1::DF_1_DISPRELPND, "DISPRELPND" }, - { DYNAMIC_FLAGS_1::DF_1_NODIRECT, "NODIRECT" }, - { DYNAMIC_FLAGS_1::DF_1_IGNMULDEF, "IGNMULDEF" }, - { DYNAMIC_FLAGS_1::DF_1_NOKSYMS, "NOKSYMS" }, - { DYNAMIC_FLAGS_1::DF_1_NOHDR, "NOHDR" }, - { DYNAMIC_FLAGS_1::DF_1_EDITED, "EDITED" }, - { DYNAMIC_FLAGS_1::DF_1_NORELOC, "NORELOC" }, - { DYNAMIC_FLAGS_1::DF_1_SYMINTPOSE, "SYMINTPOSE" }, - { DYNAMIC_FLAGS_1::DF_1_GLOBAUDIT, "GLOBAUDIT" }, - { DYNAMIC_FLAGS_1::DF_1_SINGLETON, "SINGLETON" }, - { DYNAMIC_FLAGS_1::DF_1_PIE, "PIE" }, - }; - - const auto it = enum_strings_flags1.find(e); - return it == enum_strings_flags1.end() ? "UNDEFINED" : it->second; -} - const char* to_string(ELF_SEGMENT_FLAGS e) { CONST_MAP(ELF_SEGMENT_FLAGS, const char*, 4) enum_strings { { ELF_SEGMENT_FLAGS::PF_NONE, "NONE" }, diff --git a/src/ELF/ExeLayout.hpp b/src/ELF/ExeLayout.hpp index ded16f2d09..21c07acb12 100644 --- a/src/ELF/ExeLayout.hpp +++ b/src/ELF/ExeLayout.hpp @@ -103,30 +103,30 @@ class LIEF_LOCAL ExeLayout : public Layout { for (std::unique_ptr& entry : binary_->dynamic_entries_) { switch (entry->tag()) { - case DYNAMIC_TAGS::DT_NEEDED: + case DynamicEntry::TAG::NEEDED: { const std::string& name = entry->as()->name(); opt_list.push_back(name); break; } - case DYNAMIC_TAGS::DT_SONAME: + case DynamicEntry::TAG::SONAME: { const std::string& name = entry->as()->name(); opt_list.push_back(name); break; } - case DYNAMIC_TAGS::DT_RPATH: + case DynamicEntry::TAG::RPATH: { - const std::string& name = entry->as()->name(); + const std::string& name = entry->as()->rpath(); opt_list.push_back(name); break; } - case DYNAMIC_TAGS::DT_RUNPATH: + case DynamicEntry::TAG::RUNPATH: { - const std::string& name = entry->as()->name(); + const std::string& name = entry->as()->runpath(); opt_list.push_back(name); break; } @@ -185,7 +185,7 @@ class LIEF_LOCAL ExeLayout : public Layout { } template - size_t dynamic_arraysize(DYNAMIC_TAGS tag) { + size_t dynamic_arraysize(DynamicEntry::TAG tag) { using uint = typename ELF_T::uint; DynamicEntry* entry = binary_->get(tag); if (entry == nullptr || !DynamicEntryArray::classof(entry)) { @@ -396,7 +396,7 @@ class LIEF_LOCAL ExeLayout : public Layout { using Elf_Rel = typename ELF_T::Elf_Rel; const Binary::it_dynamic_relocations& dyn_relocs = binary_->dynamic_relocations(); - const size_t computed_size = binary_->has(DYNAMIC_TAGS::DT_RELA) ? + const size_t computed_size = binary_->has(DynamicEntry::TAG::RELA) ? dyn_relocs.size() * sizeof(Elf_Rela) : dyn_relocs.size() * sizeof(Elf_Rel); return computed_size; @@ -408,10 +408,10 @@ class LIEF_LOCAL ExeLayout : public Layout { using Elf_Rel = typename ELF_T::Elf_Rel; const Binary::it_pltgot_relocations& pltgot_relocs = binary_->pltgot_relocations(); - const DynamicEntry* dt_rela = binary_->get(DYNAMIC_TAGS::DT_PLTREL); + const DynamicEntry* dt_rela = binary_->get(DynamicEntry::TAG::PLTREL); const bool is_rela = dt_rela != nullptr && - dt_rela->value() == static_cast(DYNAMIC_TAGS::DT_RELA); + DynamicEntry::from_value(dt_rela->value()) == DynamicEntry::TAG::RELA; if (is_rela) { return pltgot_relocs.size() * sizeof(Elf_Rela); @@ -770,7 +770,7 @@ class LIEF_LOCAL ExeLayout : public Layout { if (dynsym_size_ > 0) { // Update .dynsym / DT_SYMTAB - DynamicEntry* dt_symtab = binary_->get(DYNAMIC_TAGS::DT_SYMTAB); + DynamicEntry* dt_symtab = binary_->get(DynamicEntry::TAG::SYMTAB); if (dt_symtab == nullptr) { LIEF_ERR("Can't find DT_SYMTAB"); @@ -798,8 +798,8 @@ class LIEF_LOCAL ExeLayout : public Layout { if (relocate_dynstr_) { // Update .dynstr section, DT_SYMTAB, DT_STRSZ - DynamicEntry* dt_strtab = binary_->get(DYNAMIC_TAGS::DT_STRTAB); - DynamicEntry* dt_strsize = binary_->get(DYNAMIC_TAGS::DT_STRSZ); + DynamicEntry* dt_strtab = binary_->get(DynamicEntry::TAG::STRTAB); + DynamicEntry* dt_strsize = binary_->get(DynamicEntry::TAG::STRSZ); if (dt_strtab == nullptr || dt_strsize == nullptr) { LIEF_ERR("Can't find DT_STRTAB/DT_STRSZ"); @@ -828,7 +828,7 @@ class LIEF_LOCAL ExeLayout : public Layout { if (sver_size_ > 0) { - DynamicEntry* dt_versym = binary_->get(DYNAMIC_TAGS::DT_VERSYM); + DynamicEntry* dt_versym = binary_->get(DynamicEntry::TAG::VERSYM); if (dt_versym == nullptr) { LIEF_ERR("Can't find DT_VERSYM"); return make_error_code(lief_errors::file_format_error); @@ -854,7 +854,7 @@ class LIEF_LOCAL ExeLayout : public Layout { } if (sverd_size_ > 0) { - DynamicEntry* dt_verdef = binary_->get(DYNAMIC_TAGS::DT_VERDEF); + DynamicEntry* dt_verdef = binary_->get(DynamicEntry::TAG::VERDEF); if (dt_verdef == nullptr) { LIEF_ERR("Can't find DT_VERDEF"); @@ -881,7 +881,7 @@ class LIEF_LOCAL ExeLayout : public Layout { } if (sverr_size_ > 0) { - DynamicEntry* dt_verreq = binary_->get(DYNAMIC_TAGS::DT_VERNEED); + DynamicEntry* dt_verreq = binary_->get(DynamicEntry::TAG::VERNEED); if (dt_verreq == nullptr) { LIEF_ERR("Can't find DT_VERNEED"); @@ -913,12 +913,12 @@ class LIEF_LOCAL ExeLayout : public Layout { // - DT_RELSZ / DT_RELASZ // - .dyn.rel - DynamicEntry* dt_rela = binary_->get(DYNAMIC_TAGS::DT_RELA); + DynamicEntry* dt_rela = binary_->get(DynamicEntry::TAG::RELA); const bool is_rela = dt_rela != nullptr; - DynamicEntry* dt_reloc = is_rela ? dt_rela : binary_->get(DYNAMIC_TAGS::DT_REL); - DynamicEntry* dt_relocsz = is_rela ? binary_->get(DYNAMIC_TAGS::DT_RELASZ) : - binary_->get(DYNAMIC_TAGS::DT_RELSZ); + DynamicEntry* dt_reloc = is_rela ? dt_rela : binary_->get(DynamicEntry::TAG::REL); + DynamicEntry* dt_relocsz = is_rela ? binary_->get(DynamicEntry::TAG::RELASZ) : + binary_->get(DynamicEntry::TAG::RELSZ); if (dt_reloc == nullptr || dt_relocsz == nullptr) { LIEF_ERR("Can't find DT_REL(A) / DT_REL(A)SZ"); @@ -950,8 +950,8 @@ class LIEF_LOCAL ExeLayout : public Layout { // Update: // - DT_JMPREL / DT_PLTRELSZ // - .plt.rel - DynamicEntry* dt_reloc = binary_->get(DYNAMIC_TAGS::DT_JMPREL); - DynamicEntry* dt_relocsz = binary_->get(DYNAMIC_TAGS::DT_PLTRELSZ); + DynamicEntry* dt_reloc = binary_->get(DynamicEntry::TAG::JMPREL); + DynamicEntry* dt_relocsz = binary_->get(DynamicEntry::TAG::PLTRELSZ); if (dt_reloc == nullptr || dt_relocsz == nullptr) { LIEF_ERR("Can't find DT_JMPREL, DT_PLTRELSZ"); @@ -982,7 +982,7 @@ class LIEF_LOCAL ExeLayout : public Layout { if (relocate_gnu_hash_) { // Update .gnu.hash section / DT_GNU_HASH - DynamicEntry* dt_gnu_hash = binary_->get(DYNAMIC_TAGS::DT_GNU_HASH); + DynamicEntry* dt_gnu_hash = binary_->get(DynamicEntry::TAG::GNU_HASH); if (dt_gnu_hash == nullptr) { LIEF_ERR("Can't find DT_GNU_HASH"); @@ -1010,7 +1010,7 @@ class LIEF_LOCAL ExeLayout : public Layout { if (sysv_size_ > 0) { // Update .hash section / DT_HASH - DynamicEntry* dt_hash = binary_->get(DYNAMIC_TAGS::DT_HASH); + DynamicEntry* dt_hash = binary_->get(DynamicEntry::TAG::HASH); if (dt_hash == nullptr) { LIEF_ERR("Can't find DT_HASH"); @@ -1040,13 +1040,13 @@ class LIEF_LOCAL ExeLayout : public Layout { // RW-Segment // ==================================== if (init_size_ > 0) { // .init_array - DynamicEntry* raw_dt_init = binary_->get(DYNAMIC_TAGS::DT_INIT_ARRAY); + DynamicEntry* raw_dt_init = binary_->get(DynamicEntry::TAG::INIT_ARRAY); if (raw_dt_init == nullptr || !DynamicEntryArray::classof(raw_dt_init)) { LIEF_ERR("DT_INIT_ARRAY not found"); return make_error_code(lief_errors::file_format_error); } auto* dt_init_array = raw_dt_init->as(); - DynamicEntry* dt_init_arraysz = binary_->get(DYNAMIC_TAGS::DT_INIT_ARRAYSZ); + DynamicEntry* dt_init_arraysz = binary_->get(DynamicEntry::TAG::INIT_ARRAYSZ); if (dt_init_arraysz == nullptr) { LIEF_ERR("Can't find DT_INIT_ARRAYSZ"); @@ -1096,13 +1096,13 @@ class LIEF_LOCAL ExeLayout : public Layout { } if (preinit_size_ > 0) { // .preinit_array - DynamicEntry* raw_dt_preinit = binary_->get(DYNAMIC_TAGS::DT_PREINIT_ARRAY); + DynamicEntry* raw_dt_preinit = binary_->get(DynamicEntry::TAG::PREINIT_ARRAY); if (raw_dt_preinit == nullptr || !DynamicEntryArray::classof(raw_dt_preinit)) { LIEF_ERR("DT_PREINIT_ARRAY not found"); return make_error_code(lief_errors::file_format_error); } auto* dt_preinit_array = raw_dt_preinit->as(); - DynamicEntry* dt_preinit_arraysz = binary_->get(DYNAMIC_TAGS::DT_PREINIT_ARRAYSZ); + DynamicEntry* dt_preinit_arraysz = binary_->get(DynamicEntry::TAG::PREINIT_ARRAYSZ); if (dt_preinit_array == nullptr) { LIEF_ERR("Can't find DT_PREINIT_ARRAYSZ"); @@ -1149,13 +1149,13 @@ class LIEF_LOCAL ExeLayout : public Layout { if (fini_size_ > 0) { // .fini_array - DynamicEntry* raw_dt_fini = binary_->get(DYNAMIC_TAGS::DT_FINI_ARRAY); + DynamicEntry* raw_dt_fini = binary_->get(DynamicEntry::TAG::FINI_ARRAY); if (raw_dt_fini == nullptr || !DynamicEntryArray::classof(raw_dt_fini)) { LIEF_ERR("DT_FINI_ARRAY not found"); return make_error_code(lief_errors::file_format_error); } auto* dt_fini_array = raw_dt_fini->as(); - DynamicEntry* dt_fini_arraysz = binary_->get(DYNAMIC_TAGS::DT_FINI_ARRAYSZ); + DynamicEntry* dt_fini_arraysz = binary_->get(DynamicEntry::TAG::FINI_ARRAYSZ); if (dt_fini_arraysz == nullptr) { LIEF_ERR("Can't find DT_FINI_ARRAYSZ"); diff --git a/src/ELF/Parser.cpp b/src/ELF/Parser.cpp index f13842c7d0..d5f89701ce 100644 --- a/src/ELF/Parser.cpp +++ b/src/ELF/Parser.cpp @@ -399,7 +399,7 @@ result Parser::get_dynamic_string_table_from_segments() const { } auto dt = *res; - if (static_cast(dt.d_tag) == DYNAMIC_TAGS::DT_STRTAB) { + if (DynamicEntry::from_value(dt.d_tag) == DynamicEntry::TAG::STRTAB) { return binary_->virtual_address_to_offset(dt.d_un.d_val); } } @@ -414,7 +414,7 @@ result Parser::get_dynamic_string_table_from_segments() const { } const auto dt = *res; - if (static_cast(dt.d_tag) == DYNAMIC_TAGS::DT_STRTAB) { + if (DynamicEntry::from_value(dt.d_tag) == DynamicEntry::TAG::STRTAB) { return binary_->virtual_address_to_offset(dt.d_un.d_val); } } diff --git a/src/ELF/Parser.tcc b/src/ELF/Parser.tcc index c6285972ab..dd6f724c71 100644 --- a/src/ELF/Parser.tcc +++ b/src/ELF/Parser.tcc @@ -96,8 +96,8 @@ ok_error_t Parser::parse_binary() { // Parse dynamic symbols // ===================== { - DynamicEntry* dt_symtab = binary_->get(DYNAMIC_TAGS::DT_SYMTAB); - DynamicEntry* dt_syment = binary_->get(DYNAMIC_TAGS::DT_SYMENT); + DynamicEntry* dt_symtab = binary_->get(DynamicEntry::TAG::SYMTAB); + DynamicEntry* dt_syment = binary_->get(DynamicEntry::TAG::SYMENT); if (dt_symtab != nullptr && dt_syment != nullptr && config_.parse_dyn_symbols) { const uint64_t virtual_address = dt_symtab->value(); @@ -115,8 +115,8 @@ ok_error_t Parser::parse_binary() { // RELA // ---- { - DynamicEntry* dt_rela = binary_->get(DYNAMIC_TAGS::DT_RELA); - DynamicEntry* dt_relasz = binary_->get(DYNAMIC_TAGS::DT_RELASZ); + DynamicEntry* dt_rela = binary_->get(DynamicEntry::TAG::RELA); + DynamicEntry* dt_relasz = binary_->get(DynamicEntry::TAG::RELASZ); if (dt_rela != nullptr && dt_relasz != nullptr && config_.parse_relocations) { const uint64_t virtual_address = dt_rela->value(); @@ -134,8 +134,8 @@ ok_error_t Parser::parse_binary() { // REL // --- { - DynamicEntry* dt_rel = binary_->get(DYNAMIC_TAGS::DT_REL); - DynamicEntry* dt_relsz = binary_->get(DYNAMIC_TAGS::DT_RELSZ); + DynamicEntry* dt_rel = binary_->get(DynamicEntry::TAG::REL); + DynamicEntry* dt_relsz = binary_->get(DynamicEntry::TAG::RELSZ); if (dt_rel != nullptr && dt_relsz != nullptr && config_.parse_relocations) { const uint64_t virtual_address = dt_rel->value(); @@ -152,27 +152,27 @@ ok_error_t Parser::parse_binary() { // Parse PLT/GOT Relocations // ========================== { - DynamicEntry* dt_jmprel = binary_->get(DYNAMIC_TAGS::DT_JMPREL); - DynamicEntry* dt_pltrelsz = binary_->get(DYNAMIC_TAGS::DT_PLTRELSZ); + DynamicEntry* dt_jmprel = binary_->get(DynamicEntry::TAG::JMPREL); + DynamicEntry* dt_pltrelsz = binary_->get(DynamicEntry::TAG::PLTRELSZ); if (dt_jmprel != nullptr && dt_pltrelsz != nullptr && config_.parse_relocations) { const uint64_t virtual_address = dt_jmprel->value(); const uint64_t size = dt_pltrelsz->value(); - DynamicEntry* dt_pltrel = binary_->get(DYNAMIC_TAGS::DT_PLTREL); - DYNAMIC_TAGS type; + DynamicEntry* dt_pltrel = binary_->get(DynamicEntry::TAG::PLTREL); + DynamicEntry::TAG type; if (dt_pltrel != nullptr) { - type = static_cast(dt_pltrel->value()); + type = DynamicEntry::from_value(dt_pltrel->value()); } else { // Try to guess: We assume that on ELF64 -> DT_RELA and on ELF32 -> DT_REL - if (std::is_same::value) { - type = DYNAMIC_TAGS::DT_RELA; + if constexpr (std::is_same_v) { + type = DynamicEntry::TAG::RELA; } else { - type = DYNAMIC_TAGS::DT_REL; + type = DynamicEntry::TAG::REL; } } if (auto res = binary_->virtual_address_to_offset(virtual_address)) { - type == DYNAMIC_TAGS::DT_RELA ? + type == DynamicEntry::TAG::RELA ? parse_pltgot_relocations(*res, size) : parse_pltgot_relocations(*res, size); binary_->sizing_info_->jmprel = size; @@ -185,7 +185,7 @@ ok_error_t Parser::parse_binary() { // Parse Symbol Version // ==================== if (config_.parse_symbol_versions && config_.parse_dyn_symbols) { - if (DynamicEntry* dt_versym = binary_->get(DYNAMIC_TAGS::DT_VERSYM)) { + if (DynamicEntry* dt_versym = binary_->get(DynamicEntry::TAG::VERSYM)) { const uint64_t virtual_address = dt_versym->value(); if (auto res = binary_->virtual_address_to_offset(virtual_address)) { parse_symbol_version(*res); @@ -200,8 +200,8 @@ ok_error_t Parser::parse_binary() { // Parse Symbol Version Requirement // ================================ if (config_.parse_symbol_versions) { - DynamicEntry* dt_verneed = binary_->get(DYNAMIC_TAGS::DT_VERNEED); - DynamicEntry* dt_verneed_num = binary_->get(DYNAMIC_TAGS::DT_VERNEEDNUM); + DynamicEntry* dt_verneed = binary_->get(DynamicEntry::TAG::VERNEED); + DynamicEntry* dt_verneed_num = binary_->get(DynamicEntry::TAG::VERNEEDNUM); if (dt_verneed != nullptr && dt_verneed_num != nullptr) { const uint64_t virtual_address = dt_verneed->value(); @@ -219,8 +219,8 @@ ok_error_t Parser::parse_binary() { // Parse Symbol Version Definition // =============================== if (config_.parse_symbol_versions) { - DynamicEntry* dt_verdef = binary_->get(DYNAMIC_TAGS::DT_VERDEF); - DynamicEntry* dt_verdef_num = binary_->get(DYNAMIC_TAGS::DT_VERDEFNUM); + DynamicEntry* dt_verdef = binary_->get(DynamicEntry::TAG::VERDEF); + DynamicEntry* dt_verdef_num = binary_->get(DynamicEntry::TAG::VERDEFNUM); if (dt_verdef != nullptr && dt_verdef_num != nullptr) { const uint64_t virtual_address = dt_verdef->value(); const auto size = static_cast(dt_verdef_num->value()); @@ -256,7 +256,7 @@ ok_error_t Parser::parse_binary() { // Parse Symbols's hash // ==================== - if (DynamicEntry* dt_hash = binary_->get(DYNAMIC_TAGS::DT_HASH)) { + if (DynamicEntry* dt_hash = binary_->get(DynamicEntry::TAG::HASH)) { if (auto res = binary_->virtual_address_to_offset(dt_hash->value())) { parse_symbol_sysv_hash(*res); } else { @@ -265,7 +265,7 @@ ok_error_t Parser::parse_binary() { } - if (DynamicEntry* dt_gnu_hash = binary_->get(DYNAMIC_TAGS::DT_GNU_HASH)) { + if (DynamicEntry* dt_gnu_hash = binary_->get(DynamicEntry::TAG::GNU_HASH)) { if (auto res = binary_->virtual_address_to_offset(dt_gnu_hash->value())) { parse_symbol_gnu_hash(*res); } else { @@ -508,8 +508,8 @@ result Parser::nb_dynsym_relocations() const { // RELA // ---- - DynamicEntry* dt_rela = binary_->get(DYNAMIC_TAGS::DT_RELA); - DynamicEntry* dt_relasz = binary_->get(DYNAMIC_TAGS::DT_RELASZ); + DynamicEntry* dt_rela = binary_->get(DynamicEntry::TAG::RELA); + DynamicEntry* dt_relasz = binary_->get(DynamicEntry::TAG::RELASZ); if (dt_rela != nullptr && dt_relasz != nullptr) { const uint64_t virtual_address = dt_rela->value(); const uint64_t size = dt_relasz->value(); @@ -521,8 +521,8 @@ result Parser::nb_dynsym_relocations() const { // REL // --- - DynamicEntry* dt_rel = binary_->get(DYNAMIC_TAGS::DT_REL); - DynamicEntry* dt_relsz = binary_->get(DYNAMIC_TAGS::DT_RELSZ); + DynamicEntry* dt_rel = binary_->get(DynamicEntry::TAG::REL); + DynamicEntry* dt_relsz = binary_->get(DynamicEntry::TAG::RELSZ); if (dt_rel != nullptr && dt_relsz != nullptr) { const uint64_t virtual_address = dt_rel->value(); @@ -535,25 +535,25 @@ result Parser::nb_dynsym_relocations() const { // Parse PLT/GOT Relocations // ========================== - DynamicEntry* dt_jmprel = binary_->get(DYNAMIC_TAGS::DT_JMPREL); - DynamicEntry* dt_pltrelsz = binary_->get(DYNAMIC_TAGS::DT_PLTRELSZ); + DynamicEntry* dt_jmprel = binary_->get(DynamicEntry::TAG::JMPREL); + DynamicEntry* dt_pltrelsz = binary_->get(DynamicEntry::TAG::PLTRELSZ); if (dt_jmprel != nullptr && dt_pltrelsz != nullptr) { const uint64_t virtual_address = dt_jmprel->value(); const uint64_t size = dt_pltrelsz->value(); - DynamicEntry* dt_pltrel = binary_->get(DYNAMIC_TAGS::DT_PLTREL); - DYNAMIC_TAGS type; + DynamicEntry* dt_pltrel = binary_->get(DynamicEntry::TAG::PLTREL); + DynamicEntry::TAG type; if (dt_pltrel != nullptr) { - type = static_cast(dt_pltrel->value()); + type = DynamicEntry::from_value(dt_pltrel->value()); } else { // Try to guess: We assume that on ELF64 -> DT_RELA and on ELF32 -> DT_REL - if (std::is_same::value) { - type = DYNAMIC_TAGS::DT_RELA; + if constexpr (std::is_same_v) { + type = DynamicEntry::TAG::RELA; } else { - type = DYNAMIC_TAGS::DT_REL; + type = DynamicEntry::TAG::REL; } } if (auto res = binary_->virtual_address_to_offset(virtual_address)) { - if (type == DYNAMIC_TAGS::DT_RELA) { + if (type == DynamicEntry::TAG::RELA) { nb_symbols = std::max(nb_symbols, max_relocation_index(*res, size)); } else { nb_symbols = std::max(nb_symbols, max_relocation_index(*res, size)); @@ -605,11 +605,11 @@ result Parser::nb_dynsym_section() const { template result Parser::nb_dynsym_hash() const { - if (binary_->has(DYNAMIC_TAGS::DT_HASH)) { + if (binary_->has(DynamicEntry::TAG::HASH)) { return nb_dynsym_sysv_hash(); } - if (binary_->has(DYNAMIC_TAGS::DT_GNU_HASH)) { + if (binary_->has(DynamicEntry::TAG::GNU_HASH)) { return nb_dynsym_gnu_hash(); } @@ -621,7 +621,7 @@ template result Parser::nb_dynsym_sysv_hash() const { using Elf_Off = typename ELF_T::Elf_Off; - const DynamicEntry* dyn_hash = binary_->get(DYNAMIC_TAGS::DT_HASH); + const DynamicEntry* dyn_hash = binary_->get(DynamicEntry::TAG::HASH); if (dyn_hash == nullptr) { LIEF_ERR("Can't find DT_GNU_HASH"); return make_error_code(lief_errors::not_found); @@ -648,7 +648,7 @@ result Parser::nb_dynsym_gnu_hash() const { using uint__ = typename ELF_T::uint; using Elf_Off = typename ELF_T::Elf_Off; - const DynamicEntry* dyn_hash = binary_->get(DYNAMIC_TAGS::DT_GNU_HASH); + const DynamicEntry* dyn_hash = binary_->get(DynamicEntry::TAG::GNU_HASH); if (dyn_hash == nullptr) { LIEF_ERR("Can't find DT_GNU_HASH"); return make_error_code(lief_errors::not_found); @@ -1066,7 +1066,7 @@ ok_error_t Parser::parse_dynamic_symbols(uint64_t offset) { binary_->dynamic_symbols_.push_back(std::move(symbol)); } binary_->sizing_info_->dynsym = binary_->dynamic_symbols_.size() * sizeof(Elf_Sym); - if (const auto* dt_strsz = binary_->get(DYNAMIC_TAGS::DT_STRSZ)) { + if (const auto* dt_strsz = binary_->get(DynamicEntry::TAG::STRSZ)) { binary_->sizing_info_->dynstr = dt_strsz->value(); } return ok(); @@ -1100,8 +1100,8 @@ ok_error_t Parser::parse_dynamic_entries(uint64_t offset, uint64_t size) { std::unique_ptr dynamic_entry; - switch (static_cast(entry.d_tag)) { - case DYNAMIC_TAGS::DT_NEEDED : + switch (DynamicEntry::from_value(entry.d_tag)) { + case DynamicEntry::TAG::NEEDED : { dynamic_entry = std::make_unique(entry); auto library_name = stream_->peek_string_at(dynamic_string_offset + dynamic_entry->value()); @@ -1113,7 +1113,7 @@ ok_error_t Parser::parse_dynamic_entries(uint64_t offset, uint64_t size) { break; } - case DYNAMIC_TAGS::DT_SONAME : + case DynamicEntry::TAG::SONAME : { dynamic_entry = std::make_unique(entry); auto sharename = stream_->peek_string_at(dynamic_string_offset + dynamic_entry->value()); @@ -1125,7 +1125,7 @@ ok_error_t Parser::parse_dynamic_entries(uint64_t offset, uint64_t size) { break; } - case DYNAMIC_TAGS::DT_RPATH: + case DynamicEntry::TAG::RPATH: { dynamic_entry = std::make_unique(entry); auto name = stream_->peek_string_at(dynamic_string_offset + dynamic_entry->value()); @@ -1133,11 +1133,11 @@ ok_error_t Parser::parse_dynamic_entries(uint64_t offset, uint64_t size) { LIEF_ERR("Can't read rpath string value for DT_RPATH"); break; } - dynamic_entry->as()->name(std::move(*name)); + dynamic_entry->as()->rpath(std::move(*name)); break; } - case DYNAMIC_TAGS::DT_RUNPATH: + case DynamicEntry::TAG::RUNPATH: { dynamic_entry = std::make_unique(entry); auto name = stream_->peek_string_at(dynamic_string_offset + dynamic_entry->value()); @@ -1145,45 +1145,45 @@ ok_error_t Parser::parse_dynamic_entries(uint64_t offset, uint64_t size) { LIEF_ERR("Can't read runpath string value for DT_RUNPATH"); break; } - dynamic_entry->as()->name(std::move(*name)); + dynamic_entry->as()->runpath(std::move(*name)); break; } - case DYNAMIC_TAGS::DT_FLAGS_1: - case DYNAMIC_TAGS::DT_FLAGS: + case DynamicEntry::TAG::FLAGS_1: + case DynamicEntry::TAG::FLAGS: { dynamic_entry = std::make_unique(entry); break; } - case DYNAMIC_TAGS::DT_SYMTAB: - case DYNAMIC_TAGS::DT_SYMENT: - case DYNAMIC_TAGS::DT_RELA: - case DYNAMIC_TAGS::DT_RELASZ: - case DYNAMIC_TAGS::DT_REL: - case DYNAMIC_TAGS::DT_RELSZ: - case DYNAMIC_TAGS::DT_JMPREL: - case DYNAMIC_TAGS::DT_PLTRELSZ: - case DYNAMIC_TAGS::DT_PLTREL: - case DYNAMIC_TAGS::DT_VERSYM: - case DYNAMIC_TAGS::DT_VERNEED: - case DYNAMIC_TAGS::DT_VERNEEDNUM: - case DYNAMIC_TAGS::DT_VERDEF: - case DYNAMIC_TAGS::DT_VERDEFNUM: + case DynamicEntry::TAG::SYMTAB: + case DynamicEntry::TAG::SYMENT: + case DynamicEntry::TAG::RELA: + case DynamicEntry::TAG::RELASZ: + case DynamicEntry::TAG::REL: + case DynamicEntry::TAG::RELSZ: + case DynamicEntry::TAG::JMPREL: + case DynamicEntry::TAG::PLTRELSZ: + case DynamicEntry::TAG::PLTREL: + case DynamicEntry::TAG::VERSYM: + case DynamicEntry::TAG::VERNEED: + case DynamicEntry::TAG::VERNEEDNUM: + case DynamicEntry::TAG::VERDEF: + case DynamicEntry::TAG::VERDEFNUM: { dynamic_entry = std::make_unique(entry); break; } - case DYNAMIC_TAGS::DT_FINI_ARRAY: - case DYNAMIC_TAGS::DT_INIT_ARRAY: - case DYNAMIC_TAGS::DT_PREINIT_ARRAY: + case DynamicEntry::TAG::FINI_ARRAY: + case DynamicEntry::TAG::INIT_ARRAY: + case DynamicEntry::TAG::PREINIT_ARRAY: { dynamic_entry = std::make_unique(entry); break; } - case DYNAMIC_TAGS::DT_NULL: + case DynamicEntry::TAG::DT_NULL: { dynamic_entry = std::make_unique(entry); end_of_dynamic = true; @@ -1209,8 +1209,8 @@ ok_error_t Parser::parse_dynamic_entries(uint64_t offset, uint64_t size) { // Check for INIT array // ==================== - if (DynamicEntry* dt_init_array = binary_->get(DYNAMIC_TAGS::DT_INIT_ARRAY)) { - if (DynamicEntry* dt_init_arraysz = binary_->get(DYNAMIC_TAGS::DT_INIT_ARRAYSZ)) { + if (DynamicEntry* dt_init_array = binary_->get(DynamicEntry::TAG::INIT_ARRAY)) { + if (DynamicEntry* dt_init_arraysz = binary_->get(DynamicEntry::TAG::INIT_ARRAYSZ)) { binary_->sizing_info_->init_array = dt_init_arraysz->value(); std::vector& array = dt_init_array->as()->array(); const auto nb_functions = static_cast(dt_init_arraysz->value() / sizeof(uint__)); @@ -1232,8 +1232,8 @@ ok_error_t Parser::parse_dynamic_entries(uint64_t offset, uint64_t size) { // Check for FINI array // ==================== - if (DynamicEntry* dt_fini_array = binary_->get(DYNAMIC_TAGS::DT_FINI_ARRAY)) { - if (DynamicEntry* dt_fini_arraysz = binary_->get(DYNAMIC_TAGS::DT_FINI_ARRAYSZ)) { + if (DynamicEntry* dt_fini_array = binary_->get(DynamicEntry::TAG::FINI_ARRAY)) { + if (DynamicEntry* dt_fini_arraysz = binary_->get(DynamicEntry::TAG::FINI_ARRAYSZ)) { binary_->sizing_info_->fini_array = dt_fini_arraysz->value(); std::vector& array = dt_fini_array->as()->array(); @@ -1256,8 +1256,8 @@ ok_error_t Parser::parse_dynamic_entries(uint64_t offset, uint64_t size) { // Check for PREINIT array // ======================= - if (DynamicEntry* dt_preini_array = binary_->get(DYNAMIC_TAGS::DT_PREINIT_ARRAY)) { - if (DynamicEntry* dt_preinit_arraysz = binary_->get(DYNAMIC_TAGS::DT_PREINIT_ARRAYSZ)) { + if (DynamicEntry* dt_preini_array = binary_->get(DynamicEntry::TAG::PREINIT_ARRAY)) { + if (DynamicEntry* dt_preinit_arraysz = binary_->get(DynamicEntry::TAG::PREINIT_ARRAYSZ)) { binary_->sizing_info_->preinit_array = dt_preinit_arraysz->value(); std::vector& array = dt_preini_array->as()->array(); diff --git a/src/ELF/Structures.hpp b/src/ELF/Structures.hpp index ff73ba6539..a78f38a492 100644 --- a/src/ELF/Structures.hpp +++ b/src/ELF/Structures.hpp @@ -118,45 +118,6 @@ static const LOONGARCH_EFLAGS loongarch_eflags_array[] = { LOONGARCH_EFLAGS::EF_LOONGARCH_ABI_DOUBLE_FLOAT, }; -static const DYNAMIC_FLAGS dynamic_flags_array[] = { - DYNAMIC_FLAGS::DF_ORIGIN, - DYNAMIC_FLAGS::DF_SYMBOLIC, - DYNAMIC_FLAGS::DF_TEXTREL, - DYNAMIC_FLAGS::DF_BIND_NOW, - DYNAMIC_FLAGS::DF_STATIC_TLS, -}; - - -static const DYNAMIC_FLAGS_1 dynamic_flags_1_array[] = { - DYNAMIC_FLAGS_1::DF_1_NOW, - DYNAMIC_FLAGS_1::DF_1_GLOBAL, - DYNAMIC_FLAGS_1::DF_1_GROUP, - DYNAMIC_FLAGS_1::DF_1_NODELETE, - DYNAMIC_FLAGS_1::DF_1_LOADFLTR, - DYNAMIC_FLAGS_1::DF_1_INITFIRST, - DYNAMIC_FLAGS_1::DF_1_NOOPEN, - DYNAMIC_FLAGS_1::DF_1_ORIGIN, - DYNAMIC_FLAGS_1::DF_1_DIRECT, - DYNAMIC_FLAGS_1::DF_1_TRANS, - DYNAMIC_FLAGS_1::DF_1_INTERPOSE, - DYNAMIC_FLAGS_1::DF_1_NODEFLIB, - DYNAMIC_FLAGS_1::DF_1_NODUMP, - DYNAMIC_FLAGS_1::DF_1_CONFALT, - DYNAMIC_FLAGS_1::DF_1_ENDFILTEE, - DYNAMIC_FLAGS_1::DF_1_DISPRELDNE, - DYNAMIC_FLAGS_1::DF_1_DISPRELPND, - DYNAMIC_FLAGS_1::DF_1_NODIRECT, - DYNAMIC_FLAGS_1::DF_1_IGNMULDEF, - DYNAMIC_FLAGS_1::DF_1_NOKSYMS, - DYNAMIC_FLAGS_1::DF_1_NOHDR, - DYNAMIC_FLAGS_1::DF_1_EDITED, - DYNAMIC_FLAGS_1::DF_1_NORELOC, - DYNAMIC_FLAGS_1::DF_1_SYMINTPOSE, - DYNAMIC_FLAGS_1::DF_1_GLOBAUDIT, - DYNAMIC_FLAGS_1::DF_1_SINGLETON, - DYNAMIC_FLAGS_1::DF_1_PIE, -}; - struct Elf64_Prpsinfo { char pr_state; diff --git a/src/ELF/json.cpp b/src/ELF/json.cpp index fbebd933f4..366cc8cb0f 100644 --- a/src/ELF/json.cpp +++ b/src/ELF/json.cpp @@ -261,23 +261,13 @@ void JsonVisitor::visit(const DynamicEntryFlags& entry) { std::vector flags_str; flags_str.reserve(flags.size()); - if (entry.tag() == DYNAMIC_TAGS::DT_FLAGS) { - std::transform( - std::begin(flags), std::end(flags), - std::back_inserter(flags_str), - [] (uint32_t f) { - return to_string(static_cast(f)); - }); - } - - if (entry.tag() == DYNAMIC_TAGS::DT_FLAGS_1) { - std::transform( - std::begin(flags), std::end(flags), - std::back_inserter(flags_str), - [] (uint32_t f) { - return to_string(static_cast(f)); - }); - } + std::transform( + std::begin(flags), std::end(flags), + std::back_inserter(flags_str), + [] (DynamicEntryFlags::FLAG f) { + return to_string(f); + }); + node_["flags"] = flags_str; } diff --git a/tests/elf/test_466.py b/tests/elf/test_466.py index 6d773a05f0..ff29057923 100644 --- a/tests/elf/test_466.py +++ b/tests/elf/test_466.py @@ -24,8 +24,8 @@ def test_freebl(tmp_path): if ls is None: ls = lief.parse("/bin/ls") - if lief.ELF.DYNAMIC_TAGS.FLAGS_1 in ls and ls[lief.ELF.DYNAMIC_TAGS.FLAGS_1].has(lief.ELF.DYNAMIC_FLAGS_1.PIE): - ls[lief.ELF.DYNAMIC_TAGS.FLAGS_1].remove(lief.ELF.DYNAMIC_FLAGS_1.PIE) + if lief.ELF.DynamicEntry.TAG.FLAGS_1 in ls and ls[lief.ELF.DynamicEntry.TAG.FLAGS_1].has(lief.ELF.DynamicEntryFlags.FLAG.PIE): + ls[lief.ELF.DynamicEntry.TAG.FLAGS_1].remove(lief.ELF.DynamicEntryFlags.FLAG.PIE) ls.add_library("libfreebl3.so") diff --git a/tests/elf/test_add_content.py b/tests/elf/test_add_content.py index 7e19beec23..a0f7df9fa0 100644 --- a/tests/elf/test_add_content.py +++ b/tests/elf/test_add_content.py @@ -100,14 +100,14 @@ def test_simple(tmp_path: Path): new_ep = (STUB.header.entrypoint - STUB.segments[0].virtual_address) + segment.virtual_address - if libadd.has(lief.ELF.DYNAMIC_TAGS.INIT_ARRAY): - init_array = libadd.get(lief.ELF.DYNAMIC_TAGS.INIT_ARRAY) + if libadd.has(lief.ELF.DynamicEntry.TAG.INIT_ARRAY): + init_array = libadd.get(lief.ELF.DynamicEntry.TAG.INIT_ARRAY) callbacks = init_array.array callbacks[0] = new_ep init_array.array = callbacks - if libadd.has(lief.ELF.DYNAMIC_TAGS.INIT): - init = libadd.get(lief.ELF.DYNAMIC_TAGS.INIT) + if libadd.has(lief.ELF.DynamicEntry.TAG.INIT): + init = libadd.get(lief.ELF.DynamicEntry.TAG.INIT) init.value = new_ep libadd.write(libadd_so.as_posix()) diff --git a/tests/elf/test_bin2lib.py b/tests/elf/test_bin2lib.py index 50d14219c1..060ac8ce6b 100644 --- a/tests/elf/test_bin2lib.py +++ b/tests/elf/test_bin2lib.py @@ -93,8 +93,8 @@ def modif_1(libadd: lief.ELF.Binary, output: Path): libadd_hidden.binding = lief.ELF.SYMBOL_BINDINGS.GLOBAL libadd_hidden.visibility = lief.ELF.SYMBOL_VISIBILITY.DEFAULT libadd_hidden = libadd.add_dynamic_symbol(libadd_hidden, lief.ELF.SymbolVersion.global_) - if lief.ELF.DYNAMIC_TAGS.FLAGS_1 in libadd and libadd[lief.ELF.DYNAMIC_TAGS.FLAGS_1].has(lief.ELF.DYNAMIC_FLAGS_1.PIE): - libadd[lief.ELF.DYNAMIC_TAGS.FLAGS_1].remove(lief.ELF.DYNAMIC_FLAGS_1.PIE) + if lief.ELF.DynamicEntry.TAG.FLAGS_1 in libadd and libadd[lief.ELF.DynamicEntry.TAG.FLAGS_1].has(lief.ELF.DynamicEntryFlags.FLAG.PIE): + libadd[lief.ELF.DynamicEntry.TAG.FLAGS_1].remove(lief.ELF.DynamicEntryFlags.FLAG.PIE) print(libadd_hidden) @@ -104,8 +104,8 @@ def modif_1(libadd: lief.ELF.Binary, output: Path): def modif_2(libadd: lief.ELF.Binary, output: Path): libadd.export_symbol("add_hidden") - if lief.ELF.DYNAMIC_TAGS.FLAGS_1 in libadd and libadd[lief.ELF.DYNAMIC_TAGS.FLAGS_1].has(lief.ELF.DYNAMIC_FLAGS_1.PIE): - libadd[lief.ELF.DYNAMIC_TAGS.FLAGS_1].remove(lief.ELF.DYNAMIC_FLAGS_1.PIE) + if lief.ELF.DynamicEntry.TAG.FLAGS_1 in libadd and libadd[lief.ELF.DynamicEntry.TAG.FLAGS_1].has(lief.ELF.DynamicEntryFlags.FLAG.PIE): + libadd[lief.ELF.DynamicEntry.TAG.FLAGS_1].remove(lief.ELF.DynamicEntryFlags.FLAG.PIE) libadd.write(output.as_posix()) @@ -113,8 +113,8 @@ def modif_3(libadd: lief.ELF.Binary, output: Path): add_hidden_static = libadd.get_static_symbol("add_hidden") libadd.add_exported_function(add_hidden_static.value, add_hidden_static.name) - if lief.ELF.DYNAMIC_TAGS.FLAGS_1 in libadd and libadd[lief.ELF.DYNAMIC_TAGS.FLAGS_1].has(lief.ELF.DYNAMIC_FLAGS_1.PIE): - libadd[lief.ELF.DYNAMIC_TAGS.FLAGS_1].remove(lief.ELF.DYNAMIC_FLAGS_1.PIE) + if lief.ELF.DynamicEntry.TAG.FLAGS_1 in libadd and libadd[lief.ELF.DynamicEntry.TAG.FLAGS_1].has(lief.ELF.DynamicEntryFlags.FLAG.PIE): + libadd[lief.ELF.DynamicEntry.TAG.FLAGS_1].remove(lief.ELF.DynamicEntryFlags.FLAG.PIE) libadd.write(output.as_posix()) diff --git a/tests/elf/test_dynamic.py b/tests/elf/test_dynamic.py index 98795302c7..66e88a03bd 100644 --- a/tests/elf/test_dynamic.py +++ b/tests/elf/test_dynamic.py @@ -167,8 +167,8 @@ def test_remove_tag(tmp_path: Path): binadd = lief.parse(binadd_bin.as_posix()) - binadd -= lief.ELF.DYNAMIC_TAGS.NEEDED - assert all(e.tag != lief.ELF.DYNAMIC_TAGS.NEEDED for e in binadd.dynamic_entries) + binadd -= lief.ELF.DynamicEntry.TAG.NEEDED + assert all(e.tag != lief.ELF.DynamicEntry.TAG.NEEDED for e in binadd.dynamic_entries) @pytest.mark.skipif(not is_linux(), reason="requires Linux") def test_runpath_api(tmp_path: Path): @@ -228,16 +228,16 @@ def test_change_libname(tmp_path: Path): new_name = "libwhichhasalongverylongname.so" - assert lief.ELF.DYNAMIC_TAGS.SONAME in libadd + assert lief.ELF.DynamicEntry.TAG.SONAME in libadd - libadd[lief.ELF.DYNAMIC_TAGS.SONAME].name = new_name + libadd[lief.ELF.DynamicEntry.TAG.SONAME].name = new_name libfoo_path = tmp_path / new_name libadd.write(libfoo_path.as_posix()) libfoo = lief.parse(libfoo_path.as_posix()) - new_so_name = libfoo[lief.ELF.DYNAMIC_TAGS.SONAME] + new_so_name = libfoo[lief.ELF.DynamicEntry.TAG.SONAME] # Check builder did the job right assert new_so_name.name == new_name diff --git a/tests/elf/test_elf.py b/tests/elf/test_elf.py index 184419c88f..a742880f44 100644 --- a/tests/elf/test_elf.py +++ b/tests/elf/test_elf.py @@ -21,25 +21,24 @@ def test_rpath(): dynamic_entries = etterlog.dynamic_entries - rpath = [e for e in dynamic_entries if e.tag == lief.ELF.DYNAMIC_TAGS.RPATH] + rpath = [e for e in dynamic_entries if e.tag == lief.ELF.DynamicEntry.TAG.RPATH] assert len(rpath) == 1 rpath = rpath.pop() - assert rpath.name == "/usr/lib" - assert rpath.rpath == rpath.name + assert rpath.rpath == "/usr/lib" def test_runpath(): etterlog = lief.parse(get_sample('ELF/ELF64_x86-64_binary_systemd-resolve.bin')) dynamic_entries = etterlog.dynamic_entries - runpath = [e for e in dynamic_entries if e.tag == lief.ELF.DYNAMIC_TAGS.RUNPATH] + runpath = [e for e in dynamic_entries if e.tag == lief.ELF.DynamicEntry.TAG.RUNPATH] assert len(runpath) == 1 runpath = runpath.pop() - assert runpath.name == "/usr/lib/systemd" + assert runpath.runpath == "/usr/lib/systemd" def test_gnuhash(): @@ -215,11 +214,11 @@ def test_sectionless(): def test_dynamic_flags(): sample = "ELF/ELF32_ARM_binary_ls.bin" ls = lief.parse(get_sample(sample)) - d_flags = ls.get(lief.ELF.DYNAMIC_TAGS.FLAGS) - d_flags_1 = ls.get(lief.ELF.DYNAMIC_TAGS.FLAGS_1) + d_flags = ls.get(lief.ELF.DynamicEntry.TAG.FLAGS) + d_flags_1 = ls.get(lief.ELF.DynamicEntry.TAG.FLAGS_1) - assert lief.ELF.DYNAMIC_FLAGS.BIND_NOW in d_flags - assert lief.ELF.DYNAMIC_FLAGS_1.NOW in d_flags_1 + assert lief.ELF.DynamicEntryFlags.FLAG.BIND_NOW in d_flags + assert lief.ELF.DynamicEntryFlags.FLAG.NOW in d_flags_1 def test_unwind_arm(): diff --git a/tests/elf/test_empty_gnu_hash.py b/tests/elf/test_empty_gnu_hash.py index dc53203c8b..aa087f6363 100644 --- a/tests/elf/test_empty_gnu_hash.py +++ b/tests/elf/test_empty_gnu_hash.py @@ -21,7 +21,7 @@ def test_gnu_hash(tmpdir): output = os.path.join(tmpdir, "libnoempty.so") binary = lief.parse(target_path) - binary[lief.ELF.DYNAMIC_TAGS.FLAGS_1].remove(lief.ELF.DYNAMIC_FLAGS_1.PIE) + binary[lief.ELF.DynamicEntry.TAG.FLAGS_1].remove(lief.ELF.DynamicEntryFlags.FLAG.PIE) for name, addr in SYMBOLS.items(): binary.add_exported_function(addr, name) diff --git a/tests/elf/test_hash.py b/tests/elf/test_hash.py index adf2a1fb0f..3a122b75ef 100644 --- a/tests/elf/test_hash.py +++ b/tests/elf/test_hash.py @@ -106,7 +106,7 @@ def test_simple(tmp_path: Path, flag: str): # change library name in the binary for entry in binadd.dynamic_entries: - if entry.tag == lief.ELF.DYNAMIC_TAGS.NEEDED and entry.name == "libadd.so": + if entry.tag == lief.ELF.DynamicEntry.TAG.NEEDED and entry.name == "libadd.so": entry.name = "libabc.so" libadd_modified = tmp_path / "libabc.so" diff --git a/tests/elf/test_parser.py b/tests/elf/test_parser.py index bfda877a08..9683e95de9 100644 --- a/tests/elf/test_parser.py +++ b/tests/elf/test_parser.py @@ -101,9 +101,9 @@ def test_issue_897(): def test_issue_954(): target = lief.ELF.parse(get_sample('ELF/main.relr.elf')) - assert target.get(lief.ELF.DYNAMIC_TAGS.RELA) is not None - assert target.get(lief.ELF.DYNAMIC_TAGS.RELRSZ) is not None - assert target.get(lief.ELF.DYNAMIC_TAGS.RELRENT) is not None + assert target.get(lief.ELF.DynamicEntry.TAG.RELA) is not None + assert target.get(lief.ELF.DynamicEntry.TAG.RELRSZ) is not None + assert target.get(lief.ELF.DynamicEntry.TAG.RELRENT) is not None def test_issue_958(): target = lief.ELF.parse(get_sample('ELF/issue_958.elf')) diff --git a/tests/elf/test_parser_simple.py b/tests/elf/test_parser_simple.py index bca0688cb8..02e6977101 100644 --- a/tests/elf/test_parser_simple.py +++ b/tests/elf/test_parser_simple.py @@ -49,7 +49,7 @@ def test_dynamic(): assert len(entries) == 28 assert entries[0].name == "libc.so.6" assert entries[3].array == [2208, 1782] - assert TARGET[lief.ELF.DYNAMIC_TAGS.FLAGS_1].value == 0x8000000 + assert TARGET[lief.ELF.DynamicEntry.TAG.FLAGS_1].value == 0x8000000 def test_relocations(): dynamic_relocations = TARGET.dynamic_relocations diff --git a/tests/elf/test_str_hash.py b/tests/elf/test_str_hash.py index a6baa5fab3..7fabfceb45 100644 --- a/tests/elf/test_str_hash.py +++ b/tests/elf/test_str_hash.py @@ -23,29 +23,29 @@ def test_hash(): assert hello_c_debug.gnu_hash is not None assert hash(hello_c_debug.gnu_hash) > 0 - assert empty_gnu_hash[lief.ELF.DYNAMIC_TAGS.FLAGS_1] is not None - assert hash(empty_gnu_hash[lief.ELF.DYNAMIC_TAGS.FLAGS_1]) > 0 + assert empty_gnu_hash[lief.ELF.DynamicEntry.TAG.FLAGS_1] is not None + assert hash(empty_gnu_hash[lief.ELF.DynamicEntry.TAG.FLAGS_1]) > 0 - assert arm_ls[lief.ELF.DYNAMIC_TAGS.FLAGS] is not None - assert hash(arm_ls[lief.ELF.DYNAMIC_TAGS.FLAGS]) > 0 + assert arm_ls[lief.ELF.DynamicEntry.TAG.FLAGS] is not None + assert hash(arm_ls[lief.ELF.DynamicEntry.TAG.FLAGS]) > 0 - assert libfreebl3[lief.ELF.DYNAMIC_TAGS.SONAME] is not None - assert hash(libfreebl3[lief.ELF.DYNAMIC_TAGS.SONAME]) > 0 + assert libfreebl3[lief.ELF.DynamicEntry.TAG.SONAME] is not None + assert hash(libfreebl3[lief.ELF.DynamicEntry.TAG.SONAME]) > 0 - assert hello_c_debug[lief.ELF.DYNAMIC_TAGS.GNU_HASH] is not None - assert hash(hello_c_debug[lief.ELF.DYNAMIC_TAGS.GNU_HASH]) > 0 + assert hello_c_debug[lief.ELF.DynamicEntry.TAG.GNU_HASH] is not None + assert hash(hello_c_debug[lief.ELF.DynamicEntry.TAG.GNU_HASH]) > 0 - assert hello_c_debug[lief.ELF.DYNAMIC_TAGS.INIT_ARRAY] is not None - assert hash(hello_c_debug[lief.ELF.DYNAMIC_TAGS.INIT_ARRAY]) > 0 + assert hello_c_debug[lief.ELF.DynamicEntry.TAG.INIT_ARRAY] is not None + assert hash(hello_c_debug[lief.ELF.DynamicEntry.TAG.INIT_ARRAY]) > 0 - assert hello_c_debug[lief.ELF.DYNAMIC_TAGS.NEEDED] is not None - assert hash(hello_c_debug[lief.ELF.DYNAMIC_TAGS.NEEDED]) > 0 + assert hello_c_debug[lief.ELF.DynamicEntry.TAG.NEEDED] is not None + assert hash(hello_c_debug[lief.ELF.DynamicEntry.TAG.NEEDED]) > 0 - assert etterlog[lief.ELF.DYNAMIC_TAGS.RPATH] is not None - assert hash(etterlog[lief.ELF.DYNAMIC_TAGS.RPATH]) > 0 + assert etterlog[lief.ELF.DynamicEntry.TAG.RPATH] is not None + assert hash(etterlog[lief.ELF.DynamicEntry.TAG.RPATH]) > 0 - assert resolve[lief.ELF.DYNAMIC_TAGS.RUNPATH] is not None - assert hash(resolve[lief.ELF.DYNAMIC_TAGS.RUNPATH]) > 0 + assert resolve[lief.ELF.DynamicEntry.TAG.RUNPATH] is not None + assert hash(resolve[lief.ELF.DynamicEntry.TAG.RUNPATH]) > 0 assert hash(resolve.header) > 0 assert hash(etterlog.notes[0]) > 0 @@ -80,30 +80,30 @@ def test_str(capsys): assert hello_c_debug.gnu_hash is not None print(hello_c_debug.gnu_hash) - assert empty_gnu_hash[lief.ELF.DYNAMIC_TAGS.FLAGS_1] is not None - print(empty_gnu_hash[lief.ELF.DYNAMIC_TAGS.FLAGS_1]) + assert empty_gnu_hash[lief.ELF.DynamicEntry.TAG.FLAGS_1] is not None + print(empty_gnu_hash[lief.ELF.DynamicEntry.TAG.FLAGS_1]) - assert arm_ls[lief.ELF.DYNAMIC_TAGS.FLAGS] is not None - print(arm_ls[lief.ELF.DYNAMIC_TAGS.FLAGS]) + assert arm_ls[lief.ELF.DynamicEntry.TAG.FLAGS] is not None + print(arm_ls[lief.ELF.DynamicEntry.TAG.FLAGS]) - assert libfreebl3[lief.ELF.DYNAMIC_TAGS.SONAME] is not None - print(libfreebl3[lief.ELF.DYNAMIC_TAGS.SONAME]) + assert libfreebl3[lief.ELF.DynamicEntry.TAG.SONAME] is not None + print(libfreebl3[lief.ELF.DynamicEntry.TAG.SONAME]) - assert hello_c_debug[lief.ELF.DYNAMIC_TAGS.GNU_HASH] is not None - print(hello_c_debug[lief.ELF.DYNAMIC_TAGS.GNU_HASH]) + assert hello_c_debug[lief.ELF.DynamicEntry.TAG.GNU_HASH] is not None + print(hello_c_debug[lief.ELF.DynamicEntry.TAG.GNU_HASH]) - assert hello_c_debug[lief.ELF.DYNAMIC_TAGS.INIT_ARRAY] is not None - print(hello_c_debug[lief.ELF.DYNAMIC_TAGS.INIT_ARRAY]) + assert hello_c_debug[lief.ELF.DynamicEntry.TAG.INIT_ARRAY] is not None + print(hello_c_debug[lief.ELF.DynamicEntry.TAG.INIT_ARRAY]) - assert hello_c_debug[lief.ELF.DYNAMIC_TAGS.NEEDED] is not None - print(hello_c_debug[lief.ELF.DYNAMIC_TAGS.NEEDED]) + assert hello_c_debug[lief.ELF.DynamicEntry.TAG.NEEDED] is not None + print(hello_c_debug[lief.ELF.DynamicEntry.TAG.NEEDED]) - assert etterlog[lief.ELF.DYNAMIC_TAGS.RPATH] is not None - print(etterlog[lief.ELF.DYNAMIC_TAGS.RPATH]) + assert etterlog[lief.ELF.DynamicEntry.TAG.RPATH] is not None + print(etterlog[lief.ELF.DynamicEntry.TAG.RPATH]) - assert resolve[lief.ELF.DYNAMIC_TAGS.RUNPATH] is not None - print(resolve[lief.ELF.DYNAMIC_TAGS.RUNPATH]) + assert resolve[lief.ELF.DynamicEntry.TAG.RUNPATH] is not None + print(resolve[lief.ELF.DynamicEntry.TAG.RUNPATH]) print(resolve.header) print(etterlog.notes[0])