
@K7]c           @   s_  y d  d l  m Z Wn! e k
 r7 d  d l m Z n Xd  d l m Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 m Z m Z d  d l Z d  d l Z d  d l Z d d l m Z d d l m Z d d l m Z e Z e Z y d  d l Z e Z Wn n Xd	   Z d
   Z d   Z e d  Z e rDe Z n  d   Z d   Z  d   Z! d   Z" e rd   Z# e e# d d d e j$ j% j& Z' e e# d d d e j$ j% j( Z) n d   Z' d   Z) d   Z* d   Z+ d d  Z, d d d  Z- d   Z. d   Z/ d    Z0 d!   Z1 d g  d d d"  Z3 e e d d d d#  Z4 e e d d d d$  Z5 d d%  Z6 d&   Z7 d' Z8 d(   Z9 d)   Z: d*   Z; d+   Z< d,   Z= d-   Z> d e d.  Z? d d/  Z@ e e e d d0  ZA d1 eB f d2     YZC eC d e d3   ZD eC d d4   ZE eC d d5   ZF eC d6    ZG eC d d d d7   ZH d S(8   i(   t   Hashable(   t   partialN(   t   Popent   PIPEi   (   t   inspect_linkages(   t   codefile_type(   t   find_executablec         C   s3   y t  |  t  SWn t k
 r. t  |  t  SXd  S(   N(   t
   isinstancet
   basestringt	   NameErrort   str(   t   s(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt	   is_string   s    c         C   sS   t  |   s |  Sy' t j j |   s) g  St j |   SWn d j |   GHn Xd  S(   Ns-   WARNING: liefldd: failed to ensure_binary({})(   R   t   ost   patht   existst   lieft   parset   formatt   None(   t   file(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   ensure_binary+   s    c         C   sz   t  } yX t j |   } | j } t |  d k r] x' | D] } t |  GH| GHt } q: Wn  Wn n X| sv d GHn  d S(   s'    Return symbols from *filename* binary i    s   No symbols foundN(   t   FalseR   R   t   symbolst   lent   dirt   True(   t   filenamet   donet   binaryR   t   symbol(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   nm8   s    	c         C   s   t  |   } d  } | r | j t j j k rg t j j r | j j t j j	 j
 @r[ d } qd d } q q | j t j j k r d } q | j t j j k r d } q n  | S(   Nt   DLLfilet   EXEfilet	   machofilet   elffile(   R   R   R   R   t   EXE_FORMATSt   PEt   DLL_CHARACTERISTICSt   headert   characteristicst   HEADER_CHARACTERISTICSt   DLLt   MACHOt   ELF(   R   t   skip_symlinksR   t   result(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   codefile_type_lieflddJ   s    		c         C   s3   x, |  j  d  s! |  j  d  r. |  d  }  q W|  S(   Nt   /s   \i(   t   endswith(   t   sysroot(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   _trim_sysroot_   s    !c         C   s  g  } t  |   } | r| j t j j k r9 | j } qg  | j D]! } t |  r[ | n | j ^ qC } d  } | j t j j	 k rg  | j
 D]' } | j t j j j k r | j ^ q } t |  r | d n d  } g  | D]. } | s | | k r t | j d  |  ^ q } qn  | S(   Ni    (   R   R   R   R$   R%   t	   librariesR   t   nameR   R+   t   commandst   commandt   MachOt   LOAD_COMMAND_TYPESt   ID_DYLIBR   t   from_os_varnames(   R   R.   R   t   libt   binary_nameR7   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_librariese   s    1'4c         C   s>   |  j  } g  | D]$ } | j | k r t | |  ^ q } | S(   N(   t   dynamic_entriest   tagt   getattr(   R   t	   attributet   dyn_tagR?   t   et   rpaths_colons(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   _get_elf_rpathy_thingx   s    	.c         C   s   |  j  } t } x | D] } | rs | j t j j j k rs t j j | j	 |  rs | j	 | k rs | | _	 t
 } q | r | j t j j j k r t j j | j |  r | j | k r | | _ t
 } q q W| S(   N(   R?   R   R@   R   R,   t   DYNAMIC_TAGSt   RUNPATHt   glob2t   fnmatcht   runpathR   t   RPATHt   rpath(   R   t   old_matchingt	   new_rpatht	   set_rpatht   set_runpathR?   t   changedRD   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   _set_elf_rpathy_thing   s     				c         C   s  d } d } t |   } g  } | r | j } | t j j k r | j } | t j j j k sr | t j j j	 k r t
 | | |  } q q | t j j k r | j r | t j j j k r | j g  | j D]' } | j t j j j k r | j ^ q  q n  | | | f S(   s   
        By raw we mean that no processing is done on them whatsoever. The values are taken directly from
        LIEF. For anything but Linux, this means an empty list.
        N(   R   R   R   R   R$   R,   t   typet	   ELF_CLASSt   CLASS32t   CLASS64RF   R+   t	   has_rpathRG   RL   t   extendR6   R7   R8   R9   R   (   R   t   elf_attributet   elf_dyn_tagt   binary_formatt   binary_typeR   t   rpathsR7   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_rpathy_thing_raw_partial   s     		*	.RZ   RK   R[   RM   c         C   s   g  S(   N(    (   R   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_runpaths_raw   s    c         C   s   g  S(   N(    (   R   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_rpaths_raw   s    c         C   sU   t  |   \ } } } t |  s? t |   \ } } } d } n d } | | | | f S(   s]   
    Can be called on all OSes. On linux, if runpaths are present they are
    returned.
    R^   t   runpaths(   R`   R   Ra   (   R   R^   R\   R]   t   _t   rpaths_type(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_runpaths_or_rpaths_raw   s    	c         C   s   t  |  } | j t j j k r | j t j j j k sQ | j t j j j k r t	 | |  | d t
 d t r | j |  q n  d  S(   NRP   RQ   (   R   R   R   R$   R,   RT   RU   RV   RW   RS   R   R   t   write(   RN   RO   R   R   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyRP      s
    0t    c   
      C   sE  t  |   \ } } } } | t j j k r | rL | j | j d d   n  | r~ | j d j | d f   | j |  n  | r"| j t t	 |    q"n | t j j
 k r g  | D] } | j d  ^ q } nH | t j j k r"g  }	 x$ | D] } |	 j | j d   q W|	 } n  g  | D] } t | | |  ^ q)S(   Ns   \R0   t   System32t   :(   Re   R   R$   R%   t   appendt   replacet   joinRY   t   listt   _get_path_dirsR+   t   rstripR,   t   splitR;   (
   R   t   exe_dirnamet   envroott   windows_rootR^   Rd   R\   R]   RM   R.   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt
   get_rpaths   s"    %	t   nativec         C   s   t  j j |   s d g  g  f St |  } yF t j |   } t j t j	 |   } | rp |  | d | d f SWn d j
 |   GHn Xd g  g  f S(   sM   

    :param filename:
    :param sysroot:
    :param arch:
    :return:
    t   imported_librariess3   WARNING: liefldd: failed _inspect_linkages_this({})N(   R   R   R   R   R3   R   R   t   jsont   loadst   to_jsonR   (   R   R2   t   archR   t	   json_data(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   _inspect_linkages_this   s    	c         C   s   |  j  t j j k r= | j d d  j d d  j d d  S|  j  t j j k r |  j j d k rm d } n d	 } t j d d
  j | d  Sd S(   sL   Don't make these functions - they are methods to match the API for elffiles.s   $SELFDIRs   @loader_paths   $EXEDIRs   @executable_paths   $RPATHs   @rpathi   s   /lib64s   /libs   $ORIGINs   $LIBN(	   R   R   R$   R+   Rk   R,   t   ehdrt   sz_ptrt   input(   R   t   input_t   libdir(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   to_os_varnames   s    
	c         C   s   |  t  j j k r: | j d d  j d d  j d d  S|  t  j j k r | t  j j j k rj d } n d } | j d	 d  j d
 |  S|  t  j j k r | Sd S(   sL   Don't make these functions - they are methods to match the API for elffiles.s   @loader_paths   $SELFDIRs   @executable_paths   $EXEDIRs   @rpaths   $RPATHs   /lib64s   /libs   $ORIGINs   $LIBN(   R   R$   R+   Rk   R,   RU   RW   R%   (   R\   R]   R   R   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyR;     s    
	
c         c   s   d j  |  f  Vd j  |  d d d f  Vd j  |  d d d f  Vd j  |  d d f  Vd j  |  d f  Vd j  |  d f  Vd  S(   NR0   t   Librarys	   mingw-w64t   bint   usrt   Scripts(   Rl   (   t   prefix(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyRn   !  s    c         C   s   t  |   } | j t j j k r( | j S| j t j j k r | j t j j j	 k sm | j t j j j
 k r | j } g  | D]' } | j t j j j k r} | j ^ q} } | r | d S| j S| j S(   Ni    (   R   R   R   R$   R+   R5   R,   RT   RU   RV   RW   R?   R@   RG   t   SONAME(   R   R   R?   RD   R.   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_uniqueness_key*  s    0	4c	            s  d }	 t }
 | s g  n | j d  }   j d  r| rE | g n* | | g  | D] } | j d |  ^ qS } x | D] }   j d |  j d |  j d |  } t j j |  } | o | o | j |  } | s | s | ry | }	 t }
 Pqy qy W|
 s  d t f Sn t	   f d   d	 D  r|  j d |  j d |  } t j j |  } | ov| ov| j |  } n8   j d  r  d t f St j j
 |    d t f S| |	 | f S(
   sU  
       From `man ld.so`

       When resolving shared object dependencies, the dynamic linker first inspects each dependency
       string to see if it contains a slash (this can occur if a shared object pathname containing
       slashes was specified at link time).  If a slash is found, then the dependency string is
       interpreted as a (relative or absolute) pathname, and the shared object is loaded using that
       pathname.

       If a shared object dependency does not contain a slash, then it is searched for in the
       following order:

       o Using the directories specified in the DT_RPATH dynamic section attribute of the binary
         if present and DT_RUNPATH attribute does not exist.  Use of DT_RPATH is deprecated.

       o Using the environment variable LD_LIBRARY_PATH (unless the executable is being run in
         secure-execution mode; see below).  in which case it is ignored.

       o Using the directories specified in the DT_RUNPATH dynamic section attribute of the
         binary if present. Such directories are searched only to find those objects required
         by DT_NEEDED (direct dependencies) entries and do not apply to those objects' children,
         which must themselves have their own DT_RUNPATH entries. This is unlike DT_RPATH,
         which is applied to searches for all children in the dependency tree.

       o From the cache file /etc/ld.so.cache, which contains a compiled list of candidate
         shared objects previously found in the augmented library path. If, however, the binary
         was linked with the -z nodeflib linker option, shared objects in the default paths are
         skipped. Shared objects installed in hardware capability directories (see below) are
         preferred to other shared objects.

       o In the default path /lib, and then /usr/lib. (On some 64-bit architectures, the default
         paths for 64-bit shared objects are /lib64, and then /usr/lib64.)  If the binary was
         linked with the -z nodeflib linker option, this step is skipped.

       Returns a tuple of resolved location, rpath_used, in_sysroot
    Ri   s   $RPATHs   $SYSROOTs   $SELFDIRs   $EXEDIRc         3   s   |  ] } |   k Vq d  S(   N(    (   t   .0t   a(   t
   unresolved(    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pys	   <genexpr>{  s    R0   N(   s   $SELFDIRs   $EXEDIR(   R   R   Rp   t
   startswithRk   R   R   R   R   t   anyRl   (   t   codefileR   t   exedirt   selfdirt   rpaths_transitivet   LD_LIBRARY_PATHt   default_pathsR2   t   resolved_rpatht   rpath_resultt   foundt   ld_library_pathst   dpt   these_rpathsRM   t   resolvedR   t   exists_sysroot(    (   R   s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   _get_resolved_location9  s8    -&c         C   s  t    } t j j |   } t j |   } |  | g g }	 t |  } g  }
 | j t j j	 k r | j
 t j	 j j k r d d d d g }
 q d d g }
 nE | j t j j k r d g }
 n$ | j t j j k r d d g }
 n  t    } t   } t i d  |  6 } x|	 rxz|	 D]r} |	 j d  | d } | d } t |  } | | k rd  } | j t j j k r| } xK | r| rt |  d	 k rt j j |  } n  | | } qyWn | } t | | | j t j d
  |  | | <| } g  } | j t j j k r| | } n% x" | r>| | | d *| | } qWt |  } | | k rg| j |  n  g  | D]K } | j d
  r| j d  r| j t j j k rd | n | ^ qn} x | D] } t | | | | d | d |
 d | } | r| j | d  | | | d <n | j |  | rt j j | d  rn|	 j | d t j | d  g  qnqqW| j t |   qqWq	W| S(   Ns   $SYSROOT/lib64s   $SYSROOT/usr/lib64s   $SYSROOT/libs   $SYSROOT/usr/libs   $SYSROOT/System32/Wbems(   $SYSROOT/System32/WindowsPowerShell/v1.0i    i   R!   R0   t   $s   $RPATH/R   R   R2   (   t   setR   R   t   dirnameR   R   R3   R   R$   R,   RT   RU   RW   R+   R%   t   dictR   t   popR   R   Rt   Rk   t   sepR>   t   removeR   R   t   addR   Rj   (   R   t   resolve_filenamest   recurseR2   Rr   Rz   t   already_seenR   R   t   todoR   t   resultst   rpaths_by_binaryt   parents_by_filenamet   elementt	   filename2t   uniqueness_keyt   parent_exe_dirnamet   tmp_filenameR   R4   R<   t
   these_origt   origR   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   inspect_linkages_lief  s    				

		U	.c         C   s   g  } t  |   d	 k rI t |  d | d | d | d | } t sI | Sn  t sS | St |  d | d | d | d | d | } | r t |  t |  k r d j |  | | | | | | |  GHn  | S(
   NR    R!   R   R   R2   Rz   Rr   s   WARNING: Disagreement in get_linkages(filename={}, resolve_filenames={}, recurse={}, sysroot={}, envroot={}, arch={}):
 lief: {}
pyldd: {}
  (using lief)(   R    R!   (   R   t   inspect_linkages_pylddt	   have_liefR   R   R   (   R   R   R   R2   Rr   Rz   t   result_pylddt   result_lief(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_linkages  s     c         C   s,   t  |   } g  | j D] } t |  ^ q S(   N(   R   t   imported_functionsR
   (   R   Rz   R   t   i(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_imports  s    c      	   C   sf   yW t  |  d  B } d } | j d  } t j d | | d ! \ } | d f SWd  QXWn d SXd  S(   Nt   rbi    i   s   <8sRg   (   Rg   i    (   t   opent   readt   structt   unpack(   R   t   ft   indext   contentt	   signature(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   _get_archive_signature  s    i    c         C   s&   t  |   \ } } | d k r" t St S(   Ns   !<arch>
(   R   R   R   (   R   R   Rc   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt
   is_archive  s    c   ,      C   s4  d   } g  } t  |   \ } } | d k r? d j |   GH| St |  d  } t rh d j |   GHn  d } | j   } | | 7} t   } t   }	 g  }
 | d @r | d 7} n  t r d j t |   GHn  | | |  \ } } } } } | d	 k rOt j d
 | | | d ! \ } g  } xY t	 |  D]K } t j d
 | | d | d | d | d d ! \ } | j
 |  q-Wg  | | d | d | | !j d  |  D] } | j d  ^ q} xt	 |  D]y } | | | |  \ } } } } } | j |  |	 j | |  t rd j | | | | | | | | d ! GHqqWn}| j d  rd | k ryd } d } n d } d } t j |  d } t j |  } t j d | | | | | ! \ } | d } t j d | | | | | | | d d | | ! \ } g  } | | d } xb t	 |  D]T } t j d | | | | | | | | d | ! \ } } | j
 | | f  q2Wt d k rd j t | | |  t | | | |   GHn  | | | | | | | | !}  |  j d d d }  g  } x t	 |  D] } | | }! |! \ }" }# |  |" |" |  |" j d  !}$ | j
 |$  t d k rd j | | t |"  t |#   GHn  | | |#  \ }% } } } } | j |%  |	 j |#  qWn  |	 j t |   t t |   } t t |	   d }	 t d k r7d j d j d   | D   GHn  t d k rgd j d j d   |	 D   GHn  x~t | |	  D]m\ }& }' d }( d  }) t j d! | |& |& d ! \ }* t d k rt |&  t |'  |' |& f GHn  |* |( |) f k r9y$ t j j d" | |& |' d ! }+ Wq}t d k r,d# GHn  d  }+ q}XnD |* d$ k rat j d" | |& |' ! }+ n t j j d" | |& |' ! }+ |+ s| g  | D] }$ d d g ^ q| g  | D] }$ d d g ^ qf S|
 j t |+ d% t d& t  qwW|
 g  |
 D] }$ d d g ^ q|
 g  |
 D] }$ d d g ^ qf SWd  QXd  S('   Nc         S   s  d } t  j |  } t  j | |  | | | ! \ } } } } } }	 }
 y t |	  }	 Wn( d j | |	  GH| d d d d f SXd } | j d  rd } t | d  } t  j d	 t |  d
 |  | | | | | ! \ } d | k rY| | j d   } qYnQ | j d  r d } n9 | j   d k r;d } n | j d  rSd } n d } d | k r{| | j d   } n  | | | 7} | | | |	 | f S(   s  
        0   16  File identifier                 ASCII
        16  12 	File modification timestamp     Decimal
        28  6   Owner ID                        Decimal
        34  6   Group ID                        Decimal
        40  8   File mode                       Octal
        48  10  File size in bytes              Decimal
        58  2   Ending characters               0x60 0x0A
        s   <16s 12s 6s 6s 8s 10s 2ss%   ERROR: {} has non-integral size of {}Rg   i    t   INVALIDs   #1/t   BSDi   t   <R   s    s   //t	   GNU_TABLER0   t   GNU_SYMBOLSt   GNUt   NORMAL(	   R   t   calcsizeR   t   intR   R   R
   t   findt   strip(   R   R   t
   header_fmtt	   header_szR5   t   modifiedt   ownert   groupt   modet   sizet   endingt   name_lent   typ(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   _parse_ar_hdr  s4    
26			s   !<arch>
s   ERROR: {} is not an archiveR   s   Archive file {}i    i   s   ar_hdr index = {}R   s   >Ii   s    s   utf-8s'   symname {}, offset {}, name {}, elf? {}s	   __.SYMDEFt   64t   Qt   Ii   R   i   s   string_table: start: {} end: {}t   errorst   ignores   {} :: strx={}, off={}s   obj_starts: {}t    c         s   s   |  ] } d  j  |  Vq d S(   s   0x{:05x}N(   R   (   R   t   o(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pys	   <genexpr>  s    s     obj_ends: {}c         s   s   |  ] } d  j  |  Vq d S(   s   0x{:05x}N(   R   (   R   R   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pys	   <genexpr>  s    iL  id  s   <Ht   rawsF   get_static_lib_exports failed, PECOFF not supported by LIEF nor pyldd.i  t   definedt	   undefined(   R   R   R   t   debug_static_archivesR   R   t   hexR   R   t   rangeRj   Rp   t   decodeR   R   R   R   R   t   sortedRm   Rl   t   zipR   R%   R   R   R,   RY   t   get_symbolsR   R   (,   R   R   R   R   t   len_signatureR   R   R   t
   obj_startst   obj_endst	   functionsR5   R   R   R   t   nsymbolst   offsetsR   t   offsett   symnamet   symst   index2t   ranlib_struct_field_fmtt   toc_integers_fmtt   ranlib_struct_szt   toc_integers_szt   size_ranlib_structst   size_string_tablet   ranlib_structst   ranlib_indext   ran_offt   ran_strxt   string_tablet   ranlib_structt   strxt   offt   symt   off2t	   obj_startt   obj_endt   IMAGE_FILE_MACHINE_I386t   IMAGE_FILE_MACHINE_AMD64t   MACHINE_TYPEt   obj(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_static_lib_exports  s    	)
		
 8C"4	$
/*!
'$$ !$	B	#c         C   s   g  g  g  g  f S(   N(    (   R   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_static_lib_exports_nope  s    c         C   s1  t  d  } t j d k r+ | r+ d } n  | sE t j j |  rI d  Sd } t j d k rg d } n  y t | | |  g d t d t	 j
   \ } } | j d	  j d
 d  j   } g  | D]5 } d | k r | j d  r | j d  d ^ q } | j   Wn% t k
 r,d j |   GHd  } n X| S(   NR   t   win32s   C:\msys64\mingw64\bin\nm.exes   -Pgt   darwins   -PgUjt   shellt   stdouts   utf-8s   
s   
s    T s   .text R   i    s&   WARNING: nm: failed to get_exports({})(   R   t   syst   platformR   R   R   R   R   R   R   t   communicateR   Rk   t
   splitlinesR   Rp   t   sortt   OSErrorR   (   R   t   nm_exet   flagst   outRc   R   t   r(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_static_lib_exports_nm  s$    		!B
c            s  t  d  } | sYt j d } g  t j |  D] } | j d  r/ | ^ q/ } g  } x | D] } d d l m } | t j j | |  d  } x | D]} } ym t	 | |  g d t
 d t j   \ }	 }
 |	 j d	  j   } | d
 j d  d } | j | | f  Wq q Xq Wq] Wd d l m   t | d   f d   } | d d
 } n  | scd Sd g } g  } xd D]} y t	 | g | | g |  g d t
 d t j   \ }	 }
 |	 j d	  j   } | d k r| j g  | D]( } | j d  r| j d  d ^ q nE | j g  | D]1 } d | k r(d | k r(| j d  d ^ q( Wqyt k
 rd j |   GHd } qyXqyW| j   | S(   sQ  
    > dumpbin /SYMBOLS /NOLOGO C:\msys64\mingw64\lib\libasprintf.a
    > C:\Program Files (x86)\Microsoft Visual Studio9\Community\VC\Tools\MSVC.20.27508in\Hostx64d\dumpbin.exe
    > 020 00000000 UNDEF  notype ()    External     | malloc
    > vs
    > 004 00000010 SECT1  notype ()    External     | _ZN3gnu11autosprintfC1EPKcz
    t   dumpbins   PROGRAMFILES(X86)s   Microsoft Visual Studioi(   t   rec_globs   dumpbin.exeR  R  s   utf-8i    R   (   t   VersionOrdert   keyc            s     |  d  S(   Ni   (    (   t   x(   R"  (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   <lambda>  Rg   s   /NOLOGOs   /SYMBOLSs   /EXPORTSs                     s	   External s   UNDEF s&   WARNING: nm: failed to get_exports({})(   s   dumpbin.exeN(   s   /SYMBOLSs   /EXPORTS(   R   R   t   environt   listdirR   t   conda_build.utilsR!  R   Rl   R   R   R   R  R   R  Rp   Rj   t   conda_build.conda_interfaceR"  R   R   RY   R  R   R  (   R   t   dumpbin_exet   pfx86t   pt   programsR   R!  R   R.   R  Rc   t   linest   versionR  t   exportst   flagR  (    (   R"  s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_static_lib_exports_dumpbin  sJ    1	$?I
c         C   s\   t  |   } t |   } | d  k r( | S| d  k r8 | S| | k rX d j | |  GHn  | S(   Ns*   ERROR :: res_nm != res_dumpbin
{}
 != 
{}
(   R  R2  R   R   (   R   t   res_nmt   res_dumpbin(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt!   get_static_lib_exports_externally  s    c         C   s   g  } | rt  |  t  rt j j |   r|  j d  sK |  j d  rt |   rt j d k rt	 s{ t j d k r t
 |   } n  t j d k r | } n t |   \ } } } } | } t	 r| rt |  t |  k rt |  j t |   }	 t |  j t |   }
 t |	  t |
  } t	 rYd j | t |	  t |
   GHn  t	 rd j |  t |  t |   GHn  d j d j |	   GHd j d j |
   GHqqqn  | st |   } | rg  | j D] } t |  ^ q} qn  | S(	   Ns   .as   .libR  s   errors: {} (-{}, +{})si   WARNING :: Disagreement regarding static lib exports in {} between nm (nsyms={}) and lielfldd (nsyms={}):s+   ** nm.diff(liefldd) [MISSING SYMBOLS] **
{}s   
s+   ** liefldd.diff(nm) [  EXTRA SYMBOLS] **
{}(   R   R
   R   R   R   R1   R   R  R  R   R5  R  R   t
   differenceR   R   Rl   R   t   exported_functions(   R   Rz   t   enable_staticR.   R0  t   exports2t   flags2t   exports2_allt
   flags2_allt   diff1t   diff2t   error_countR   RD   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_exports  s8    	##(c         C   s   t  j j |   s g  Syw t j |   } g  } t | j  r xH | j D]= } | j rG | j r | j j	 r | j
 | j j	  q qG qG W| SWn d j |   GHn Xg  S(   Ns,   WARNING: liefldd: failed get_relocations({})(   R   R   R   R   R   R   t   relocationst
   has_symbolR   R5   Rj   R   (   R   Rz   R   t   resR  (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_relocationsE  s    	c         C   s-  t  |   } d } d } t | t j j  rj | j rj y' | j } | j } | | j d } Wqj qj Xn  g  }	 t	 | j
  r | j
 }
 n< t	 | j  r | j }
 n! t	 | j  r | j }
 n g  }
 x_t |
  D]Q\ } } t d k r | GHn  t } | | k o| | k } | j t j j k rt | t  rCd | } qd | j } | j rv| j rvd j | j  GHn  | j rt } t } q| j rt } qn& d | j } | j d @rt n t } | t k s| t k r | r| r|	 j d |  q%| r%| r%|	 j d |  q%q q W|	 S(   Ni    ii   s   %ss.   Weird, symbol {} is both imported and exported(   R   R   R   R8   t   Binaryt   has_dynamic_symbol_commandt   dynamic_symbol_commandt   idx_undefined_symbolt   nb_undefined_symbolsR   R7  R   t   static_symbolst	   enumerateR   R   t	   __class__R
   R5   t   exportedt   importedR   R   RT   Rj   (   R   R   R   t   notexportedRz   R   t   first_undefined_symbolt   last_undefined_symbolt   dyscmdRC  R   R   R   t   is_notexportedt   is_undefinedt   s_name(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyR   W  sT    					t   memoized_by_arg0_filehashc           B   s    e  Z d  Z d   Z d   Z RS(   s  Decorator. Caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned
    (not reevaluated).

    The first argument is required to be an existing filename and it is
    always converted to an inode number.
    c         C   s%   | |  _  i  |  _ t j   |  _ d  S(   N(   t   funct   cachet	   threadingt   Lockt   lock(   t   selfRW  (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   __init__  s    		c   
      O   sY  g  } x | D] } | | d k r t  j   } t | d  : } x0 t rs | j d  } | sc Pn  | j |  qD WWd  QX| j   } n  t | t  r | j	 t
 |   q t | t  s |  j | |   S| j	 |  q Wt
 |  } | t t | j     f } |  j B | |  j k r,|  j | S|  j | |   }	 |	 |  j | <|	 SWd  QXd  S(   Ni    R   i   (   t   hashlibt   sha1R   R   R   t   updatet	   hexdigestR   Rm   Rj   t   tupleR    RW  t	   frozensetR   t   itemsR[  RX  (
   R\  t   argst   kwt   newargst   argR_  R   t   dataR#  t   value(    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   __call__  s0    	
(   t   __name__t
   __module__t   __doc__R]  Rk  (    (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyRV    s   	c         C   s   t  |  d | d | S(   NRz   R8  (   R@  (   R   Rz   R8  (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_exports_memoized  s    c         C   s   t  |  d | S(   NRz   (   R   (   R   Rz   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_imports_memoized  s    c         C   s   t  |  d | S(   NRz   (   RD  (   R   Rz   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_relocations_memoized  s    c         C   s   t  |  d | d | d | S(   NR   R   Rz   (   R   (   R   R   R   Rz   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_symbols_memoized  s    c         C   s(   t  |  d | d | d | d | d | S(   NR   R   R2   Rr   Rz   (   R   (   R   R   R   R2   Rr   Rz   (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   get_linkages_memoized  s    (I   t   collections.abcR    t   ImportErrort   collectionst	   functoolsR   RI   R^  Rw   R   t
   subprocessR   R   R   R  RY  t   pylddR   R   R   t   codefile_type_pylddt   externalR   R   R   R   R   R   R   R   R/   R3   R>   RF   RS   R_   R,   RG   RH   R`   RL   Ra   Re   RP   Rt   R|   R   R;   Rn   R   R   R   R   R   R   R   R   R   R  R  R  R2  R5  R@  RD  R   t   objectRV  Ro  Rp  Rq  Rr  Rs  (    (    (    s;   lib/python2.7/site-packages/conda_build/os_utils/liefldd.pyt   <module>   s   
									!$									IO						8	+6,