'Get all executable memory regions from the binaries
:param binary: Binary object to collect regions from. If None, regions from all project binary objects are used.
:param bool force_segment: Rely on binary segments instead of sections.
:return: A sorted list of tuples (beginning_address, end_address)'

def _executable_memory_regions(self, binary=None, force_segment=False):

    if (binary is None):
        binaries = self.project.loader.all_objects
    else:
        binaries = [binary]
    memory_regions = []
    for b in binaries:
        if isinstance(b, ELF):
            if ((not force_segment) and b.sections):
                for section in b.sections:
                    if section.is_executable:
                        tpl = (section.min_addr, section.max_addr)
                        memory_regions.append(tpl)
            else:
                for segment in b.segments:
                    if segment.is_executable:
                        tpl = (segment.min_addr, segment.max_addr)
                        memory_regions.append(tpl)
        elif isinstance(b, PE):
            for section in b.sections:
                if section.is_executable:
                    tpl = (section.min_addr, section.max_addr)
                    memory_regions.append(tpl)
        elif isinstance(b, Blob):
            tpl = (b.min_addr, b.max_addr)
            memory_regions.append(tpl)
        elif isinstance(b, (ExternObject, KernelObject, TLSObject)):
            pass
        else:
            l.warning('Unsupported    object    format    "%s".    Treat    it    as    an    executable.', b.__class__.__name__)
            tpl = (b.min_addr, b.max_addr)
            memory_regions.append(tpl)
    if (not memory_regions):
        memory_regions = [(start, (start + len(cbacker))) for (start, cbacker) in self.project.loader.memory.cbackers]
    memory_regions = sorted(memory_regions, key=(lambda x: x[0]))
    return memory_regions
