a oe @sdZddlZddlZddlZddlmZmZmZGdddeZ Gdddej Z Gdd d ej Z Gd d d ej Z Gd d d ZdS)a; ELF file parser. This provides a class ``ELFFile`` that parses an ELF executable in a similar interface to ``ZipFile``. Only the read interface is implemented. Based on: https://gist.github.com/lyssdod/f51579ae8d93c8657a5564aefc2ffbca ELF header: https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html N)IOOptionalTuplec@s eZdZdS) ELFInvalidN)__name__ __module__ __qualname__r r FC:\Program Files\Certbot\pkgs\setuptools\_vendor\packaging\_elffile.pyrsrc@seZdZdZdZdS)EIClassN)rrrZC32ZC64r r r r r sr c@seZdZdZdZdS)EIDatar r N)rrrZLsbZMsbr r r r rsrc@s eZdZdZdZdZdZdZdS)EMachine(>N)rrrZI386ZS390ZArmZX8664ZAArc64r r r r rs rc@sReZdZdZeeddddZeee dfddd Z e e ed d d Z dS) ELFFilez. Representation of an ELF executable. N)freturnc Cs&||_z|d}Wntjy0tdYn0t|dd}|dkrXtd||d|_|d|_z(ddd d d |j|jf\}|_|_ Wn,t ytd |jd |jdYn0z,||\ }|_ }}|_ }|_ }|_|_Wn2tjy }ztd|WYd}~n d}~00dS)NZ16Bzunable to parse identificationsELFzinvalid magic: )z HHIIIIIHHHz >IIIIIIIIr)z HHIQQQIHHHz >IIQQQQQQr))r r )r r )r r )r r zunrecognized capacity (z) or encoding ()z/unable to parse machine and section information)_f_readstructerrorrbytesZcapacityencoding_p_fmt_p_idxKeyErrormachine_e_phoffflags _e_phentsize_e_phnum)selfridentmagicZe_fmt_er r r __init__,sP        zELFFile.__init__.)fmtrcCst||jt|S)N)runpackrreadcalcsize)r+r1r r r rZsz ELFFile._read)rc Cst|jD]}|j|j|j|z||j}Wntj yNYq Yn0||j ddkrdq |j||j dt |j ||j ddSdS)zH The path recorded in the ``PT_INTERP`` section header. rrr r N)ranger*rseekr'r)rr#rr r$osfsdecoder3strip)r+indexdatar r r interpreter]s &zELFFile.interpreter)rrr__doc__rr!r0strrintrpropertyrr=r r r r r's .r)r>enumr8rtypingrrr ValueErrorrIntEnumr rrrr r r r s