ó
Zö_c           @  sm   d  d l  m Z d  d l Z d  d l Z d d
 d     YZ d d d     YZ d   Z d   Z d	   Z d S(   i˙˙˙˙(   t   with_statementNt   Sectionc           B  s    e  Z d  Z d   Z d   Z RS(   să    Basic class for tracking linker sections
    
        This class if used for tracking any instances created in the SECTIONS
        portion of a linker script (.ld). Also used for tracking hardware
        memory regions.
    c         C  s   | |  _  | |  _ | |  _ d S(   s    Inits Section infoN(   t   namet   addresst   size(   t   selfR   R   R   (    (    sw   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/MapParser.pyt   __init__   s    		c         C  s)   |  j  d t |  j  d t |  j  S(   Ns   	Addr: s   	Size: (   R   t   hexR   R   (   R   (    (    sw   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/MapParser.pyt   __str__   s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    sw   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/MapParser.pyR      s   	t   Symbolc           B  s    e  Z d  Z d   Z d   Z RS(   sł    Basic class for tracking linker symbols

        This class is used for tracking member symbols of sections defined in
        the SECTIONS portion of a linker script (.ld).
    c         C  s:   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ d S(   s    Inits Symbol info N(   R   R   t   objt   libt   segmentR   (   R   R   R   R   R   t   segR   (    (    sw   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/MapParser.pyR      s    					c         C  sJ   |  j  d t |  j  d t |  j  d |  j d |  j d |  j S(   Ns   	(   R   R   R   t   strR   R   R   R   (   R   (    (    sw   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/MapParser.pyR   "   s    (   R	   R
   R   R   R   (    (    (    sw   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/MapParser.pyR      s   	c         C  sn   t  |   I } | j |  } x0 | j |  } | d k r@ Pq! | j |  q! WWd QX| j d d    d S(   s   Parses sections and symbols from .map file

        Scans a chosen .map file and extracts symbol information.
        This information is stored in a list of symbols

        Args:
            filename: Name of .map file to parse
            sections: list to fill with symbol info
            compiler: Library of parsing functions specific to compiler that
                      generated the .map file
    Nt   keyc         S  s   |  j  S(   N(   R   (   t   sym(    (    sw   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/MapParser.pyt   <lambda>?   s    (   t   opent   MapScannerTrackert   get_next_map_tokent   Nonet   appendt   sort(   t   filenamet   symbolst   compilert   fht   stt   ret(    (    sw   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/MapParser.pyt	   parse_map*   s    c         C  sX   t  |   F } | j |  } x- | j |  } | d k r@ Pq! i  | | <q! WWd QXd S(   s   Parses memory regions from .xml file (IPCAT)

        Scans a chosen .xml file from IPCAT and extracts hardware memory 
        regions. The regions are stored as keys in an input map. Values
        are set to empty dicts which are assumed to initalized later
        with symbols extracted from a .map file

        Args:
            filename: Name of .xml file to parse
            regions: Map to fill with hardware memory regions info
            compiler: Library of parsing functions specific to .xml file
    N(   R   t   XMLScannerTrackert   get_next_xml_tokenR   (   R   t   regionsR   R   R   R    (    (    sw   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/MapParser.pyt	   parse_xmlD   s    c         C  s`   t  |   N } | j |  } x5 | j |  } | d k r@ Pq! | d | | d <q! WWd QXd S(   s^   Parses PHDR types of .ld file

        Scan a chosen .ld file and extracts PHDR types of each entity defined
        in the SECTIONS area. This is stored in an input map as section to
        PHDR type.

        Args:
            filename: Name of .ld file to parse
            types: Map to fill with .ld type information
            compiler:
    i   i    N(   R   t   LDScannerTrackert   get_next_ld_tokenR   (   R   t   typesR   R   R   R    (    (    sw   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/MapParser.pyt   parse_ld]   s    (    (    (	   t
   __future__R    t   ret   sysR   R   R!   R%   R)   (    (    (    sw   /local/mnt/workspace/CRMBuilds/BOOT.XF.3.3.1-00042-SAIPANLAZ-1_20200710_161241/b/boot_images/QcomPkg/Tools/MapParser.pyt   <module>   s   		