
    m&ph                         S r SSKrSSKrSSKrSSKJrJrJr   " S S\5      r	 " S S\R                  5      r " S S	\R                  5      r " S
 S\R                  5      r " S S5      rg)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)IOOptionalTuplec                       \ rS rSrSrg)
ELFInvalid    N)__name__
__module____qualname____firstlineno____static_attributes__r	       T/var/www/html/venv/lib/python3.13/site-packages/wheel/vendored/packaging/_elffile.pyr   r      s    r   r   c                       \ rS rSrSrSrSrg)EIClass         r	   N)r
   r   r   r   C32C64r   r	   r   r   r   r          
C
Cr   r   c                       \ rS rSrSrSrSrg)EIData   r   r   r	   N)r
   r   r   r   LsbMsbr   r	   r   r   r   r      r   r   r   c                   (    \ rS rSrSrSrSrSrSrSr	g)	EMachine         (   >      r	   N)
r
   r   r   r   I386S390ArmX8664AArc64r   r	   r   r   r   r      s    DD
CEFr   r   c                   j    \ rS rSrSrS\\   SS4S jrS\S\	\
S4   4S	 jr\S\\   4S
 j5       rSrg)ELFFile'   z&
Representation of an ELF executable.
freturnNc           
      h   Xl          U R                  S5      n[        US S 5      nUS:w  a  [	        SU< 35      eUS   U l        US   U l         SSS	S
S.U R                  U R                  4   u  o@l        U l	         U R                  U5      u
  nU l        nnU l        nU l        nU l        U l        g ! [        R                   a    [	        S5      ef = f! [         a'    [	        SU R                   SU R                   S35      ef = f! [        R                   a  n[	        S5      UeS nAff = f)N16Bzunable to parse identification   s   ELFzinvalid magic:    )z<HHIIIIIHHHz	<IIIIIIIIr   r   r2   )z>HHIIIIIHHHz	>IIIIIIIIr4   )z<HHIQQQIHHHz	<IIQQQQQQr   r   r3   )z>HHIQQQIHHHz	>IIQQQQQQr5   ))r   r   )r   r   )r   r   )r   r   zunrecognized capacity (z) or encoding ()z/unable to parse machine and section information)_f_readstructerrorr   bytescapacityencoding_p_fmt_p_idxKeyErrormachine_e_phoffflags_e_phentsize_e_phnum)selfr.   identmagice_fmt_es          r   __init__ELFFile.__init__,   s^   	?JJu%E eBQi Jui899aa	
 @???	/
 }}dmm,/.+E;	W 

5!
!I || 	?=>>	?&  	)$-- 9!]]O1. 	& || 	WNOUVV	Ws/   B5 -C ?5D 5 C1D	D1 D,,D1fmt.c                     [         R                  " XR                  R                  [         R                  " U5      5      5      $ )N)r9   unpackr7   readcalcsize)rF   rN   s     r   r8   ELFFile._readZ   s'    }}S'',,vs/C"DEEr   c                 0   [        U R                  5       H  nU R                  R                  U R                  U R
                  U-  -   5         U R                  U R                  5      nX R                  S      S:w  a  Mk  U R                  R                  X R                  S      5        [        R                  " U R                  R                  X R                  S      5      5      R                  S5      s  $    g! [        R                   a     M  f = f)z8
The path recorded in the ``PT_INTERP`` section header.
r   r!   r   r    N)rangerE   r7   seekrB   rD   r8   r>   r9   r:   r?   osfsdecoderQ   strip)rF   indexdatas      r   interpreterELFFile.interpreter]   s    
 4==)EGGLL):):U)BBCzz$++. KKN#q(GGLLkk!n-.;;tww||DQ,@ABHHNN *  << s   C==DD)
rD   rE   rB   r7   r>   r?   r<   r=   rC   rA   )r
   r   r   r   __doc__r   r;   rL   strr   intr8   propertyr   r]   r   r	   r   r   r,   r,   '   s_    ,W"U) ,W ,W\F FsCx F Xc]  r   r,   )r_   enumrX   r9   typingr   r   r   
ValueErrorr   IntEnumr   r   r   r,   r	   r   r   <module>rg      sc     	  & &	 	dll 
T\\ 
t|| E Er   