HEX
Server: LiteSpeed
System: Linux br-asc-web1845.main-hosting.eu 5.14.0-611.42.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 24 05:30:20 EDT 2026 x86_64
User: u790421558 (790421558)
PHP: 8.2.30
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //lib/python3.9/site-packages/elftools/dwarf/__pycache__/callframe.cpython-39.opt-1.pyc
a

�#�_�u�@s:ddlZddlmZddlmZmZmZddlmZm	Z	ddl
mZmZddl
mZdd	lmZdd
lTGdd�de�Zd
d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zedd�ZdZd ZiZe e	e!���D] Z"e"�#d!��re"ee!�e"<�qdS)"�N)�
namedtuple�)�struct_parse�dwarf_assert�preserve_stream_pos)�	iterbytes�iterkeys)�Struct�Switch�)�DW_EH_encoding_flags)�DWARFStructs)�*c@sneZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
edd��ZdS)�
CallFrameInfoa� DWARF CFI (Call Frame Info)

    Note that this also supports unwinding information as found in .eh_frame
    sections: its format differs slightly from the one in .debug_frame. See
    <http://www.airs.com/blog/archives/460>.

        stream, size:
            A stream holding the .debug_frame section, and the size of the
            section in it.

        address:
            Virtual address for this section. This is used to decode relative
            addresses.

        base_structs:
            The structs to be used as the base for parsing this section.
            Eventually, each entry gets its own structs based on the initial
            length field it starts with. The address_size, however, is taken
            from base_structs. This appears to be a limitation of the DWARFv3
            standard, fixed in v4.
            A discussion I had on dwarf-discuss confirms this.
            So for DWARFv4 we'll take the address size from the CIE header,
            but for earlier versions will use the elfclass of the containing
            file; more sophisticated methods are used by libdwarf and others,
            such as guessing which CU contains which FDEs (based on their
            address ranges) and taking the address_size from those CUs.
    FcCs.||_||_||_||_d|_i|_||_dS�N)�stream�size�address�base_structs�entries�_entry_cache�for_eh_frame)�selfrrrrr�r�</usr/lib/python3.9/site-packages/elftools/dwarf/callframe.py�__init__/szCallFrameInfo.__init__cCs|jdur|��|_|jS)z� Get a list of entries that constitute this CFI. The list consists
            of CIE or FDE objects, in the order of their appearance in the
            section.
        N)r�_parse_entries�rrrr�get_entriesAs

zCallFrameInfo.get_entriescCs2g}d}||jkr.|�|�|��|j��}q|S)Nr)r�append�_parse_entry_atr�tell)rr�offsetrrrrLs
zCallFrameInfo._parse_entriesc	Cs�||jvr|j|St|j�d�|j|�}|jr@|dkr@t|�S|dkrLdnd}t|jj||jj	d�}t|�
d�|j�}|jr�|dk}n|dkr�|dkp�|dk}|r�|jr�|jn|j}t||j|�}n|�
||�}|js�|jdkr�t|j|j|j	d�}|�r|�||�\}	}
nZ|�|||�}|�|�}	|j�d	td
�}|td
k�rd|�||j��t|	�|�}
nd}
||j|��}|�||j��|�}|�r�t||||
|	|d�|j|<n*|�|||�}t||||||	|
d
�|j|<|j|S)z� Parse an entry from self.stream starting with the given offset.
            Return the entry object. self.stream will point right after the
            entry.
        �rl���@� )�
little_endian�dwarf_format�address_sizel������
LSDA_encodingZ
DW_EH_PE_omitN)�header�instructionsr"�augmentation_dict�augmentation_bytes�structs)r+r,r"r/�cier.�lsda_pointer)rrr�Dwarf_uint32rr�ZEROr
r&r(�Dwarf_offsetZ
EH_CIE_headerZDwarf_CIE_header�_parse_fde_headerZ
dwarf_versionr'�_parse_cie_augmentation�_parse_cie_for_fde�_read_augmentation_datar-�getr�_parse_lsda_pointerr!�len�lengthZinitial_length_field_size�_parse_instructions�CIE�FDE)rr"Zentry_lengthr'�
entry_structsZCIE_idZis_CIEZ
header_structr+�	aug_bytes�aug_dictr0Z
lsda_encodingr1�
end_offsetr,rrrr Ts�

���
������

������zCallFrameInfo._parse_entry_atc	Csrg}||k�rnt|�d�|j|�}g}|t@}|t@}|tkrH|g}�n|tkrj|t|�d�|j�g}�n�|tkr||g}�n�|t	t
tfvr�g}�n�|tkr�t|�
d�|j�g}�n�|tkr�t|�d�|j�g}�n~|tkr�t|�d�|j�g}�n^|tk�rt|�d�|j�g}�n<|ttttfv�rNt|�d�|j�t|�d�|j�g}�n|tttttfv�rxt|�d�|j�g}n�|tk�r�t|�d�|j�g}n�|tk�r�t|jd|j�g}n�|t t!fv�r�t|�d�|j�t|jd|j�g}nd|t"t#t$fv�r"t|�d�|j�t|�d�|j�g}n.|t%k�rBt|�d�|j�g}nt&dd|�|�'t(||d��|j�)�}q|S)z� Parse a list of CFI instructions from self.stream, starting with
            the offset and until (not including) end_offset.
            Return a list of CallFrameInstruction objects.
        r#Z
DW_FORM_blockFzUnknown CFI opcode: 0x%x��opcode�args)*r�Dwarf_uint8r�
_PRIMARY_MASK�_PRIMARY_ARG_MASK�DW_CFA_advance_loc�
DW_CFA_offset�
Dwarf_uleb128�DW_CFA_restoreZ
DW_CFA_nop�DW_CFA_remember_state�DW_CFA_restore_state�DW_CFA_set_loc�Dwarf_target_addr�DW_CFA_advance_loc1�DW_CFA_advance_loc2�Dwarf_uint16�DW_CFA_advance_loc4r2�DW_CFA_offset_extended�DW_CFA_register�DW_CFA_def_cfa�DW_CFA_val_offset�DW_CFA_restore_extended�DW_CFA_undefined�DW_CFA_same_value�DW_CFA_def_cfa_register�DW_CFA_def_cfa_offsetZDW_CFA_def_cfa_offset_sf�
Dwarf_sleb128�DW_CFA_def_cfa_expressionZ
Dwarf_dw_form�DW_CFA_expression�DW_CFA_val_expression�DW_CFA_offset_extended_sf�DW_CFA_def_cfa_sf�DW_CFA_val_offset_sfZDW_CFA_GNU_args_sizerr�CallFrameInstructionr!)	rr/r"rCr,rErF�primaryZprimary_argrrrr=�s|

�
��
���

�����
z!CallFrameInfo._parse_instructionscCsb|jr"|d}||jd|}n|d}t|j��|�|�Wd�S1sT0YdS)z3 Parse the CIE that corresponds to an FDE.
        �CIE_pointer�N)rr'rrr )rZ
fde_offsetZ
fde_headerr@Zcie_displacementZ
cie_offsetrrrr7�s�z CallFrameInfo._parse_cie_for_fdecCs
|�d�}|sdifS|�d�|�d�|�d�dtd|�d�td	d
d�dd
�|�|���D���d�}g}i}t|�D]F}z||}Wnty�Yq�Yn0|dur�d||<qv|�	|�qv|j
��}	tdg|�R�}
|�t
|
|j
|	��|j
�|	�|�|�}||fS)z� Parse CIE augmentation data from the annotation string in `header`.

        Return a tuple that contains 1) the augmentation data as a string
        (without the length field) and 2) the augmentation data as a dict.
        �augmentationr#r<r*�FDE_encodingTZpersonality�encoding�functioncSs
|jd@S)N�)rl)�ctxrrr�<lambda>�z7CallFrameInfo._parse_cie_augmentation.<locals>.<lambda>cSsi|]\}}||d��qS)rmr)�.0�encZfld_consrrr�
<dictcomp>s�z9CallFrameInfo._parse_cie_augmentation.<locals>.<dictcomp>)�z�L�R�S�P�Augmentation_Data)r9rLrGr	r
�_eh_encoding_to_field�itemsr�KeyErrorrrr!�updater�seekr8)rr+r@rjZavailable_fields�fieldsrB�bZfldr"�structrArrrr6s>
���


z%CallFrameInfo._parse_cie_augmentationcCs2|js
dSttd|�d��|j�d}|j�|�S)z� Read augmentation data.

        This assumes that the augmentation string starts with 'z', i.e. that
        augmentation data is prefixed by a length field, which is not returned.
        rqZDummy_Augmentation_Datar<)rrr	rLr�read)rr@Zaugmentation_data_lengthrrrr8As���z%CallFrameInfo._read_augmentation_datacCsj|d@}|d@}|�|�}ttd||d��|j|d�d}|tdkrJn|tdkrf||j|7}n|S)a} Parse bytes to get an LSDA pointer.

        The basic encoding (lower four bits of the encoding) describes how the values are encoded in a CIE or an FDE.
        The modifier (upper four bits of the encoding) describes how the raw values, after decoded using a basic
        encoding, should be modified before using.

        Ref: https://www.airs.com/blog/archives/460
        rn��rzZLSDA_pointer)Z
stream_pos�DW_EH_PE_absptr�DW_EH_PE_pcrel)r{rr	rrr)rr/Z
stream_offsetrl�basic_encoding�modifier�formatsZptrrrrr:Ps 


���z!CallFrameInfo._parse_lsda_pointercCs�|jst|j|j|�S|�d�|�d�g}ttdg|�R�|j|�}|�|||�}|j��}|j	d}|d@}|d@}	|�
|�}
|�|
|d��|�|
|d��ttd	g|�R�|j|�}|	d
kr�n$|	tdkr�|d|j
|7<n|S)zB Compute a struct to parse the header of the current FDE.
        r<rhZeh_frame_minimal_headerrkrnr��initial_locationZ
address_range�Dwarf_FDE_headerrr�)rrr�rZDwarf_initial_lengthr4r	r7r!r-r{rrr)rr@r"r�Zminimal_headerr0Zinitial_location_offsetrlr�Zencoding_modifierr��resultrrrr5os<
����


��zCallFrameInfo._parse_fde_headercCs^td|jtd|jtd|jtd|jtd|jtd|jtd|jtd|jtd	|j	i	S)
z�
        Return a mapping from basic encodings (DW_EH_encoding_flags) the
        corresponding field constructors (for instance
        entry_structs.Dwarf_uint32).
        r�ZDW_EH_PE_uleb128ZDW_EH_PE_udata2ZDW_EH_PE_udata4ZDW_EH_PE_udata8ZDW_EH_PE_sleb128ZDW_EH_PE_sdata2ZDW_EH_PE_sdata4ZDW_EH_PE_sdata8)
rrQrLrTr2ZDwarf_uint64r_ZDwarf_int16ZDwarf_int32ZDwarf_int64)r@rrrr{�s&�z#CallFrameInfo._eh_encoding_to_fieldN)F)�__name__�
__module__�__qualname__�__doc__rrrr r=r7r6r8r:r5�staticmethodr{rrrrrs�
`B9.rcCs$|t@}|dkrt|St|SdS)z3 Given an opcode, return the instruction name.
    rN)rH�_OPCODE_NAME_MAP)rErgrrr�instruction_name�sr�c@s eZdZdZdd�Zdd�ZdS)rfa An instruction in the CFI section. opcode is the instruction
        opcode, numeric - as it appears in the section. args is a list of
        arguments (including arguments embedded in the low bits of some
        instructions, when applicable), decoded from the stream.
    cCs||_||_dSrrD)rrErFrrrr�szCallFrameInstruction.__init__cCsdt|j�|j|jfS)Nz
%s (0x%x): %s)r�rErFrrrr�__repr__�s�zCallFrameInstruction.__repr__N�r�r�r�r�rr�rrrrrf�srfc@s2eZdZdZddd�Zdd�Zdd	�Zd
d�ZdS)
�CFIEntryaX A common base class for CFI entries.
        Contains a header and a list of instructions (CallFrameInstruction).
        offset: the offset of this entry from the beginning of the section
        cie: for FDEs, a CIE pointer is required
        augmentation_dict: Augmentation data as a parsed struct (dict): see
            CallFrameInfo._parse_cie_augmentation and
            http://www.airs.com/blog/archives/460.
        augmentation_bytes: Augmentation data as a chain of bytes: see
            CallFrameInfo._parse_cie_augmentation and
            http://www.airs.com/blog/archives/460.
    NrqcCs<||_||_||_||_||_d|_|r,|ni|_||_dSr)r+r/r,r"r0�_decoded_tabler-r.)rr+r/r,r"r-r.r0rrrr�szCFIEntry.__init__cCs|jdur|��|_|jS)z� Decode the CFI contained in this entry and return a
            DecodedCallFrameTable object representing it. See the documentation
            of that class to understand how to interpret the decoded table.
        N)r��_decode_CFI_tablerrrr�get_decoded�s

zCFIEntry.get_decodedcCs
|j|S)z6 Implement dict-like access to header entries
        )r+)r�namerrr�__getitem__�szCFIEntry.__getitem__cs4t|t�r(|}tdtddd�d�}g�nb|j}|��}t|j�dkr`t�|jd�}t�|�}nttddd�d�}|d|d<t�|j	��g}g}�fd	d
�}|j
D�]X}t|j�}	|	dkr�|�
t�|��|jd|d<q�|	dv�r|�
t�|��|d|jd|d
7<q�|	dk�r>t|jd|jdd�|d<q�|	dk�rnt|jd|jd|d
d�|d<q�|	dk�r�t|jd|djd�|d<q�|	dk�r�t|dj|jdd�|d<q�|	dk�r�t|jdd�|d<q�|	dk�r||jd�ttj�||jd<q�|	dk�r:||jd�ttj�||jd<q�|	dv�rx||jd�ttj|jd|d�||jd<q�|	dv�r�||jd�ttj|jd|d�||jd<q�|	dk�r�||jd�ttj|jd�||jd<q�|	dk�r"||jd�ttj|jd�||jd<q�|	dk�rX||jd�ttj|jd�||jd<q�|	dv�r�||jd�tt|t�d|	�|jd|v�r�||jd||jd<n|�|jdd�q�|	d k�r�|�
t�|��q�|	d!kr�|d}
|��}|
|d<q�|djdu�st|�d"k�r(|�
|�t|�d#�S)$zr Decode the instructions contained in the given CFI entry and return
            a DecodedCallFrameTable.
        rN)�regr")�pc�cfa���)r�r�r�cs|�vr��|�dSr)r)Zregnum��	reg_orderrr�
_add_to_ordersz1CFIEntry._decode_CFI_table.<locals>._add_to_orderrP)rRrSrUrJZcode_alignment_factorrXrr�rdr]r^r`)�exprr[r\)rKrVrcZdata_alignment_factor)rYrerWrarb)rMrZz%s instruction must be in a FDErNrOr)�tabler�)�
isinstancer>�dict�CFARuler0r�r;r��copyr�r,r�rErrFr"r��RegisterRule�	UNDEFINED�
SAME_VALUE�OFFSET�
VAL_OFFSET�REGISTER�
EXPRESSION�VAL_EXPRESSIONrr?�pop�deepcopy�DecodedCallFrameTable)rr0Zcur_lineZcie_decoded_tableZlast_line_in_CIEr�Z
line_stackr�Zinstrr�r�rr�rr��s�


 
�
�
�
�



�
�
�
�
�
�


zCFIEntry._decode_CFI_table)NrqN)r�r�r�r�rr�r�r�rrrrr��s�
	r�c@seZdZdS)r>N)r�r�r�rrrrr>ysr>cseZdZd�fdd�	Z�ZS)r?Ncs&tt|�j||||||d�||_dS)N)r.r0)�superr?rr1)rr+r/r,r"r.r0r1��	__class__rrr~szFDE.__init__)NNN)r�r�r�r�
__classcell__rrr�rr?}sr?c@seZdZdZdd�ZdS)r3z� End marker for the sequence of CIE/FDE.

    This is specific to `.eh_frame` sections: this kind of entry does not exist
    in pure DWARF. `readelf` displays these as "ZERO terminator", hence the
    class name.
    cCs
||_dSr)r")rr"rrrr�sz
ZERO.__init__N)r�r�r�r�rrrrrr3�sr3c@sBeZdZdZdZdZdZdZdZdZ	dZ
d	Zddd�Zd
d�Z
d
S)r�z� Register rules are used to find registers in call frames. Each rule
        consists of a type (enumeration following DWARFv3 section 6.4.1)
        and an optional argument to augment the type.
    r�r�r�r�r�r�r��
ARCHITECTURALNcCs||_||_dSr��type�arg)rr�r�rrrr�szRegisterRule.__init__cCsd|j|jfS)NzRegisterRule(%s, %s)r�rrrrr��szRegisterRule.__repr__)N)r�r�r�r�r�r�r�r�r�r�r�r�rr�rrrrr��s
r�c@s"eZdZdZddd�Zdd�ZdS)r�z� A CFA rule is used to compute the CFA for each location. It either
        consists of a register+offset, or a DWARF expression.
    NcCs||_||_||_dSr�r�r"r�)rr�r"r�rrrr�szCFARule.__init__cCsd|j|j|jfS)Nz#CFARule(reg=%s, offset=%s, expr=%s)r�rrrrr��s�zCFARule.__repr__)NNNr�rrrrr��s
r�r�ztable reg_order��?ZDW_CFA)$r��collectionsrZcommon.utilsrrrZcommon.py3compatrrZ	constructr	r
Zenumsrr/r
Z	constants�objectrr�rfr�r>r?r3r�r�r�rHrIr��list�globalsr��
startswithrrrr�<module>	s:+
&!�