# Path: cle/backends/region.py
# class Segment(Region):
#     pass
# 
# class Section(Region):
#     """
#     Simple representation of a loaded section.
# 
#     :ivar str name:     The name of the section
#     """
#     def __init__(self, name, offset, vaddr, size):
#         """
#         :param str name:    The name of the section
#         :param int offset:  The offset into the binary file this section begins
#         :param int vaddr:   The address in virtual memory this section begins
#         :param int size:    How large this section is
#         """
#         super().__init__(offset, vaddr, size, size)
#         self.name = name
# 
#     @property
#     def is_readable(self):
#         """
#         Whether this section has read permissions
#         """
#         raise NotImplementedError()
# 
#     @property
#     def is_writable(self):
#         """
#         Whether this section has write permissions
#         """
#         raise NotImplementedError()
# 
#     @property
#     def is_executable(self):
#         """
#         Whether this section has execute permissions
#         """
#         raise NotImplementedError()
# 
#     @property
#     def only_contains_uninitialized_data(self):
#         """
#         Whether this section is initialized to zero after the executable is loaded.
#         """
#         raise NotImplementedError()
# 
#     def __repr__(self):
#         return "<%s | offset %#x, vaddr %#x, size %#x>" % (
#             self.name if self.name else "Unnamed",
#             self.offset,
#             self.vaddr,
#             self.memsize
#         )


from ..region import Segment, Section


class ELFSegment(Segment):
    """
    Represents a segment for the ELF format.
    """
    def __init__(self, readelf_seg, relro=False):
        self.flags = readelf_seg.header.p_flags
        self.relro = relro
        super().__init__(readelf_seg.header.p_offset,
                                         readelf_seg.header.p_vaddr,
                                         readelf_seg.header.p_filesz,
                                         readelf_seg.header.p_memsz)

    @property
    def is_readable(self):
        return self.flags & 4 != 0

    @property
    def is_writable(self):
        return self.flags & 2 != 0

    @property
    def is_executable(self):
        return self.flags & 1 != 0

    @property
    def is_relro(self):
        return self.relro


# Path: cle/backends/region.py
# class Segment(Region):
#     pass
# 
# class Section(Region):
#     """
#     Simple representation of a loaded section.
# 
#     :ivar str name:     The name of the section
#     """
#     def __init__(self, name, offset, vaddr, size):
#         """
#         :param str name:    The name of the section
#         :param int offset:  The offset into the binary file this section begins
#         :param int vaddr:   The address in virtual memory this section begins
#         :param int size:    How large this section is
#         """
#         super().__init__(offset, vaddr, size, size)
#         self.name = name
# 
#     @property
#     def is_readable(self):
#         """
#         Whether this section has read permissions
#         """
#         raise NotImplementedError()
# 
#     @property
#     def is_writable(self):
#         """
#         Whether this section has write permissions
#         """
#         raise NotImplementedError()
# 
#     @property
#     def is_executable(self):
#         """
#         Whether this section has execute permissions
#         """
#         raise NotImplementedError()
# 
#     @property
#     def only_contains_uninitialized_data(self):
#         """
#         Whether this section is initialized to zero after the executable is loaded.
#         """
#         raise NotImplementedError()
# 
#     def __repr__(self):
#         return "<%s | offset %#x, vaddr %#x, size %#x>" % (
#             self.name if self.name else "Unnamed",
#             self.offset,
#             self.vaddr,
#             self.memsize
#         )


# Path: cle/backends/elf/regions.py
from ..region import Segment, Section



class ELFSegment(Segment):
    """
    Represents a segment for the ELF format.
    """
    def __init__(self, readelf_seg, relro=False):
        self.flags = readelf_seg.header.p_flags
        self.relro = relro
        super().__init__(readelf_seg.header.p_offset,
                                         readelf_seg.header.p_vaddr,
                                         readelf_seg.header.p_filesz,
                                         readelf_seg.header.p_memsz)

    @property
    def is_readable(self):
        return self.flags & 4 != 0

    @property
    def is_writable(self):
        return self.flags & 2 != 0

    @property
    def is_executable(self):
        return self.flags & 1 != 0

    @property
    def is_relro(self):
        return self.relro


class ELFSection(Section):