malwaredb-types 0.3.4

Data types and parsers for MalwareDB.
Documentation
// SPDX-License-Identifier: Apache-2.0

use flagset::flags;

flags! {
    /// ELF Program Header flags
    #[non_exhaustive]
    pub enum ProgramHeaderFlags: u32 {
        /// PT_NULL: Program header entry is unused
        Null = 0,

        /// PT_LOAD: Loadable segment
        Loadable = 1,

        /// PT_DYNAMIC
        Dynamic = 2,

        /// PT_INTERP: Interpreter information
        Interpreter = 3,

        /// PT_NOTE: Extra information
        Note = 4,

        /// PT_SHLIB: Reserved
        Reserved = 5,

        /// PT_PHDR: Program header table
        ProgramHeaderTable = 6,

        /// PT_TLS: Thread Local Storage template
        TLS = 7,

        /// PT_LOOS: Start of OS-specific fields
        LoOS = 0x6000_0000,

        /// PT_HIOS: End of OS-specific fields
        HiOS = 0x6fff_ffff,

        /// PT_LOPROC: Start of processor-specific fields
        LoProc = 0x7000_0000,

        /// PT_HIPROC: End of processor-specific fields
        HiProc = 0x7fff_ffff,
    }

    /// ELF Section Header types
    #[non_exhaustive]
    pub enum SectionHeaderTypes: u32 {
        /// SHT_NULL: Unused
        NULL = 0,

        /// SHT_PROGBITS: Program data
        ProgramBits = 1,

        /// SHT_SYMTAB: Symbol table
        SymbolTable = 2,

        /// SHT_STRTAB: String table
        StringTable = 3,

        /// SHT_RELA: Relocation entries with addends (to be computed)
        RelocationsAddends = 4,

        /// SHT_HASH: Symbol hash table
        Hash = 5,

        /// SHT_DYNAMIC: Dynamic linking information
        DynamicLinking = 6,

        /// SHT_NOTE: Notes
        Notes = 7,

        /// SHT_NOBITS: Program space with no data (bss)
        NoBits = 8,

        /// SHT_REL: Relocation entries, no addends
        Relocations = 9,

        /// SHT_SHLIB: Reserved
        Shlib = 0xA,

        /// SHT_DYNSYM: Dynamic symbol linker table
        DynamicSymbolsTable = 0xB,

        /// SHT_INIT_ARRAY: Array of constructors
        InitArray = 0xE,

        /// SHT_FINI_ARRAY: Array of destructors
        FiniArray = 0xF,

        /// SHT_PREINIT_ARRAY: Array of pre-constructors
        PreInitArray = 0x10,

        /// SHT_GROUP: Section group
        Group = 0x11,

        /// SHT_SYMTAB_SHNDX: Extended section indices
        ExtendedIndices = 0x12,

        /// SHT_NUM: Number of defined types
        NumTypes = 0x13,

        /// SHT_LOOS: Start OS-specific
        LoOS = 0x6000_0000,

        /// SHT_GNU_ATTRIBUTES: GNU object attributes
        GnuAttributes = 0x6fff_fff5,

        /// SHT_GNU_HASH: GNU hash table
        GnuHash = 0x6fff_fff6,

        /// SHT_GNU_LIBLIST: GNU prelink libraries
        LibList = 0x6fff_fff7,

        /// SHT_GNU_VERDEF: GNU version definitions
        VerDef = 0x6fff_fffd,

        /// SHT_GNU_VERNEED: GNU version needs
        VerNeed = 0x6fff_fffe,

        /// SHT_GNU_VERSYM: GNU version symbol table
        VerSym = 0x6fff_ffff,

        /// SHT_HIOS: Last of OS-specific
        HiOS = 0x6fff_ffff,

        /// SHT_LOPROC: Reserved range for processors
        LoProc = 0x7000_0000,

        /// SHT_MIPS_ABIFLAGS: MIPS ABI flags
        MipsABI = 0x7000_002a,

        /// SHT_HIPROC: Last of processor-specific headers
        HiProc = 0x7fff_ffff,

        /// SHT_LOUSER: Start of application-specific range
        LoUser = 0x8000_0000,

        /// SHT_HIUSER: End of application-specific range
        HiUser = 0xffff_ffff,
    }

    /// ELF Section Header flags
    #[non_exhaustive]
    pub enum SectionHeaderFlags: u32 {
        /// SHF_WRITE: writable data
        Write = 1,

        /// SHF_ALLOC: section occupies memory
        Alloc = 2,

        /// SHF_EXECINSTR: section contains instructions
        Exec = 4,

        /// SHF_MERGE: section may be merged
        Mergeable = 0x10,

        /// SHF_STRINGS: section contains strings
        Strings = 0x20,

        /// SHF_INFO_LINK: holds section index
        InfoLink = 0x40,

        /// SHF_LINK_ORDER: special ordering requirements
        LinkOrder = 0x80,

        /// SHF_OS_NONCONFORMING: OS-specific processing required
        OSNonConforming = 0x100,

        /// SHF_GROUP: Member of section group
        Group = 0x200,

        /// SHF_TLS: section contains Thread Local Storage (TLS) data
        TLS = 0x400,

        /// SHF_COMPRESSED: section is compressed
        Compressed = 0x800,

        /// SHF_MASKOS: OS-specific items
        MaskOS = 0x0ff0_0000,

        /// SHF_MASKPROC: processor-specific items
        MaskProc = 0xf000_0000,
    }
}