pal_loader 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. if [ "$1" == "SGX" ]; then
  3. if [ "$SGX" != "0" ]; then
  4. export SGX=1
  5. # Sometimes, we end up with a stray SGX_RUN in the environment,
  6. # which makes the Makefile.Host unhappy
  7. unset SGX_RUN
  8. # The interaction of SGX and SGX_RUN is getting pretty unwieldly.
  9. # We should kill off SGX_RUN. Here, we can get in trouble
  10. # if the make invocation below gets SGX_RUN via an MAKEFLAGS
  11. # from a wrapper makefile (e.g., the regression tests)
  12. unset MAKEFLAGS
  13. fi
  14. shift
  15. fi
  16. RUNTIME_DIR=$(/usr/bin/dirname $(readlink -f ${BASH_SOURCE[0]}))
  17. PAL_HOST=$(/usr/bin/make --quiet -f $RUNTIME_DIR/../Pal/src/Makefile.Host print_host 2>&1)
  18. MANIFEST=
  19. PERF_CMD=
  20. GDB_CMD=
  21. PAL_CMD=$RUNTIME_DIR/pal-$PAL_HOST
  22. if [ "$GDB" == "1" ]; then
  23. GDB=$RUNTIME_DIR/pal_gdb-$PAL_HOST
  24. if [ ! -f $GDB ]; then
  25. GDB="/usr/bin/gdb"
  26. fi
  27. fi
  28. if [ "$GDB" != "" ] && [ "$GDB" != "0" ]; then
  29. GDB_CMD="$GDB --args"
  30. fi
  31. if [ "$PERF" == "1" ]; then
  32. GDB_CMD="perf stat"
  33. fi
  34. if [ "$SEC" == "1" ]; then
  35. echo "Use reference monitor"
  36. PAL_CMD=$RUNTIME_DIR/pal_sec-$PAL_HOST
  37. fi
  38. while [ "$1" != "" ];
  39. do
  40. if [ "$MANIFEST" == "" ]; then
  41. MANIFEST=$1
  42. shift
  43. continue
  44. fi
  45. break
  46. done
  47. if [ ! -f "$PAL_CMD" ]; then
  48. echo "$PAL_CMD is not built, or security mode is not supported"
  49. exit 1
  50. fi
  51. exec $GDB_CMD $PAL_CMD $MANIFEST "$@"