ó
Zö_c           @   sà   d  d l  Z  d  d l Z e Z d d d „  ƒ  YZ d „  Z i d d 6d d 6d	 d
 6d d 6d	 d 6d d 6d	 d 6d d 6d d 6d d 6d d 6d d 6d d 6Z d „  Z d d d „  ƒ  YZ d „  Z	 d d d „  ƒ  YZ
 d „  Z d S(    iÿÿÿÿNt   MapScannerTrackerc           B   s   e  Z d  Z d „  Z RS(   s’    Tracking info for scanning .map files

        This class is used to keep track of scanning data across calls of
        get_next_map_token.
    c         C   s¦   | |  _  t |  _ t |  _ t |  _ t |  _ d |  _ d |  _ d |  _	 d |  _
 d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d S(   s    Inits MapScannerTracker info t    N(   t   fht   Falset   split_line_sectiont   split_line_symbolt   split_line_common_symbolt   split_line_common_symbol_namet   Nonet   curr_sectiont   curr_section_namet   curr_section_addrt   curr_section_sizet   prev_sectiont   prev_section_namet   prev_section_addrt   prev_section_sizet   prev_objt   curr_symbolt   curr_objt   curr_libt   curr_segment(   t   selfR   (    (    sz   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/Parser_CLANG.pyt   __init__   s$    																	(   t   __name__t
   __module__t   __doc__R   (    (    (    sz   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/Parser_CLANG.pyR       s   c      	   C   s5  x.|  j  D]#} t j d d d | ƒ } | rÀ| j d ƒ d k rd } |  j d k r“ |  j d k r“ t j |  j	 |  j
 d |  j d d ƒ } n  t j | j d ƒ t | j d ƒ d	 ƒ t | j d
 ƒ d	 ƒ ƒ } | j d ƒ |  _ t | j d ƒ d	 ƒ |  _ t | j d
 ƒ d	 ƒ |  _ | |  _ |  j |  _	 |  j |  _
 | |  _ t |  _ t |  _ d |  _ d |  _ d |  _ | rº| Sq
 | j d ƒ |  _ t |  _ t r
 d | d | d GHq
 q
 n  |  j r8t j d | ƒ } t |  _ | r
 t j |  j t | j d ƒ d	 ƒ t | j d ƒ d	 ƒ ƒ } | |  _ q
 q
 n  |  j d k r
 t j d | ƒ } | r³|  j d k r³| j d ƒ d k r˜t |  _ d |  _ q
 t |  _ d |  _ q
 q³n  |  j rWt j d d | ƒ } | rSt | j d ƒ d	 ƒ |  _ t | j d ƒ d	 ƒ |  _ | j d
 ƒ |  _ | j d ƒ |  _ t |  j ƒ |  _ t |  _ q
 qWt j d | ƒ } | rº|  j r¶t j |  j |  j |  j |  j |  j | j d ƒ ƒ } t |  _ n  | St j d | ƒ } | rBt j t | j d ƒ d	 ƒ t | j d ƒ d	 ƒ |  j |  j |  j | j d ƒ ƒ } t | j d ƒ ƒ |  _ | St |  _ t |  _ n  t j d | ƒ } | r`|  j d k r`| j d ƒ |  _ | j d ƒ d k rQt j t | j d ƒ d	 ƒ t | j d
 ƒ d	 ƒ | j d ƒ | j d ƒ t | j d ƒ ƒ | j d ƒ ƒ } | j d ƒ |  _ | j d ƒ |  _ t | j d ƒ ƒ |  _ | St |  _ q
 n  |  j r<t j d d | ƒ } t |  _ | r
 t rœd GHn  t j t | j d ƒ d	 ƒ t | j d ƒ d	 ƒ | j d
 ƒ | j d ƒ t |  j ƒ |  j ƒ } | j d
 ƒ |  _ | j d ƒ |  _ t |  j ƒ |  _ | Sq
 n  t j d | ƒ } | r¬t j t | j d ƒ d	 ƒ t | j d ƒ d	 ƒ |  j |  j |  j | j d ƒ ƒ } | St j d | ƒ } | r
 |  j |  _ |  j |  _ t |  _ t |  _ d |  _ d |  _ d |  _ t |  _ n q
 t |  _ t |  _ q
 q
 Wd S(   s‘   Parses next section/symbol from map file

        Scans through the .map file tracked by input MapScannerTracker looking
        for Symbols defined in .map file. Returns the first symbol encountered.

        Args:
            scanner: MapScannerTracker with current tracking info

        Returns:
            Symbol object representing next symbol found. None when EOF is 
            reached
    s   ^([0-9_A-Z]+)s<   (\s+(0x[0-9a-fA-F]+)\s+(0x[0-9a-fA-F]+)\s+(#)\s+([a-zA-Z]+:)s<   \s+(0x[0-9a-fA-F,]+)\s+([a-zA-Z:]+)\s+(0x[0-9a-fA-F]+))?\s*$i   t   NULLt   ZIi   i   i    i   s   [Sector Head]t   (t   )s+   ^\s+(0x[0-9a-fA-F]*)\s+(0x[0-9a-fA-F]+)\s*$s*   ^([\*\.a-zA-Z0-9_]+)(\(\s?COMMON\s?\))\s*$s	   (COMMON )t   COMMONs-   ^\s+(0x[0-9a-fA-F]+)\s+(0x[0-9a-fA-F]+)\s+.*?s-   ([^\\/]+\.lib)\((.*)\)(\s+[#A-Z_,\|0-9]+)\s*$s(   ^\s+(0x[0-9a-fA-F]*)\s+([0-9a-zA-Z_-]+)$sN   ^(PADDING_ALIGNMENT)\s+(0x[0-9a-fA-f]+)\s+(0x[0-9a-fA-f]+)\s+(0x[0-9a-fA-f]+)$sm   ^([\.a-zA-Z0-9_]+)(\s+(0x[0-9a-fA-F]+)\s+(0x+[0-9a-fA-F]+)\s+.*?([^\/]+\.lib)\((.*)\))(\s+[#A-Z_,\|0-9]*)\s*$i   i   s   ([^\\/]+\.lib)\((.*)\)\s*$s    catched symbol in the split lines   ^$R   N(   R   t   ret   searcht   groupR   R   R   t	   MapParsert   SymbolR   R   R   t   Sectiont   intR
   R   R   R	   R   R   R   R   R   R   t   TrueR   t
   Debug_flagt   extract_segmentR   R   (   t   scannert   linet   mt   symbolt   section(    (    sz   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/Parser_CLANG.pyt   get_next_map_token&   s,   																																		t   CODEt   textt   RWt   dataR   t   bsst   ROt   rodataR   t   BOOT_UTIL_ASMt   CACHE_MMU_ZIt   DDRSS_MEM_RDWRt   ARM_MMUt   SBL1_VECTOR_TABLEt   SBL1_EXCEPTION_HANDLERSt   XBL_SDI_ASMt
   SBL1_ENTRYc         C   sF   t  j d |  ƒ } | r* | j d ƒ }  n  |  t k r> t |  Sd Sd  S(   Ns   ^\.?([^\.]+)i   t   OTHER(   R    R!   R"   t   section_map(   t   nameR,   (    (    sz   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/Parser_CLANG.pyR)      s    t   XMLScannerTrackerc           B   s   e  Z d  Z d „  Z RS(   s’    Tracking info for scanning .xml files

        This class is used to keep track of scanning data across calls of
        get_next_xml_token.
    c         C   s   | |  _  t |  _ d S(   s    Inits XMLScannerTracker info N(   R   R   t   in_hw(   R   R   (    (    sz   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/Parser_CLANG.pyR     s    	(   R   R   R   R   (    (    (    sz   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/Parser_CLANG.pyRB     s   c         C   s  x|  j  D]û } t j d | ƒ } | r7 t |  _ q
 n  t j d | ƒ } | r^ t |  _ q
 n  |  j r
 t j d d | ƒ } | r| j d ƒ } | j d d ƒ } | j d d	 ƒ } | j d
 d ƒ } t j	 | j d ƒ t
 | j d ƒ d ƒ t | ƒ ƒ } | Sq
 q
 Wd S(   s¯   Parses next memory region from xml file

        Scans through the .xml file tracked by input XMLScannerTracker looking
        for hardware memory regions. Returns the first region found.

        Args:
            scanner: XMLScannerTracker with current tracking info

        Returns:
            None if scanner has finished file, otherwise Section containing
            info for next hardware memory regions encountered
    s
   <Hardware>s   </Hardware>s$   <Bank name="([^"]+)" addr="([^"]+)" s   size="([^"]+)"/>i   t   Ks   * 1024t   Ms   * 1024 * 1024t   Gs   * 1024 * 1024 * 1024i   i   i    N(   R   R    R!   R'   RC   R   R"   t   replaceR#   R%   R&   t   evalR   (   R*   R+   R,   t   sizeR.   (    (    sz   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/Parser_CLANG.pyt   get_next_xml_token  s.    					t   LDScannerTrackerc           B   s   e  Z d  Z d „  Z RS(   s    Tracking info for scanning .ld files

        This class is used to keep track of scanning data across calls of
        get_next_ld_token.
    c         C   s1   | |  _  t |  _ d |  _ t |  _ g  |  _ d S(   s    Init LDScannerTracker info i    N(   R   R   t   in_sectionst   brace_deptht
   in_sectiont   section_types(   R   R   (    (    sz   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/Parser_CLANG.pyR   R  s
    				(   R   R   R   R   (    (    (    sz   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/Parser_CLANG.pyRK   L  s   c         C   s   d  S(   N(   R   (   R*   (    (    sz   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/Parser_CLANG.pyt   get_next_ld_token]  s    (    (    (    (   R    R#   R   R(   R    R/   R@   R)   RB   RJ   RK   RP   (    (    (    sz   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/Parser_CLANG.pyt   <module>   s.   	Ç
		.