summaryrefslogtreecommitdiffstats
path: root/test_code/gen_symbol_offsets.sh
blob: 80bb2ee6c35702f790af60c01439d9349f30c3bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash

LOG="debug.log"
BUILD="/home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64"
SYMOUT="symbol-files"
PEINFO="../../peinfo/peinfo"

cat ${LOG} | grep Loading | grep -i efi | while read LINE; do
  BASE="`echo ${LINE} | cut -d " " -f4`"
  NAME="`echo ${LINE} | cut -d " " -f6 | tr -d "[:cntrl:]"`"
  if [ "$NAME" == "MemtestEfi.efi" ];
  then
    ADDR="`${PEINFO} hda-contents/MemtestEfi.efi \
          | grep -A 5 text | grep VirtualAddress | cut -d " " -f2`"

    TEXT="`python -c "print(hex(${BASE} + ${ADDR}))"`"
    echo "add-symbol-file /home/koenigr/Memtest/git/memtest86/efi_memtest/MemtestEfi.debug ${TEXT}"
  else
    ADDR="`${PEINFO} ${BUILD}/${NAME} \
          | grep -A 5 text | grep VirtualAddress | cut -d " " -f2`"
    TEXT="`python -c "print(hex(${BASE} + ${ADDR}))"`"
    SYMS="`echo ${NAME} | sed -e "s/\.efi/\.debug/g"`"
    echo "add-symbol-file ${BUILD}/${SYMS} ${TEXT}"
  fi
done