From 442601197ce91c3c8dd0855f2d2e2e2cb6295238 Mon Sep 17 00:00:00 2001 From: Jeremiah Orians Date: Sat, 30 Mar 2019 09:25:52 -0400 Subject: [PATCH] 17/24 working tests for armv7l --- CHANGELOG.org | 1 + cc_core.c | 12 +-- makefile | 14 +++- test/common_armv7l/armv7l_defs.M1 | 5 ++ test/common_armv7l/functions/execve.c | 48 ++++++++++++ test/common_armv7l/functions/file.c | 1 - test/common_armv7l/functions/fork.c | 22 ++++++ test/common_armv7l/functions/getchar.c | 29 +++++++ test/common_armv7l/functions/stat.c | 51 +++++++++++++ test/common_armv7l/functions/uname.c | 33 ++++++++ test/common_armv7l/libc-core.M1 | 49 +++--------- .../common_x86/functions}/execve.c | 0 .../common_x86/functions}/fork.c | 0 test/test.answers | 47 ++++++------ test/test100/proof.answer | 2 +- test/test21/hello-armv7l.sh | 66 ++++++++++++++++ test/test22/hello-armv7l.sh | 73 ++++++++++++++++++ test/test23/hello-armv7l.sh | 75 +++++++++++++++++++ test/test25/{hello.sh => hello-x86.sh} | 4 +- test/test26/{hello.sh => hello-x86.sh} | 0 20 files changed, 459 insertions(+), 73 deletions(-) create mode 100644 test/common_armv7l/functions/execve.c create mode 100644 test/common_armv7l/functions/fork.c create mode 100644 test/common_armv7l/functions/getchar.c create mode 100644 test/common_armv7l/functions/stat.c create mode 100644 test/common_armv7l/functions/uname.c rename {functions => test/common_x86/functions}/execve.c (100%) rename {functions => test/common_x86/functions}/fork.c (100%) create mode 100755 test/test21/hello-armv7l.sh create mode 100755 test/test22/hello-armv7l.sh create mode 100755 test/test23/hello-armv7l.sh rename test/test25/{hello.sh => hello-x86.sh} (95%) rename test/test26/{hello.sh => hello-x86.sh} (100%) diff --git a/CHANGELOG.org b/CHANGELOG.org index d485f30..1cf0d28 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -21,6 +21,7 @@ Added 15/24 working tests for armv7l ** Changed ** Fixed +Fixed unsigned division in ARMv7l port ** Removed diff --git a/cc_core.c b/cc_core.c index 38bebf3..14bbda1 100644 --- a/cc_core.c +++ b/cc_core.c @@ -177,8 +177,8 @@ void function_call(char* s, int bool) emit_out(s); emit_out(" R0 SUB BP ARITH_ALWAYS\n"); emit_out("!0 R0 LOAD32 R0 MEMORY\n"); - emit_out("'0' R11 BP NO_SHIFT MOVE_ALWAYS\n"); emit_out("{LR} PUSH_ALWAYS\t# Protect the old link register\n"); + emit_out("'0' R11 BP NO_SHIFT MOVE_ALWAYS\n"); emit_out("'3' R0 CALL_REG_ALWAYS\n"); emit_out("{LR} POP_ALWAYS\t# Prevent overwrite\n"); } @@ -288,14 +288,14 @@ void global_load(struct token_list* a) current_target = a->type; if(KNIGHT_POSIX == Architecture) emit_out("LOADR R0 4\nJUMP 4\n&GLOBAL_"); else if(X86 == Architecture) emit_out("LOAD_IMMEDIATE_eax &GLOBAL_"); - else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#global_load\n"); + else if(ARMV7L == Architecture) emit_out("!0 R0 LOAD32 R15 MEMORY\n~0 JUMP_ALWAYS\n&GLOBAL_"); emit_out(a->s); emit_out("\n"); if(!match("=", global_token->s)) { if(KNIGHT_POSIX == Architecture) emit_out("LOAD R0 R0 0\n"); else if(X86 == Architecture) emit_out("LOAD_INTEGER\n"); - else if(ARMV7L == Architecture) emit_out("PLACEHOLDER\t#global_load\n"); + else if(ARMV7L == Architecture) emit_out("!0 R0 LOAD32 R0 MEMORY\n"); } } @@ -1157,7 +1157,7 @@ void return_result() if(KNIGHT_POSIX == Architecture) emit_out("RET R15\n"); else if(X86 == Architecture) emit_out("RETURN\n"); - else if(ARMV7L == Architecture) emit_out("'0' LR PC NO_SHIFT MOVE_ALWAYS\n"); + else if(ARMV7L == Architecture) emit_out("'1' LR RETURN\n"); } void process_break() @@ -1207,7 +1207,7 @@ void recursive_statement() if(((X86 == Architecture) && !match("RETURN\n", out->s)) || ((KNIGHT_POSIX == Architecture) && !match("RET R15\n", out->s)) || - (ARMV7L == Architecture)) + ((ARMV7L == Architecture) && !match("'1' LR RETURN\n", out->s))) { struct token_list* i; for(i = function->locals; frame != i; i = i->next) @@ -1373,7 +1373,7 @@ void declare_function() /* Prevent duplicate RETURNS */ if((KNIGHT_POSIX == Architecture) && !match("RET R15\n", out->s)) emit_out("RET R15\n"); else if((X86 == Architecture) && !match("RETURN\n", out->s)) emit_out("RETURN\n"); - else if((ARMV7L == Architecture) && !match("'0' LR PC NO_SHIFT MOVE_ALWAYS\n", out->s)) emit_out("'0' LR PC NO_SHIFT MOVE_ALWAYS\n"); + else if((ARMV7L == Architecture) && !match("'1' LR RETURN\n", out->s)) emit_out("'1' LR RETURN\n"); } } diff --git a/makefile b/makefile index 229f263..d34aefd 100644 --- a/makefile +++ b/makefile @@ -19,7 +19,7 @@ VPATH = bin:test:test/results all: M2-Planet -M2-Planet: bin results +M2-Planet: bin results cc.h cc_reader.c cc_strings.c cc_types.c cc_core.c cc.c ./test/test100/hello.sh # Clean up after ourselves @@ -109,6 +109,9 @@ test: test00-knight-posix-binary \ test17-armv7l-binary \ test18-armv7l-binary \ test19-armv7l-binary \ + test20-armv7l-binary \ + test21-armv7l-binary \ + test22-armv7l-binary \ test00-x86-binary \ test01-x86-binary \ test02-x86-binary \ @@ -279,6 +282,15 @@ test18-armv7l-binary: M2-Planet | results test19-armv7l-binary: M2-Planet | results test/test19/hello-armv7l.sh +test20-armv7l-binary: M2-Planet | results + test/test20/hello-armv7l.sh + +test21-armv7l-binary: M2-Planet | results + test/test21/hello-armv7l.sh + +test22-armv7l-binary: M2-Planet | results + test/test22/hello-armv7l.sh + test00-x86-binary: M2-Planet | results test/test00/hello-x86.sh diff --git a/test/common_armv7l/armv7l_defs.M1 b/test/common_armv7l/armv7l_defs.M1 index a3727c1..57fb81e 100644 --- a/test/common_armv7l/armv7l_defs.M1 +++ b/test/common_armv7l/armv7l_defs.M1 @@ -14,6 +14,9 @@ ## You should have received a copy of the GNU General Public License ## along with stage0. If not, see . +# M2-Planet standards +DEFINE NOP 00000000 + # Registers DEFINE R0 0 DEFINE R1 1 @@ -72,6 +75,7 @@ DEFINE JUMP_EQUAL 0A DEFINE JUMP_NE 1A DEFINE CALL_ALWAYS EB DEFINE CALL_REG_ALWAYS FF2FE1 +DEFINE RETURN FF2FE1 # Data movement DEFINE MOVE_ALWAYS A0E1 @@ -90,6 +94,7 @@ DEFINE ARITH_LT B2 DEFINE ARITH_NE 12 DEFINE ARITH2_ALWAYS E0 DEFINE ARITH2_GE A0 +DEFINE ADC 0A DEFINE ADCS 0B DEFINE ADD 08 DEFINE ADDS 09 diff --git a/test/common_armv7l/functions/execve.c b/test/common_armv7l/functions/execve.c new file mode 100644 index 0000000..6c86dac --- /dev/null +++ b/test/common_armv7l/functions/execve.c @@ -0,0 +1,48 @@ +/* Copyright (C) 2016 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 . + */ + +void exit(int value); + +void _exit(int value) +{ + exit(value); +} + +int waitpid (int pid, int* status_ptr, int options) +{ + asm("!114 R7 LOADI8_ALWAYS" + "!12 R2 SUB R12 ARITH_ALWAYS" + "!0 R2 LOAD32 R2 MEMORY" + "!8 R1 SUB R12 ARITH_ALWAYS" + "!0 R1 LOAD32 R1 MEMORY" + "!4 R0 SUB R12 ARITH_ALWAYS" + "!0 R0 LOAD32 R0 MEMORY" + "SYSCALL_ALWAYS"); +} + + +int execve(char* file_name, char** argv, char** envp) +{ + asm("!11 R7 LOADI8_ALWAYS" + "!12 R2 SUB R12 ARITH_ALWAYS" + "!0 R2 LOAD32 R2 MEMORY" + "!8 R1 SUB R12 ARITH_ALWAYS" + "!0 R1 LOAD32 R1 MEMORY" + "!4 R0 SUB R12 ARITH_ALWAYS" + "!0 R0 LOAD32 R0 MEMORY" + "SYSCALL_ALWAYS"); +} diff --git a/test/common_armv7l/functions/file.c b/test/common_armv7l/functions/file.c index 38ce412..6a89889 100644 --- a/test/common_armv7l/functions/file.c +++ b/test/common_armv7l/functions/file.c @@ -91,7 +91,6 @@ FILE* fopen(char* filename, char* mode) int close(int fd) { asm("!4 R0 SUB R12 ARITH_ALWAYS" - "!0 R0 LOAD32 R0 MEMORY" "!6 R7 LOADI8_ALWAYS" "SYSCALL_ALWAYS"); } diff --git a/test/common_armv7l/functions/fork.c b/test/common_armv7l/functions/fork.c new file mode 100644 index 0000000..b8a2e65 --- /dev/null +++ b/test/common_armv7l/functions/fork.c @@ -0,0 +1,22 @@ +/* Copyright (C) 2016 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 . + */ + +int fork() +{ + asm("!2 R7 LOADI8_ALWAYS" + "SYSCALL_ALWAYS"); +} diff --git a/test/common_armv7l/functions/getchar.c b/test/common_armv7l/functions/getchar.c new file mode 100644 index 0000000..ba3b616 --- /dev/null +++ b/test/common_armv7l/functions/getchar.c @@ -0,0 +1,29 @@ +/* Copyright (C) 2016 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 . + */ + +int getchar() +{ + asm("!0 R0 LOADI8_ALWAYS" + "{R0} PUSH_ALWAYS" + "'0' SP R1 NO_SHIFT MOVE_ALWAYS" + "!1 R2 LOADI8_ALWAYS" + "!3 R7 LOADI8_ALWAYS" + "SYSCALL_ALWAYS" + "!0 CMPI8 R0 IMM_ALWAYS" + "{R0} POP_ALWAYS" + "!0 R0 MVNI8_EQUAL"); +} diff --git a/test/common_armv7l/functions/stat.c b/test/common_armv7l/functions/stat.c new file mode 100644 index 0000000..ae9436a --- /dev/null +++ b/test/common_armv7l/functions/stat.c @@ -0,0 +1,51 @@ +/* Copyright (C) 2016 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 . + */ + +/* + * chmod() changes the mode of the file specified whose pathname is given in + * pathname, which is dereferenced if it is a symbolic link. + * fchmod() changes the mode of the file referred to by the open file + * descriptor fd. + * The new file mode is specified in mode, which is a bit mask created by + * ORing together zero or more of the following: + * S_ISUID (04000) set-user-ID (set process effective user ID on execve(2)) + * S_ISGID (02000) set-group-ID (set process effective group ID on execve(2) + * mandatory locking, as described in fcntl(2); take a new file's group from + * parent directory, as described in chown(2) and mkdir(2)) + * S_ISVTX (01000) sticky bit (restricted deletion flag, as described in + * unlink(2)) + * S_IRUSR (00400) read by owner + * S_IWUSR (00200) write by owner + * S_IXUSR (00100) execute/search by owner ("search" applies for directories + * , and means that entries within the directory can be accessed) + * S_IRGRP (00040) read by group + * S_IWGRP (00020) write by group + * S_IXGRP (00010) execute/search by group + * S_IROTH (00004) read by others + * S_IWOTH (00002) write by others + * S_IXOTH (00001) execute/search by others + */ + +int chmod(char *pathname, int mode) +{ + asm("!15 R7 LOADI8_ALWAYS" + "!8 R1 SUB R12 ARITH_ALWAYS" + "!0 R1 LOAD32 R1 MEMORY" + "!4 R0 SUB R12 ARITH_ALWAYS" + "!0 R0 LOAD32 R0 MEMORY" + "SYSCALL_ALWAYS"); +} diff --git a/test/common_armv7l/functions/uname.c b/test/common_armv7l/functions/uname.c new file mode 100644 index 0000000..48d1549 --- /dev/null +++ b/test/common_armv7l/functions/uname.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2016 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 . + */ + +struct utsname +{ + char sysname[65]; /* Operating system name (e.g., "Linux") */ + char nodename[65]; /* Name within "some implementation-defined network" */ + char release[65]; /* Operating system release (e.g., "2.6.28") */ + char version[65]; /* Operating system version */ + char machine[65]; /* Hardware identifier */ +}; + +int uname(struct utsname* unameData) +{ + asm("!122 R7 LOADI8_ALWAYS" + "!4 R0 SUB R12 ARITH_ALWAYS" + "!0 R0 LOAD32 R0 MEMORY" + "SYSCALL_ALWAYS"); +} diff --git a/test/common_armv7l/libc-core.M1 b/test/common_armv7l/libc-core.M1 index b6c539c..1f14aae 100644 --- a/test/common_armv7l/libc-core.M1 +++ b/test/common_armv7l/libc-core.M1 @@ -47,7 +47,7 @@ !0 R0 LOADI8_ALWAYS ; MOV R0,#0 !0 CMPI8 R2 IMM_ALWAYS ; CMP R2,#0 - !0 R2 RSUB R2 ARITH_LT ; RSBLT R2,R2,#0 +; !0 R2 RSUB R2 ARITH_LT ; RSBLT R2,R2,#0 !1 R0 SUB R0 ARITH_LT ; SUBLT R0,R0,#1 !0 CMPI8 R3 IMM_ALWAYS ; CMP R3,#0 !0 R3 RSUB R3 ARITH_LT ; RSBLT R3,R3,#0 @@ -66,50 +66,19 @@ !0 CMPI8 R0 IMM_ALWAYS ; CMP R0,#0 ^~divide_loop JUMP_NE ; BNE loop - !0 CMPI8 R4 IMM_ALWAYS ; CMP R4,#0 - !0 R2 RSUB R2 ARITH_NE ; RSBNE R2,R2,#0 +; !0 CMPI8 R4 IMM_ALWAYS ; CMP R4,#0 +; !0 R2 RSUB R2 ARITH_NE ; RSBNE R2,R2,#0 '0' R2 R0 NO_SHIFT MOVE_ALWAYS ; MOV R0,R2 {R2} POP_ALWAYS ; Restore R2 {R3} POP_ALWAYS ; Restore R3 {R4} POP_ALWAYS ; Restore R4 - '0' R14 R15 NO_SHIFT MOVE_ALWAYS + '1' LR RETURN # Stub that simply returns :modulus - {R4} PUSH_ALWAYS ; Protect R4 - {R3} PUSH_ALWAYS ; Protect R3 - {R2} PUSH_ALWAYS ; Protect R2 - - '0' R0 R3 NO_SHIFT MOVE_ALWAYS ; MOV R3,R0 - '0' R1 R2 NO_SHIFT MOVE_ALWAYS ; MOV R2,R1 - - !0 R0 LOADI8_ALWAYS ; MOV R0,#0 - !0 CMPI8 R2 IMM_ALWAYS ; CMP R2,#0 - !0 R2 RSUB R2 ARITH_LT ; RSBLT R2,R2,#0 - !1 R0 SUB R0 ARITH_LT ; SUBLT R0,R0,#1 - !0 CMPI8 R3 IMM_ALWAYS ; CMP R3,#0 - !0 R3 RSUB R3 ARITH_LT ; RSBLT R3,R3,#0 - '0' R0 R0 MVN_LT ; MVNLT R0,R0 - '0' R0 R4 NO_SHIFT MOVE_ALWAYS ; MOV R4,R0 - - !32 R0 LOADI8_ALWAYS ; MOV R0,#32. - !0 R1 LOADI8_ALWAYS ; MOV R1,#0 -:modulus_loop - '0' R2 R2 ADDS R2 ARITH2_ALWAYS ; ADDS R2,R2,R2 - '0' R1 R1 ADCS R1 ARITH2_ALWAYS ; ADCS R1,R1,R1 - '0' R3 CMP R1 AUX_ALWAYS ; CMP R1,R3 - '0' R3 R1 SUB R1 ARITH2_GE ; SUBGE R1,R1,R3 - !1 R2 ADD R2 ARITH_GE ; ADDGE R2,R2,#1 - !1 R0 SUB R0 ARITH_ALWAYS ; SUB R0,R0,#1 - !0 CMPI8 R0 IMM_ALWAYS ; CMP R0,#0 - ^~modulus_loop JUMP_NE ; BNE loop - - !0 CMPI8 R4 IMM_ALWAYS ; CMP R4,#0 - !0 R1 RSUB R2 ARITH_NE ; RSBNE R2,R2,#0 - '0' R1 R0 NO_SHIFT MOVE_ALWAYS ; MOV R0,R2 - - {R2} POP_ALWAYS ; Restore R2 - {R3} POP_ALWAYS ; Restore R3 - {R4} POP_ALWAYS ; Restore R4 - '0' R14 R15 NO_SHIFT MOVE_ALWAYS + {LR} PUSH_ALWAYS ; Prepare to leverage divide + ^~divide CALL_ALWAYS ; Use divide + '0' R1 R0 NO_SHIFT MOVE_ALWAYS ; MOV R0,R1 + {LR} POP_ALWAYS ; Prepare for return + '1' LR RETURN diff --git a/functions/execve.c b/test/common_x86/functions/execve.c similarity index 100% rename from functions/execve.c rename to test/common_x86/functions/execve.c diff --git a/functions/fork.c b/test/common_x86/functions/fork.c similarity index 100% rename from functions/fork.c rename to test/common_x86/functions/fork.c diff --git a/test/test.answers b/test/test.answers index 56620bf..6164d42 100644 --- a/test/test.answers +++ b/test/test.answers @@ -1,69 +1,72 @@ -d61b0f0acc0c23f7b0b7778449f83539ad92a8969bcde9fe503ad50966a09672 test/results/test00-armv7l-binary +d33b2703ff3ab3bf61911ce98213fc9294caff69717dd2502df77a24be113e3a test/results/test00-armv7l-binary 64879eebceb475f21e54cb1f2e872996ca80e8c1fbb8b5895fb5fb6bac0c4384 test/results/test00-knight-posix-binary c52562bd0aabb86ce8ca177f22f8d0455769b444df2d4d62894faab63b7151d8 test/results/test00-x86-binary -ba2f63bcefdab8648955b181a6028938cc1409dd88938e2bd5f51e85f8e79fd8 test/results/test01-armv7l-binary +fbd4aa3a509608adfc0c171d96c7c61f96494414bec6001c4c4bf238f2040361 test/results/test01-armv7l-binary 486ee05ccea796a9cfa9bfb23189b8e014b7ce8d14fea03b27d679d410fe17dd test/results/test01-knight-posix-binary eae96857f2b6d8e8ba86ac06e72345ea572622b358b23978bb5f2db1baadf41c test/results/test01-x86-binary -eca3b8f019cd343a5433d5fffa5b3b5fd9653b967b7df3a1772f29864a91be7d test/results/test02-armv7l-binary +90d65efce4a9dd695944de7f0aa6022bb2e8e4d5ae56d90250d691a3b58d3fd9 test/results/test02-armv7l-binary e6493845b9e94a617649638252f23502f9212de583fd00cba6cc07fffd296e32 test/results/test02-knight-posix-binary 8ead336d2f3f72d5874230492e0472edec61d355905e8636e3dfb2731695037c test/results/test02-x86-binary -c39545274d6b677fc4aa7915b89b50700ffc83260d9e0f073924bd474952105c test/results/test03-armv7l-binary +013460f5fb75837d6b836875d45bdaffd6d1834eda46765c1c574148ff49dacf test/results/test03-armv7l-binary 96849d5a9294799a9648c24db21b2dab1555dd5ba69d172d77df800622347226 test/results/test03-knight-posix-binary 2313cb3f1a2b9eb6bf15f8d43418e15d6c16f7f1b5c22700fdfc2b38beb59192 test/results/test03-x86-binary -4463231ba4218eeecc9a37a98519ac8d39396e21cfb9263372b40abbd88b50d2 test/results/test04-armv7l-binary +bfcc2f0893998737cf0ff2ca50a1c065c4af9426cbead6aeb90d841ca1658459 test/results/test04-armv7l-binary df9ba08dfa69ac6cbb4483146dbbe079ef575d7de8318e2e52283151ebf24bd3 test/results/test04-knight-posix-binary b7ddb37063c541c6a315809c4438aa235d6702f54bb64f4ffc88dbe78617de81 test/results/test04-x86-binary -692aff5e76d70b47d6ece4cdf2678c5db1fd7f327934fd5995c5a8ec5eb1ee3e test/results/test05-armv7l-binary +4bb7750c5561cf655dae88e80ff5337f01e3c6221afb96279207e2ac777559b7 test/results/test05-armv7l-binary 5db3a2fbd84150dae41e1c778f2822d053a0539cbdf59bba56e5514222f46674 test/results/test05-knight-posix-binary b5b76320ccda887a30b0bbefc2a5c302c8f2aa3c398d92ef3a79526690b25d6f test/results/test05-x86-binary -443c8c5d8c0f324bc547c195c49067d4ced532298034ca0690cd06009f41e054 test/results/test06-armv7l-binary +f798c846d3e1b0169a09a526ccccbf2a9f846697f19817d672d02bc0f0e4ea38 test/results/test06-armv7l-binary b177d769ae44c3509d9a08d0ee631ec69654dc5d723408bf0decdc67c42aae27 test/results/test06-knight-posix-binary 663fc6eefe965f237b6bf5a211398c8ae1210f97ff39b59603677e92462c68c7 test/results/test06-x86-binary -522e359ef287493f6f0bd33b9f786a7b28452f2abac44d32cf2ab8afaf69d882 test/results/test07-armv7l-binary +a61620928a09b5ac23480d687b2edd4de0785909ef83f159a8e5a806e00b0f15 test/results/test07-armv7l-binary 9159c4ba8196b24ec78bc9ebfbc7066d510ddbf03461736e7795a48634134dc5 test/results/test07-knight-posix-binary a9a3e332d13ded5f80d7431f8717f26527b3722b33ea57760a9a5723dffc099c test/results/test07-x86-binary -8f48e296e2cda43fd3991b5d5e5161a1e17b5c9549d808cfffa9a9fa6a0d71a2 test/results/test08-armv7l-binary +61899e1383dfc36260022d1f0bd3f655f7f0f0311da76ce9bc160646c390c00d test/results/test08-armv7l-binary b824859fd0e39f1417742a1b9a1cec18ade78afdd80ce2c64cb54cdf7683f53a test/results/test08-knight-posix-binary f1c01feb865c4d552033186d9ce50dd39468a7e8aebf762886c13ad3e03b5011 test/results/test08-x86-binary -e51082e94a5e1db490e69aaf21ddbcf5d7c40c736e7d60dc0ea6c09f8d67ea7f test/results/test09-armv7l-binary +cf429533b6473e725c6f6f046ac028181090c532f52f73cd07b87f1e6da64820 test/results/test09-armv7l-binary 0feaacc13ad24c2b513fd9d46a58c38b1af57e77275c9a148cafb4a0d3cc7b7a test/results/test09-knight-posix-binary 3b39e72f3de90ed690adfaf6145af46157cef2ec5e72867ac577fa27a0229894 test/results/test09-x86-binary -7c677be4b211bff23ef44dad9baebdf3ba8b80f66308b765253e190264454561 test/results/test10-armv7l-binary +d2b4095983ddd89328e17d983dd8802956c30a4de67267a080772b2e43ee1466 test/results/test10-armv7l-binary c1b5a2a3cd46c5e95e5540e871c2a916e028684ca80f51c001ef489342e27625 test/results/test10-knight-posix-binary 020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-x86-binary -ff78d3b3fd12b22209fbe1ec00e5951dfff5ee0f1fd17f76895c9d158737b813 test/results/test100-knight-posix-binary -27dae5fb2488e7cb5f2232f43d3107177aff476308c3ce078ce68745254836e3 test/results/test100-x86-binary -ee1f6f1dfebc705f9fa8e02185b9d698b40dee3c58e03846fc84b90ea9665bc0 test/results/test11-armv7l-binary +e42c3c0759430314229f431a492be9f0f04ccb79552a68fc4cfc6a692c2a55f8 test/results/test100-knight-posix-binary +7449bc586cf05b4bf63908b74280ad9e59aaf4f6d142af621680961cf5fecfc4 test/results/test100-x86-binary +ea5065ec0604f4701713d8c96a588f96ffc610d7787bca0c3bb3af6db884691a test/results/test11-armv7l-binary 63fd5fbf389d1b19031026df193ec55e98d923b8568007125b80bc246c094496 test/results/test11-knight-posix-binary 3fd11bad4a426ce1ff8fd9c6d7d2b943effae9f3f5740b7376e426e9b0555851 test/results/test11-x86-binary -cb6851568754a78da8d451df3b7ad7cd08894dcd7d85d55b42b86fae27289063 test/results/test12-armv7l-binary +611638cecf9cd4661c7af1d7a4b1bfe91ef447e9927ff8649f14343a243e29e0 test/results/test12-armv7l-binary 313536f9209d29d4c3b40f6ada898f81c1fb3b650ca1a84754f90b1db3b9e001 test/results/test12-knight-posix-binary f98ab8e4bb35580e0dde96126d7a56aff66bda208d02c8d89390b40d6cff591c test/results/test12-x86-binary -dd3a885a0d9ec82be2fabc9c5681333e5082e9f277ff1a71ba0f72d112187a94 test/results/test13-armv7l-binary +0d2b20a8962c02ce605b3ee659c42918ba6342ff834babe921717b57a569910c test/results/test13-armv7l-binary e50c97ba330823cb5cbe938bb9d1575340b083e60fc42db8edefcfd95851daa2 test/results/test13-knight-posix-binary 5051ffca2615144419f8ec1a5d4999486ae81e7781428f59e47e866af97cef92 test/results/test13-x86-binary -0f77dcc7236dfdd135ccd4bafba2692fae890b0cf20de7e70c6fb0fa03eb8ee9 test/results/test14-armv7l-binary +378316cef7126c0538627b7225c0ebca8d7e735870b09ed6a8b3f92584a14191 test/results/test14-armv7l-binary 156fa1e6b5814da94a542dfe742f77e155d52724b34f75f3513b9e8f6f2503dd test/results/test14-knight-posix-binary a8218958b628066e2fda63d3933f1bf607c358d7bdfe84fc02596393698ea5f6 test/results/test14-x86-binary -e0d83fe73686c09db16a0f9fa65d4611b297da0c435a77b9cd51a89df7d2c16d test/results/test15-armv7l-binary +2fb75063994bb49dd13eb13ecd63fad79bc44f1702dc691ddfcb391a383e01a4 test/results/test15-armv7l-binary 9f7c81e278248a3160d80a3f5ca0c39a5505ca9b45adc002e9b527db3e5f084a test/results/test15-knight-posix-binary 3adb4a5f3995583ba711151361728a26c3fbf0140864d13b4b042978ca45d683 test/results/test15-x86-binary -2a07f8aa3ef9e733c67318558220ce7c96987156903f6d4feb8b8a92caf4f036 test/results/test16-armv7l-binary +46edd2a14916ff5adf1d1d4b8826671dd812c0fc12652cd12fad550161a58b28 test/results/test16-armv7l-binary 84f5472ce5711b9cad28fcd4c177eea673047c2561ea010ccb6bf5f50d89c713 test/results/test16-knight-posix-binary d70e072f4f1f077d10ff65e9216ca8b423b996e35d68d208025db7a78b062f50 test/results/test16-x86-binary -b4090b8fa5bd67ad00c6ef62e8647fe28462d824807d348ec3be5304409f8bd8 test/results/test17-armv7l-binary +b631b066d284ad3e1657fcaac9d02f8b14eb7de6df550fb7ca214cdf8c1ed06c test/results/test17-armv7l-binary 0323ae8fa9e79cae9a58eec89a80b2c354db276d76c6f50b3bf50840327d4950 test/results/test17-knight-posix-binary 9b4ba350b07cc1cf4e12dc77d0d960ded1511f13b887363b0eb33421e2f626de test/results/test17-x86-binary -dd62c0e2d2bdac340d22a5cd7ba38b0dde1792620c24024bcff3a5c2b6ad74bd test/results/test18-armv7l-binary +e08f5759f5dad762603fff32e09f9e65eb6e54aa60bb4567768887df8c702390 test/results/test18-armv7l-binary d0f0b1428c8db70806d6e2e5b81aca4b6752c4a581a3fa83da064317ceb605b0 test/results/test18-knight-posix-binary 8de7384c4633b1d5c60bbbb298d7f4b738e52fbc266ef4ef9a48b3cb995e3176 test/results/test18-x86-binary -952e0e9d4ae098c73b6152422a5ed9eb29ac2fc3b853c8246433ea8832766598 test/results/test19-armv7l-binary +3108c15dc5e50f18f9ce1d30f04565c6acea1d7bc253a86b5b969db2795cef31 test/results/test19-armv7l-binary 32ba6ae74a8756fe4b95c65a643513bdd785778f98a878b3ea5459b5aaccaa38 test/results/test19-knight-posix-binary cefc5a53513abdb9069dc8bdb7b4529307420d5dd412a10112c3253bdcd29c46 test/results/test19-x86-binary +0f2b7439f9635a1b8872f0bf2190a0c34ceb578d17ade9632271db964d0c15a0 test/results/test20-armv7l-binary 6a59795dbb4397d0efaf1ad613d646ec435eec62db30eb758bcf2499d651520e test/results/test20-knight-posix-binary 365c96fb8368710d620a76facd6bebcdeeb6f6d30ceaf0a6f1567fc3fcbe9b54 test/results/test20-x86-binary +997108ef0bf3c6eecfca4ac2f393be295a2cfeab4ab8e5e57167a89eafce224e test/results/test21-armv7l-binary 3c096914ca492c60bd53193fcc109549fae170052b347e3e62dabcbd9784691f test/results/test21-knight-posix-binary 3c7654eb26247e5f0460dad9e539220a68078cd8c56aae8457b5a97dc6eab892 test/results/test21-x86-binary +f73bbd1494149af5a45cb21b130c46ea35bc08c26cd2a47a168f9bf90a9f46d1 test/results/test22-armv7l-binary 7ccc16255ce81a9b35934649b5446face10db899cadaf00008c582934eefaa37 test/results/test22-knight-posix-binary 3d0a08c9f38b995318f459884880dbcd309930fb9f51de05c83eb1fcc3fa1825 test/results/test22-x86-binary 1b86c800067f64ffd6cfd4b39155b81e3b0fc7ffa6d43d1edd75852edd2d583f test/results/test23-knight-posix-binary diff --git a/test/test100/proof.answer b/test/test100/proof.answer index 6b146a0..fecfc19 100644 --- a/test/test100/proof.answer +++ b/test/test100/proof.answer @@ -1 +1 @@ -c111540d35439feebbc51768ebe98207f1b0b96d53f13f2b2967e6f26a93fb23 test/test100/proof +1a06f00383c0200463f09f48a5bfc0d485eeb2b52a9fb4232169099d17446c1d test/test100/proof diff --git a/test/test21/hello-armv7l.sh b/test/test21/hello-armv7l.sh new file mode 100755 index 0000000..990156c --- /dev/null +++ b/test/test21/hello-armv7l.sh @@ -0,0 +1,66 @@ +#! /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 -x +# Build the test +./bin/M2-Planet --architecture armv7l -f test/common_armv7l/functions/exit.c \ + -f test/common_armv7l/functions/file.c \ + -f functions/file_print.c \ + -f test/common_armv7l/functions/malloc.c \ + -f functions/calloc.c \ + -f functions/match.c \ + -f test/test21/blood-elf.c \ + --debug \ + -o test/test21/blood-elf.M1 || exit 1 + +# Build debug footer +blood-elf -f test/test21/blood-elf.M1 \ + -o test/test21/blood-elf-footer.M1 || exit 2 + +# 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/test21/blood-elf.M1 \ + -f test/test21/blood-elf-footer.M1 \ + --LittleEndian \ + --architecture armv7l \ + -o test/test21/blood-elf.hex2 || exit 3 + +# Resolve all linkages +hex2 -f test/common_armv7l/ELF-armv7l-debug.hex2 \ + -f test/test21/blood-elf.hex2 \ + --LittleEndian \ + --architecture armv7l \ + --BaseAddress 0x10000 \ + -o test/results/test21-armv7l-binary \ + --exec_enable || exit 4 + +# Ensure binary works if host machine supports test +if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "armv7l" ] +then + # Verify that the compiled program returns the correct result + out=$(./test/results/test21-armv7l-binary --version 2>&1 ) + [ 0 = $? ] || exit 5 + [ "$out" = "blood-elf 0.1 +(Basically Launches Odd Object Dump ExecutabLe Files" ] || exit 6 + + # Verify that the resulting file works + ./test/results/test21-armv7l-binary -f test/test21/test.M1 -o test/test21/proof || exit 7 + out=$(sha256sum -c test/test21/proof.answer) + [ "$out" = "test/test21/proof: OK" ] || exit 8 +fi +exit 0 diff --git a/test/test22/hello-armv7l.sh b/test/test22/hello-armv7l.sh new file mode 100755 index 0000000..321514c --- /dev/null +++ b/test/test22/hello-armv7l.sh @@ -0,0 +1,73 @@ +#! /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 -x +# Build the test +./bin/M2-Planet --architecture armv7l -f test/common_armv7l/functions/exit.c \ + -f test/common_armv7l/functions/file.c \ + -f functions/file_print.c \ + -f test/common_armv7l/functions/malloc.c \ + -f functions/calloc.c \ + -f functions/match.c \ + -f functions/in_set.c \ + -f functions/numerate_number.c \ + -f test/common_armv7l/functions/stat.c \ + -f test/test22/hex2_linker.c \ + --debug \ + -o test/test22/hex2_linker.M1 || exit 1 + +# Build debug footer +blood-elf -f test/test22/hex2_linker.M1 \ + -o test/test22/hex2_linker-footer.M1 || exit 2 + +# 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/test22/hex2_linker.M1 \ + -f test/test22/hex2_linker-footer.M1 \ + --LittleEndian \ + --architecture armv7l \ + -o test/test22/hex2_linker.hex2 || exit 3 + +# Resolve all linkages +hex2 -f test/common_armv7l/ELF-armv7l-debug.hex2 \ + -f test/test22/hex2_linker.hex2 \ + --LittleEndian \ + --architecture armv7l \ + --BaseAddress 0x10000 \ + -o test/results/test22-armv7l-binary \ + --exec_enable || exit 4 + +# Ensure binary works if host machine supports test +if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "armv7l" ] +then + # Verify that the compiled program returns the correct result + out=$(./test/results/test22-armv7l-binary --version 2>&1 ) + [ 0 = $? ] || exit 5 + [ "$out" = "hex2 0.3" ] || exit 6 + + # Verify that the resulting file works + ./test/results/test22-armv7l-binary -f test/common_x86/ELF-i386.hex2 \ + -f test/test22/test.hex2 \ + --LittleEndian \ + --architecture x86 \ + --BaseAddress 0x8048000 \ + -o test/test22/proof || exit 7 + out=$(sha256sum -c test/test22/proof.answer) + [ "$out" = "test/test22/proof: OK" ] || exit 8 +fi +exit 0 diff --git a/test/test23/hello-armv7l.sh b/test/test23/hello-armv7l.sh new file mode 100755 index 0000000..ea05310 --- /dev/null +++ b/test/test23/hello-armv7l.sh @@ -0,0 +1,75 @@ +#! /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 -x +# Build the test +./bin/M2-Planet --architecture armv7l -f test/common_armv7l/functions/exit.c \ + -f test/common_armv7l/functions/file.c \ + -f functions/file_print.c \ + -f test/common_armv7l/functions/malloc.c \ + -f functions/calloc.c \ + -f functions/match.c \ + -f functions/in_set.c \ + -f functions/numerate_number.c \ + -f functions/string.c \ + -f test/test23/M1-macro.c \ + --debug \ + -o test/test23/M1-macro.M1 || exit 1 + +# Build debug footer +blood-elf -f test/test23/M1-macro.M1 \ + -o test/test23/M1-macro-footer.M1 || exit 2 + +# 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/test23/M1-macro.M1 \ + -f test/test23/M1-macro-footer.M1 \ + --LittleEndian \ + --architecture armv7l \ + -o test/test23/M1-macro.hex2 || exit 3 + +# Resolve all linkages +hex2 -f test/common_armv7l/ELF-armv7l-debug.hex2 \ + -f test/test23/M1-macro.hex2 \ + --LittleEndian \ + --architecture armv7l \ + --BaseAddress 0x10000 \ + -o test/results/test23-armv7l-binary \ + --exec_enable || exit 4 + +# Ensure binary works if host machine supports test +if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "armv7l" ] +then + # Verify that the compiled program returns the correct result + out=$(./test/results/test23-armv7l-binary --version 2>&1 ) + [ 0 = $? ] || exit 5 + [ "$out" = "M1 0.3" ] || exit 6 + + # Verify that the resulting file works + ./test/results/test23-armv7l-binary -f \ + test/common_x86/x86_defs.M1 \ + -f test/common_x86/libc-core.M1 \ + -f test/test21/test.M1 \ + --LittleEndian \ + --architecture x86 \ + -o test/test23/proof || exit 7 + + out=$(sha256sum -c test/test23/proof.answer) + [ "$out" = "test/test23/proof: OK" ] || exit 8 +fi +exit 0 diff --git a/test/test25/hello.sh b/test/test25/hello-x86.sh similarity index 95% rename from test/test25/hello.sh rename to test/test25/hello-x86.sh index a7ab525..4dce086 100755 --- a/test/test25/hello.sh +++ b/test/test25/hello-x86.sh @@ -25,8 +25,8 @@ set -x -f functions/match.c \ -f functions/in_set.c \ -f functions/numerate_number.c \ - -f functions/fork.c \ - -f functions/execve.c \ + -f test/common_x86/functions/fork.c \ + -f test/common_x86/functions/execve.c \ -f test/test25/kaem.c \ --debug \ -o test/test25/kaem.M1 || exit 1 diff --git a/test/test26/hello.sh b/test/test26/hello-x86.sh similarity index 100% rename from test/test26/hello.sh rename to test/test26/hello-x86.sh