fastinterp/build_fast_interp_lib.cpp
// Logic stolen from llvm/tools/llvm-objdump/llvm-objdump.cpp
// Get a map from section to all its relocations
// tbh I have no idea why we have to call the 'getRelocatedSection'..
//
Logic stolen from llvm/tools/llvm-objdump/llvm-objdump.cpp
Get a map from section to all its relocations
tbh I have no idea why we have to call the 'getRelocatedSection'
Logic stolen from llvm / tools / llvm - objdump / llvm - objdump . cpp Get a map from section to all its relocations tbh I have no idea why we have to call the ' getRelocatedSection '
std::map<SectionRef, std::vector<RelocationRef>> GetRelocationMap(ObjectFile const &Obj)
{
    std::map<SectionRef, std::vector<RelocationRef>> Ret;
    for (SectionRef Sec : Obj.sections())
    {
        Expected<section_iterator> RelocatedOrErr = Sec.getRelocatedSection();
        if (!RelocatedOrErr)
        {
            fprintf(stderr, "[INTERNAL ERROR] Failed to get a relocated section. Please report a bug.\n");
            abort();
        }
        section_iterator Relocated = *RelocatedOrErr;
        if (Relocated == Obj.section_end()) continue;
        std::vector<RelocationRef> &V = Ret[*Relocated];
        for (const RelocationRef &R : Sec.relocations())
        {
            V.push_back(R);
        }
        llvm::stable_sort(V, IsRelocAddressLess);
    }
    for (SectionRef Sec : Obj.sections())
    {
        if (!Ret.count(Sec))
        {
            Ret[Sec] = std::vector<RelocationRef>();
        }
    }
    return Ret;
}
std :: map < SectionRef , std :: vector < RelocationRef > > GetRelocationMap ( ObjectFile const & Obj ) { std :: map < SectionRef , std :: vector < RelocationRef > > Ret ; for ( SectionRef Sec : Obj . sections ( ) ) { Expected < section_iterator > RelocatedOrErr = Sec . getRelocatedSection ( ) ; if ( ! RelocatedOrErr ) { fprintf ( stderr , " \n " ) ; abort ( ) ; } section_iterator Relocated = * RelocatedOrErr ; if ( Relocated == Obj . section_end ( ) ) continue ; std :: vector < RelocationRef > & V = Ret [ * Relocated ] ; for ( const RelocationRef & R : Sec . relocations ( ) ) { V . push_back ( R ) ; } llvm :: stable_sort ( V , IsRelocAddressLess ) ; } for ( SectionRef Sec : Obj . sections ( ) ) { if ( ! Ret . count ( Sec ) ) { Ret [ Sec ] = std :: vector < RelocationRef > ( ) ; } } return Ret ; }
Logic stolen from llvm/tools/llvm-objdump/llvm-objdump.cpp
Get a map from section to all its relocations
tbh I have no idea why we have to call the 'getRelocatedSection'..
Logic stolen from llvm / tools / llvm - objdump / llvm - objdump . cpp Get a map from section to all its relocations tbh I have no idea why we have to call the ' getRelocatedSection ' ..
// Sort relocations by address. //