def load_symbols_at(self, addr, verbose=False): if self.DebugInfos == []: self.get_debug_info() for debug_info in self.DebugInfos: if (addr >= debug_info[0]) and (addr < debug_info[0] + debug_info[1]): if debug_info[2] == EfiFileSection.EFI_SECTION_TE: section = EfiSectionTE(self.ec, debug_info[0] + 0x4) elif debug_info[2] == EfiFileSection.EFI_SECTION_PE32: section = EfiSectionPE32(self.ec, debug_info[0] + 0x4) else: raise Exception('FirmwareVolume', 'Section Type not supported') try: edk2_debugger.load_symbol_from_file( self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose) except Exception, (ErrorClass, ErrorMessage): if verbose: print "Error while loading a symbol file (%s: %s)" % ( ErrorClass, ErrorMessage) return debug_info
def load_symbols_at(self, addr, verbose=False): if self.DebugInfos == []: self.get_debug_info() found = False for debug_info in self.DebugInfos: if (addr >= debug_info[0]) and (addr < debug_info[0] + debug_info[1]): if edk2_debugger.is_aarch64(self.ec): section = firmware_volume.EfiSectionPE64( self.ec, debug_info[0]) else: section = firmware_volume.EfiSectionPE32( self.ec, debug_info[0]) try: edk2_debugger.load_symbol_from_file( self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose) except Exception, (ErrorClass, ErrorMessage): if verbose: print "Error while loading a symbol file (%s: %s)" % ( ErrorClass, ErrorMessage) found = True return debug_info
def load_all_symbols(self, verbose = False): if self.DebugInfos == []: self.get_debug_info() for debug_info in self.DebugInfos: section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0]) try: edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose) except Exception, (ErrorClass, ErrorMessage): if verbose: print "Error while loading a symbol file (%s: %s)" % (ErrorClass, ErrorMessage) pass
def load_all_symbols(self, verbose=False): if self.DebugInfos == []: self.get_debug_info() for debug_info in self.DebugInfos: section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0]) try: edk2_debugger.load_symbol_from_file( self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose) except Exception, (ErrorClass, ErrorMessage): if verbose: print "Error while loading a symbol file (%s: %s)" % ( ErrorClass, ErrorMessage) pass
def load_all_symbols(self, verbose = False): if self.DebugInfos == []: self.get_debug_info() for debug_info in self.DebugInfos: if debug_info[2] == EfiFileSection.EFI_SECTION_TE: section = EfiSectionTE(self.ec, debug_info[0] + 0x4) elif debug_info[2] == EfiFileSection.EFI_SECTION_PE32: section = EfiSectionPE32(self.ec, debug_info[0] + 0x4) else: continue try: edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose) except Exception, (ErrorClass, ErrorMessage): if verbose: print "Error while loading a symbol file (%s: %s)" % (ErrorClass, ErrorMessage)
def load_symbols_at(self, addr, verbose = False): if self.DebugInfos == []: self.get_debug_info() found = False for debug_info in self.DebugInfos: if (addr >= debug_info[0]) and (addr < debug_info[0] + debug_info[1]): section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0]) try: edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose) except Exception, (ErrorClass, ErrorMessage): if verbose: print "Error while loading a symbol file (%s: %s)" % (ErrorClass, ErrorMessage) pass found = True return debug_info
def load_symbols_at(self, addr, verbose = False): if self.DebugInfos == []: self.get_debug_info() for debug_info in self.DebugInfos: if (addr >= debug_info[0]) and (addr < debug_info[0] + debug_info[1]): if debug_info[2] == EfiFileSection.EFI_SECTION_TE: section = EfiSectionTE(self.ec, debug_info[0] + 0x4) elif debug_info[2] == EfiFileSection.EFI_SECTION_PE32: section = EfiSectionPE32(self.ec, debug_info[0] + 0x4) else: raise Exception('FirmwareVolume','Section Type not supported') try: edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose) except Exception, (ErrorClass, ErrorMessage): if verbose: print "Error while loading a symbol file (%s: %s)" % (ErrorClass, ErrorMessage) return debug_info
def load_symbol_from_console(ec, console_file, objdump, verbose): if objdump is None: print "Error: A path to objdump tool is not specified, but -i parameter is provided" elif not os.path.exists(objdump): print "Error: Provided path to objdump is invalid: %s" % objdump elif not os.path.exists(console_file): print "Error: UEFI console file is not found: %s" % console_file else: full_list = open(console_file).read().splitlines() efi_list = [i for i in full_list if "EntryPoint=" in i] full_list = dict.fromkeys(full_list) full_list = [i for i in full_list if "add-symbol-file" in i] module_dict = {} for line in full_list: name = get_module_name(line) module_dict[name] = (get_module_path(line), get_module_entrypoint(efi_list, name)) for module in module_dict: entrypoint_addr = module_dict[module][1] if entrypoint_addr is not None: path = module_dict[module][0] if not os.path.exists(path): print "Module not found: " + path + ". Skipping..." continue sp = subprocess.Popen([objdump,'-S', path], stdout = subprocess.PIPE) objdump_out = sp.stdout.readlines() entrypoint_record = [i for i in objdump_out if "<_ModuleEntryPoint>" in i] entrypoint_offset = entrypoint_record[0].split(' ')[0] load_addr = int(entrypoint_addr, 16) - int(entrypoint_offset, 16) edk2_debugger.load_symbol_from_file(ec, path, load_addr, verbose)