hello-aarch64.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #! /bin/sh
  2. ## Copyright (C) 2017 Jeremiah Orians
  3. ## Copyright (C) 2020-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 -ex
  19. TMPDIR="test/test0015/tmp-aarch64"
  20. mkdir -p ${TMPDIR}
  21. # Build the test
  22. bin/M2-Planet \
  23. --architecture aarch64 \
  24. -f M2libc/AArch64/Linux/unistd.h \
  25. -f M2libc/stdlib.c \
  26. -f M2libc/AArch64/Linux/fcntl.h \
  27. -f M2libc/stdio.c \
  28. -f test/test0015/file_read.c \
  29. -o ${TMPDIR}/file_read.M1 \
  30. || exit 1
  31. # Macro assemble with libc written in M1-Macro
  32. M1 \
  33. -f M2libc/AArch64/aarch64_defs.M1 \
  34. -f M2libc/AArch64/libc-full.M1 \
  35. -f ${TMPDIR}/file_read.M1 \
  36. --LittleEndian \
  37. --architecture aarch64 \
  38. -o ${TMPDIR}/file_read.hex2 \
  39. || exit 2
  40. # Resolve all linkages
  41. hex2 \
  42. -f M2libc/AArch64/ELF-aarch64.hex2 \
  43. -f ${TMPDIR}/file_read.hex2 \
  44. --LittleEndian \
  45. --architecture aarch64 \
  46. --BaseAddress 0x400000 \
  47. -o test/results/test0015-aarch64-binary \
  48. --exec_enable \
  49. || exit 3
  50. # Ensure binary works if host machine supports test
  51. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "aarch64" ]
  52. then
  53. . ./sha256.sh
  54. # Verify that the resulting file works
  55. ./test/results/test0015-aarch64-binary test/test0015/file_read.c >| test/test0015/proof || exit 4
  56. out=$(sha256_check test/test0015/proof.answer)
  57. [ "$out" = "test/test0015/proof: OK" ] || exit 5
  58. fi
  59. exit 0