diff --git a/api/c/include/LIEF/ELF/enums.h b/api/c/include/LIEF/ELF/enums.h index d91a11639..3bcd71133 100644 --- a/api/c/include/LIEF/ELF/enums.h +++ b/api/c/include/LIEF/ELF/enums.h @@ -695,6 +695,11 @@ enum LIEF_DYNAMIC_TAGS { LIEF_DT_PREINIT_ARRAY = 32, /**< Pointer to array of preinit functions. */ LIEF_DT_PREINIT_ARRAYSZ = 33, /**< Size of the DT_PREINIT_ARRAY array. */ + LIEF_DT_SYMTAB_SHNDX = 34, /**< Address of SYMTAB_SHNDX section */ + LIEF_DT_RELRSZ = 35, /**< Total size of RELR relative relocations */ + LIEF_DT_RELR = 36, /**< Address of RELR relative relocations */ + LIEF_DT_RELRENT = 37, /**< Size of one RELR relative relocaction */ + LIEF_DT_LOOS = 0x60000000, /**< Start of environment specific tags. */ LIEF_DT_HIOS = 0x6FFFFFFF, /**< End of environment specific tags. */ LIEF_DT_LOPROC = 0x70000000, /**< Start of processor specific tags. */ @@ -757,6 +762,8 @@ enum LIEF_DYNAMIC_TAGS { LIEF_DT_MIPS_AUX_DYNAMIC = 0x70000031, /**< Address of auxiliary .dynamic. */ LIEF_DT_MIPS_PLTGOT = 0x70000032, /**< Address of the base of the PLTGOT. */ LIEF_DT_MIPS_RWPLT = 0x70000034, /**< Points to the base of a writable PLT. */ + LIEF_DT_MIPS_RLD_MAP_REL = 0x70000035, + LIEF_DT_MIPS_XHASH = 0x70000036, /* Android specific dynamic table entry tags. */ LIEF_DT_ANDROID_REL_OFFSET = 0x6000000D, /**< The offset of packed relocation data (older version < M) (Android specific. */ @@ -765,10 +772,35 @@ enum LIEF_DYNAMIC_TAGS { LIEF_DT_ANDROID_RELSZ = 0x60000010, /**< The size of packed relocation data in bytes (Android specific. */ LIEF_DT_ANDROID_RELA = 0x60000011, /**< The offset of packed relocation data (Android specific. */ LIEF_DT_ANDROID_RELASZ = 0x60000012, /**< The size of packed relocation data in bytes (Android specific. */ - LIEF_DT_RELR = 0x6FFFE000, /**< The offset of new relr relocation data (Android specific. */ - LIEF_DT_RELRSZ = 0x6FFFE001, /**< The size of nre relr relocation data in bytes (Android specific. */ - LIEF_DT_RELRENT = 0x6FFFE003, /**< The size of a new relr relocation entry (Android specific. */ - LIEF_DT_RELRCOUNT = 0x6FFFE005 /**< Specifies the relative count of new relr relocation entries (Android specific. */ + LIEF_DT_ANDROID_RELR = 0x6FFFE000, /**< The offset of new relr relocation data (Android specific. */ + LIEF_DT_ANDROID_RELRSZ = 0x6FFFE001, /**< The size of nre relr relocation data in bytes (Android specific. */ + LIEF_DT_ANDROID_RELRENT = 0x6FFFE003, /**< The size of a new relr relocation entry (Android specific. */ + LIEF_DT_ANDROID_RELRCOUNT = 0x6FFFE005, /**< Specifies the relative count of new relr relocation entries (Android specific. */ + + LIEF_DT_AARCH64_BTI_PLT = 0x70000001, + LIEF_DT_AARCH64_PAC_PLT = 0x70000003, + LIEF_DT_AARCH64_VARIANT_PCS = 0x70000005, + LIEF_DT_AARCH64_MEMTAG_MODE = 0x70000009, + LIEF_DT_AARCH64_MEMTAG_HEAP = 0x7000000b, + LIEF_DT_AARCH64_MEMTAG_STACK = 0x7000000c, + LIEF_DT_AARCH64_MEMTAG_GLOBALS = 0x7000000d, + LIEF_DT_AARCH64_MEMTAG_GLOBALSSZ = 0x7000000f, + + LIEF_DT_HEXAGON_SYMSZ = 0x70000000, + LIEF_DT_HEXAGON_VER = 0x70000001, + LIEF_DT_HEXAGON_PLT = 0x70000002, + + LIEF_DT_PPC_GOT = 0x70000000, + LIEF_DT_PPC_OPT = 0x70000001, + + LIEF_DT_PPC64_GLINK = 0x70000000, + LIEF_DT_PPC64_OPT = 0x70000003, + + LIEF_DT_RISCV_VARIANT_CC = 0x70000003, + + LIEF_DT_X86_64_PLT = 0x70000000, + LIEF_DT_X86_64_PLTSZ = 0x70000001, + LIEF_DT_X86_64_PLTENT = 0x70000003 }; /** DT_FLAGS and DT_FLAGS_1 values. */ diff --git a/api/python/lief/ELF.pyi b/api/python/lief/ELF.pyi index b74a939b1..a374cfbbb 100644 --- a/api/python/lief/ELF.pyi +++ b/api/python/lief/ELF.pyi @@ -1055,6 +1055,9 @@ class DynamicEntry(lief.Object): VERNEED: ClassVar[DynamicEntry.TAG] = ... VERNEEDNUM: ClassVar[DynamicEntry.TAG] = ... VERSYM: ClassVar[DynamicEntry.TAG] = ... + X86_64_PLT: ClassVar[DynamicEntry.TAG] = ... + X86_64_PLTSZ: ClassVar[DynamicEntry.TAG] = ... + X86_64_PLTENT: ClassVar[DynamicEntry.TAG] = ... __name__: str def __init__(self, *args, **kwargs) -> None: ... @staticmethod diff --git a/api/python/src/ELF/objects/pyDynamicEntry.cpp b/api/python/src/ELF/objects/pyDynamicEntry.cpp index 34faa3b0c..b517530a8 100644 --- a/api/python/src/ELF/objects/pyDynamicEntry.cpp +++ b/api/python/src/ELF/objects/pyDynamicEntry.cpp @@ -159,6 +159,10 @@ void create(nb::module_& m) { ENTRY(PPC64_OPT) ENTRY(RISCV_VARIANT_CC) + + ENTRY(X86_64_PLT) + ENTRY(X86_64_PLTSZ) + ENTRY(X86_64_PLTENT) ; #undef ENTRY diff --git a/api/rust/cargo/lief/src/elf/dynamic.rs b/api/rust/cargo/lief/src/elf/dynamic.rs index 80839c99d..e7043f457 100644 --- a/api/rust/cargo/lief/src/elf/dynamic.rs +++ b/api/rust/cargo/lief/src/elf/dynamic.rs @@ -126,6 +126,9 @@ pub enum Tag { PPC64_GLINK, PPC64_OPT, RISCV_VARIANT_CC, + X86_64_PLT, + X86_64_PLTSZ, + X86_64_PLTENT, UNKNOWN(u64), } @@ -251,6 +254,9 @@ impl From for Tag { 0x570000000 => Tag::PPC64_GLINK, 0x570000003 => Tag::PPC64_OPT, 0x670000003 => Tag::RISCV_VARIANT_CC, + 0x770000000 => Tag::X86_64_PLT, + 0x770000001 => Tag::X86_64_PLTSZ, + 0x770000003 => Tag::X86_64_PLTENT, _ => Tag::UNKNOWN(value), } @@ -378,6 +384,9 @@ impl From for u64 { Tag::PPC64_GLINK => 0x570000000, Tag::PPC64_OPT => 0x570000003, Tag::RISCV_VARIANT_CC => 0x670000003, + Tag::X86_64_PLT => 0x770000000, + Tag::X86_64_PLTSZ => 0x770000001, + Tag::X86_64_PLTENT => 0x770000003, Tag::UNKNOWN(value) => value, } } diff --git a/doc/sphinx/changelog.rst b/doc/sphinx/changelog.rst index 75a83c617..230d4495d 100644 --- a/doc/sphinx/changelog.rst +++ b/doc/sphinx/changelog.rst @@ -9,7 +9,6 @@ Changelog * Add support for the ``LC_SUBCLIENT`` command: :class:`lief.MachO.SubClient` * Add support for the ``LC_ROUTINE/LC_ROUTINE64`` command: :class:`lief.MachO.Routine` - 0.15.1 - July 23th, 2024 ------------------------ diff --git a/include/LIEF/ELF/DynamicEntry.hpp b/include/LIEF/ELF/DynamicEntry.hpp index 5a0e4f881..76e82953b 100644 --- a/include/LIEF/ELF/DynamicEntry.hpp +++ b/include/LIEF/ELF/DynamicEntry.hpp @@ -41,6 +41,7 @@ class LIEF_API DynamicEntry : public Object { static constexpr uint64_t PPC_DISC = 0x400000000; static constexpr uint64_t PPC64_DISC = 0x500000000; static constexpr uint64_t RISCV_DISC = 0x600000000; + static constexpr uint64_t X86_64_DISC = 0x700000000; enum class TAG : uint64_t { UNKNOWN = uint64_t(-1), @@ -174,6 +175,10 @@ class LIEF_API DynamicEntry : public Object { PPC64_OPT = PPC64_DISC + 0x70000003, RISCV_VARIANT_CC = RISCV_DISC + 0x70000003, + + X86_64_PLT = X86_64_DISC + 0x70000000, + X86_64_PLTSZ = X86_64_DISC + 0x70000001, + X86_64_PLTENT = X86_64_DISC + 0x70000003, }; static TAG from_value(uint64_t value, ARCH arch); diff --git a/src/ELF/DynamicEntry.cpp b/src/ELF/DynamicEntry.cpp index 585bd17f7..023312f1f 100644 --- a/src/ELF/DynamicEntry.cpp +++ b/src/ELF/DynamicEntry.cpp @@ -51,6 +51,9 @@ DynamicEntry::TAG DynamicEntry::from_value(uint64_t value, ARCH arch) { case ARCH::RISCV: return TAG(RISCV_DISC + value); + case ARCH::X86_64: + return TAG(X86_64_DISC + value); + default: LIEF_WARN("Dynamic tag: 0x{:04x} is not supported for the " "current architecture", value); @@ -83,9 +86,12 @@ uint64_t DynamicEntry::to_value(DynamicEntry::TAG tag) { return raw_value - PPC64_DISC; } - if (RISCV_DISC <= raw_value) { + if (RISCV_DISC <= raw_value && raw_value < X86_64_DISC) { return raw_value - RISCV_DISC; } + if (X86_64_DISC <= raw_value) { + return raw_value - X86_64_DISC; + } return raw_value; } @@ -237,6 +243,10 @@ const char* to_string(DynamicEntry::TAG tag) { ENTRY(PPC64_OPT), ENTRY(RISCV_VARIANT_CC), + + ENTRY(X86_64_PLT), + ENTRY(X86_64_PLTSZ), + ENTRY(X86_64_PLTENT), }; #undef ENTRY