CURRENT PATH:
/
usr
/
lib
/
python3.9
/
site-packages
/
elftools
/
dwarf
/
__pycache__
/
[ ⬅ KEMBALI ]
|
[ HOME ]
Upload File:
Upload Ke Sini
Dir Baru
File Baru
Editing:
namelut.cpython-39.pyc
a �#�_� � @ s| d dl Z d dlZd dlmZ ddlmZ ddlmZ d dlmZ d dl Z ddl mZmZm Z e�dd �ZG d d� de�ZdS )� N)�OrderedDict� )�struct_parse)�Mapping)�bisect_right)�CString�Struct�If�NameLUTEntryzcu_ofs die_ofsc @ sb e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z ddd�Zdd� Zdd� Z dS )�NameLUTaO A "Name LUT" holds any of the tables specified by .debug_pubtypes or .debug_pubnames sections. This is basically a dictionary where the key is the symbol name (either a public variable, function or a type), and the value is the tuple (cu_offset, die_offset) corresponding to the variable. The die_offset is an absolute offset (meaning, it can be used to search the CU by iterating until a match is obtained). An ordered dictionary is used to preserve the CU order (i.e, items are stored on a per-CU basis (as it was originally in the .debug_* section). Usage: The NameLUT walks and talks like a dictionary and hence it can be used as such. Some examples below: # get the pubnames (a NameLUT from DWARF info). pubnames = dwarf_info.get_pubnames() # lookup a variable. entry1 = pubnames["var_name1"] entry2 = pubnames.get("var_name2", default=<default_var>) print(entry2.cu_ofs) ... # iterate over items. for (name, entry) in pubnames.items(): # do stuff with name, entry.cu_ofs, entry.die_ofs # iterate over items on a per-CU basis. import itertools for cu_ofs, item_list in itertools.groupby(pubnames.items(), key = lambda x: x[1].cu_ofs): # items are now grouped by cu_ofs. # item_list is an iterator yeilding NameLUTEntry'ies belonging # to cu_ofs. # We can parse the CU at cu_offset and use the parsed CU results # to parse the pubname DIEs in the CU listed by item_list. for item in item_list: # work with item which is part of the CU with cu_ofs. c C s"