hello-aarch64.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 -x
  19. TMPDIR="test/test0103/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 functions/file_print.c \
  29. -f functions/match.c \
  30. -f test/test0103/get_machine.c \
  31. --debug \
  32. -o ${TMPDIR}/get_machine.M1 \
  33. || exit 1
  34. # Build debug footer
  35. blood-elf \
  36. --64 \
  37. -f ${TMPDIR}/get_machine.M1 \
  38. --entry _start \
  39. -o ${TMPDIR}/get_machine-footer.M1 \
  40. || exit 2
  41. # Macro assemble with libc written in M1-Macro
  42. M1 \
  43. -f M2libc/AArch64/aarch64_defs.M1 \
  44. -f M2libc/AArch64/libc-full.M1 \
  45. -f ${TMPDIR}/get_machine.M1 \
  46. -f ${TMPDIR}/get_machine-footer.M1 \
  47. --LittleEndian \
  48. --architecture aarch64 \
  49. -o ${TMPDIR}/get_machine.hex2 \
  50. || exit 3
  51. # Resolve all linkages
  52. hex2 \
  53. -f M2libc/AArch64/ELF-aarch64-debug.hex2 \
  54. -f ${TMPDIR}/get_machine.hex2 \
  55. --LittleEndian \
  56. --architecture aarch64 \
  57. --BaseAddress 0x400000 \
  58. -o test/results/test0103-aarch64-binary \
  59. --exec_enable \
  60. || exit 4
  61. # Ensure binary works if host machine supports test
  62. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "aarch64" ]
  63. then
  64. # Verify that the compiled program returns the correct result
  65. out=$(./test/results/test0103-aarch64-binary ${GET_MACHINE_FLAGS} 2>&1 )
  66. [ 0 = $? ] || exit 5
  67. [ "$out" = "aarch64" ] || exit 6
  68. fi
  69. exit 0