当前位置: 首页>>代码示例>>C++>>正文


C++ ObjectImage::section_end方法代码示例

本文整理汇总了C++中ObjectImage::section_end方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectImage::section_end方法的具体用法?C++ ObjectImage::section_end怎么用?C++ ObjectImage::section_end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjectImage的用法示例。


在下文中一共展示了ObjectImage::section_end方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NotifyObjectEmitted

    virtual void NotifyObjectEmitted(const ObjectImage &obj)
#endif
    {
        int8_t gc_state = jl_gc_safe_enter();
        uv_rwlock_wrlock(&threadsafe);
        jl_gc_safe_leave(gc_state);
#ifdef LLVM36
        object::section_iterator Section = obj.section_begin();
        object::section_iterator EndSection = obj.section_end();
#else
        object::section_iterator Section = obj.begin_sections();
        object::section_iterator EndSection = obj.end_sections();
#endif

#if defined(_OS_WINDOWS_)
        uint64_t SectionAddrCheck = 0; // assert that all of the Sections are at the same location
        uint8_t *UnwindData = NULL;
#if defined(_CPU_X86_64_)
        uint8_t *catchjmp = NULL;
        for (const object::SymbolRef &sym_iter : obj.symbols()) {
            StringRef sName;
#ifdef LLVM37
            sName = sym_iter.getName().get();
#else
            sym_iter.getName(sName);
#endif
            uint8_t **pAddr = NULL;
            if (sName.equals("__UnwindData")) {
                pAddr = &UnwindData;
            }
            else if (sName.equals("__catchjmp")) {
                pAddr = &catchjmp;
            }
            if (pAddr) {
                uint64_t Addr, SectionAddr;
#if defined(LLVM38)
                Addr = sym_iter.getAddress().get();
                Section = sym_iter.getSection().get();
                assert(Section != EndSection && Section->isText());
                SectionAddr = L.getSectionLoadAddress(*Section);
#elif defined(LLVM37)
                Addr = sym_iter.getAddress().get();
                sym_iter.getSection(Section);
                assert(Section != EndSection && Section->isText());
                Section->getName(sName);
                SectionAddr = L.getSectionLoadAddress(sName);
#elif defined(LLVM36)
                sym_iter.getAddress(Addr);
                sym_iter.getSection(Section);
                assert(Section != EndSection && Section->isText());
                Section->getName(sName);
                SectionAddr = L.getSectionLoadAddress(sName);
#else // LLVM35
                sym_iter.getAddress(Addr);
                sym_iter.getSection(Section);
                assert(Section != EndSection);
                assert(!Section->isText(isText) && isText);
                Section->getAddress(SectionAddr);
#endif
#ifdef LLVM36
                Addr += SectionAddr;
#endif
                *pAddr = (uint8_t*)Addr;
                if (SectionAddrCheck)
                    assert(SectionAddrCheck == SectionAddr);
                else
                    SectionAddrCheck = SectionAddr;
            }
        }
        assert(catchjmp);
        assert(UnwindData);
        assert(SectionAddrCheck);
        catchjmp[0] = 0x48;
        catchjmp[1] = 0xb8; // mov RAX, QWORD PTR [&_seh_exception_handle]
        *(uint64_t*)(&catchjmp[2]) = (uint64_t)&_seh_exception_handler;
        catchjmp[10] = 0xff;
        catchjmp[11] = 0xe0; // jmp RAX
        UnwindData[0] = 0x09; // version info, UNW_FLAG_EHANDLER
        UnwindData[1] = 4;    // size of prolog (bytes)
        UnwindData[2] = 2;    // count of unwind codes (slots)
        UnwindData[3] = 0x05; // frame register (rbp) = rsp
        UnwindData[4] = 4;    // second instruction
        UnwindData[5] = 0x03; // mov RBP, RSP
        UnwindData[6] = 1;    // first instruction
        UnwindData[7] = 0x50; // push RBP
        *(DWORD*)&UnwindData[8] = (DWORD)(catchjmp - (uint8_t*)SectionAddrCheck); // relative location of catchjmp
#endif // defined(_OS_X86_64_)
#endif // defined(_OS_WINDOWS_)

#ifdef LLVM37
        auto symbols = object::computeSymbolSizes(obj);
        for(const auto &sym_size : symbols) {
            const object::SymbolRef &sym_iter = sym_size.first;
            object::SymbolRef::Type SymbolType = sym_iter.getType();
            if (SymbolType != object::SymbolRef::ST_Function) continue;
            uint64_t Size = sym_size.second;
            uint64_t Addr = sym_iter.getAddress().get();
#ifdef LLVM38
            Section = sym_iter.getSection().get();
#else
//.........这里部分代码省略.........
开发者ID:btaidm,项目名称:julia,代码行数:101,代码来源:debuginfo.cpp

示例2: NotifyObjectEmitted

    virtual void NotifyObjectEmitted(const ObjectImage &obj)
#endif
    {
        uint64_t Addr;
        uint64_t Size;
        object::SymbolRef::Type SymbolType;
#ifdef LLVM36
        object::section_iterator Section = obj.section_begin();
        object::section_iterator EndSection = obj.section_end();
        uint64_t SectionAddr = 0;
        StringRef sName;
#else
        object::section_iterator Section = obj.begin_sections();
        object::section_iterator EndSection = obj.end_sections();
        bool isText;
#ifndef _OS_LINUX_
        StringRef sName;
#endif
#endif

#ifndef LLVM36
        uint64_t SectionAddr = 0;
#endif
        uint64_t SectionSize = 0;
        uint64_t SectionAddrCheck = 0; // assert that all of the Sections are at the same location

#if defined(_OS_WINDOWS_)
#if defined(_CPU_X86_64_)
        uint8_t *UnwindData = NULL;
        uint8_t *catchjmp = NULL;
        for (const object::SymbolRef &sym_iter : obj.symbols()) {
#  ifdef LLVM37
            sName = sym_iter.getName().get();
#  else
            sym_iter.getName(sName);
#  endif
            if (sName.equals("__UnwindData")) {
#  ifdef LLVM37
                Addr = sym_iter.getAddress().get();
#  else
                sym_iter.getAddress(Addr);
#  endif
                sym_iter.getSection(Section);
#  ifdef LLVM36
                assert(Section->isText());
                Section->getName(sName);
                SectionAddr = L.getSectionLoadAddress(sName);
                Addr += SectionAddr;
#  else
                if (Section->isText(isText) || !isText) assert(0 && "!isText");
                Section->getAddress(SectionAddr);
#  endif
                UnwindData = (uint8_t*)Addr;
                if (SectionAddrCheck)
                    assert(SectionAddrCheck == SectionAddr);
                else
                    SectionAddrCheck = SectionAddr;
            }
            if (sName.equals("__catchjmp")) {
#  ifdef LLVM37
                Addr = sym_iter.getAddress().get();
#  else
                sym_iter.getAddress(Addr);
#  endif
                sym_iter.getSection(Section);
#  ifdef LLVM36
                assert(Section->isText());
                Section->getName(sName);
                SectionAddr = L.getSectionLoadAddress(sName);
                Addr += SectionAddr;
#  else
                if (Section->isText(isText) || !isText) assert(0 && "!isText");
                Section->getAddress(SectionAddr);
#  endif
                catchjmp = (uint8_t*)Addr;
                if (SectionAddrCheck)
                    assert(SectionAddrCheck == SectionAddr);
                else
                    SectionAddrCheck = SectionAddr;
            }
        }
        assert(catchjmp);
        assert(UnwindData);
        catchjmp[0] = 0x48;
        catchjmp[1] = 0xb8; // mov RAX, QWORD PTR [&_seh_exception_handle]
        *(uint64_t*)(&catchjmp[2]) = (uint64_t)&_seh_exception_handler;
        catchjmp[10] = 0xff;
        catchjmp[11] = 0xe0; // jmp RAX
        UnwindData[0] = 0x09; // version info, UNW_FLAG_EHANDLER
        UnwindData[1] = 4;    // size of prolog (bytes)
        UnwindData[2] = 2;    // count of unwind codes (slots)
        UnwindData[3] = 0x05; // frame register (rbp) = rsp
        UnwindData[4] = 4;    // second instruction
        UnwindData[5] = 0x03; // mov RBP, RSP
        UnwindData[6] = 1;    // first instruction
        UnwindData[7] = 0x50; // push RBP
        *(DWORD*)&UnwindData[8] = (DWORD)(catchjmp - (uint8_t*)SectionAddr); // relative location of catchjmp
#else // defined(_OS_X86_64_)
        uint8_t *UnwindData = NULL;
#endif // defined(_OS_X86_64_)
//.........这里部分代码省略.........
开发者ID:GordStephen,项目名称:julia,代码行数:101,代码来源:debuginfo.cpp


注:本文中的ObjectImage::section_end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。