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/common/__pycache__/utils.cpython-39.pyc
a

�#�_B�@s�ddlmZddlmZmZmZddlmZddlm	Z	m
Z
dd�Zd	d
�Zddd
�Z
ddd�Zddd�Zd dd�Zedd��Zdd�Zdd�Zdd�ZdS)!�)�contextmanager�)�
ELFParseError�ELFError�
DWARFError��int2byte�)�ConstructError�ULInt8cGsi}|D]}|�|�q|S)z6Given any number of dicts, merges them into a new one.)�update)Zdicts�result�d�r�9/usr/lib/python3.9/site-packages/elftools/common/utils.py�merge_dictssrcCsd�dd�|D��S)zd Convert a list of byte values (e.g. [0x10 0x20 0x00]) to a bytes object
        (e.g. b' ').
    �css|]}t|�VqdS�Nr)�.0�brrr�	<genexpr>rz"bytelist2string.<locals>.<genexpr>)�join)Zbytelistrrr�bytelist2stringsrNc
CsTz|dur|�|�|�|�WStyN}ztt|���WYd}~n
d}~00dS)a4 Convenience function for using the given struct to parse a stream.
        If stream_pos is provided, the stream is seeked to this position before
        the parsing is done. Otherwise, the current position of the stream is
        used.
        Wraps the error thrown by construct with ELFParseError.
    N)�seekZparse_streamr
r�str)�struct�stream�
stream_pos�errr�struct_parses
rcCs�|dur|�|�d}g}d}|�|�}|�d�}|dkrT|�|d|��d}qnn
|�|�t|�|krqnq|r|d�|�SdS)a� Parse a C-string from the given stream. The string is returned without
        the terminating  byte. If the terminating byte wasn't found, None
        is returned (the stream is exhausted).
        If stream_pos is provided, the stream is seeked to this position before
        the parsing is done. Otherwise, the current position of the stream is
        used.
        Note: a bytes object is returned here, because this is what's read from
        the binary file.
    N�@F�rTr)r�read�find�append�lenr)rrZ	CHUNKSIZE�chunks�found�chunkZ	end_indexrrr�parse_cstring_from_stream-s




r)�cCst||t�dS)z= Assert that cond is True, otherwise raise ELFError(msg)
    N)�_assert_with_exceptionr��cond�msgrrr�
elf_assertJsr/cCst||t�dS)z? Assert that cond is True, otherwise raise DWARFError(msg)
    N)r+rr,rrr�dwarf_assertPsr0ccs|��}dV|�|�dS)z� Usage:
        # stream has some position FOO (return value of stream.tell())
        with preserve_stream_pos(stream):
            # do stuff that manipulates the stream
        # stream still has position FOO
    N)�tellr)rZ	saved_posrrr�preserve_stream_posVsr2cCs|dd|>dBdS)z� Round up a number to nearest multiple of 2^bits. The result is a number
        where the least significant bits passed in bits are 0.
    rr)Znum�bitsrrr�roundupcsr4cs�fdd�t|�D�S)z9Read length bytes from stream, return a list of ints
    csg|]}ttd����qS)r*)rr)r�i�rrr�
<listcomp>lrzread_blob.<locals>.<listcomp>)�range)r�lengthrr6r�	read_blobisr:cCs|s||��dSrr)r-r.Zexception_typerrrr+psr+)N)N)r*)r*)�
contextlibr�
exceptionsrrrZ	py3compatrZ	constructr
rrrrr)r/r0r2r4r:r+rrrr�<module>	s