pal_loader 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env 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 --no-print-directory --quiet -f $RUNTIME_DIR/../Pal/src/Makefile.Host print_host 2>&1)
  18. MANIFEST=
  19. PREFIX=
  20. PAL_CMD=$RUNTIME_DIR/pal-$PAL_HOST
  21. if [ "$GDB" == "1" ]; then
  22. GDB=$RUNTIME_DIR/pal_gdb-$PAL_HOST
  23. if [ ! -f $GDB ]; then
  24. GDB="/usr/bin/gdb"
  25. fi
  26. fi
  27. if [ "$GDB" != "" ] && [ "$GDB" != "0" ]; then
  28. PREFIX="$GDB --args"
  29. fi
  30. if [ "$PERF" == "1" ]; then
  31. PREFIX="perf stat"
  32. fi
  33. if [ "$MEMUSG" == "1" ]; then
  34. PREFIX="$RUNTIME_DIR/../Scripts/memusg"
  35. fi
  36. if [ "$SEC" == "1" ]; then
  37. echo "Use reference monitor"
  38. PAL_CMD=$RUNTIME_DIR/pal_sec-$PAL_HOST
  39. fi
  40. while [ "$1" != "" ];
  41. do
  42. if [ "$MANIFEST" == "" ]; then
  43. MANIFEST=$1
  44. shift
  45. continue
  46. fi
  47. break
  48. done
  49. if [ ! -f "$PAL_CMD" ]; then
  50. echo "$PAL_CMD is not built, or security mode is not supported"
  51. exit 1
  52. fi
  53. exec $PREFIX $PAL_CMD $MANIFEST "$@"