Ë
    Öùd¿   ã                   ó´   — d dl mZ d dlmZmZ ddlmZmZ  G d„ de«      Z	 G d„ de«      Z
 G d	„ d
e«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)é   )ÚCString)Ústruct_parseÚ
elf_asserté   )ÚSectionÚSymbolc                   ó   — e Zd ZdZdd„Zd„ Zy)ÚVersiona[   Version object - representing a version definition or dependency
        entry from a "Version Needed" or a "Version Dependency" table section.

        This kind of entry contains a pointer to an array of auxiliary entries
        that store the information about version names or dependencies.
        These entries are not stored in this object and should be accessed
        through the appropriate method of a section object which will return
        an iterator of VersionAuxiliary objects.

        Similarly to Section objects, allows dictionary-like access to
        verdef/verneed entry
    Nc                 ó    — || _         || _        y ©N©ÚentryÚname©Úselfr   r   s      ú:/usr/lib/python3/dist-packages/elftools/elf/gnuversions.pyÚ__init__zVersion.__init__   ó   € ØˆŒ
Øˆ�	ó    c                 ó    — | j                   |   S )z- Implement dict-like access to entry
        ©r   ©r   r   s     r   Ú__getitem__zVersion.__getitem__   ó   € ð �z‰z˜$ÑÐr   r   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r
   r
      s   „ ñóó r   r
   c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚVersionAuxiliaryzÞ Version Auxiliary object - representing an auxiliary entry of a version
        definition or dependency entry

        Similarly to Section objects, allows dictionary-like access to the
        verdaux/vernaux entry
    c                 ó    — || _         || _        y r   r   r   s      r   r   zVersionAuxiliary.__init__,   r   r   c                 ó    — | j                   |   S )z/ Implement dict-like access to entries
        r   r   s     r   r   zVersionAuxiliary.__getitem__0   r   r   Nr   r    r   r   r"   r"   %   s   „ ñòó r   r"   c                   ó<   ‡ — e Zd ZdZˆ fd„Zd„ Zdd„Zd„ Zd„ Zˆ xZ	S )ÚGNUVersionSectionz{ Common ancestor class for ELF SUNW|GNU Version Needed/Dependency
        sections class which contains shareable code
    c                 óh   •— t         t        | �  |||«       || _        || _        || _        || _        y r   )Úsuperr&   r   ÚstringtableÚfield_prefixÚversion_structÚversion_auxiliaries_struct)	r   Úheaderr   Úelffiler)   r*   r+   r,   Ú	__class__s	           €r   r   zGNUVersionSection.__init__;   s7   ø€ äÔ Ñ/°¸¸gÔFØ&ˆÔØ(ˆÔØ,ˆÔØ*DˆÕ'r   c                 ó   — | d   S )z2 Number of version entries in the section
        Úsh_infor    ©r   s    r   Únum_versionszGNUVersionSection.num_versionsC   s   € ð �I‰Ðr   c                 ó2   — |rdnd}| j                   |z   |z   S )zZ Return the real field's name of version or a version auxiliary
            entry
        Úa_Ú_)r*   )r   r   Ú	auxiliaryÚmiddles       r   Ú_field_namezGNUVersionSection._field_nameH   s#   € ñ #‘¨ˆØ× Ñ  6Ñ)¨DÑ0Ð0r   c              #   ó(  K  — | j                  dd¬«      }| j                  dd¬«      }t        |«      D ]Z  }t        | j                  | j                  |¬«      }| j
                  j                  ||   «      }t        ||«      }|–— |||   z  }Œ\ y­w)z8 Yield all auxiliary entries of a version entry
        r   T)r7   Únext©Ú
stream_posN)r9   Úranger   r,   Ústreamr)   Ú
get_stringr"   )	r   Úentry_offsetÚcountÚ
name_fieldÚ
next_fieldr6   r   r   Úversion_auxs	            r   Ú_iter_version_auxiliariesz+GNUVersionSection._iter_version_auxiliariesO   s    è ø€ ð ×%Ñ% f¸Ð%Ó=ˆ
Ø×%Ñ% f¸Ð%Ó=ˆ
ä�u“ò 
	.ˆAÜ Ø×7Ñ7ØŸ™Ø#/ô1ˆEð
 ×#Ñ#×.Ñ.¨u°ZÑ/@ÓAˆDÜ*¨5°$Ó7ˆKØÒà˜E *Ñ-Ñ-‰Lñ
	.ùs   ‚BBc           
   #   óª  K  — | j                  d«      }| j                  d«      }| j                  d«      }| d   }t        | j                  «       «      D ]{  }t        | j                  | j
                  |¬«      }t        ||   dkD  d|›dt        |«      ›�«       t        |«      }|||   z   }| j                  |||   «      }	||	f–— |||   z  }Œ} y	­w)
z¶ Yield all the version entries in the section
            Each time it returns the main version structure
            and an iterator to walk through its auxiliaries entries
        ÚauxÚcntr;   Ú	sh_offsetr<   é    z.Expected number of version auxiliary entries (z,) to be > 0for the following version entry: N)
r9   r>   r3   r   r+   r?   r   Ústrr
   rF   )
r   Ú	aux_fieldÚcount_fieldrD   rA   r6   r   ÚversionÚaux_entries_offsetÚversion_auxiliaries_iters
             r   Úiter_versionszGNUVersionSection.iter_versionsa   sõ   è ø€ ð
 ×$Ñ$ UÓ+ˆ	Ø×&Ñ& uÓ-ˆØ×%Ñ% fÓ-ˆ
à˜KÑ(ˆÜ�t×(Ñ(Ó*Ó+ò 	.ˆAÜ Ø×#Ñ#Ø—‘Ø'ô)ˆEô
 �u˜[Ñ)¨AÒ-ò  ¤ U¤ð-ô.ô
 ˜e“nˆGØ!-°°iÑ0@Ñ!@ÐØ'+×'EÑ'EØ&¨¨kÑ(:ó(<Ð$ð Ð3Ð3Ò3à˜E *Ñ-Ñ-‰Lñ%	.ùs   ‚CC)F)
r   r   r   r   r   r3   r9   rF   rR   Ú__classcell__©r/   s   @r   r&   r&   6   s"   ø„ ñôEòó
1ò.ö$.r   r&   c                   ó8   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ fd„Zd„ Zˆ xZS )ÚGNUVerNeedSectionz‚ ELF SUNW or GNU Version Needed table section.
        Has an associated StringTableSection that's passed in the constructor.
    c           	      ó–   •— t         t        | �  ||||d|j                  j                  |j                  j
                  «       d | _        y )NÚvn)r(   rV   r   ÚstructsÚElf_VerneedÚElf_VernauxÚ_has_indexes©r   r-   r   r.   r)   r/   s        €r   r   zGNUVerNeedSection.__init__„   sB   ø€ ÜÔ Ñ/Ø˜˜g {°DØ—‘×+Ñ+¨W¯_©_×-HÑ-Hô	Jð !ˆÕr   c                 óš   — | j                   €4d| _         | j                  «       D ]  \  }}|D ]  }|d   sŒ	d| _          Œ Œ | j                   S )z¹ Return True if at least one version definition entry has an index
            that is stored in the vna_other field.
            This information is used for symbol versioning
        FÚ	vna_otherT)r\   rR   )r   r6   Úvernaux_iterÚvernauxs       r   Úhas_indexeszGNUVerNeedSection.has_indexesŠ   sd   € ð
 ×ÑÐ$Ø %ˆDÔØ#'×#5Ñ#5Ó#7ò ‘��<Ø+ò �GØ˜{Ó+Ø,0˜Ô)Ùñðð × Ñ Ð r   c              #   ó”   •K  — t         t        | �  «       D ].  \  }}| j                  j	                  |d   «      |_        ||f–— Œ0 y ­w)NÚvn_file)r(   rV   rR   r)   r@   r   )r   Úverneedra   r/   s      €r   rR   zGNUVerNeedSection.iter_versions™   sN   øè ø€ Ü %Ô&7¸Ñ LÓ Nò 	#ÑˆG�WØ×+Ñ+×6Ñ6°w¸yÑ7IÓJˆGŒLØ˜7Ð"Ó"ñ	#ùs   ƒAAc                 ób   — | j                  «       D ]  \  }}|D ]  }|d   |k(  sŒ||fc c S  Œ y)zÁ Get the version information located at index #n in the table
            Return boths the verneed structure and the vernaux structure
            that contains the name of the version
        r_   N©rR   )r   Úindexre   r`   ra   s        r   Úget_versionzGNUVerNeedSection.get_versionž   sM   € ð
 &*×%7Ñ%7Ó%9ò 	,Ñ!ˆG�\Ø'ò ,�Ø˜;Ñ'¨5Ó0Ø" GÐ+Ô+ñ,ð	,ð
 r   )	r   r   r   r   r   rb   rR   ri   rS   rT   s   @r   rV   rV   €   s   ø„ ñô!ò!ô#ö

r   rV   c                   ó(   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ xZS )ÚGNUVerDefSectionz† ELF SUNW or GNU Version Definition table section.
        Has an associated StringTableSection that's passed in the constructor.
    c           	      óˆ   •— t         t        | �  ||||d|j                  j                  |j                  j
                  «       y )NÚvd)r(   rk   r   rY   Ú
Elf_VerdefÚElf_Verdauxr]   s        €r   r   zGNUVerDefSection.__init__¯   s8   ø€ ÜÔ Ñ.Ø˜˜g {°DØ—‘×*Ñ*¨G¯O©O×,GÑ,Gõ	Ir   c                 óP   — | j                  «       D ]  \  }}|d   |k(  sŒ||fc S  y)zï Get the version information located at index #n in the table
            Return boths the verdef structure and an iterator to retrieve
            both the version names and dependencies in the form of
            verdaux entries
        Úvd_ndxNrg   )r   rh   ÚverdefÚverdaux_iters       r   ri   zGNUVerDefSection.get_version´   s>   € ð %)×$6Ñ$6Ó$8ò 	,Ñ ˆF�LØ�hÑ 5Ó(Ø˜|Ð+Ò+ð	,ð r   )r   r   r   r   r   ri   rS   rT   s   @r   rk   rk   «   s   ø„ ñôIö

r   rk   c                   ó4   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zd„ Zˆ xZS )ÚGNUVerSymSectionzz ELF SUNW or GNU Versym table section.
        Has an associated SymbolTableSection that's passed in the constructor.
    c                 ó>   •— t         t        | �  |||«       || _        y r   )r(   ru   r   Úsymboltable)r   r-   r   r.   rw   r/   s        €r   r   zGNUVerSymSection.__init__Å   s   ø€ ÜÔ Ñ.¨v°t¸WÔEØ&ˆÕr   c                 ó   — | d   | d   z  S )z( Number of symbols in the table
        Úsh_sizeÚ
sh_entsizer    r2   s    r   Únum_symbolszGNUVerSymSection.num_symbolsÉ   s   € ð �I‰ $ |Ñ"4Ñ4Ð4r   c                 óØ   — | d   || d   z  z   }t        | j                  j                  | j                  |¬«      }| j                  j                  |«      j                  }t        ||«      S )zÄ Get the symbol at index #n from the table (Symbol object)
            It begins at 1 and not 0 since the first entry is used to
            store the current version of the syminfo table
        rJ   rz   r<   )r   rY   Ú
Elf_Versymr?   rw   Ú
get_symbolr   r   )r   ÚnrA   r   r   s        r   r~   zGNUVerSymSection.get_symbolÎ   si   € ð ˜KÑ(¨1¨t°LÑ/AÑ+AÑAˆÜØ�L‰L×#Ñ#Ø�K‰KØ#ô%ˆð
 ×Ñ×*Ñ*¨1Ó-×2Ñ2ˆÜ�e˜TÓ"Ð"r   c              #   ón   K  — t        | j                  «       «      D ]  }| j                  |«      –— Œ y­w)z, Yield all the symbols in the table
        N)r>   r{   r~   )r   Úis     r   Úiter_symbolszGNUVerSymSection.iter_symbolsÝ   s4   è ø€ ô �t×'Ñ'Ó)Ó*ò 	%ˆAØ—/‘/ !Ó$Ó$ñ	%ùs   ‚35)	r   r   r   r   r   r{   r~   r‚   rS   rT   s   @r   ru   ru   Á   s   ø„ ñô'ò5ò
#ö%r   ru   N)Ú	constructr   Úcommon.utilsr   r   Úsectionsr   r   Úobjectr
   r"   r&   rV   rk   ru   r    r   r   ú<module>r‡      s^   ðõ  ß 3ß %ô ˆfô  ô. �vô  ô"G.˜ô G.ôT(Ð)ô (ôVÐ(ô ô, %�wõ  %r   