Last active
December 11, 2018 07:58
-
-
Save droogie/30684af9367820b1a4c108499cf842cc to your computer and use it in GitHub Desktop.
UEFI driver gdb symbol loading script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This quick and dirty script will print a chunk that you can copy into gdb for loading of UEFI driver symbols | |
# requires objdump to be in your env path | |
# Expects a debug.log file which it will parse for all loaded drivers | |
import glob, os | |
import sys | |
import subprocess | |
DEBUG_FILE = "debug.log" | |
UEFI_PATH = "/home/droogie/src/edk2/Build/OvmfX64/DEBUG_GCC5/X64/" | |
def obtainOffset(filename, section): | |
command = "objdump -h " + filename + " | grep " + section + " | tr -s ' ' | cut -d ' ' -f 7" | |
try: | |
offset = subprocess.check_output(command, shell=True) | |
except: | |
print "Error: Do you have objdump?\n" | |
sys.exit(1) | |
return offset | |
def printSymbolLine(filename, entry): | |
os.chdir(UEFI_PATH) | |
for file in glob.glob(filename): | |
data = int(entry, 16) + int(obtainOffset(filename, "data").strip(), 16) | |
text = int(entry, 16) + int(obtainOffset(filename, "text").strip(), 16) | |
print("add-symbol-file %s%s 0x%x -s .data 0x%x" % (UEFI_PATH, filename.replace('efi', 'debug'), text, data)) | |
print "set confirm off\n" | |
with open(DEBUG_FILE) as f: | |
for line in f: | |
if "Loading driver at" in line: | |
printSymbolLine(line.split(' ')[5].strip(), line.split(' ')[3].strip()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment