summaryrefslogtreecommitdiffstats
path: root/test_code/gen_symbol_offsets.sh
blob: dda608cdb1af8231e1093ae516653172c9b2503c (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
#!/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`"
  else
    ADDR="`${PEINFO} ${BUILD}/${NAME} \
          | grep -A 5 text | grep VirtualAddress | cut -d " " -f2`"
  fi
  TEXT="`python -c "print(hex(${BASE} + ${ADDR}))"`"
  SYMS="`echo ${NAME} | sed -e "s/\.efi/\.debug/g"`"
  echo "add-symbol-file ${SYMOUT}/${SYMS} ${TEXT}"
done