diff --git a/CHANGELOG.org b/CHANGELOG.org index 06a010b..a41d441 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -16,7 +16,7 @@ * Current ** Added -Added 8/24 working tests for armv7l +Added 10/24 working tests for armv7l ** Changed diff --git a/cc_core.c b/cc_core.c index fd6f1a7..8c70024 100644 --- a/cc_core.c +++ b/cc_core.c @@ -865,7 +865,7 @@ void collect_local() { if(KNIGHT_POSIX == Architecture) a->depth = 20; else if(X86 == Architecture) a->depth = -20; - else if(ARMV7L == Architecture) a->depth = 4; + else if(ARMV7L == Architecture) a->depth = 16; } else if((NULL == function->arguments) && (NULL == function->locals)) { diff --git a/makefile b/makefile index 71c1088..14ab354 100644 --- a/makefile +++ b/makefile @@ -101,6 +101,8 @@ test: test00-knight-posix-binary \ test09-armv7l-binary \ test10-armv7l-binary \ test11-armv7l-binary \ + test12-armv7l-binary \ + test13-armv7l-binary \ test00-x86-binary \ test01-x86-binary \ test02-x86-binary \ @@ -247,6 +249,12 @@ test10-armv7l-binary: M2-Planet | results test11-armv7l-binary: M2-Planet | results test/test11/hello-armv7l.sh +test12-armv7l-binary: M2-Planet | results + test/test12/hello-armv7l.sh + +test13-armv7l-binary: M2-Planet | results + test/test13/hello-armv7l.sh + test00-x86-binary: M2-Planet | results test/test00/hello-x86.sh diff --git a/test/common_armv7l/libc-core.M1 b/test/common_armv7l/libc-core.M1 index 82d210e..3cac0ae 100644 --- a/test/common_armv7l/libc-core.M1 +++ b/test/common_armv7l/libc-core.M1 @@ -15,15 +15,31 @@ ## along with M2-Planet. If not, see . :_start -'0' R13 R12 NO_SHIFT MOVE_ALWAYS -^~FUNCTION_main CALL_ALWAYS -!1 R7 LOADI8_ALWAYS -SYSCALL_ALWAYS + '0' SP BP NO_SHIFT MOVE_ALWAYS ; Setup Base Pointer + + ;; Prepare argv + !4 R0 ADD BP ARITH_ALWAYS ; ARGV_address = EBP + 4 + {R0} PUSH_ALWAYS ; Put argv on the stack + + ;; Prepare envp + '0' BP R0 NO_SHIFT MOVE_ALWAYS ; Address we need to load from + !0 R0 LOAD32 R0 MEMORY ; Get ARGC + !2 R0 ADD R0 ARITH_ALWAYS ; OFFSET = ARGC + 2 + '0' R0 R0 '1' MOVE_ALWAYS ; OFFSET = OFFSET * WORDSIZE + '0' R0 R0 ADD BP ARITH2_ALWAYS ; ENVP_address = EBP + OFFSET + {R0} PUSH_ALWAYS ; Put envp on the stack + + ;; Stack offset + !4 BP ADD BP ARITH_ALWAYS ; Fix ebp + + ^~FUNCTION_main CALL_ALWAYS ; Jump right into main + !1 R7 LOADI8_ALWAYS ; Setup for final exit + SYSCALL_ALWAYS ; Exit # Stub that simply returns :divide -'0' R14 R15 NO_SHIFT MOVE_ALWAYS + '0' R14 R15 NO_SHIFT MOVE_ALWAYS # Stub that simply returns :modulus -'0' R14 R15 NO_SHIFT MOVE_ALWAYS + '0' R14 R15 NO_SHIFT MOVE_ALWAYS diff --git a/test/test.answers b/test/test.answers index 790f42d..f1579ef 100644 --- a/test/test.answers +++ b/test/test.answers @@ -1,43 +1,45 @@ -8433f2c58f8e04a61a4403b9a5d5245513d8d52b9eb0d42c6b5ed66829394aa6 test/results/test00-armv7l-binary +30f3b6ec29b446709c14eeeb9f2f3943c078329ef25fe04adffa8ecc14a567ad test/results/test00-armv7l-binary 64879eebceb475f21e54cb1f2e872996ca80e8c1fbb8b5895fb5fb6bac0c4384 test/results/test00-knight-posix-binary c52562bd0aabb86ce8ca177f22f8d0455769b444df2d4d62894faab63b7151d8 test/results/test00-x86-binary -d77efa49034f3590ed7c77a8a18339d98be613f872ca7ee0adf41821d66bad81 test/results/test01-armv7l-binary +c531011fc5f54e90558cd8ed965c08af299f6e3b578cf32752fbca3374d4e411 test/results/test01-armv7l-binary 486ee05ccea796a9cfa9bfb23189b8e014b7ce8d14fea03b27d679d410fe17dd test/results/test01-knight-posix-binary eae96857f2b6d8e8ba86ac06e72345ea572622b358b23978bb5f2db1baadf41c test/results/test01-x86-binary -e85fdccb8626730ac9c3058225de1181af1da3004a4c8a776122e82bddc3ad20 test/results/test02-armv7l-binary +7ab0660ca3f7cc3812b27200da5638c3ec1843dc7e94b0d33ecfccf298704ff8 test/results/test02-armv7l-binary e6493845b9e94a617649638252f23502f9212de583fd00cba6cc07fffd296e32 test/results/test02-knight-posix-binary 8ead336d2f3f72d5874230492e0472edec61d355905e8636e3dfb2731695037c test/results/test02-x86-binary -4aabcedfb3b0a47808da7adc91616b03968dfe5876a656c8870c5aafe83ee0e7 test/results/test03-armv7l-binary +0c0542e4bd78c68d78b92d340c751129b51596eaa1bc21652c2c24b1a6362139 test/results/test03-armv7l-binary 96849d5a9294799a9648c24db21b2dab1555dd5ba69d172d77df800622347226 test/results/test03-knight-posix-binary 2313cb3f1a2b9eb6bf15f8d43418e15d6c16f7f1b5c22700fdfc2b38beb59192 test/results/test03-x86-binary -3014112897ad80d2f72382104b5bf3badd95db52fb60cdfd71c93148c16a38de test/results/test04-armv7l-binary +12af27e9925b88ea6e135246e920847c1b3a7a316db9f28b54881942faf32b4f test/results/test04-armv7l-binary df9ba08dfa69ac6cbb4483146dbbe079ef575d7de8318e2e52283151ebf24bd3 test/results/test04-knight-posix-binary b7ddb37063c541c6a315809c4438aa235d6702f54bb64f4ffc88dbe78617de81 test/results/test04-x86-binary -400f8b25f27b31d26b956686c8cc1f4f174466f6f3d0c4cc1d02e2718e005606 test/results/test05-armv7l-binary +18632e614634a1124aee22e5a39665f485a18e6486ba19a0b2c4ed3200b61202 test/results/test05-armv7l-binary 5db3a2fbd84150dae41e1c778f2822d053a0539cbdf59bba56e5514222f46674 test/results/test05-knight-posix-binary b5b76320ccda887a30b0bbefc2a5c302c8f2aa3c398d92ef3a79526690b25d6f test/results/test05-x86-binary -2d0d9778c9de385f7a78009bee00345611a90b24e7418f9e8773018bd6113bd4 test/results/test06-armv7l-binary +4e8bb78009a1a2986e46ec564d98996accfbe948723a11c9857b7aa39740dbdd test/results/test06-armv7l-binary b177d769ae44c3509d9a08d0ee631ec69654dc5d723408bf0decdc67c42aae27 test/results/test06-knight-posix-binary 663fc6eefe965f237b6bf5a211398c8ae1210f97ff39b59603677e92462c68c7 test/results/test06-x86-binary -1c125d2e347037ab8e2c542a2f77a4047edba17e49d9cfddf51bcbcdddd8ab9d test/results/test07-armv7l-binary +3a15eeae94c7db6f77e9647b20d09f96ed32290282eb3cfba6d3c9d83937c8f1 test/results/test07-armv7l-binary 9159c4ba8196b24ec78bc9ebfbc7066d510ddbf03461736e7795a48634134dc5 test/results/test07-knight-posix-binary a9a3e332d13ded5f80d7431f8717f26527b3722b33ea57760a9a5723dffc099c test/results/test07-x86-binary -1e23922a948e4ed066e8277899eefdd4e1b30621cac39d99a58728b9867d45e7 test/results/test08-armv7l-binary +f9b926f945ed1d89b0115f5902892eac3bc443d2371e7cd211ac78e650669ae7 test/results/test08-armv7l-binary b824859fd0e39f1417742a1b9a1cec18ade78afdd80ce2c64cb54cdf7683f53a test/results/test08-knight-posix-binary f1c01feb865c4d552033186d9ce50dd39468a7e8aebf762886c13ad3e03b5011 test/results/test08-x86-binary -c3c230a7cb41de90f3838752731ac102c6635f0ae937f5994c7880dfc13c31ef test/results/test09-armv7l-binary +3f7fcdb09da02dadae1e1591ff2ddbebd2ac7d9b08bc277bd49fc7277c84eeba test/results/test09-armv7l-binary 0feaacc13ad24c2b513fd9d46a58c38b1af57e77275c9a148cafb4a0d3cc7b7a test/results/test09-knight-posix-binary 3b39e72f3de90ed690adfaf6145af46157cef2ec5e72867ac577fa27a0229894 test/results/test09-x86-binary -2cd8d061bb1593016278f303c0772a367e5473e9dd763e50934a7e3d3738cbe5 test/results/test10-armv7l-binary +e5e366ee8119a407b953f1b3c968fbea4b182195c8faeed075e04179af1c1f6e test/results/test10-armv7l-binary c1b5a2a3cd46c5e95e5540e871c2a916e028684ca80f51c001ef489342e27625 test/results/test10-knight-posix-binary 020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-x86-binary -e7129da32a2d2b63c926463efcb064ad7165f4e23d0baa977932f516693b504c test/results/test100-knight-posix-binary -01ab3efcf5b57c11573fd774072ed3fd4ec42cca4bf5d64a35a1b878c63f6976 test/results/test100-x86-binary -aec370b762dc586ac9035c4fdfc98302a79628e9199ec28706765ab17a26b6d8 test/results/test11-armv7l-binary +6221bd208e7cd811cb986438afc106fb8f4fe86e5bd24ebbcd0e105ac7266a8b test/results/test100-knight-posix-binary +33f6ebf5e99395dd737275a83fc3d95f5587a97f1ed27df81ca45f473d466abd test/results/test100-x86-binary +56a8f3a60aa24cf0b6ff7874c50857a5a4bac9ad85b8eb342b97f6e6fb45107a test/results/test11-armv7l-binary 63fd5fbf389d1b19031026df193ec55e98d923b8568007125b80bc246c094496 test/results/test11-knight-posix-binary 3fd11bad4a426ce1ff8fd9c6d7d2b943effae9f3f5740b7376e426e9b0555851 test/results/test11-x86-binary +4617e974d1a4d9ba96b06d1f344f6ded437bfe9d4845c61f7423bfb352756527 test/results/test12-armv7l-binary 313536f9209d29d4c3b40f6ada898f81c1fb3b650ca1a84754f90b1db3b9e001 test/results/test12-knight-posix-binary f98ab8e4bb35580e0dde96126d7a56aff66bda208d02c8d89390b40d6cff591c test/results/test12-x86-binary +d0b387c93e0c09bbb3ffec64b9d6c432df4fe7180ac4897c7c143408611c8edd test/results/test13-armv7l-binary e50c97ba330823cb5cbe938bb9d1575340b083e60fc42db8edefcfd95851daa2 test/results/test13-knight-posix-binary 5051ffca2615144419f8ec1a5d4999486ae81e7781428f59e47e866af97cef92 test/results/test13-x86-binary 156fa1e6b5814da94a542dfe742f77e155d52724b34f75f3513b9e8f6f2503dd test/results/test14-knight-posix-binary diff --git a/test/test100/proof.answer b/test/test100/proof.answer index c7c92b4..b1dd60c 100644 --- a/test/test100/proof.answer +++ b/test/test100/proof.answer @@ -1 +1 @@ -db5953b6829313313f43b9f0474891c6436addd283de27f78436ad8e60da8b74 test/test100/proof +ba11e8d2eba93ac348c0e4fd3aa572a17e11e19c6a3073ecd4376edc665440bb test/test100/proof diff --git a/test/test12/hello-armv7l.sh b/test/test12/hello-armv7l.sh new file mode 100755 index 0000000..4b51637 --- /dev/null +++ b/test/test12/hello-armv7l.sh @@ -0,0 +1,44 @@ +#! /bin/sh +## Copyright (C) 2017 Jeremiah Orians +## This file is part of M2-Planet. +## +## M2-Planet is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## M2-Planet is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with M2-Planet. If not, see . + +set -ex +# Build the test +bin/M2-Planet --architecture armv7l -f test/common_armv7l/functions/putchar.c \ + -f test/common_armv7l/functions/exit.c \ + -f test/test12/break-for.c \ + -o test/test12/break-for.M1 || exit 1 + +# Macro assemble with libc written in M1-Macro +M1 -f test/common_armv7l/armv7l_defs.M1 \ + -f test/common_armv7l/libc-core.M1 \ + -f test/test12/break-for.M1 \ + --LittleEndian \ + --architecture armv7l \ + -o test/test12/break-for.hex2 || exit 2 + +# Resolve all linkages +hex2 -f test/common_armv7l/ELF-armv7l.hex2 -f test/test12/break-for.hex2 --LittleEndian --architecture armv7l --BaseAddress 0x10000 -o test/results/test12-armv7l-binary --exec_enable || exit 3 + +# Ensure binary works if host machine supports test +if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "armv7l" ] +then + # Verify that the resulting file works + ./test/results/test12-armv7l-binary >| test/test12/proof || exit 4 + out=$(sha256sum -c test/test12/proof.answer) + [ "$out" = "test/test12/proof: OK" ] || exit 5 +fi +exit 0 diff --git a/test/test13/hello-armv7l.sh b/test/test13/hello-armv7l.sh new file mode 100755 index 0000000..80a237f --- /dev/null +++ b/test/test13/hello-armv7l.sh @@ -0,0 +1,44 @@ +#! /bin/sh +## Copyright (C) 2017 Jeremiah Orians +## This file is part of M2-Planet. +## +## M2-Planet is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## M2-Planet is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with M2-Planet. If not, see . + +set -ex +# Build the test +bin/M2-Planet --architecture armv7l -f test/common_armv7l/functions/putchar.c \ + -f test/common_armv7l/functions/exit.c \ + -f test/test13/break-while.c \ + -o test/test13/break-while.M1 || exit 1 + +# Macro assemble with libc written in M1-Macro +M1 -f test/common_armv7l/armv7l_defs.M1 \ + -f test/common_armv7l/libc-core.M1 \ + -f test/test13/break-while.M1 \ + --LittleEndian \ + --architecture armv7l \ + -o test/test13/break-while.hex2 || exit 2 + +# Resolve all linkages +hex2 -f test/common_armv7l/ELF-armv7l.hex2 -f test/test13/break-while.hex2 --LittleEndian --architecture armv7l --BaseAddress 0x10000 -o test/results/test13-armv7l-binary --exec_enable || exit 3 + +# Ensure binary works if host machine supports test +if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "armv7l" ] +then + # Verify that the resulting file works + ./test/results/test13-armv7l-binary >| test/test13/proof || exit 4 + out=$(sha256sum -c test/test13/proof.answer) + [ "$out" = "test/test13/proof: OK" ] || exit 5 +fi +exit 0 diff --git a/test/test14/hello-armv7l.sh b/test/test14/hello-armv7l.sh new file mode 100755 index 0000000..f8d3cbb --- /dev/null +++ b/test/test14/hello-armv7l.sh @@ -0,0 +1,43 @@ +#! /bin/sh +## Copyright (C) 2017 Jeremiah Orians +## This file is part of M2-Planet. +## +## M2-Planet is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## M2-Planet is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with M2-Planet. If not, see . + +set -ex +# Build the test +bin/M2-Planet --architecture armv7l -f test/common_armv7l/functions/putchar.c \ + -f test/test14/basic_args.c \ + -o test/test14/basic_args.M1 || exit 1 + +# Macro assemble with libc written in M1-Macro +M1 -f test/common_armv7l/armv7l_defs.M1 \ + -f test/common_armv7l/libc-core.M1 \ + -f test/test14/basic_args.M1 \ + --LittleEndian \ + --architecture armv7l \ + -o test/test14/basic_args.hex2 || exit 2 + +# Resolve all linkages +hex2 -f test/common_armv7l/ELF-armv7l.hex2 -f test/test14/basic_args.hex2 --LittleEndian --architecture armv7l --BaseAddress 0x10000 -o test/results/test14-armv7l-binary --exec_enable || exit 3 + +# Ensure binary works if host machine supports test +if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "armv7l" ] +then + # Verify that the resulting file works + ./test/results/test14-armv7l-binary 314 1 5926 5 35897 932384626 43 383279 50288 419 71693 99375105 820974944 >| test/test14/proof || exit 4 + out=$(sha256sum -c test/test14/proof-armv7l.answer) + [ "$out" = "test/test14/proof: OK" ] || exit 5 +fi +exit 0 diff --git a/test/test14/proof-armv7l.answer b/test/test14/proof-armv7l.answer new file mode 100644 index 0000000..1fed2eb --- /dev/null +++ b/test/test14/proof-armv7l.answer @@ -0,0 +1 @@ +1f5476289bd20383b15f0c20c963406a098569b03ff4ef5407a2606cf56129dc test/test14/proof