hf dZddlZddlZddlZddlmZmZmZGddeZ Gddej Z Gdd ej Z Gd d ej Z Gd 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)IOOptionalTupleceZdZdS) ELFInvalidN)__name__ __module__ __qualname__r/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/packaging/_elffile.pyrrsDr rceZdZdZdZdS)EIClassN)rr r C32C64r r r rr C CCCr rceZdZdZdZdS)EIDatarrN)rr r LsbMsbr r r rrrr rc"eZdZdZdZdZdZdZdS)EMachine(>N)rr r I386S390ArmX8664AArc64r r r rrs' D D C E FFFr rcveZdZdZdeeddfdZdedee dffdZ e de efd Z dS) ELFFilez. Representation of an ELF executable. freturnNc ||_ |d}n"#tj$rt dwxYwt |dd}|dkrt d||d|_|d|_ ddd d d |j|jf\}|_|_ n.#t$r!t d |jd |jdwxYw ||\ }|_ }}|_ }|_ }|_|_dS#tj$r}t d|d}~wwxYw)N16Bzunable to parse identificationsELFzinvalid magic: )z HHIIIIIHHHz >IIIIIIIIr-)z HHIQQQIHHHz >IIQQQQQQr.))rr)rr)rr)rrzunrecognized capacity (z) or encoding ()z/unable to parse machine and section information)_f_readstructerrorrbytescapacityencoding_p_fmt_p_idxKeyErrormachine_e_phoffflags _e_phentsize_e_phnum)selfr'identmagice_fmt_es r __init__zELFFile.__init__,s ?JJu%%EE| ? ? ?=>> > ?eBQBi   J  8u8899 9a a   @??? // }dm, /. +E4;    .$-..!]...    W 5!!    ! | W W WNOOUV V Ws,> 'B33+C"9DE,D<<Efmt.ctj||jtj|S)N)r2unpackr0readcalcsize)r?rFs r r1z ELFFile._readZs,}S$',,vs/C/C"D"DEEEr ct|jD]}|j|j|j|zz ||j}n#tj $rYYwxYw||j ddkru|j||j dtj |j ||j ddcSdS)zH The path recorded in the ``PT_INTERP`` section header. rrrrN)ranger>r0seekr;r=r1r7r2r3r8osfsdecoderIstrip)r?indexdatas r interpreterzELFFile.interpreter]s 4=)) O OE GLL):U)BB C C C zz$+..<    DKN#q(( GLLdk!n- . . .;tw||DQ,@AABBHHNN N N NtsAA/.A/)rr r __doc__rr4rEstrrintr1propertyrrTr r r r&r&'s,W"U),W,W,W,W,W\FFsCxFFFFXc]Xr r&)rUenumrOr2typingrrr ValueErrorrIntEnumrrrr&r r r r]s4 &&&&&&&&&&             dl        T\   t|EEEEEEEEEEr