8f dZddlmZddlZddlZddlZddlmZGddeZ Gddej Z Gd d ej Z Gd d ej Z Gd dZdS)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 ) annotationsN)IOceZdZdS) ELFInvalidN)__name__ __module__ __qualname__~/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/packaging/_elffile.pyrrsDr rceZdZdZdZdS)EIClassN)rrr C32C64r r r rr C CCCr rceZdZdZdZdS)EIDatarrN)rrr LsbMsbr r r rrrr rc"eZdZdZdZdZdZdZdS)EMachine(>N)rrr I386S390ArmX8664AArc64r r r rr!s' D D C E FFFr rc:eZdZdZddZdd Zedd Zd S)ELFFilez. Representation of an ELF executable. f IO[bytes]returnNonec ||_ |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<<Efmtstrtuple[int, ...]ctj||jtj|S)N)r3unpackr1readcalcsize)r@rGs r r2z ELFFile._read\s,}S$',,vs/C/C"D"DEEEr str | Nonect|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?r1seekr<r>r2r8r3r4r9osfsdecoderLstrip)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/N)r&r'r(r))rGrHr(rI)r(rN)rrr __doc__rFr2propertyrXr r r r%r%)so,W,W,W,W\FFFFXr r%)rY __future__renumrSr3typingr ValueErrorrIntEnumrrrr%r r r r`s:#"""""              dl        T\   t|EEEEEEEEEEr