Executable and Linkable Format: C++11/STL parsing library

Application

SVR4 ABI and up, many *nix systems

KS implementation details

License: CC0-1.0
Minimal Kaitai Struct required: 0.9

References

This page hosts a formal specification of Executable and Linkable Format using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

Usage

Runtime library

All parsing code for C++11/STL generated by Kaitai Struct depends on the C++/STL runtime library. You have to install it before you can parse data.

For C++, the easiest way is to clone the runtime library sources and build them along with your project.

Code

Using Kaitai Struct in C++/STL usually consists of 3 steps.

  1. We need to create an STL input stream (std::istream). One can open local file for that, or use existing std::string or char* buffer.
    #include <fstream>
    
    std::ifstream is("path/to/local/file.elf", std::ifstream::binary);
    
    #include <sstream>
    
    std::istringstream is(str);
    
    #include <sstream>
    
    const char buf[] = { ... };
    std::string str(buf, sizeof buf);
    std::istringstream is(str);
    
  2. We need to wrap our input stream into Kaitai stream:
    #include "kaitai/kaitaistream.h"
    
    kaitai::kstream ks(&is);
    
  3. And finally, we can invoke the parsing:
    elf_t data(&ks);
    

After that, one can get various attributes from the structure by invoking getter methods like:

data.magic() // => File identification, must be 0x7f + "ELF".

C++11/STL source code to parse Executable and Linkable Format

elf.h

#pragma once

// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild

#include "kaitai/kaitaistruct.h"
#include <stdint.h>
#include <memory>
#include <vector>

#if KAITAI_STRUCT_VERSION < 9000L
#error "Incompatible Kaitai Struct C++/STL API: version 0.9 or later is required"
#endif

/**
 * \sa https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/elf.h;hb=HEAD Source
 * \sa https://refspecs.linuxfoundation.org/elf/gabi4+/contents.html Source
 * \sa https://docs.oracle.com/cd/E37838_01/html/E36783/glcfv.html Source
 */

class elf_t : public kaitai::kstruct {

public:
    class phdr_type_flags_t;
    class section_header_flags_t;
    class dt_flag_1_values_t;
    class endian_elf_t;

    enum symbol_visibility_t {
        SYMBOL_VISIBILITY_DEFAULT = 0,
        SYMBOL_VISIBILITY_INTERNAL = 1,
        SYMBOL_VISIBILITY_HIDDEN = 2,
        SYMBOL_VISIBILITY_PROTECTED = 3,
        SYMBOL_VISIBILITY_EXPORTED = 4,
        SYMBOL_VISIBILITY_SINGLETON = 5,
        SYMBOL_VISIBILITY_ELIMINATE = 6
    };

    enum symbol_binding_t {
        SYMBOL_BINDING_LOCAL = 0,
        SYMBOL_BINDING_GLOBAL_SYMBOL = 1,
        SYMBOL_BINDING_WEAK = 2,
        SYMBOL_BINDING_OS10 = 10,
        SYMBOL_BINDING_OS11 = 11,
        SYMBOL_BINDING_OS12 = 12,
        SYMBOL_BINDING_PROC13 = 13,
        SYMBOL_BINDING_PROC14 = 14,
        SYMBOL_BINDING_PROC15 = 15
    };

    enum endian_t {
        ENDIAN_LE = 1,
        ENDIAN_BE = 2
    };

    enum sh_type_t {
        SH_TYPE_NULL_TYPE = 0,
        SH_TYPE_PROGBITS = 1,
        SH_TYPE_SYMTAB = 2,
        SH_TYPE_STRTAB = 3,
        SH_TYPE_RELA = 4,
        SH_TYPE_HASH = 5,
        SH_TYPE_DYNAMIC = 6,
        SH_TYPE_NOTE = 7,
        SH_TYPE_NOBITS = 8,
        SH_TYPE_REL = 9,
        SH_TYPE_SHLIB = 10,
        SH_TYPE_DYNSYM = 11,
        SH_TYPE_INIT_ARRAY = 14,
        SH_TYPE_FINI_ARRAY = 15,
        SH_TYPE_PREINIT_ARRAY = 16,
        SH_TYPE_GROUP = 17,
        SH_TYPE_SYMTAB_SHNDX = 18,
        SH_TYPE_SUNW_SYMNSORT = 1879048172,
        SH_TYPE_SUNW_PHNAME = 1879048173,
        SH_TYPE_SUNW_ANCILLARY = 1879048174,
        SH_TYPE_SUNW_CAPCHAIN = 1879048175,
        SH_TYPE_SUNW_CAPINFO = 1879048176,
        SH_TYPE_SUNW_SYMSORT = 1879048177,
        SH_TYPE_SUNW_TLSSORT = 1879048178,
        SH_TYPE_SUNW_LDYNSYM = 1879048179,
        SH_TYPE_SUNW_DOF = 1879048180,
        SH_TYPE_SUNW_CAP = 1879048181,
        SH_TYPE_SUNW_SIGNATURE = 1879048182,
        SH_TYPE_SUNW_ANNOTATE = 1879048183,
        SH_TYPE_SUNW_DEBUGSTR = 1879048184,
        SH_TYPE_SUNW_DEBUG = 1879048185,
        SH_TYPE_SUNW_MOVE = 1879048186,
        SH_TYPE_SUNW_COMDAT = 1879048187,
        SH_TYPE_SUNW_SYMINFO = 1879048188,
        SH_TYPE_SUNW_VERDEF = 1879048189,
        SH_TYPE_SUNW_VERNEED = 1879048190,
        SH_TYPE_SUNW_VERSYM = 1879048191,
        SH_TYPE_SPARC_GOTDATA = 1879048192,
        SH_TYPE_AMD64_UNWIND = 1879048193,
        SH_TYPE_ARM_PREEMPTMAP = 1879048194,
        SH_TYPE_ARM_ATTRIBUTES = 1879048195,
        SH_TYPE_ARM_DEBUGOVERLAY = 1879048196,
        SH_TYPE_ARM_OVERLAYSECTION = 1879048197
    };

    enum os_abi_t {
        OS_ABI_SYSTEM_V = 0,
        OS_ABI_HP_UX = 1,
        OS_ABI_NETBSD = 2,
        OS_ABI_GNU = 3,
        OS_ABI_SOLARIS = 6,
        OS_ABI_AIX = 7,
        OS_ABI_IRIX = 8,
        OS_ABI_FREEBSD = 9,
        OS_ABI_TRU64 = 10,
        OS_ABI_MODESTO = 11,
        OS_ABI_OPENBSD = 12,
        OS_ABI_OPENVMS = 13,
        OS_ABI_NSK = 14,
        OS_ABI_AROS = 15,
        OS_ABI_FENIXOS = 16,
        OS_ABI_CLOUDABI = 17,
        OS_ABI_OPENVOS = 18
    };

    enum machine_t {
        MACHINE_NO_MACHINE = 0,
        MACHINE_M32 = 1,
        MACHINE_SPARC = 2,
        MACHINE_X86 = 3,
        MACHINE_M68K = 4,
        MACHINE_M88K = 5,
        MACHINE_MIPS = 8,
        MACHINE_POWERPC = 20,
        MACHINE_POWERPC64 = 21,
        MACHINE_S390 = 22,
        MACHINE_ARM = 40,
        MACHINE_SUPERH = 42,
        MACHINE_SPARCV9 = 43,
        MACHINE_IA_64 = 50,
        MACHINE_X86_64 = 62,
        MACHINE_AVR = 83,
        MACHINE_QDSP6 = 164,
        MACHINE_AARCH64 = 183,
        MACHINE_AVR32 = 185,
        MACHINE_AMDGPU = 224,
        MACHINE_RISCV = 243,
        MACHINE_BPF = 247,
        MACHINE_CSKY = 252
    };

    enum symbol_type_t {
        SYMBOL_TYPE_NO_TYPE = 0,
        SYMBOL_TYPE_OBJECT = 1,
        SYMBOL_TYPE_FUNC = 2,
        SYMBOL_TYPE_SECTION = 3,
        SYMBOL_TYPE_FILE = 4,
        SYMBOL_TYPE_COMMON = 5,
        SYMBOL_TYPE_TLS = 6,
        SYMBOL_TYPE_RELC = 8,
        SYMBOL_TYPE_SRELC = 9,
        SYMBOL_TYPE_GNU_IFUNC = 10,
        SYMBOL_TYPE_OS11 = 11,
        SYMBOL_TYPE_OS12 = 12,
        SYMBOL_TYPE_PROC13 = 13,
        SYMBOL_TYPE_PROC14 = 14,
        SYMBOL_TYPE_PROC15 = 15
    };

    enum dynamic_array_tags_t {
        DYNAMIC_ARRAY_TAGS_NULL = 0,
        DYNAMIC_ARRAY_TAGS_NEEDED = 1,
        DYNAMIC_ARRAY_TAGS_PLTRELSZ = 2,
        DYNAMIC_ARRAY_TAGS_PLTGOT = 3,
        DYNAMIC_ARRAY_TAGS_HASH = 4,
        DYNAMIC_ARRAY_TAGS_STRTAB = 5,
        DYNAMIC_ARRAY_TAGS_SYMTAB = 6,
        DYNAMIC_ARRAY_TAGS_RELA = 7,
        DYNAMIC_ARRAY_TAGS_RELASZ = 8,
        DYNAMIC_ARRAY_TAGS_RELAENT = 9,
        DYNAMIC_ARRAY_TAGS_STRSZ = 10,
        DYNAMIC_ARRAY_TAGS_SYMENT = 11,
        DYNAMIC_ARRAY_TAGS_INIT = 12,
        DYNAMIC_ARRAY_TAGS_FINI = 13,
        DYNAMIC_ARRAY_TAGS_SONAME = 14,
        DYNAMIC_ARRAY_TAGS_RPATH = 15,
        DYNAMIC_ARRAY_TAGS_SYMBOLIC = 16,
        DYNAMIC_ARRAY_TAGS_REL = 17,
        DYNAMIC_ARRAY_TAGS_RELSZ = 18,
        DYNAMIC_ARRAY_TAGS_RELENT = 19,
        DYNAMIC_ARRAY_TAGS_PLTREL = 20,
        DYNAMIC_ARRAY_TAGS_DEBUG = 21,
        DYNAMIC_ARRAY_TAGS_TEXTREL = 22,
        DYNAMIC_ARRAY_TAGS_JMPREL = 23,
        DYNAMIC_ARRAY_TAGS_BIND_NOW = 24,
        DYNAMIC_ARRAY_TAGS_INIT_ARRAY = 25,
        DYNAMIC_ARRAY_TAGS_FINI_ARRAY = 26,
        DYNAMIC_ARRAY_TAGS_INIT_ARRAYSZ = 27,
        DYNAMIC_ARRAY_TAGS_FINI_ARRAYSZ = 28,
        DYNAMIC_ARRAY_TAGS_RUNPATH = 29,
        DYNAMIC_ARRAY_TAGS_FLAGS = 30,
        DYNAMIC_ARRAY_TAGS_PREINIT_ARRAY = 32,
        DYNAMIC_ARRAY_TAGS_PREINIT_ARRAYSZ = 33,
        DYNAMIC_ARRAY_TAGS_SYMTAB_SHNDX = 34,
        DYNAMIC_ARRAY_TAGS_DEPRECATED_SPARC_REGISTER = 117440513,
        DYNAMIC_ARRAY_TAGS_SUNW_AUXILIARY = 1610612749,
        DYNAMIC_ARRAY_TAGS_SUNW_RTLDINF = 1610612750,
        DYNAMIC_ARRAY_TAGS_SUNW_FILTER = 1610612751,
        DYNAMIC_ARRAY_TAGS_SUNW_CAP = 1610612752,
        DYNAMIC_ARRAY_TAGS_SUNW_SYMTAB = 1610612753,
        DYNAMIC_ARRAY_TAGS_SUNW_SYMSZ = 1610612754,
        DYNAMIC_ARRAY_TAGS_SUNW_SORTENT = 1610612755,
        DYNAMIC_ARRAY_TAGS_SUNW_SYMSORT = 1610612756,
        DYNAMIC_ARRAY_TAGS_SUNW_SYMSORTSZ = 1610612757,
        DYNAMIC_ARRAY_TAGS_SUNW_TLSSORT = 1610612758,
        DYNAMIC_ARRAY_TAGS_SUNW_TLSSORTSZ = 1610612759,
        DYNAMIC_ARRAY_TAGS_SUNW_CAPINFO = 1610612760,
        DYNAMIC_ARRAY_TAGS_SUNW_STRPAD = 1610612761,
        DYNAMIC_ARRAY_TAGS_SUNW_CAPCHAIN = 1610612762,
        DYNAMIC_ARRAY_TAGS_SUNW_LDMACH = 1610612763,
        DYNAMIC_ARRAY_TAGS_SUNW_SYMTAB_SHNDX = 1610612764,
        DYNAMIC_ARRAY_TAGS_SUNW_CAPCHAINENT = 1610612765,
        DYNAMIC_ARRAY_TAGS_SUNW_DEFERRED = 1610612766,
        DYNAMIC_ARRAY_TAGS_SUNW_CAPCHAINSZ = 1610612767,
        DYNAMIC_ARRAY_TAGS_SUNW_PHNAME = 1610612768,
        DYNAMIC_ARRAY_TAGS_SUNW_PARENT = 1610612769,
        DYNAMIC_ARRAY_TAGS_SUNW_SX_ASLR = 1610612771,
        DYNAMIC_ARRAY_TAGS_SUNW_RELAX = 1610612773,
        DYNAMIC_ARRAY_TAGS_SUNW_KMOD = 1610612775,
        DYNAMIC_ARRAY_TAGS_SUNW_SX_NXHEAP = 1610612777,
        DYNAMIC_ARRAY_TAGS_SUNW_SX_NXSTACK = 1610612779,
        DYNAMIC_ARRAY_TAGS_SUNW_SX_ADIHEAP = 1610612781,
        DYNAMIC_ARRAY_TAGS_SUNW_SX_ADISTACK = 1610612783,
        DYNAMIC_ARRAY_TAGS_SUNW_SX_SSBD = 1610612785,
        DYNAMIC_ARRAY_TAGS_SUNW_SYMNSORT = 1610612786,
        DYNAMIC_ARRAY_TAGS_SUNW_SYMNSORTSZ = 1610612787,
        DYNAMIC_ARRAY_TAGS_GNU_FLAGS_1 = 1879047668,
        DYNAMIC_ARRAY_TAGS_GNU_PRELINKED = 1879047669,
        DYNAMIC_ARRAY_TAGS_GNU_CONFLICTSZ = 1879047670,
        DYNAMIC_ARRAY_TAGS_GNU_LIBLISTSZ = 1879047671,
        DYNAMIC_ARRAY_TAGS_CHECKSUM = 1879047672,
        DYNAMIC_ARRAY_TAGS_PLTPADSZ = 1879047673,
        DYNAMIC_ARRAY_TAGS_MOVEENT = 1879047674,
        DYNAMIC_ARRAY_TAGS_MOVESZ = 1879047675,
        DYNAMIC_ARRAY_TAGS_FEATURE_1 = 1879047676,
        DYNAMIC_ARRAY_TAGS_POSFLAG_1 = 1879047677,
        DYNAMIC_ARRAY_TAGS_SYMINSZ = 1879047678,
        DYNAMIC_ARRAY_TAGS_SYMINENT = 1879047679,
        DYNAMIC_ARRAY_TAGS_GNU_HASH = 1879047925,
        DYNAMIC_ARRAY_TAGS_TLSDESC_PLT = 1879047926,
        DYNAMIC_ARRAY_TAGS_TLSDESC_GOT = 1879047927,
        DYNAMIC_ARRAY_TAGS_GNU_CONFLICT = 1879047928,
        DYNAMIC_ARRAY_TAGS_GNU_LIBLIST = 1879047929,
        DYNAMIC_ARRAY_TAGS_CONFIG = 1879047930,
        DYNAMIC_ARRAY_TAGS_DEPAUDIT = 1879047931,
        DYNAMIC_ARRAY_TAGS_AUDIT = 1879047932,
        DYNAMIC_ARRAY_TAGS_PLTPAD = 1879047933,
        DYNAMIC_ARRAY_TAGS_MOVETAB = 1879047934,
        DYNAMIC_ARRAY_TAGS_SYMINFO = 1879047935,
        DYNAMIC_ARRAY_TAGS_VERSYM = 1879048176,
        DYNAMIC_ARRAY_TAGS_RELACOUNT = 1879048185,
        DYNAMIC_ARRAY_TAGS_RELCOUNT = 1879048186,
        DYNAMIC_ARRAY_TAGS_FLAGS_1 = 1879048187,
        DYNAMIC_ARRAY_TAGS_VERDEF = 1879048188,
        DYNAMIC_ARRAY_TAGS_VERDEFNUM = 1879048189,
        DYNAMIC_ARRAY_TAGS_VERNEED = 1879048190,
        DYNAMIC_ARRAY_TAGS_VERNEEDNUM = 1879048191,
        DYNAMIC_ARRAY_TAGS_SPARC_REGISTER = 1879048193,
        DYNAMIC_ARRAY_TAGS_AUXILIARY = 2147483645,
        DYNAMIC_ARRAY_TAGS_USED = 2147483646,
        DYNAMIC_ARRAY_TAGS_FILTER = 2147483647
    };

    enum bits_t {
        BITS_B32 = 1,
        BITS_B64 = 2
    };

    enum ph_type_t {
        PH_TYPE_NULL_TYPE = 0,
        PH_TYPE_LOAD = 1,
        PH_TYPE_DYNAMIC = 2,
        PH_TYPE_INTERP = 3,
        PH_TYPE_NOTE = 4,
        PH_TYPE_SHLIB = 5,
        PH_TYPE_PHDR = 6,
        PH_TYPE_TLS = 7,
        PH_TYPE_GNU_EH_FRAME = 1685382480,
        PH_TYPE_GNU_STACK = 1685382481,
        PH_TYPE_GNU_RELRO = 1685382482,
        PH_TYPE_GNU_PROPERTY = 1685382483,
        PH_TYPE_PAX_FLAGS = 1694766464,
        PH_TYPE_ARM_EXIDX = 1879048193
    };

    enum obj_type_t {
        OBJ_TYPE_NO_FILE_TYPE = 0,
        OBJ_TYPE_RELOCATABLE = 1,
        OBJ_TYPE_EXECUTABLE = 2,
        OBJ_TYPE_SHARED = 3,
        OBJ_TYPE_CORE = 4
    };

    enum section_header_idx_special_t {
        SECTION_HEADER_IDX_SPECIAL_UNDEFINED = 0,
        SECTION_HEADER_IDX_SPECIAL_BEFORE = 65280,
        SECTION_HEADER_IDX_SPECIAL_AFTER = 65281,
        SECTION_HEADER_IDX_SPECIAL_AMD64_LCOMMON = 65282,
        SECTION_HEADER_IDX_SPECIAL_SUNW_IGNORE = 65343,
        SECTION_HEADER_IDX_SPECIAL_ABS = 65521,
        SECTION_HEADER_IDX_SPECIAL_COMMON = 65522,
        SECTION_HEADER_IDX_SPECIAL_XINDEX = 65535
    };

    elf_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = nullptr, elf_t* p__root = nullptr);

private:
    void _read();
    void _clean_up();

public:
    ~elf_t();

    class phdr_type_flags_t : public kaitai::kstruct {

    public:

        phdr_type_flags_t(uint32_t p_value, kaitai::kstream* p__io, elf_t::endian_elf_t::program_header_t* p__parent = nullptr, elf_t* p__root = nullptr);

    private:
        void _read();
        void _clean_up();

    public:
        ~phdr_type_flags_t();

    private:
        bool f_read;
        bool m_read;

    public:
        bool read();

    private:
        bool f_write;
        bool m_write;

    public:
        bool write();

    private:
        bool f_execute;
        bool m_execute;

    public:
        bool execute();

    private:
        bool f_mask_proc;
        bool m_mask_proc;

    public:
        bool mask_proc();

    private:
        uint32_t m_value;
        elf_t* m__root;
        elf_t::endian_elf_t::program_header_t* m__parent;

    public:
        uint32_t value() const { return m_value; }
        elf_t* _root() const { return m__root; }
        elf_t::endian_elf_t::program_header_t* _parent() const { return m__parent; }
    };

    class section_header_flags_t : public kaitai::kstruct {

    public:

        section_header_flags_t(uint32_t p_value, kaitai::kstream* p__io, elf_t::endian_elf_t::section_header_t* p__parent = nullptr, elf_t* p__root = nullptr);

    private:
        void _read();
        void _clean_up();

    public:
        ~section_header_flags_t();

    private:
        bool f_merge;
        bool m_merge;

    public:

        /**
         * might be merged
         */
        bool merge();

    private:
        bool f_mask_os;
        bool m_mask_os;

    public:

        /**
         * OS-specific
         */
        bool mask_os();

    private:
        bool f_exclude;
        bool m_exclude;

    public:

        /**
         * section is excluded unless referenced or allocated (Solaris)
         */
        bool exclude();

    private:
        bool f_mask_proc;
        bool m_mask_proc;

    public:

        /**
         * Processor-specific
         */
        bool mask_proc();

    private:
        bool f_strings;
        bool m_strings;

    public:

        /**
         * contains nul-terminated strings
         */
        bool strings();

    private:
        bool f_os_non_conforming;
        bool m_os_non_conforming;

    public:

        /**
         * non-standard OS specific handling required
         */
        bool os_non_conforming();

    private:
        bool f_alloc;
        bool m_alloc;

    public:

        /**
         * occupies memory during execution
         */
        bool alloc();

    private:
        bool f_exec_instr;
        bool m_exec_instr;

    public:

        /**
         * executable
         */
        bool exec_instr();

    private:
        bool f_info_link;
        bool m_info_link;

    public:

        /**
         * 'sh_info' contains SHT index
         */
        bool info_link();

    private:
        bool f_write;
        bool m_write;

    public:

        /**
         * writable
         */
        bool write();

    private:
        bool f_link_order;
        bool m_link_order;

    public:

        /**
         * preserve order after combining
         */
        bool link_order();

    private:
        bool f_ordered;
        bool m_ordered;

    public:

        /**
         * special ordering requirement (Solaris)
         */
        bool ordered();

    private:
        bool f_tls;
        bool m_tls;

    public:

        /**
         * section hold thread-local data
         */
        bool tls();

    private:
        bool f_group;
        bool m_group;

    public:

        /**
         * section is member of a group
         */
        bool group();

    private:
        uint32_t m_value;
        elf_t* m__root;
        elf_t::endian_elf_t::section_header_t* m__parent;

    public:
        uint32_t value() const { return m_value; }
        elf_t* _root() const { return m__root; }
        elf_t::endian_elf_t::section_header_t* _parent() const { return m__parent; }
    };

    class dt_flag_1_values_t : public kaitai::kstruct {

    public:

        dt_flag_1_values_t(uint32_t p_value, kaitai::kstream* p__io, elf_t::endian_elf_t::dynamic_section_entry_t* p__parent = nullptr, elf_t* p__root = nullptr);

    private:
        void _read();
        void _clean_up();

    public:
        ~dt_flag_1_values_t();

    private:
        bool f_singleton;
        bool m_singleton;

    public:

        /**
         * Singleton symbols are used.
         */
        bool singleton();

    private:
        bool f_ignmuldef;
        bool m_ignmuldef;

    public:
        bool ignmuldef();

    private:
        bool f_loadfltr;
        bool m_loadfltr;

    public:

        /**
         * Trigger filtee loading at runtime.
         */
        bool loadfltr();

    private:
        bool f_initfirst;
        bool m_initfirst;

    public:

        /**
         * Set RTLD_INITFIRST for this object
         */
        bool initfirst();

    private:
        bool f_symintpose;
        bool m_symintpose;

    public:

        /**
         * Object has individual interposers.
         */
        bool symintpose();

    private:
        bool f_noreloc;
        bool m_noreloc;

    public:
        bool noreloc();

    private:
        bool f_confalt;
        bool m_confalt;

    public:

        /**
         * Configuration alternative created.
         */
        bool confalt();

    private:
        bool f_dispreldne;
        bool m_dispreldne;

    public:

        /**
         * Disp reloc applied at build time.
         */
        bool dispreldne();

    private:
        bool f_rtld_global;
        bool m_rtld_global;

    public:

        /**
         * Set RTLD_GLOBAL for this object.
         */
        bool rtld_global();

    private:
        bool f_nodelete;
        bool m_nodelete;

    public:

        /**
         * Set RTLD_NODELETE for this object.
         */
        bool nodelete();

    private:
        bool f_trans;
        bool m_trans;

    public:
        bool trans();

    private:
        bool f_origin;
        bool m_origin;

    public:

        /**
         * $ORIGIN must be handled.
         */
        bool origin();

    private:
        bool f_now;
        bool m_now;

    public:

        /**
         * Set RTLD_NOW for this object.
         */
        bool now();

    private:
        bool f_nohdr;
        bool m_nohdr;

    public:
        bool nohdr();

    private:
        bool f_endfiltee;
        bool m_endfiltee;

    public:

        /**
         * Filtee terminates filters search.
         */
        bool endfiltee();

    private:
        bool f_nodirect;
        bool m_nodirect;

    public:

        /**
         * Object has no-direct binding.
         */
        bool nodirect();

    private:
        bool f_globaudit;
        bool m_globaudit;

    public:

        /**
         * Global auditing required.
         */
        bool globaudit();

    private:
        bool f_noksyms;
        bool m_noksyms;

    public:
        bool noksyms();

    private:
        bool f_interpose;
        bool m_interpose;

    public:

        /**
         * Object is used to interpose.
         */
        bool interpose();

    private:
        bool f_nodump;
        bool m_nodump;

    public:

        /**
         * Object can't be dldump'ed.
         */
        bool nodump();

    private:
        bool f_disprelpnd;
        bool m_disprelpnd;

    public:

        /**
         * Disp reloc applied at run-time.
         */
        bool disprelpnd();

    private:
        bool f_noopen;
        bool m_noopen;

    public:

        /**
         * Set RTLD_NOOPEN for this object.
         */
        bool noopen();

    private:
        bool f_stub;
        bool m_stub;

    public:
        bool stub();

    private:
        bool f_direct;
        bool m_direct;

    public:

        /**
         * Direct binding enabled.
         */
        bool direct();

    private:
        bool f_edited;
        bool m_edited;

    public:

        /**
         * Object is modified after built.
         */
        bool edited();

    private:
        bool f_group;
        bool m_group;

    public:

        /**
         * Set RTLD_GROUP for this object.
         */
        bool group();

    private:
        bool f_pie;
        bool m_pie;

    public:
        bool pie();

    private:
        bool f_nodeflib;
        bool m_nodeflib;

    public:

        /**
         * Ignore default lib search path.
         */
        bool nodeflib();

    private:
        uint32_t m_value;
        elf_t* m__root;
        elf_t::endian_elf_t::dynamic_section_entry_t* m__parent;

    public:
        uint32_t value() const { return m_value; }
        elf_t* _root() const { return m__root; }
        elf_t::endian_elf_t::dynamic_section_entry_t* _parent() const { return m__parent; }
    };

    class endian_elf_t : public kaitai::kstruct {

    public:
        class note_section_t;
        class program_header_t;
        class dynamic_section_entry_t;
        class section_header_t;
        class relocation_section_t;
        class dynamic_section_t;
        class dynsym_section_t;
        class relocation_section_entry_t;
        class dynsym_section_entry_t;
        class note_section_entry_t;
        class strings_struct_t;

        endian_elf_t(kaitai::kstream* p__io, elf_t* p__parent = nullptr, elf_t* p__root = nullptr);

    private:
        int m__is_le;

    public:

    private:
        void _read();
        void _read_le();
        void _read_be();
        void _clean_up();

    public:
        ~endian_elf_t();

        class note_section_t : public kaitai::kstruct {

        public:

            note_section_t(kaitai::kstream* p__io, elf_t::endian_elf_t::section_header_t* p__parent = nullptr, elf_t* p__root = nullptr, int p_is_le = -1);

        private:
            int m__is_le;

        public:

        private:
            void _read();
            void _read_le();
            void _read_be();
            void _clean_up();

        public:
            ~note_section_t();

        private:
            std::unique_ptr<std::vector<std::unique_ptr<note_section_entry_t>>> m_entries;
            elf_t* m__root;
            elf_t::endian_elf_t::section_header_t* m__parent;

        public:
            std::vector<std::unique_ptr<note_section_entry_t>>* entries() const { return m_entries.get(); }
            elf_t* _root() const { return m__root; }
            elf_t::endian_elf_t::section_header_t* _parent() const { return m__parent; }
        };

        class program_header_t : public kaitai::kstruct {

        public:

            program_header_t(kaitai::kstream* p__io, elf_t::endian_elf_t* p__parent = nullptr, elf_t* p__root = nullptr, int p_is_le = -1);

        private:
            int m__is_le;

        public:

        private:
            void _read();
            void _read_le();
            void _read_be();
            void _clean_up();

        public:
            ~program_header_t();

        private:
            bool f_flags_obj;
            std::unique_ptr<phdr_type_flags_t> m_flags_obj;
            bool n_flags_obj;

        public:
            bool _is_null_flags_obj() { flags_obj(); return n_flags_obj; };

        private:

        public:
            phdr_type_flags_t* flags_obj();

        private:
            ph_type_t m_type;
            uint32_t m_flags64;
            bool n_flags64;

        public:
            bool _is_null_flags64() { flags64(); return n_flags64; };

        private:
            uint64_t m_offset;
            bool n_offset;

        public:
            bool _is_null_offset() { offset(); return n_offset; };

        private:
            uint64_t m_vaddr;
            bool n_vaddr;

        public:
            bool _is_null_vaddr() { vaddr(); return n_vaddr; };

        private:
            uint64_t m_paddr;
            bool n_paddr;

        public:
            bool _is_null_paddr() { paddr(); return n_paddr; };

        private:
            uint64_t m_filesz;
            bool n_filesz;

        public:
            bool _is_null_filesz() { filesz(); return n_filesz; };

        private:
            uint64_t m_memsz;
            bool n_memsz;

        public:
            bool _is_null_memsz() { memsz(); return n_memsz; };

        private:
            uint32_t m_flags32;
            bool n_flags32;

        public:
            bool _is_null_flags32() { flags32(); return n_flags32; };

        private:
            uint64_t m_align;
            bool n_align;

        public:
            bool _is_null_align() { align(); return n_align; };

        private:
            elf_t* m__root;
            elf_t::endian_elf_t* m__parent;

        public:
            ph_type_t type() const { return m_type; }
            uint32_t flags64() const { return m_flags64; }
            uint64_t offset() const { return m_offset; }
            uint64_t vaddr() const { return m_vaddr; }
            uint64_t paddr() const { return m_paddr; }
            uint64_t filesz() const { return m_filesz; }
            uint64_t memsz() const { return m_memsz; }
            uint32_t flags32() const { return m_flags32; }
            uint64_t align() const { return m_align; }
            elf_t* _root() const { return m__root; }
            elf_t::endian_elf_t* _parent() const { return m__parent; }
        };

        /**
         * \sa https://docs.oracle.com/cd/E37838_01/html/E36783/chapter6-42444.html Source
         * \sa https://refspecs.linuxfoundation.org/elf/gabi4+/ch5.dynamic.html#dynamic_section Source
         */

        class dynamic_section_entry_t : public kaitai::kstruct {

        public:

            dynamic_section_entry_t(kaitai::kstream* p__io, elf_t::endian_elf_t::dynamic_section_t* p__parent = nullptr, elf_t* p__root = nullptr, int p_is_le = -1);

        private:
            int m__is_le;

        public:

        private:
            void _read();
            void _read_le();
            void _read_be();
            void _clean_up();

        public:
            ~dynamic_section_entry_t();

        private:
            bool f_tag_enum;
            dynamic_array_tags_t m_tag_enum;

        public:
            dynamic_array_tags_t tag_enum();

        private:
            bool f_flag_1_values;
            std::unique_ptr<dt_flag_1_values_t> m_flag_1_values;
            bool n_flag_1_values;

        public:
            bool _is_null_flag_1_values() { flag_1_values(); return n_flag_1_values; };

        private:

        public:
            dt_flag_1_values_t* flag_1_values();

        private:
            bool f_value_str;
            std::string m_value_str;
            bool n_value_str;

        public:
            bool _is_null_value_str() { value_str(); return n_value_str; };

        private:

        public:
            std::string value_str();

        private:
            bool f_is_value_str;
            bool m_is_value_str;

        public:
            bool is_value_str();

        private:
            uint64_t m_tag;
            bool n_tag;

        public:
            bool _is_null_tag() { tag(); return n_tag; };

        private:
            uint64_t m_value_or_ptr;
            bool n_value_or_ptr;

        public:
            bool _is_null_value_or_ptr() { value_or_ptr(); return n_value_or_ptr; };

        private:
            elf_t* m__root;
            elf_t::endian_elf_t::dynamic_section_t* m__parent;

        public:
            uint64_t tag() const { return m_tag; }
            uint64_t value_or_ptr() const { return m_value_or_ptr; }
            elf_t* _root() const { return m__root; }
            elf_t::endian_elf_t::dynamic_section_t* _parent() const { return m__parent; }
        };

        class section_header_t : public kaitai::kstruct {

        public:

            section_header_t(kaitai::kstream* p__io, elf_t::endian_elf_t* p__parent = nullptr, elf_t* p__root = nullptr, int p_is_le = -1);

        private:
            int m__is_le;

        public:

        private:
            void _read();
            void _read_le();
            void _read_be();
            void _clean_up();

        public:
            ~section_header_t();

        private:
            bool f_body;
            std::unique_ptr<kaitai::kstruct> m_body;
            bool n_body;

        public:
            bool _is_null_body() { body(); return n_body; };

        private:

        public:
            kaitai::kstruct* body();

        private:
            bool f_linked_section;
            section_header_t* m_linked_section;
            bool n_linked_section;

        public:
            bool _is_null_linked_section() { linked_section(); return n_linked_section; };

        private:

        public:

            /**
             * may reference a later section header, so don't try to access too early (use only lazy `instances`)
             * \sa https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.sheader.html#sh_link Source
             */
            section_header_t* linked_section();

        private:
            bool f_name;
            std::string m_name;

        public:
            std::string name();

        private:
            bool f_flags_obj;
            std::unique_ptr<section_header_flags_t> m_flags_obj;

        public:
            section_header_flags_t* flags_obj();

        private:
            uint32_t m_ofs_name;
            sh_type_t m_type;
            uint64_t m_flags;
            bool n_flags;

        public:
            bool _is_null_flags() { flags(); return n_flags; };

        private:
            uint64_t m_addr;
            bool n_addr;

        public:
            bool _is_null_addr() { addr(); return n_addr; };

        private:
            uint64_t m_ofs_body;
            bool n_ofs_body;

        public:
            bool _is_null_ofs_body() { ofs_body(); return n_ofs_body; };

        private:
            uint64_t m_len_body;
            bool n_len_body;

        public:
            bool _is_null_len_body() { len_body(); return n_len_body; };

        private:
            uint32_t m_linked_section_idx;
            std::string m_info;
            uint64_t m_align;
            bool n_align;

        public:
            bool _is_null_align() { align(); return n_align; };

        private:
            uint64_t m_entry_size;
            bool n_entry_size;

        public:
            bool _is_null_entry_size() { entry_size(); return n_entry_size; };

        private:
            elf_t* m__root;
            elf_t::endian_elf_t* m__parent;
            std::string m__raw_body;
            std::unique_ptr<kaitai::kstream> m__io__raw_body;

        public:
            uint32_t ofs_name() const { return m_ofs_name; }
            sh_type_t type() const { return m_type; }
            uint64_t flags() const { return m_flags; }
            uint64_t addr() const { return m_addr; }
            uint64_t ofs_body() const { return m_ofs_body; }
            uint64_t len_body() const { return m_len_body; }
            uint32_t linked_section_idx() const { return m_linked_section_idx; }
            std::string info() const { return m_info; }
            uint64_t align() const { return m_align; }
            uint64_t entry_size() const { return m_entry_size; }
            elf_t* _root() const { return m__root; }
            elf_t::endian_elf_t* _parent() const { return m__parent; }
            std::string _raw_body() const { return m__raw_body; }
            kaitai::kstream* _io__raw_body() const { return m__io__raw_body.get(); }
        };

        /**
         * \sa https://docs.oracle.com/cd/E37838_01/html/E36783/chapter6-54839.html Source
         * \sa https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.reloc.html Source
         */

        class relocation_section_t : public kaitai::kstruct {

        public:

            relocation_section_t(bool p_has_addend, kaitai::kstream* p__io, elf_t::endian_elf_t::section_header_t* p__parent = nullptr, elf_t* p__root = nullptr, int p_is_le = -1);

        private:
            int m__is_le;

        public:

        private:
            void _read();
            void _read_le();
            void _read_be();
            void _clean_up();

        public:
            ~relocation_section_t();

        private:
            std::unique_ptr<std::vector<std::unique_ptr<relocation_section_entry_t>>> m_entries;
            bool m_has_addend;
            elf_t* m__root;
            elf_t::endian_elf_t::section_header_t* m__parent;

        public:
            std::vector<std::unique_ptr<relocation_section_entry_t>>* entries() const { return m_entries.get(); }
            bool has_addend() const { return m_has_addend; }
            elf_t* _root() const { return m__root; }
            elf_t::endian_elf_t::section_header_t* _parent() const { return m__parent; }
        };

        class dynamic_section_t : public kaitai::kstruct {

        public:

            dynamic_section_t(kaitai::kstream* p__io, elf_t::endian_elf_t::section_header_t* p__parent = nullptr, elf_t* p__root = nullptr, int p_is_le = -1);

        private:
            int m__is_le;

        public:

        private:
            void _read();
            void _read_le();
            void _read_be();
            void _clean_up();

        public:
            ~dynamic_section_t();

        private:
            bool f_is_string_table_linked;
            bool m_is_string_table_linked;

        public:
            bool is_string_table_linked();

        private:
            std::unique_ptr<std::vector<std::unique_ptr<dynamic_section_entry_t>>> m_entries;
            elf_t* m__root;
            elf_t::endian_elf_t::section_header_t* m__parent;

        public:
            std::vector<std::unique_ptr<dynamic_section_entry_t>>* entries() const { return m_entries.get(); }
            elf_t* _root() const { return m__root; }
            elf_t::endian_elf_t::section_header_t* _parent() const { return m__parent; }
        };

        class dynsym_section_t : public kaitai::kstruct {

        public:

            dynsym_section_t(kaitai::kstream* p__io, elf_t::endian_elf_t::section_header_t* p__parent = nullptr, elf_t* p__root = nullptr, int p_is_le = -1);

        private:
            int m__is_le;

        public:

        private:
            void _read();
            void _read_le();
            void _read_be();
            void _clean_up();

        public:
            ~dynsym_section_t();

        private:
            bool f_is_string_table_linked;
            bool m_is_string_table_linked;

        public:
            bool is_string_table_linked();

        private:
            std::unique_ptr<std::vector<std::unique_ptr<dynsym_section_entry_t>>> m_entries;
            elf_t* m__root;
            elf_t::endian_elf_t::section_header_t* m__parent;

        public:
            std::vector<std::unique_ptr<dynsym_section_entry_t>>* entries() const { return m_entries.get(); }
            elf_t* _root() const { return m__root; }
            elf_t::endian_elf_t::section_header_t* _parent() const { return m__parent; }
        };

        class relocation_section_entry_t : public kaitai::kstruct {

        public:

            relocation_section_entry_t(kaitai::kstream* p__io, elf_t::endian_elf_t::relocation_section_t* p__parent = nullptr, elf_t* p__root = nullptr, int p_is_le = -1);

        private:
            int m__is_le;

        public:

        private:
            void _read();
            void _read_le();
            void _read_be();
            void _clean_up();

        public:
            ~relocation_section_entry_t();

        private:
            uint64_t m_offset;
            bool n_offset;

        public:
            bool _is_null_offset() { offset(); return n_offset; };

        private:
            uint64_t m_info;
            bool n_info;

        public:
            bool _is_null_info() { info(); return n_info; };

        private:
            int64_t m_addend;
            bool n_addend;

        public:
            bool _is_null_addend() { addend(); return n_addend; };

        private:
            elf_t* m__root;
            elf_t::endian_elf_t::relocation_section_t* m__parent;

        public:
            uint64_t offset() const { return m_offset; }
            uint64_t info() const { return m_info; }
            int64_t addend() const { return m_addend; }
            elf_t* _root() const { return m__root; }
            elf_t::endian_elf_t::relocation_section_t* _parent() const { return m__parent; }
        };

        /**
         * \sa https://docs.oracle.com/cd/E37838_01/html/E36783/man-sts.html Source
         * \sa https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.symtab.html Source
         */

        class dynsym_section_entry_t : public kaitai::kstruct {

        public:

            dynsym_section_entry_t(kaitai::kstream* p__io, elf_t::endian_elf_t::dynsym_section_t* p__parent = nullptr, elf_t* p__root = nullptr, int p_is_le = -1);

        private:
            int m__is_le;

        public:

        private:
            void _read();
            void _read_le();
            void _read_be();
            void _clean_up();

        public:
            ~dynsym_section_entry_t();

        private:
            bool f_is_sh_idx_reserved;
            bool m_is_sh_idx_reserved;

        public:
            bool is_sh_idx_reserved();

        private:
            bool f_is_sh_idx_os;
            bool m_is_sh_idx_os;

        public:
            bool is_sh_idx_os();

        private:
            bool f_is_sh_idx_proc;
            bool m_is_sh_idx_proc;

        public:
            bool is_sh_idx_proc();

        private:
            bool f_size;
            uint64_t m_size;

        public:
            uint64_t size();

        private:
            bool f_visibility;
            symbol_visibility_t m_visibility;

        public:
            symbol_visibility_t visibility();

        private:
            bool f_value;
            uint64_t m_value;

        public:
            uint64_t value();

        private:
            bool f_name;
            std::string m_name;
            bool n_name;

        public:
            bool _is_null_name() { name(); return n_name; };

        private:

        public:
            std::string name();

        private:
            bool f_sh_idx_special;
            section_header_idx_special_t m_sh_idx_special;

        public:
            section_header_idx_special_t sh_idx_special();

        private:
            uint32_t m_ofs_name;
            uint32_t m_value_b32;
            bool n_value_b32;

        public:
            bool _is_null_value_b32() { value_b32(); return n_value_b32; };

        private:
            uint32_t m_size_b32;
            bool n_size_b32;

        public:
            bool _is_null_size_b32() { size_b32(); return n_size_b32; };

        private:
            symbol_binding_t m_bind;
            symbol_type_t m_type;
            uint8_t m_other;
            uint16_t m_sh_idx;
            uint64_t m_value_b64;
            bool n_value_b64;

        public:
            bool _is_null_value_b64() { value_b64(); return n_value_b64; };

        private:
            uint64_t m_size_b64;
            bool n_size_b64;

        public:
            bool _is_null_size_b64() { size_b64(); return n_size_b64; };

        private:
            elf_t* m__root;
            elf_t::endian_elf_t::dynsym_section_t* m__parent;

        public:
            uint32_t ofs_name() const { return m_ofs_name; }
            uint32_t value_b32() const { return m_value_b32; }
            uint32_t size_b32() const { return m_size_b32; }
            symbol_binding_t bind() const { return m_bind; }
            symbol_type_t type() const { return m_type; }

            /**
             * don't read this field, access `visibility` instead
             */
            uint8_t other() const { return m_other; }

            /**
             * section header index
             */
            uint16_t sh_idx() const { return m_sh_idx; }
            uint64_t value_b64() const { return m_value_b64; }
            uint64_t size_b64() const { return m_size_b64; }
            elf_t* _root() const { return m__root; }
            elf_t::endian_elf_t::dynsym_section_t* _parent() const { return m__parent; }
        };

        /**
         * \sa https://docs.oracle.com/cd/E37838_01/html/E36783/chapter6-18048.html Source
         * \sa https://refspecs.linuxfoundation.org/elf/gabi4+/ch5.pheader.html#note_section Source
         */

        class note_section_entry_t : public kaitai::kstruct {

        public:

            note_section_entry_t(kaitai::kstream* p__io, elf_t::endian_elf_t::note_section_t* p__parent = nullptr, elf_t* p__root = nullptr, int p_is_le = -1);

        private:
            int m__is_le;

        public:

        private:
            void _read();
            void _read_le();
            void _read_be();
            void _clean_up();

        public:
            ~note_section_entry_t();

        private:
            uint32_t m_len_name;
            uint32_t m_len_descriptor;
            uint32_t m_type;
            std::string m_name;
            std::string m_name_padding;
            std::string m_descriptor;
            std::string m_descriptor_padding;
            elf_t* m__root;
            elf_t::endian_elf_t::note_section_t* m__parent;

        public:
            uint32_t len_name() const { return m_len_name; }
            uint32_t len_descriptor() const { return m_len_descriptor; }
            uint32_t type() const { return m_type; }

            /**
             * Although the ELF specification seems to hint that the `note_name` field
             * is ASCII this isn't the case for Linux binaries that have a
             * `.gnu.build.attributes` section.
             * \sa https://fedoraproject.org/wiki/Toolchain/Watermark#Proposed_Specification_for_non-loaded_notes Source
             */
            std::string name() const { return m_name; }
            std::string name_padding() const { return m_name_padding; }
            std::string descriptor() const { return m_descriptor; }
            std::string descriptor_padding() const { return m_descriptor_padding; }
            elf_t* _root() const { return m__root; }
            elf_t::endian_elf_t::note_section_t* _parent() const { return m__parent; }
        };

        class strings_struct_t : public kaitai::kstruct {

        public:

            strings_struct_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = nullptr, elf_t* p__root = nullptr, int p_is_le = -1);

        private:
            int m__is_le;

        public:

        private:
            void _read();
            void _read_le();
            void _read_be();
            void _clean_up();

        public:
            ~strings_struct_t();

        private:
            std::unique_ptr<std::vector<std::string>> m_entries;
            elf_t* m__root;
            kaitai::kstruct* m__parent;

        public:
            std::vector<std::string>* entries() const { return m_entries.get(); }
            elf_t* _root() const { return m__root; }
            kaitai::kstruct* _parent() const { return m__parent; }
        };

    private:
        bool f_program_headers;
        std::unique_ptr<std::vector<std::unique_ptr<program_header_t>>> m_program_headers;

    public:
        std::vector<std::unique_ptr<program_header_t>>* program_headers();

    private:
        bool f_section_headers;
        std::unique_ptr<std::vector<std::unique_ptr<section_header_t>>> m_section_headers;

    public:
        std::vector<std::unique_ptr<section_header_t>>* section_headers();

    private:
        bool f_section_names;
        std::unique_ptr<strings_struct_t> m_section_names;
        bool n_section_names;

    public:
        bool _is_null_section_names() { section_names(); return n_section_names; };

    private:

    public:
        strings_struct_t* section_names();

    private:
        obj_type_t m_e_type;
        machine_t m_machine;
        uint32_t m_e_version;
        uint64_t m_entry_point;
        bool n_entry_point;

    public:
        bool _is_null_entry_point() { entry_point(); return n_entry_point; };

    private:
        uint64_t m_program_header_offset;
        bool n_program_header_offset;

    public:
        bool _is_null_program_header_offset() { program_header_offset(); return n_program_header_offset; };

    private:
        uint64_t m_section_header_offset;
        bool n_section_header_offset;

    public:
        bool _is_null_section_header_offset() { section_header_offset(); return n_section_header_offset; };

    private:
        std::string m_flags;
        uint16_t m_e_ehsize;
        uint16_t m_program_header_entry_size;
        uint16_t m_qty_program_header;
        uint16_t m_section_header_entry_size;
        uint16_t m_qty_section_header;
        uint16_t m_section_names_idx;
        elf_t* m__root;
        elf_t* m__parent;
        std::unique_ptr<std::vector<std::string>> m__raw_program_headers;
        std::unique_ptr<std::vector<std::unique_ptr<kaitai::kstream>>> m__io__raw_program_headers;
        std::unique_ptr<std::vector<std::string>> m__raw_section_headers;
        std::unique_ptr<std::vector<std::unique_ptr<kaitai::kstream>>> m__io__raw_section_headers;
        std::string m__raw_section_names;
        bool n__raw_section_names;

    public:
        bool _is_null__raw_section_names() { _raw_section_names(); return n__raw_section_names; };

    private:
        std::unique_ptr<kaitai::kstream> m__io__raw_section_names;

    public:
        obj_type_t e_type() const { return m_e_type; }
        machine_t machine() const { return m_machine; }
        uint32_t e_version() const { return m_e_version; }
        uint64_t entry_point() const { return m_entry_point; }
        uint64_t program_header_offset() const { return m_program_header_offset; }
        uint64_t section_header_offset() const { return m_section_header_offset; }
        std::string flags() const { return m_flags; }
        uint16_t e_ehsize() const { return m_e_ehsize; }
        uint16_t program_header_entry_size() const { return m_program_header_entry_size; }
        uint16_t qty_program_header() const { return m_qty_program_header; }
        uint16_t section_header_entry_size() const { return m_section_header_entry_size; }
        uint16_t qty_section_header() const { return m_qty_section_header; }
        uint16_t section_names_idx() const { return m_section_names_idx; }
        elf_t* _root() const { return m__root; }
        elf_t* _parent() const { return m__parent; }
        std::vector<std::string>* _raw_program_headers() const { return m__raw_program_headers.get(); }
        std::vector<std::unique_ptr<kaitai::kstream>>* _io__raw_program_headers() const { return m__io__raw_program_headers.get(); }
        std::vector<std::string>* _raw_section_headers() const { return m__raw_section_headers.get(); }
        std::vector<std::unique_ptr<kaitai::kstream>>* _io__raw_section_headers() const { return m__io__raw_section_headers.get(); }
        std::string _raw_section_names() const { return m__raw_section_names; }
        kaitai::kstream* _io__raw_section_names() const { return m__io__raw_section_names.get(); }
    };

private:
    bool f_sh_idx_lo_os;
    int32_t m_sh_idx_lo_os;

public:
    int32_t sh_idx_lo_os();

private:
    bool f_sh_idx_lo_reserved;
    int32_t m_sh_idx_lo_reserved;

public:
    int32_t sh_idx_lo_reserved();

private:
    bool f_sh_idx_hi_proc;
    int32_t m_sh_idx_hi_proc;

public:
    int32_t sh_idx_hi_proc();

private:
    bool f_sh_idx_lo_proc;
    int32_t m_sh_idx_lo_proc;

public:
    int32_t sh_idx_lo_proc();

private:
    bool f_sh_idx_hi_os;
    int32_t m_sh_idx_hi_os;

public:
    int32_t sh_idx_hi_os();

private:
    bool f_sh_idx_hi_reserved;
    int32_t m_sh_idx_hi_reserved;

public:
    int32_t sh_idx_hi_reserved();

private:
    std::string m_magic;
    bits_t m_bits;
    endian_t m_endian;
    uint8_t m_ei_version;
    os_abi_t m_abi;
    uint8_t m_abi_version;
    std::string m_pad;
    std::unique_ptr<endian_elf_t> m_header;
    elf_t* m__root;
    kaitai::kstruct* m__parent;

public:

    /**
     * File identification, must be 0x7f + "ELF".
     */
    std::string magic() const { return m_magic; }

    /**
     * File class: designates target machine word size (32 or 64
     * bits). The size of many integer fields in this format will
     * depend on this setting.
     */
    bits_t bits() const { return m_bits; }

    /**
     * Endianness used for all integers.
     */
    endian_t endian() const { return m_endian; }

    /**
     * ELF header version.
     */
    uint8_t ei_version() const { return m_ei_version; }

    /**
     * Specifies which OS- and ABI-related extensions will be used
     * in this ELF file.
     */
    os_abi_t abi() const { return m_abi; }

    /**
     * Version of ABI targeted by this ELF file. Interpretation
     * depends on `abi` attribute.
     */
    uint8_t abi_version() const { return m_abi_version; }
    std::string pad() const { return m_pad; }
    endian_elf_t* header() const { return m_header.get(); }
    elf_t* _root() const { return m__root; }
    kaitai::kstruct* _parent() const { return m__parent; }
};

elf.cpp

// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild

#include "elf.h"
#include "kaitai/exceptions.h"

elf_t::elf_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, elf_t* p__root) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = this;
    m_header = nullptr;
    f_sh_idx_lo_os = false;
    f_sh_idx_lo_reserved = false;
    f_sh_idx_hi_proc = false;
    f_sh_idx_lo_proc = false;
    f_sh_idx_hi_os = false;
    f_sh_idx_hi_reserved = false;
    _read();
}

void elf_t::_read() {
    m_magic = m__io->read_bytes(4);
    if (!(magic() == std::string("\x7F\x45\x4C\x46", 4))) {
        throw kaitai::validation_not_equal_error<std::string>(std::string("\x7F\x45\x4C\x46", 4), magic(), _io(), std::string("/seq/0"));
    }
    m_bits = static_cast<elf_t::bits_t>(m__io->read_u1());
    m_endian = static_cast<elf_t::endian_t>(m__io->read_u1());
    m_ei_version = m__io->read_u1();
    m_abi = static_cast<elf_t::os_abi_t>(m__io->read_u1());
    m_abi_version = m__io->read_u1();
    m_pad = m__io->read_bytes(7);
    m_header = std::unique_ptr<endian_elf_t>(new endian_elf_t(m__io, this, m__root));
}

elf_t::~elf_t() {
    _clean_up();
}

void elf_t::_clean_up() {
}

elf_t::phdr_type_flags_t::phdr_type_flags_t(uint32_t p_value, kaitai::kstream* p__io, elf_t::endian_elf_t::program_header_t* p__parent, elf_t* p__root) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m_value = p_value;
    f_read = false;
    f_write = false;
    f_execute = false;
    f_mask_proc = false;
    _read();
}

void elf_t::phdr_type_flags_t::_read() {
}

elf_t::phdr_type_flags_t::~phdr_type_flags_t() {
    _clean_up();
}

void elf_t::phdr_type_flags_t::_clean_up() {
}

bool elf_t::phdr_type_flags_t::read() {
    if (f_read)
        return m_read;
    m_read = (value() & 4) != 0;
    f_read = true;
    return m_read;
}

bool elf_t::phdr_type_flags_t::write() {
    if (f_write)
        return m_write;
    m_write = (value() & 2) != 0;
    f_write = true;
    return m_write;
}

bool elf_t::phdr_type_flags_t::execute() {
    if (f_execute)
        return m_execute;
    m_execute = (value() & 1) != 0;
    f_execute = true;
    return m_execute;
}

bool elf_t::phdr_type_flags_t::mask_proc() {
    if (f_mask_proc)
        return m_mask_proc;
    m_mask_proc = (value() & 4026531840UL) != 0;
    f_mask_proc = true;
    return m_mask_proc;
}

elf_t::section_header_flags_t::section_header_flags_t(uint32_t p_value, kaitai::kstream* p__io, elf_t::endian_elf_t::section_header_t* p__parent, elf_t* p__root) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m_value = p_value;
    f_merge = false;
    f_mask_os = false;
    f_exclude = false;
    f_mask_proc = false;
    f_strings = false;
    f_os_non_conforming = false;
    f_alloc = false;
    f_exec_instr = false;
    f_info_link = false;
    f_write = false;
    f_link_order = false;
    f_ordered = false;
    f_tls = false;
    f_group = false;
    _read();
}

void elf_t::section_header_flags_t::_read() {
}

elf_t::section_header_flags_t::~section_header_flags_t() {
    _clean_up();
}

void elf_t::section_header_flags_t::_clean_up() {
}

bool elf_t::section_header_flags_t::merge() {
    if (f_merge)
        return m_merge;
    m_merge = (value() & 16) != 0;
    f_merge = true;
    return m_merge;
}

bool elf_t::section_header_flags_t::mask_os() {
    if (f_mask_os)
        return m_mask_os;
    m_mask_os = (value() & 267386880) != 0;
    f_mask_os = true;
    return m_mask_os;
}

bool elf_t::section_header_flags_t::exclude() {
    if (f_exclude)
        return m_exclude;
    m_exclude = (value() & 134217728) != 0;
    f_exclude = true;
    return m_exclude;
}

bool elf_t::section_header_flags_t::mask_proc() {
    if (f_mask_proc)
        return m_mask_proc;
    m_mask_proc = (value() & 4026531840UL) != 0;
    f_mask_proc = true;
    return m_mask_proc;
}

bool elf_t::section_header_flags_t::strings() {
    if (f_strings)
        return m_strings;
    m_strings = (value() & 32) != 0;
    f_strings = true;
    return m_strings;
}

bool elf_t::section_header_flags_t::os_non_conforming() {
    if (f_os_non_conforming)
        return m_os_non_conforming;
    m_os_non_conforming = (value() & 256) != 0;
    f_os_non_conforming = true;
    return m_os_non_conforming;
}

bool elf_t::section_header_flags_t::alloc() {
    if (f_alloc)
        return m_alloc;
    m_alloc = (value() & 2) != 0;
    f_alloc = true;
    return m_alloc;
}

bool elf_t::section_header_flags_t::exec_instr() {
    if (f_exec_instr)
        return m_exec_instr;
    m_exec_instr = (value() & 4) != 0;
    f_exec_instr = true;
    return m_exec_instr;
}

bool elf_t::section_header_flags_t::info_link() {
    if (f_info_link)
        return m_info_link;
    m_info_link = (value() & 64) != 0;
    f_info_link = true;
    return m_info_link;
}

bool elf_t::section_header_flags_t::write() {
    if (f_write)
        return m_write;
    m_write = (value() & 1) != 0;
    f_write = true;
    return m_write;
}

bool elf_t::section_header_flags_t::link_order() {
    if (f_link_order)
        return m_link_order;
    m_link_order = (value() & 128) != 0;
    f_link_order = true;
    return m_link_order;
}

bool elf_t::section_header_flags_t::ordered() {
    if (f_ordered)
        return m_ordered;
    m_ordered = (value() & 67108864) != 0;
    f_ordered = true;
    return m_ordered;
}

bool elf_t::section_header_flags_t::tls() {
    if (f_tls)
        return m_tls;
    m_tls = (value() & 1024) != 0;
    f_tls = true;
    return m_tls;
}

bool elf_t::section_header_flags_t::group() {
    if (f_group)
        return m_group;
    m_group = (value() & 512) != 0;
    f_group = true;
    return m_group;
}

elf_t::dt_flag_1_values_t::dt_flag_1_values_t(uint32_t p_value, kaitai::kstream* p__io, elf_t::endian_elf_t::dynamic_section_entry_t* p__parent, elf_t* p__root) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m_value = p_value;
    f_singleton = false;
    f_ignmuldef = false;
    f_loadfltr = false;
    f_initfirst = false;
    f_symintpose = false;
    f_noreloc = false;
    f_confalt = false;
    f_dispreldne = false;
    f_rtld_global = false;
    f_nodelete = false;
    f_trans = false;
    f_origin = false;
    f_now = false;
    f_nohdr = false;
    f_endfiltee = false;
    f_nodirect = false;
    f_globaudit = false;
    f_noksyms = false;
    f_interpose = false;
    f_nodump = false;
    f_disprelpnd = false;
    f_noopen = false;
    f_stub = false;
    f_direct = false;
    f_edited = false;
    f_group = false;
    f_pie = false;
    f_nodeflib = false;
    _read();
}

void elf_t::dt_flag_1_values_t::_read() {
}

elf_t::dt_flag_1_values_t::~dt_flag_1_values_t() {
    _clean_up();
}

void elf_t::dt_flag_1_values_t::_clean_up() {
}

bool elf_t::dt_flag_1_values_t::singleton() {
    if (f_singleton)
        return m_singleton;
    m_singleton = (value() & 33554432) != 0;
    f_singleton = true;
    return m_singleton;
}

bool elf_t::dt_flag_1_values_t::ignmuldef() {
    if (f_ignmuldef)
        return m_ignmuldef;
    m_ignmuldef = (value() & 262144) != 0;
    f_ignmuldef = true;
    return m_ignmuldef;
}

bool elf_t::dt_flag_1_values_t::loadfltr() {
    if (f_loadfltr)
        return m_loadfltr;
    m_loadfltr = (value() & 16) != 0;
    f_loadfltr = true;
    return m_loadfltr;
}

bool elf_t::dt_flag_1_values_t::initfirst() {
    if (f_initfirst)
        return m_initfirst;
    m_initfirst = (value() & 32) != 0;
    f_initfirst = true;
    return m_initfirst;
}

bool elf_t::dt_flag_1_values_t::symintpose() {
    if (f_symintpose)
        return m_symintpose;
    m_symintpose = (value() & 8388608) != 0;
    f_symintpose = true;
    return m_symintpose;
}

bool elf_t::dt_flag_1_values_t::noreloc() {
    if (f_noreloc)
        return m_noreloc;
    m_noreloc = (value() & 4194304) != 0;
    f_noreloc = true;
    return m_noreloc;
}

bool elf_t::dt_flag_1_values_t::confalt() {
    if (f_confalt)
        return m_confalt;
    m_confalt = (value() & 8192) != 0;
    f_confalt = true;
    return m_confalt;
}

bool elf_t::dt_flag_1_values_t::dispreldne() {
    if (f_dispreldne)
        return m_dispreldne;
    m_dispreldne = (value() & 32768) != 0;
    f_dispreldne = true;
    return m_dispreldne;
}

bool elf_t::dt_flag_1_values_t::rtld_global() {
    if (f_rtld_global)
        return m_rtld_global;
    m_rtld_global = (value() & 2) != 0;
    f_rtld_global = true;
    return m_rtld_global;
}

bool elf_t::dt_flag_1_values_t::nodelete() {
    if (f_nodelete)
        return m_nodelete;
    m_nodelete = (value() & 8) != 0;
    f_nodelete = true;
    return m_nodelete;
}

bool elf_t::dt_flag_1_values_t::trans() {
    if (f_trans)
        return m_trans;
    m_trans = (value() & 512) != 0;
    f_trans = true;
    return m_trans;
}

bool elf_t::dt_flag_1_values_t::origin() {
    if (f_origin)
        return m_origin;
    m_origin = (value() & 128) != 0;
    f_origin = true;
    return m_origin;
}

bool elf_t::dt_flag_1_values_t::now() {
    if (f_now)
        return m_now;
    m_now = (value() & 1) != 0;
    f_now = true;
    return m_now;
}

bool elf_t::dt_flag_1_values_t::nohdr() {
    if (f_nohdr)
        return m_nohdr;
    m_nohdr = (value() & 1048576) != 0;
    f_nohdr = true;
    return m_nohdr;
}

bool elf_t::dt_flag_1_values_t::endfiltee() {
    if (f_endfiltee)
        return m_endfiltee;
    m_endfiltee = (value() & 16384) != 0;
    f_endfiltee = true;
    return m_endfiltee;
}

bool elf_t::dt_flag_1_values_t::nodirect() {
    if (f_nodirect)
        return m_nodirect;
    m_nodirect = (value() & 131072) != 0;
    f_nodirect = true;
    return m_nodirect;
}

bool elf_t::dt_flag_1_values_t::globaudit() {
    if (f_globaudit)
        return m_globaudit;
    m_globaudit = (value() & 16777216) != 0;
    f_globaudit = true;
    return m_globaudit;
}

bool elf_t::dt_flag_1_values_t::noksyms() {
    if (f_noksyms)
        return m_noksyms;
    m_noksyms = (value() & 524288) != 0;
    f_noksyms = true;
    return m_noksyms;
}

bool elf_t::dt_flag_1_values_t::interpose() {
    if (f_interpose)
        return m_interpose;
    m_interpose = (value() & 1024) != 0;
    f_interpose = true;
    return m_interpose;
}

bool elf_t::dt_flag_1_values_t::nodump() {
    if (f_nodump)
        return m_nodump;
    m_nodump = (value() & 4096) != 0;
    f_nodump = true;
    return m_nodump;
}

bool elf_t::dt_flag_1_values_t::disprelpnd() {
    if (f_disprelpnd)
        return m_disprelpnd;
    m_disprelpnd = (value() & 65536) != 0;
    f_disprelpnd = true;
    return m_disprelpnd;
}

bool elf_t::dt_flag_1_values_t::noopen() {
    if (f_noopen)
        return m_noopen;
    m_noopen = (value() & 64) != 0;
    f_noopen = true;
    return m_noopen;
}

bool elf_t::dt_flag_1_values_t::stub() {
    if (f_stub)
        return m_stub;
    m_stub = (value() & 67108864) != 0;
    f_stub = true;
    return m_stub;
}

bool elf_t::dt_flag_1_values_t::direct() {
    if (f_direct)
        return m_direct;
    m_direct = (value() & 256) != 0;
    f_direct = true;
    return m_direct;
}

bool elf_t::dt_flag_1_values_t::edited() {
    if (f_edited)
        return m_edited;
    m_edited = (value() & 2097152) != 0;
    f_edited = true;
    return m_edited;
}

bool elf_t::dt_flag_1_values_t::group() {
    if (f_group)
        return m_group;
    m_group = (value() & 4) != 0;
    f_group = true;
    return m_group;
}

bool elf_t::dt_flag_1_values_t::pie() {
    if (f_pie)
        return m_pie;
    m_pie = (value() & 134217728) != 0;
    f_pie = true;
    return m_pie;
}

bool elf_t::dt_flag_1_values_t::nodeflib() {
    if (f_nodeflib)
        return m_nodeflib;
    m_nodeflib = (value() & 2048) != 0;
    f_nodeflib = true;
    return m_nodeflib;
}

elf_t::endian_elf_t::endian_elf_t(kaitai::kstream* p__io, elf_t* p__parent, elf_t* p__root) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m__is_le = -1;
    m_program_headers = nullptr;
    m__raw_program_headers = nullptr;
    m__io__raw_program_headers = nullptr;
    m_section_headers = nullptr;
    m__raw_section_headers = nullptr;
    m__io__raw_section_headers = nullptr;
    m_section_names = nullptr;
    m__io__raw_section_names = nullptr;
    f_program_headers = false;
    f_section_headers = false;
    f_section_names = false;
    _read();
}

void elf_t::endian_elf_t::_read() {
    switch (_root()->endian()) {
    case elf_t::ENDIAN_LE: {
        m__is_le = true;
        break;
    }
    case elf_t::ENDIAN_BE: {
        m__is_le = false;
        break;
    }
    }

    if (m__is_le == -1) {
        throw kaitai::undecided_endianness_error("/types/endian_elf");
    } else if (m__is_le == 1) {
        _read_le();
    } else {
        _read_be();
    }
}

void elf_t::endian_elf_t::_read_le() {
    m_e_type = static_cast<elf_t::obj_type_t>(m__io->read_u2le());
    m_machine = static_cast<elf_t::machine_t>(m__io->read_u2le());
    m_e_version = m__io->read_u4le();
    n_entry_point = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_entry_point = false;
        m_entry_point = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_entry_point = false;
        m_entry_point = m__io->read_u8le();
        break;
    }
    }
    n_program_header_offset = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_program_header_offset = false;
        m_program_header_offset = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_program_header_offset = false;
        m_program_header_offset = m__io->read_u8le();
        break;
    }
    }
    n_section_header_offset = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_section_header_offset = false;
        m_section_header_offset = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_section_header_offset = false;
        m_section_header_offset = m__io->read_u8le();
        break;
    }
    }
    m_flags = m__io->read_bytes(4);
    m_e_ehsize = m__io->read_u2le();
    m_program_header_entry_size = m__io->read_u2le();
    m_qty_program_header = m__io->read_u2le();
    m_section_header_entry_size = m__io->read_u2le();
    m_qty_section_header = m__io->read_u2le();
    m_section_names_idx = m__io->read_u2le();
}

void elf_t::endian_elf_t::_read_be() {
    m_e_type = static_cast<elf_t::obj_type_t>(m__io->read_u2be());
    m_machine = static_cast<elf_t::machine_t>(m__io->read_u2be());
    m_e_version = m__io->read_u4be();
    n_entry_point = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_entry_point = false;
        m_entry_point = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_entry_point = false;
        m_entry_point = m__io->read_u8be();
        break;
    }
    }
    n_program_header_offset = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_program_header_offset = false;
        m_program_header_offset = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_program_header_offset = false;
        m_program_header_offset = m__io->read_u8be();
        break;
    }
    }
    n_section_header_offset = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_section_header_offset = false;
        m_section_header_offset = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_section_header_offset = false;
        m_section_header_offset = m__io->read_u8be();
        break;
    }
    }
    m_flags = m__io->read_bytes(4);
    m_e_ehsize = m__io->read_u2be();
    m_program_header_entry_size = m__io->read_u2be();
    m_qty_program_header = m__io->read_u2be();
    m_section_header_entry_size = m__io->read_u2be();
    m_qty_section_header = m__io->read_u2be();
    m_section_names_idx = m__io->read_u2be();
}

elf_t::endian_elf_t::~endian_elf_t() {
    _clean_up();
}

void elf_t::endian_elf_t::_clean_up() {
    if (!n_entry_point) {
    }
    if (!n_program_header_offset) {
    }
    if (!n_section_header_offset) {
    }
    if (f_program_headers) {
    }
    if (f_section_headers) {
    }
    if (f_section_names && !n_section_names) {
    }
}

elf_t::endian_elf_t::note_section_t::note_section_t(kaitai::kstream* p__io, elf_t::endian_elf_t::section_header_t* p__parent, elf_t* p__root, int p_is_le) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m__is_le = p_is_le;
    m_entries = nullptr;
    _read();
}

void elf_t::endian_elf_t::note_section_t::_read() {

    if (m__is_le == -1) {
        throw kaitai::undecided_endianness_error("/types/endian_elf/types/note_section");
    } else if (m__is_le == 1) {
        _read_le();
    } else {
        _read_be();
    }
}

void elf_t::endian_elf_t::note_section_t::_read_le() {
    m_entries = std::unique_ptr<std::vector<std::unique_ptr<note_section_entry_t>>>(new std::vector<std::unique_ptr<note_section_entry_t>>());
    {
        int i = 0;
        while (!m__io->is_eof()) {
            m_entries->push_back(std::move(std::unique_ptr<note_section_entry_t>(new note_section_entry_t(m__io, this, m__root, m__is_le))));
            i++;
        }
    }
}

void elf_t::endian_elf_t::note_section_t::_read_be() {
    m_entries = std::unique_ptr<std::vector<std::unique_ptr<note_section_entry_t>>>(new std::vector<std::unique_ptr<note_section_entry_t>>());
    {
        int i = 0;
        while (!m__io->is_eof()) {
            m_entries->push_back(std::move(std::unique_ptr<note_section_entry_t>(new note_section_entry_t(m__io, this, m__root, m__is_le))));
            i++;
        }
    }
}

elf_t::endian_elf_t::note_section_t::~note_section_t() {
    _clean_up();
}

void elf_t::endian_elf_t::note_section_t::_clean_up() {
}

elf_t::endian_elf_t::program_header_t::program_header_t(kaitai::kstream* p__io, elf_t::endian_elf_t* p__parent, elf_t* p__root, int p_is_le) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m__is_le = p_is_le;
    f_flags_obj = false;
    _read();
}

void elf_t::endian_elf_t::program_header_t::_read() {

    if (m__is_le == -1) {
        throw kaitai::undecided_endianness_error("/types/endian_elf/types/program_header");
    } else if (m__is_le == 1) {
        _read_le();
    } else {
        _read_be();
    }
}

void elf_t::endian_elf_t::program_header_t::_read_le() {
    m_type = static_cast<elf_t::ph_type_t>(m__io->read_u4le());
    n_flags64 = true;
    if (_root()->bits() == elf_t::BITS_B64) {
        n_flags64 = false;
        m_flags64 = m__io->read_u4le();
    }
    n_offset = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_offset = false;
        m_offset = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_offset = false;
        m_offset = m__io->read_u8le();
        break;
    }
    }
    n_vaddr = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_vaddr = false;
        m_vaddr = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_vaddr = false;
        m_vaddr = m__io->read_u8le();
        break;
    }
    }
    n_paddr = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_paddr = false;
        m_paddr = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_paddr = false;
        m_paddr = m__io->read_u8le();
        break;
    }
    }
    n_filesz = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_filesz = false;
        m_filesz = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_filesz = false;
        m_filesz = m__io->read_u8le();
        break;
    }
    }
    n_memsz = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_memsz = false;
        m_memsz = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_memsz = false;
        m_memsz = m__io->read_u8le();
        break;
    }
    }
    n_flags32 = true;
    if (_root()->bits() == elf_t::BITS_B32) {
        n_flags32 = false;
        m_flags32 = m__io->read_u4le();
    }
    n_align = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_align = false;
        m_align = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_align = false;
        m_align = m__io->read_u8le();
        break;
    }
    }
}

void elf_t::endian_elf_t::program_header_t::_read_be() {
    m_type = static_cast<elf_t::ph_type_t>(m__io->read_u4be());
    n_flags64 = true;
    if (_root()->bits() == elf_t::BITS_B64) {
        n_flags64 = false;
        m_flags64 = m__io->read_u4be();
    }
    n_offset = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_offset = false;
        m_offset = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_offset = false;
        m_offset = m__io->read_u8be();
        break;
    }
    }
    n_vaddr = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_vaddr = false;
        m_vaddr = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_vaddr = false;
        m_vaddr = m__io->read_u8be();
        break;
    }
    }
    n_paddr = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_paddr = false;
        m_paddr = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_paddr = false;
        m_paddr = m__io->read_u8be();
        break;
    }
    }
    n_filesz = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_filesz = false;
        m_filesz = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_filesz = false;
        m_filesz = m__io->read_u8be();
        break;
    }
    }
    n_memsz = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_memsz = false;
        m_memsz = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_memsz = false;
        m_memsz = m__io->read_u8be();
        break;
    }
    }
    n_flags32 = true;
    if (_root()->bits() == elf_t::BITS_B32) {
        n_flags32 = false;
        m_flags32 = m__io->read_u4be();
    }
    n_align = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_align = false;
        m_align = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_align = false;
        m_align = m__io->read_u8be();
        break;
    }
    }
}

elf_t::endian_elf_t::program_header_t::~program_header_t() {
    _clean_up();
}

void elf_t::endian_elf_t::program_header_t::_clean_up() {
    if (!n_flags64) {
    }
    if (!n_offset) {
    }
    if (!n_vaddr) {
    }
    if (!n_paddr) {
    }
    if (!n_filesz) {
    }
    if (!n_memsz) {
    }
    if (!n_flags32) {
    }
    if (!n_align) {
    }
    if (f_flags_obj && !n_flags_obj) {
    }
}

elf_t::phdr_type_flags_t* elf_t::endian_elf_t::program_header_t::flags_obj() {
    if (f_flags_obj)
        return m_flags_obj.get();
    if (m__is_le == 1) {
        n_flags_obj = true;
        switch (_root()->bits()) {
        case elf_t::BITS_B32: {
            n_flags_obj = false;
            m_flags_obj = std::unique_ptr<phdr_type_flags_t>(new phdr_type_flags_t(flags32(), m__io, this, m__root));
            break;
        }
        case elf_t::BITS_B64: {
            n_flags_obj = false;
            m_flags_obj = std::unique_ptr<phdr_type_flags_t>(new phdr_type_flags_t(flags64(), m__io, this, m__root));
            break;
        }
        }
    } else {
        n_flags_obj = true;
        switch (_root()->bits()) {
        case elf_t::BITS_B32: {
            n_flags_obj = false;
            m_flags_obj = std::unique_ptr<phdr_type_flags_t>(new phdr_type_flags_t(flags32(), m__io, this, m__root));
            break;
        }
        case elf_t::BITS_B64: {
            n_flags_obj = false;
            m_flags_obj = std::unique_ptr<phdr_type_flags_t>(new phdr_type_flags_t(flags64(), m__io, this, m__root));
            break;
        }
        }
    }
    f_flags_obj = true;
    return m_flags_obj.get();
}

elf_t::endian_elf_t::dynamic_section_entry_t::dynamic_section_entry_t(kaitai::kstream* p__io, elf_t::endian_elf_t::dynamic_section_t* p__parent, elf_t* p__root, int p_is_le) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m__is_le = p_is_le;
    m_flag_1_values = nullptr;
    f_tag_enum = false;
    f_flag_1_values = false;
    f_value_str = false;
    f_is_value_str = false;
    _read();
}

void elf_t::endian_elf_t::dynamic_section_entry_t::_read() {

    if (m__is_le == -1) {
        throw kaitai::undecided_endianness_error("/types/endian_elf/types/dynamic_section_entry");
    } else if (m__is_le == 1) {
        _read_le();
    } else {
        _read_be();
    }
}

void elf_t::endian_elf_t::dynamic_section_entry_t::_read_le() {
    n_tag = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_tag = false;
        m_tag = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_tag = false;
        m_tag = m__io->read_u8le();
        break;
    }
    }
    n_value_or_ptr = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_value_or_ptr = false;
        m_value_or_ptr = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_value_or_ptr = false;
        m_value_or_ptr = m__io->read_u8le();
        break;
    }
    }
}

void elf_t::endian_elf_t::dynamic_section_entry_t::_read_be() {
    n_tag = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_tag = false;
        m_tag = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_tag = false;
        m_tag = m__io->read_u8be();
        break;
    }
    }
    n_value_or_ptr = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_value_or_ptr = false;
        m_value_or_ptr = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_value_or_ptr = false;
        m_value_or_ptr = m__io->read_u8be();
        break;
    }
    }
}

elf_t::endian_elf_t::dynamic_section_entry_t::~dynamic_section_entry_t() {
    _clean_up();
}

void elf_t::endian_elf_t::dynamic_section_entry_t::_clean_up() {
    if (!n_tag) {
    }
    if (!n_value_or_ptr) {
    }
    if (f_flag_1_values && !n_flag_1_values) {
    }
    if (f_value_str && !n_value_str) {
    }
}

elf_t::dynamic_array_tags_t elf_t::endian_elf_t::dynamic_section_entry_t::tag_enum() {
    if (f_tag_enum)
        return m_tag_enum;
    m_tag_enum = static_cast<elf_t::dynamic_array_tags_t>(tag());
    f_tag_enum = true;
    return m_tag_enum;
}

elf_t::dt_flag_1_values_t* elf_t::endian_elf_t::dynamic_section_entry_t::flag_1_values() {
    if (f_flag_1_values)
        return m_flag_1_values.get();
    n_flag_1_values = true;
    if (tag_enum() == elf_t::DYNAMIC_ARRAY_TAGS_FLAGS_1) {
        n_flag_1_values = false;
        if (m__is_le == 1) {
            m_flag_1_values = std::unique_ptr<dt_flag_1_values_t>(new dt_flag_1_values_t(value_or_ptr(), m__io, this, m__root));
        } else {
            m_flag_1_values = std::unique_ptr<dt_flag_1_values_t>(new dt_flag_1_values_t(value_or_ptr(), m__io, this, m__root));
        }
        f_flag_1_values = true;
    }
    return m_flag_1_values.get();
}

std::string elf_t::endian_elf_t::dynamic_section_entry_t::value_str() {
    if (f_value_str)
        return m_value_str;
    n_value_str = true;
    if ( ((is_value_str()) && (_parent()->is_string_table_linked())) ) {
        n_value_str = false;
        kaitai::kstream *io = static_cast<elf_t::endian_elf_t::strings_struct_t*>(_parent()->_parent()->linked_section()->body())->_io();
        std::streampos _pos = io->pos();
        io->seek(value_or_ptr());
        if (m__is_le == 1) {
            m_value_str = kaitai::kstream::bytes_to_str(io->read_bytes_term(0, false, true, true), std::string("ASCII"));
        } else {
            m_value_str = kaitai::kstream::bytes_to_str(io->read_bytes_term(0, false, true, true), std::string("ASCII"));
        }
        io->seek(_pos);
        f_value_str = true;
    }
    return m_value_str;
}

bool elf_t::endian_elf_t::dynamic_section_entry_t::is_value_str() {
    if (f_is_value_str)
        return m_is_value_str;
    m_is_value_str =  ((value_or_ptr() != 0) && ( ((tag_enum() == elf_t::DYNAMIC_ARRAY_TAGS_NEEDED) || (tag_enum() == elf_t::DYNAMIC_ARRAY_TAGS_SONAME) || (tag_enum() == elf_t::DYNAMIC_ARRAY_TAGS_RPATH) || (tag_enum() == elf_t::DYNAMIC_ARRAY_TAGS_RUNPATH) || (tag_enum() == elf_t::DYNAMIC_ARRAY_TAGS_SUNW_AUXILIARY) || (tag_enum() == elf_t::DYNAMIC_ARRAY_TAGS_SUNW_FILTER) || (tag_enum() == elf_t::DYNAMIC_ARRAY_TAGS_AUXILIARY) || (tag_enum() == elf_t::DYNAMIC_ARRAY_TAGS_FILTER) || (tag_enum() == elf_t::DYNAMIC_ARRAY_TAGS_CONFIG) || (tag_enum() == elf_t::DYNAMIC_ARRAY_TAGS_DEPAUDIT) || (tag_enum() == elf_t::DYNAMIC_ARRAY_TAGS_AUDIT)) )) ;
    f_is_value_str = true;
    return m_is_value_str;
}

elf_t::endian_elf_t::section_header_t::section_header_t(kaitai::kstream* p__io, elf_t::endian_elf_t* p__parent, elf_t* p__root, int p_is_le) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m__is_le = p_is_le;
    m__io__raw_body = nullptr;
    m_flags_obj = nullptr;
    f_body = false;
    f_linked_section = false;
    f_name = false;
    f_flags_obj = false;
    _read();
}

void elf_t::endian_elf_t::section_header_t::_read() {

    if (m__is_le == -1) {
        throw kaitai::undecided_endianness_error("/types/endian_elf/types/section_header");
    } else if (m__is_le == 1) {
        _read_le();
    } else {
        _read_be();
    }
}

void elf_t::endian_elf_t::section_header_t::_read_le() {
    m_ofs_name = m__io->read_u4le();
    m_type = static_cast<elf_t::sh_type_t>(m__io->read_u4le());
    n_flags = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_flags = false;
        m_flags = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_flags = false;
        m_flags = m__io->read_u8le();
        break;
    }
    }
    n_addr = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_addr = false;
        m_addr = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_addr = false;
        m_addr = m__io->read_u8le();
        break;
    }
    }
    n_ofs_body = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_ofs_body = false;
        m_ofs_body = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_ofs_body = false;
        m_ofs_body = m__io->read_u8le();
        break;
    }
    }
    n_len_body = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_len_body = false;
        m_len_body = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_len_body = false;
        m_len_body = m__io->read_u8le();
        break;
    }
    }
    m_linked_section_idx = m__io->read_u4le();
    m_info = m__io->read_bytes(4);
    n_align = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_align = false;
        m_align = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_align = false;
        m_align = m__io->read_u8le();
        break;
    }
    }
    n_entry_size = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_entry_size = false;
        m_entry_size = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_entry_size = false;
        m_entry_size = m__io->read_u8le();
        break;
    }
    }
}

void elf_t::endian_elf_t::section_header_t::_read_be() {
    m_ofs_name = m__io->read_u4be();
    m_type = static_cast<elf_t::sh_type_t>(m__io->read_u4be());
    n_flags = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_flags = false;
        m_flags = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_flags = false;
        m_flags = m__io->read_u8be();
        break;
    }
    }
    n_addr = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_addr = false;
        m_addr = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_addr = false;
        m_addr = m__io->read_u8be();
        break;
    }
    }
    n_ofs_body = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_ofs_body = false;
        m_ofs_body = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_ofs_body = false;
        m_ofs_body = m__io->read_u8be();
        break;
    }
    }
    n_len_body = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_len_body = false;
        m_len_body = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_len_body = false;
        m_len_body = m__io->read_u8be();
        break;
    }
    }
    m_linked_section_idx = m__io->read_u4be();
    m_info = m__io->read_bytes(4);
    n_align = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_align = false;
        m_align = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_align = false;
        m_align = m__io->read_u8be();
        break;
    }
    }
    n_entry_size = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_entry_size = false;
        m_entry_size = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_entry_size = false;
        m_entry_size = m__io->read_u8be();
        break;
    }
    }
}

elf_t::endian_elf_t::section_header_t::~section_header_t() {
    _clean_up();
}

void elf_t::endian_elf_t::section_header_t::_clean_up() {
    if (!n_flags) {
    }
    if (!n_addr) {
    }
    if (!n_ofs_body) {
    }
    if (!n_len_body) {
    }
    if (!n_align) {
    }
    if (!n_entry_size) {
    }
    if (f_body && !n_body) {
    }
    if (f_name) {
    }
    if (f_flags_obj) {
    }
}

kaitai::kstruct* elf_t::endian_elf_t::section_header_t::body() {
    if (f_body)
        return m_body.get();
    kaitai::kstream *io = _root()->_io();
    std::streampos _pos = io->pos();
    io->seek(ofs_body());
    if (m__is_le == 1) {
        n_body = true;
        switch (type()) {
        case elf_t::SH_TYPE_REL: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<relocation_section_t>(new relocation_section_t(false, m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        case elf_t::SH_TYPE_NOTE: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<note_section_t>(new note_section_t(m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        case elf_t::SH_TYPE_SYMTAB: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<dynsym_section_t>(new dynsym_section_t(m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        case elf_t::SH_TYPE_STRTAB: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<strings_struct_t>(new strings_struct_t(m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        case elf_t::SH_TYPE_DYNAMIC: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<dynamic_section_t>(new dynamic_section_t(m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        case elf_t::SH_TYPE_DYNSYM: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<dynsym_section_t>(new dynsym_section_t(m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        case elf_t::SH_TYPE_RELA: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<relocation_section_t>(new relocation_section_t(true, m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        default: {
            m__raw_body = io->read_bytes(len_body());
            break;
        }
        }
    } else {
        n_body = true;
        switch (type()) {
        case elf_t::SH_TYPE_REL: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<relocation_section_t>(new relocation_section_t(false, m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        case elf_t::SH_TYPE_NOTE: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<note_section_t>(new note_section_t(m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        case elf_t::SH_TYPE_SYMTAB: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<dynsym_section_t>(new dynsym_section_t(m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        case elf_t::SH_TYPE_STRTAB: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<strings_struct_t>(new strings_struct_t(m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        case elf_t::SH_TYPE_DYNAMIC: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<dynamic_section_t>(new dynamic_section_t(m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        case elf_t::SH_TYPE_DYNSYM: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<dynsym_section_t>(new dynsym_section_t(m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        case elf_t::SH_TYPE_RELA: {
            n_body = false;
            m__raw_body = io->read_bytes(len_body());
            m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
            m_body = std::unique_ptr<relocation_section_t>(new relocation_section_t(true, m__io__raw_body.get(), this, m__root, m__is_le));
            break;
        }
        default: {
            m__raw_body = io->read_bytes(len_body());
            break;
        }
        }
    }
    io->seek(_pos);
    f_body = true;
    return m_body.get();
}

elf_t::endian_elf_t::section_header_t* elf_t::endian_elf_t::section_header_t::linked_section() {
    if (f_linked_section)
        return m_linked_section;
    n_linked_section = true;
    if ( ((linked_section_idx() != elf_t::SECTION_HEADER_IDX_SPECIAL_UNDEFINED) && (linked_section_idx() < _root()->header()->qty_section_header())) ) {
        n_linked_section = false;
        m_linked_section = _root()->header()->section_headers()->at(linked_section_idx());
    }
    f_linked_section = true;
    return m_linked_section;
}

std::string elf_t::endian_elf_t::section_header_t::name() {
    if (f_name)
        return m_name;
    kaitai::kstream *io = _root()->header()->section_names()->_io();
    std::streampos _pos = io->pos();
    io->seek(ofs_name());
    if (m__is_le == 1) {
        m_name = kaitai::kstream::bytes_to_str(io->read_bytes_term(0, false, true, true), std::string("ASCII"));
    } else {
        m_name = kaitai::kstream::bytes_to_str(io->read_bytes_term(0, false, true, true), std::string("ASCII"));
    }
    io->seek(_pos);
    f_name = true;
    return m_name;
}

elf_t::section_header_flags_t* elf_t::endian_elf_t::section_header_t::flags_obj() {
    if (f_flags_obj)
        return m_flags_obj.get();
    if (m__is_le == 1) {
        m_flags_obj = std::unique_ptr<section_header_flags_t>(new section_header_flags_t(flags(), m__io, this, m__root));
    } else {
        m_flags_obj = std::unique_ptr<section_header_flags_t>(new section_header_flags_t(flags(), m__io, this, m__root));
    }
    f_flags_obj = true;
    return m_flags_obj.get();
}

elf_t::endian_elf_t::relocation_section_t::relocation_section_t(bool p_has_addend, kaitai::kstream* p__io, elf_t::endian_elf_t::section_header_t* p__parent, elf_t* p__root, int p_is_le) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m__is_le = p_is_le;
    m_has_addend = p_has_addend;
    m_entries = nullptr;
    _read();
}

void elf_t::endian_elf_t::relocation_section_t::_read() {

    if (m__is_le == -1) {
        throw kaitai::undecided_endianness_error("/types/endian_elf/types/relocation_section");
    } else if (m__is_le == 1) {
        _read_le();
    } else {
        _read_be();
    }
}

void elf_t::endian_elf_t::relocation_section_t::_read_le() {
    m_entries = std::unique_ptr<std::vector<std::unique_ptr<relocation_section_entry_t>>>(new std::vector<std::unique_ptr<relocation_section_entry_t>>());
    {
        int i = 0;
        while (!m__io->is_eof()) {
            m_entries->push_back(std::move(std::unique_ptr<relocation_section_entry_t>(new relocation_section_entry_t(m__io, this, m__root, m__is_le))));
            i++;
        }
    }
}

void elf_t::endian_elf_t::relocation_section_t::_read_be() {
    m_entries = std::unique_ptr<std::vector<std::unique_ptr<relocation_section_entry_t>>>(new std::vector<std::unique_ptr<relocation_section_entry_t>>());
    {
        int i = 0;
        while (!m__io->is_eof()) {
            m_entries->push_back(std::move(std::unique_ptr<relocation_section_entry_t>(new relocation_section_entry_t(m__io, this, m__root, m__is_le))));
            i++;
        }
    }
}

elf_t::endian_elf_t::relocation_section_t::~relocation_section_t() {
    _clean_up();
}

void elf_t::endian_elf_t::relocation_section_t::_clean_up() {
}

elf_t::endian_elf_t::dynamic_section_t::dynamic_section_t(kaitai::kstream* p__io, elf_t::endian_elf_t::section_header_t* p__parent, elf_t* p__root, int p_is_le) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m__is_le = p_is_le;
    m_entries = nullptr;
    f_is_string_table_linked = false;
    _read();
}

void elf_t::endian_elf_t::dynamic_section_t::_read() {

    if (m__is_le == -1) {
        throw kaitai::undecided_endianness_error("/types/endian_elf/types/dynamic_section");
    } else if (m__is_le == 1) {
        _read_le();
    } else {
        _read_be();
    }
}

void elf_t::endian_elf_t::dynamic_section_t::_read_le() {
    m_entries = std::unique_ptr<std::vector<std::unique_ptr<dynamic_section_entry_t>>>(new std::vector<std::unique_ptr<dynamic_section_entry_t>>());
    {
        int i = 0;
        while (!m__io->is_eof()) {
            m_entries->push_back(std::move(std::unique_ptr<dynamic_section_entry_t>(new dynamic_section_entry_t(m__io, this, m__root, m__is_le))));
            i++;
        }
    }
}

void elf_t::endian_elf_t::dynamic_section_t::_read_be() {
    m_entries = std::unique_ptr<std::vector<std::unique_ptr<dynamic_section_entry_t>>>(new std::vector<std::unique_ptr<dynamic_section_entry_t>>());
    {
        int i = 0;
        while (!m__io->is_eof()) {
            m_entries->push_back(std::move(std::unique_ptr<dynamic_section_entry_t>(new dynamic_section_entry_t(m__io, this, m__root, m__is_le))));
            i++;
        }
    }
}

elf_t::endian_elf_t::dynamic_section_t::~dynamic_section_t() {
    _clean_up();
}

void elf_t::endian_elf_t::dynamic_section_t::_clean_up() {
}

bool elf_t::endian_elf_t::dynamic_section_t::is_string_table_linked() {
    if (f_is_string_table_linked)
        return m_is_string_table_linked;
    m_is_string_table_linked = _parent()->linked_section()->type() == elf_t::SH_TYPE_STRTAB;
    f_is_string_table_linked = true;
    return m_is_string_table_linked;
}

elf_t::endian_elf_t::dynsym_section_t::dynsym_section_t(kaitai::kstream* p__io, elf_t::endian_elf_t::section_header_t* p__parent, elf_t* p__root, int p_is_le) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m__is_le = p_is_le;
    m_entries = nullptr;
    f_is_string_table_linked = false;
    _read();
}

void elf_t::endian_elf_t::dynsym_section_t::_read() {

    if (m__is_le == -1) {
        throw kaitai::undecided_endianness_error("/types/endian_elf/types/dynsym_section");
    } else if (m__is_le == 1) {
        _read_le();
    } else {
        _read_be();
    }
}

void elf_t::endian_elf_t::dynsym_section_t::_read_le() {
    m_entries = std::unique_ptr<std::vector<std::unique_ptr<dynsym_section_entry_t>>>(new std::vector<std::unique_ptr<dynsym_section_entry_t>>());
    {
        int i = 0;
        while (!m__io->is_eof()) {
            m_entries->push_back(std::move(std::unique_ptr<dynsym_section_entry_t>(new dynsym_section_entry_t(m__io, this, m__root, m__is_le))));
            i++;
        }
    }
}

void elf_t::endian_elf_t::dynsym_section_t::_read_be() {
    m_entries = std::unique_ptr<std::vector<std::unique_ptr<dynsym_section_entry_t>>>(new std::vector<std::unique_ptr<dynsym_section_entry_t>>());
    {
        int i = 0;
        while (!m__io->is_eof()) {
            m_entries->push_back(std::move(std::unique_ptr<dynsym_section_entry_t>(new dynsym_section_entry_t(m__io, this, m__root, m__is_le))));
            i++;
        }
    }
}

elf_t::endian_elf_t::dynsym_section_t::~dynsym_section_t() {
    _clean_up();
}

void elf_t::endian_elf_t::dynsym_section_t::_clean_up() {
}

bool elf_t::endian_elf_t::dynsym_section_t::is_string_table_linked() {
    if (f_is_string_table_linked)
        return m_is_string_table_linked;
    m_is_string_table_linked = _parent()->linked_section()->type() == elf_t::SH_TYPE_STRTAB;
    f_is_string_table_linked = true;
    return m_is_string_table_linked;
}

elf_t::endian_elf_t::relocation_section_entry_t::relocation_section_entry_t(kaitai::kstream* p__io, elf_t::endian_elf_t::relocation_section_t* p__parent, elf_t* p__root, int p_is_le) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m__is_le = p_is_le;
    _read();
}

void elf_t::endian_elf_t::relocation_section_entry_t::_read() {

    if (m__is_le == -1) {
        throw kaitai::undecided_endianness_error("/types/endian_elf/types/relocation_section_entry");
    } else if (m__is_le == 1) {
        _read_le();
    } else {
        _read_be();
    }
}

void elf_t::endian_elf_t::relocation_section_entry_t::_read_le() {
    n_offset = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_offset = false;
        m_offset = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_offset = false;
        m_offset = m__io->read_u8le();
        break;
    }
    }
    n_info = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_info = false;
        m_info = m__io->read_u4le();
        break;
    }
    case elf_t::BITS_B64: {
        n_info = false;
        m_info = m__io->read_u8le();
        break;
    }
    }
    n_addend = true;
    if (_parent()->has_addend()) {
        n_addend = false;
        n_addend = true;
        switch (_root()->bits()) {
        case elf_t::BITS_B32: {
            n_addend = false;
            m_addend = m__io->read_s4le();
            break;
        }
        case elf_t::BITS_B64: {
            n_addend = false;
            m_addend = m__io->read_s8le();
            break;
        }
        }
    }
}

void elf_t::endian_elf_t::relocation_section_entry_t::_read_be() {
    n_offset = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_offset = false;
        m_offset = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_offset = false;
        m_offset = m__io->read_u8be();
        break;
    }
    }
    n_info = true;
    switch (_root()->bits()) {
    case elf_t::BITS_B32: {
        n_info = false;
        m_info = m__io->read_u4be();
        break;
    }
    case elf_t::BITS_B64: {
        n_info = false;
        m_info = m__io->read_u8be();
        break;
    }
    }
    n_addend = true;
    if (_parent()->has_addend()) {
        n_addend = false;
        n_addend = true;
        switch (_root()->bits()) {
        case elf_t::BITS_B32: {
            n_addend = false;
            m_addend = m__io->read_s4be();
            break;
        }
        case elf_t::BITS_B64: {
            n_addend = false;
            m_addend = m__io->read_s8be();
            break;
        }
        }
    }
}

elf_t::endian_elf_t::relocation_section_entry_t::~relocation_section_entry_t() {
    _clean_up();
}

void elf_t::endian_elf_t::relocation_section_entry_t::_clean_up() {
    if (!n_offset) {
    }
    if (!n_info) {
    }
    if (!n_addend) {
    }
}

elf_t::endian_elf_t::dynsym_section_entry_t::dynsym_section_entry_t(kaitai::kstream* p__io, elf_t::endian_elf_t::dynsym_section_t* p__parent, elf_t* p__root, int p_is_le) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m__is_le = p_is_le;
    f_is_sh_idx_reserved = false;
    f_is_sh_idx_os = false;
    f_is_sh_idx_proc = false;
    f_size = false;
    f_visibility = false;
    f_value = false;
    f_name = false;
    f_sh_idx_special = false;
    _read();
}

void elf_t::endian_elf_t::dynsym_section_entry_t::_read() {

    if (m__is_le == -1) {
        throw kaitai::undecided_endianness_error("/types/endian_elf/types/dynsym_section_entry");
    } else if (m__is_le == 1) {
        _read_le();
    } else {
        _read_be();
    }
}

void elf_t::endian_elf_t::dynsym_section_entry_t::_read_le() {
    m_ofs_name = m__io->read_u4le();
    n_value_b32 = true;
    if (_root()->bits() == elf_t::BITS_B32) {
        n_value_b32 = false;
        m_value_b32 = m__io->read_u4le();
    }
    n_size_b32 = true;
    if (_root()->bits() == elf_t::BITS_B32) {
        n_size_b32 = false;
        m_size_b32 = m__io->read_u4le();
    }
    m_bind = static_cast<elf_t::symbol_binding_t>(m__io->read_bits_int_be(4));
    m_type = static_cast<elf_t::symbol_type_t>(m__io->read_bits_int_be(4));
    m__io->align_to_byte();
    m_other = m__io->read_u1();
    m_sh_idx = m__io->read_u2le();
    n_value_b64 = true;
    if (_root()->bits() == elf_t::BITS_B64) {
        n_value_b64 = false;
        m_value_b64 = m__io->read_u8le();
    }
    n_size_b64 = true;
    if (_root()->bits() == elf_t::BITS_B64) {
        n_size_b64 = false;
        m_size_b64 = m__io->read_u8le();
    }
}

void elf_t::endian_elf_t::dynsym_section_entry_t::_read_be() {
    m_ofs_name = m__io->read_u4be();
    n_value_b32 = true;
    if (_root()->bits() == elf_t::BITS_B32) {
        n_value_b32 = false;
        m_value_b32 = m__io->read_u4be();
    }
    n_size_b32 = true;
    if (_root()->bits() == elf_t::BITS_B32) {
        n_size_b32 = false;
        m_size_b32 = m__io->read_u4be();
    }
    m_bind = static_cast<elf_t::symbol_binding_t>(m__io->read_bits_int_be(4));
    m_type = static_cast<elf_t::symbol_type_t>(m__io->read_bits_int_be(4));
    m__io->align_to_byte();
    m_other = m__io->read_u1();
    m_sh_idx = m__io->read_u2be();
    n_value_b64 = true;
    if (_root()->bits() == elf_t::BITS_B64) {
        n_value_b64 = false;
        m_value_b64 = m__io->read_u8be();
    }
    n_size_b64 = true;
    if (_root()->bits() == elf_t::BITS_B64) {
        n_size_b64 = false;
        m_size_b64 = m__io->read_u8be();
    }
}

elf_t::endian_elf_t::dynsym_section_entry_t::~dynsym_section_entry_t() {
    _clean_up();
}

void elf_t::endian_elf_t::dynsym_section_entry_t::_clean_up() {
    if (!n_value_b32) {
    }
    if (!n_size_b32) {
    }
    if (!n_value_b64) {
    }
    if (!n_size_b64) {
    }
    if (f_name && !n_name) {
    }
}

bool elf_t::endian_elf_t::dynsym_section_entry_t::is_sh_idx_reserved() {
    if (f_is_sh_idx_reserved)
        return m_is_sh_idx_reserved;
    m_is_sh_idx_reserved =  ((sh_idx() >= _root()->sh_idx_lo_reserved()) && (sh_idx() <= _root()->sh_idx_hi_reserved())) ;
    f_is_sh_idx_reserved = true;
    return m_is_sh_idx_reserved;
}

bool elf_t::endian_elf_t::dynsym_section_entry_t::is_sh_idx_os() {
    if (f_is_sh_idx_os)
        return m_is_sh_idx_os;
    m_is_sh_idx_os =  ((sh_idx() >= _root()->sh_idx_lo_os()) && (sh_idx() <= _root()->sh_idx_hi_os())) ;
    f_is_sh_idx_os = true;
    return m_is_sh_idx_os;
}

bool elf_t::endian_elf_t::dynsym_section_entry_t::is_sh_idx_proc() {
    if (f_is_sh_idx_proc)
        return m_is_sh_idx_proc;
    m_is_sh_idx_proc =  ((sh_idx() >= _root()->sh_idx_lo_proc()) && (sh_idx() <= _root()->sh_idx_hi_proc())) ;
    f_is_sh_idx_proc = true;
    return m_is_sh_idx_proc;
}

uint64_t elf_t::endian_elf_t::dynsym_section_entry_t::size() {
    if (f_size)
        return m_size;
    m_size = ((_root()->bits() == elf_t::BITS_B32) ? (size_b32()) : (((_root()->bits() == elf_t::BITS_B64) ? (size_b64()) : (0))));
    f_size = true;
    return m_size;
}

elf_t::symbol_visibility_t elf_t::endian_elf_t::dynsym_section_entry_t::visibility() {
    if (f_visibility)
        return m_visibility;
    m_visibility = static_cast<elf_t::symbol_visibility_t>((other() & 3));
    f_visibility = true;
    return m_visibility;
}

uint64_t elf_t::endian_elf_t::dynsym_section_entry_t::value() {
    if (f_value)
        return m_value;
    m_value = ((_root()->bits() == elf_t::BITS_B32) ? (value_b32()) : (((_root()->bits() == elf_t::BITS_B64) ? (value_b64()) : (0))));
    f_value = true;
    return m_value;
}

std::string elf_t::endian_elf_t::dynsym_section_entry_t::name() {
    if (f_name)
        return m_name;
    n_name = true;
    if ( ((ofs_name() != 0) && (_parent()->is_string_table_linked())) ) {
        n_name = false;
        kaitai::kstream *io = static_cast<elf_t::endian_elf_t::strings_struct_t*>(_parent()->_parent()->linked_section()->body())->_io();
        std::streampos _pos = io->pos();
        io->seek(ofs_name());
        if (m__is_le == 1) {
            m_name = kaitai::kstream::bytes_to_str(io->read_bytes_term(0, false, true, true), std::string("ASCII"));
        } else {
            m_name = kaitai::kstream::bytes_to_str(io->read_bytes_term(0, false, true, true), std::string("ASCII"));
        }
        io->seek(_pos);
        f_name = true;
    }
    return m_name;
}

elf_t::section_header_idx_special_t elf_t::endian_elf_t::dynsym_section_entry_t::sh_idx_special() {
    if (f_sh_idx_special)
        return m_sh_idx_special;
    m_sh_idx_special = static_cast<elf_t::section_header_idx_special_t>(sh_idx());
    f_sh_idx_special = true;
    return m_sh_idx_special;
}

elf_t::endian_elf_t::note_section_entry_t::note_section_entry_t(kaitai::kstream* p__io, elf_t::endian_elf_t::note_section_t* p__parent, elf_t* p__root, int p_is_le) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m__is_le = p_is_le;
    _read();
}

void elf_t::endian_elf_t::note_section_entry_t::_read() {

    if (m__is_le == -1) {
        throw kaitai::undecided_endianness_error("/types/endian_elf/types/note_section_entry");
    } else if (m__is_le == 1) {
        _read_le();
    } else {
        _read_be();
    }
}

void elf_t::endian_elf_t::note_section_entry_t::_read_le() {
    m_len_name = m__io->read_u4le();
    m_len_descriptor = m__io->read_u4le();
    m_type = m__io->read_u4le();
    m_name = kaitai::kstream::bytes_terminate(m__io->read_bytes(len_name()), 0, false);
    m_name_padding = m__io->read_bytes(kaitai::kstream::mod(-(len_name()), 4));
    m_descriptor = m__io->read_bytes(len_descriptor());
    m_descriptor_padding = m__io->read_bytes(kaitai::kstream::mod(-(len_descriptor()), 4));
}

void elf_t::endian_elf_t::note_section_entry_t::_read_be() {
    m_len_name = m__io->read_u4be();
    m_len_descriptor = m__io->read_u4be();
    m_type = m__io->read_u4be();
    m_name = kaitai::kstream::bytes_terminate(m__io->read_bytes(len_name()), 0, false);
    m_name_padding = m__io->read_bytes(kaitai::kstream::mod(-(len_name()), 4));
    m_descriptor = m__io->read_bytes(len_descriptor());
    m_descriptor_padding = m__io->read_bytes(kaitai::kstream::mod(-(len_descriptor()), 4));
}

elf_t::endian_elf_t::note_section_entry_t::~note_section_entry_t() {
    _clean_up();
}

void elf_t::endian_elf_t::note_section_entry_t::_clean_up() {
}

elf_t::endian_elf_t::strings_struct_t::strings_struct_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, elf_t* p__root, int p_is_le) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m__is_le = p_is_le;
    m_entries = nullptr;
    _read();
}

void elf_t::endian_elf_t::strings_struct_t::_read() {

    if (m__is_le == -1) {
        throw kaitai::undecided_endianness_error("/types/endian_elf/types/strings_struct");
    } else if (m__is_le == 1) {
        _read_le();
    } else {
        _read_be();
    }
}

void elf_t::endian_elf_t::strings_struct_t::_read_le() {
    m_entries = std::unique_ptr<std::vector<std::string>>(new std::vector<std::string>());
    {
        int i = 0;
        while (!m__io->is_eof()) {
            m_entries->push_back(std::move(kaitai::kstream::bytes_to_str(m__io->read_bytes_term(0, false, true, true), std::string("ASCII"))));
            i++;
        }
    }
}

void elf_t::endian_elf_t::strings_struct_t::_read_be() {
    m_entries = std::unique_ptr<std::vector<std::string>>(new std::vector<std::string>());
    {
        int i = 0;
        while (!m__io->is_eof()) {
            m_entries->push_back(std::move(kaitai::kstream::bytes_to_str(m__io->read_bytes_term(0, false, true, true), std::string("ASCII"))));
            i++;
        }
    }
}

elf_t::endian_elf_t::strings_struct_t::~strings_struct_t() {
    _clean_up();
}

void elf_t::endian_elf_t::strings_struct_t::_clean_up() {
}

std::vector<std::unique_ptr<elf_t::endian_elf_t::program_header_t>>* elf_t::endian_elf_t::program_headers() {
    if (f_program_headers)
        return m_program_headers.get();
    std::streampos _pos = m__io->pos();
    m__io->seek(program_header_offset());
    if (m__is_le == 1) {
        int l_program_headers = qty_program_header();
        m__raw_program_headers = std::unique_ptr<std::vector<std::string>>(new std::vector<std::string>());
        m__raw_program_headers->reserve(l_program_headers);
        m__io__raw_program_headers = std::unique_ptr<std::vector<std::unique_ptr<kaitai::kstream>>>(new std::vector<std::unique_ptr<kaitai::kstream>>());
        m__io__raw_program_headers->reserve(l_program_headers);
        m_program_headers = std::unique_ptr<std::vector<std::unique_ptr<program_header_t>>>(new std::vector<std::unique_ptr<program_header_t>>());
        m_program_headers->reserve(l_program_headers);
        for (int i = 0; i < l_program_headers; i++) {
            m__raw_program_headers->push_back(std::move(m__io->read_bytes(program_header_entry_size())));
            kaitai::kstream* io__raw_program_headers = new kaitai::kstream(m__raw_program_headers->at(m__raw_program_headers->size() - 1));
            m__io__raw_program_headers->emplace_back(io__raw_program_headers);
            m_program_headers->push_back(std::move(std::unique_ptr<program_header_t>(new program_header_t(io__raw_program_headers, this, m__root, m__is_le))));
        }
    } else {
        int l_program_headers = qty_program_header();
        m__raw_program_headers = std::unique_ptr<std::vector<std::string>>(new std::vector<std::string>());
        m__raw_program_headers->reserve(l_program_headers);
        m__io__raw_program_headers = std::unique_ptr<std::vector<std::unique_ptr<kaitai::kstream>>>(new std::vector<std::unique_ptr<kaitai::kstream>>());
        m__io__raw_program_headers->reserve(l_program_headers);
        m_program_headers = std::unique_ptr<std::vector<std::unique_ptr<program_header_t>>>(new std::vector<std::unique_ptr<program_header_t>>());
        m_program_headers->reserve(l_program_headers);
        for (int i = 0; i < l_program_headers; i++) {
            m__raw_program_headers->push_back(std::move(m__io->read_bytes(program_header_entry_size())));
            kaitai::kstream* io__raw_program_headers = new kaitai::kstream(m__raw_program_headers->at(m__raw_program_headers->size() - 1));
            m__io__raw_program_headers->emplace_back(io__raw_program_headers);
            m_program_headers->push_back(std::move(std::unique_ptr<program_header_t>(new program_header_t(io__raw_program_headers, this, m__root, m__is_le))));
        }
    }
    m__io->seek(_pos);
    f_program_headers = true;
    return m_program_headers.get();
}

std::vector<std::unique_ptr<elf_t::endian_elf_t::section_header_t>>* elf_t::endian_elf_t::section_headers() {
    if (f_section_headers)
        return m_section_headers.get();
    std::streampos _pos = m__io->pos();
    m__io->seek(section_header_offset());
    if (m__is_le == 1) {
        int l_section_headers = qty_section_header();
        m__raw_section_headers = std::unique_ptr<std::vector<std::string>>(new std::vector<std::string>());
        m__raw_section_headers->reserve(l_section_headers);
        m__io__raw_section_headers = std::unique_ptr<std::vector<std::unique_ptr<kaitai::kstream>>>(new std::vector<std::unique_ptr<kaitai::kstream>>());
        m__io__raw_section_headers->reserve(l_section_headers);
        m_section_headers = std::unique_ptr<std::vector<std::unique_ptr<section_header_t>>>(new std::vector<std::unique_ptr<section_header_t>>());
        m_section_headers->reserve(l_section_headers);
        for (int i = 0; i < l_section_headers; i++) {
            m__raw_section_headers->push_back(std::move(m__io->read_bytes(section_header_entry_size())));
            kaitai::kstream* io__raw_section_headers = new kaitai::kstream(m__raw_section_headers->at(m__raw_section_headers->size() - 1));
            m__io__raw_section_headers->emplace_back(io__raw_section_headers);
            m_section_headers->push_back(std::move(std::unique_ptr<section_header_t>(new section_header_t(io__raw_section_headers, this, m__root, m__is_le))));
        }
    } else {
        int l_section_headers = qty_section_header();
        m__raw_section_headers = std::unique_ptr<std::vector<std::string>>(new std::vector<std::string>());
        m__raw_section_headers->reserve(l_section_headers);
        m__io__raw_section_headers = std::unique_ptr<std::vector<std::unique_ptr<kaitai::kstream>>>(new std::vector<std::unique_ptr<kaitai::kstream>>());
        m__io__raw_section_headers->reserve(l_section_headers);
        m_section_headers = std::unique_ptr<std::vector<std::unique_ptr<section_header_t>>>(new std::vector<std::unique_ptr<section_header_t>>());
        m_section_headers->reserve(l_section_headers);
        for (int i = 0; i < l_section_headers; i++) {
            m__raw_section_headers->push_back(std::move(m__io->read_bytes(section_header_entry_size())));
            kaitai::kstream* io__raw_section_headers = new kaitai::kstream(m__raw_section_headers->at(m__raw_section_headers->size() - 1));
            m__io__raw_section_headers->emplace_back(io__raw_section_headers);
            m_section_headers->push_back(std::move(std::unique_ptr<section_header_t>(new section_header_t(io__raw_section_headers, this, m__root, m__is_le))));
        }
    }
    m__io->seek(_pos);
    f_section_headers = true;
    return m_section_headers.get();
}

elf_t::endian_elf_t::strings_struct_t* elf_t::endian_elf_t::section_names() {
    if (f_section_names)
        return m_section_names.get();
    n_section_names = true;
    if ( ((section_names_idx() != elf_t::SECTION_HEADER_IDX_SPECIAL_UNDEFINED) && (section_names_idx() < _root()->header()->qty_section_header())) ) {
        n_section_names = false;
        std::streampos _pos = m__io->pos();
        m__io->seek(section_headers()->at(section_names_idx())->ofs_body());
        if (m__is_le == 1) {
            m__raw_section_names = m__io->read_bytes(section_headers()->at(section_names_idx())->len_body());
            m__io__raw_section_names = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_section_names));
            m_section_names = std::unique_ptr<strings_struct_t>(new strings_struct_t(m__io__raw_section_names.get(), this, m__root, m__is_le));
        } else {
            m__raw_section_names = m__io->read_bytes(section_headers()->at(section_names_idx())->len_body());
            m__io__raw_section_names = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_section_names));
            m_section_names = std::unique_ptr<strings_struct_t>(new strings_struct_t(m__io__raw_section_names.get(), this, m__root, m__is_le));
        }
        m__io->seek(_pos);
        f_section_names = true;
    }
    return m_section_names.get();
}

int32_t elf_t::sh_idx_lo_os() {
    if (f_sh_idx_lo_os)
        return m_sh_idx_lo_os;
    m_sh_idx_lo_os = 65312;
    f_sh_idx_lo_os = true;
    return m_sh_idx_lo_os;
}

int32_t elf_t::sh_idx_lo_reserved() {
    if (f_sh_idx_lo_reserved)
        return m_sh_idx_lo_reserved;
    m_sh_idx_lo_reserved = 65280;
    f_sh_idx_lo_reserved = true;
    return m_sh_idx_lo_reserved;
}

int32_t elf_t::sh_idx_hi_proc() {
    if (f_sh_idx_hi_proc)
        return m_sh_idx_hi_proc;
    m_sh_idx_hi_proc = 65311;
    f_sh_idx_hi_proc = true;
    return m_sh_idx_hi_proc;
}

int32_t elf_t::sh_idx_lo_proc() {
    if (f_sh_idx_lo_proc)
        return m_sh_idx_lo_proc;
    m_sh_idx_lo_proc = 65280;
    f_sh_idx_lo_proc = true;
    return m_sh_idx_lo_proc;
}

int32_t elf_t::sh_idx_hi_os() {
    if (f_sh_idx_hi_os)
        return m_sh_idx_hi_os;
    m_sh_idx_hi_os = 65343;
    f_sh_idx_hi_os = true;
    return m_sh_idx_hi_os;
}

int32_t elf_t::sh_idx_hi_reserved() {
    if (f_sh_idx_hi_reserved)
        return m_sh_idx_hi_reserved;
    m_sh_idx_hi_reserved = 65535;
    f_sh_idx_hi_reserved = true;
    return m_sh_idx_hi_reserved;
}