pal_loader 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. while [ "$1" != "" ];
  37. do
  38. if [ "$MANIFEST" == "" ]; then
  39. MANIFEST=$1
  40. shift
  41. continue
  42. fi
  43. break
  44. done
  45. if [ ! -f "$PAL_CMD" ]; then
  46. echo "$PAL_CMD is not built, or security mode is not supported"
  47. exit 1
  48. fi
  49. exec $PREFIX $PAL_CMD $MANIFEST "$@"