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