pal_loader 916 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. if [ "$1" == "SGX" ]; then
  3. if [ "$SGX" != "0" ]; then
  4. export SGX=1
  5. fi
  6. shift
  7. fi
  8. RUNTIME_DIR=$(/usr/bin/dirname $(readlink -f ${BASH_SOURCE[0]}))
  9. PAL_HOST=$(/usr/bin/make --quiet -f $RUNTIME_DIR/../Pal/src/Makefile.Host print_host 2>&1)
  10. MANIFEST=
  11. PERF_CMD=
  12. GDB_CMD=
  13. PAL_CMD=$RUNTIME_DIR/pal-$PAL_HOST
  14. if [ "$GDB" == "1" ]; then
  15. GDB=$RUNTIME_DIR/pal_gdb-$PAL_HOST
  16. if [ ! -f $GDB ]; then
  17. GDB="/usr/bin/gdb"
  18. fi
  19. fi
  20. if [ "$GDB" != "" ] && [ "$GDB" != "0" ]; then
  21. GDB_CMD="$GDB --args"
  22. fi
  23. if [ "$PERF" == "1" ]; then
  24. GDB_CMD="perf stat"
  25. fi
  26. if [ "$SEC" == "1" ]; then
  27. echo "Use reference monitor"
  28. PAL_CMD=$RUNTIME_DIR/pal_sec-$PAL_HOST
  29. fi
  30. while [ "$1" != "" ];
  31. do
  32. if [ "$MANIFEST" == "" ]; then
  33. MANIFEST=$1
  34. shift
  35. continue
  36. fi
  37. break
  38. done
  39. if [ ! -f "$PAL_CMD" ]; then
  40. echo "$PAL_CMD is not built, or security mode is not supported"
  41. exit 1
  42. fi
  43. exec $GDB_CMD $PAL_CMD $MANIFEST "$@"