hello-amd64.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #! /bin/sh
  2. ## Copyright (C) 2017 Jeremiah Orians
  3. ## Copyright (C) 2021 deesix <deesix@tuta.io>
  4. ## This file is part of M2-Planet.
  5. ##
  6. ## M2-Planet is free software: you can redistribute it and/or modify
  7. ## it under the terms of the GNU General Public License as published by
  8. ## the Free Software Foundation, either version 3 of the License, or
  9. ## (at your option) any later version.
  10. ##
  11. ## M2-Planet is distributed in the hope that it will be useful,
  12. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ## GNU General Public License for more details.
  15. ##
  16. ## You should have received a copy of the GNU General Public License
  17. ## along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
  18. set -x
  19. TMPDIR="test/test0023/tmp-amd64"
  20. mkdir -p ${TMPDIR}
  21. # Build the test
  22. bin/M2-Planet \
  23. --architecture amd64 \
  24. -f test/common_amd64/functions/file.c \
  25. -f test/test0023/fseek.c \
  26. --debug \
  27. --bootstrap-mode \
  28. -o ${TMPDIR}/fseek.M1 \
  29. || exit 1
  30. # Build debug footer
  31. blood-elf \
  32. --64 \
  33. -f ${TMPDIR}/fseek.M1 \
  34. --entry _start \
  35. -o ${TMPDIR}/fseek-footer.M1 \
  36. || exit 2
  37. # Macro assemble with libc written in M1-Macro
  38. M1 \
  39. -f test/common_amd64/amd64_defs.M1 \
  40. -f test/common_amd64/libc-core.M1 \
  41. -f ${TMPDIR}/fseek.M1 \
  42. -f ${TMPDIR}/fseek-footer.M1 \
  43. --LittleEndian \
  44. --architecture amd64 \
  45. -o ${TMPDIR}/fseek.hex2 \
  46. || exit 3
  47. # Resolve all linkages
  48. hex2 \
  49. -f test/common_amd64/ELF-amd64-debug.hex2 \
  50. -f ${TMPDIR}/fseek.hex2 \
  51. --LittleEndian \
  52. --architecture amd64 \
  53. --BaseAddress 0x00600000 \
  54. -o test/results/test0023-amd64-binary \
  55. --exec_enable \
  56. || exit 4
  57. # Ensure binary works if host machine supports test
  58. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "amd64" ]
  59. then
  60. . ./sha256.sh
  61. # Verify that the resulting file works
  62. ./test/results/test0023-amd64-binary test/test0023/question >| test/test0023/proof
  63. [ 0 = $? ] || exit 5
  64. out=$(sha256_check test/test0023/proof.answer)
  65. [ "$out" = "test/test0023/proof: OK" ] || exit 6
  66. fi
  67. exit 0