pal-gdb 864 B

123456789101112131415161718192021
  1. #!/bin/bash
  2. BASE=0x1021000
  3. PAL=$(PAL_DIR)/pal
  4. PALGDBINIT=$(PAL_DIR)/pal.gdbinit
  5. if [ ! -f $PALGDBINIT ] || [ $PAL -nt $PALGDBINIT ]; then
  6. echo "symbol-file" > $PALGDBINIT
  7. readelf -WS $PAL | (
  8. SECTIONS=""
  9. TEXT=""
  10. while read -r line
  11. do
  12. echo ${line:5} | awk '{if ($3 ~ /^0/) { v = sprintf("%d", "0x" $3); if (v != 0) printf("section %s 0x%x\n", $1, sprintf("%d", "'$BASE'") + v) }}' >> $PALGDBINIT
  13. TEXT+=$(echo ${line:5} | awk '{if ($1 == ".text") { v = sprintf("%d", "0x" $3); printf("0x%x", sprintf("%d", "'$BASE'") + v) }}')
  14. SECTIONS+=$(echo ${line:5} | awk '{if ($1 != ".text" && $3 ~ /^0/) { v = sprintf("%d", "0x" $3); if (v != 0) printf(" -s %s 0x%x", $1, sprintf("%d", "'$BASE'") + v) }}')
  15. done
  16. echo add-symbol-file $PAL $TEXT $SECTIONS >> $PALGDBINIT)
  17. fi
  18. exec gdb -q -ex "source $PALGDBINIT" -ex "source $(PAL_DIR)/pal.gdb" --args $PAL "$@"