Added debug support for M2-Planet output
This commit is contained in:
parent
0bb6758a10
commit
688b546281
|
@ -35,6 +35,7 @@ Added Blood-elf test
|
|||
Added Hex2_linker test
|
||||
Added M1-macro test
|
||||
Added prototypes to allow functions to be independently built
|
||||
Added support for debug format output to help debugging
|
||||
|
||||
** Changed
|
||||
Improving Documentation to help new programmers get functional
|
||||
|
@ -43,6 +44,8 @@ Enabled stand alone builds of calloc
|
|||
Unified bitwise operations
|
||||
Made string.c more independent
|
||||
Created a M1-macro stub file to simplify independent builds
|
||||
Created a hex2_linker stub file to simplify independent builds
|
||||
Created a blood-elf stub file to simplify independent builds
|
||||
|
||||
** Fixed
|
||||
Minor cleanup and removal of unneeded whitespace
|
||||
|
|
17
cc.c
17
cc.c
|
@ -31,6 +31,7 @@ char* parse_string(char* string);
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int DEBUG = FALSE;
|
||||
FILE* in = stdin;
|
||||
FILE* destination_file = stdout;
|
||||
int i = 1;
|
||||
|
@ -40,7 +41,7 @@ int main(int argc, char** argv)
|
|||
{
|
||||
i = i + 1;
|
||||
}
|
||||
else if(match(argv[i], "-f"))
|
||||
else if(match(argv[i], "-f") || match(argv[i], "--file"))
|
||||
{
|
||||
char* name = argv[i + 1];
|
||||
in = fopen(name, "r");
|
||||
|
@ -54,7 +55,7 @@ int main(int argc, char** argv)
|
|||
global_token = read_all_tokens(in, global_token, name);
|
||||
i = i + 2;
|
||||
}
|
||||
else if(match(argv[i], "-o"))
|
||||
else if(match(argv[i], "-o") || match(argv[i], "--output"))
|
||||
{
|
||||
destination_file = fopen(argv[i + 1], "w");
|
||||
if(NULL == destination_file)
|
||||
|
@ -66,12 +67,17 @@ int main(int argc, char** argv)
|
|||
}
|
||||
i = i + 2;
|
||||
}
|
||||
else if(match(argv[i], "--help"))
|
||||
else if(match(argv[i], "-g") || match(argv[i], "--debug"))
|
||||
{
|
||||
DEBUG = TRUE;
|
||||
i = i + 1;
|
||||
}
|
||||
else if(match(argv[i], "-h") || match(argv[i], "--help"))
|
||||
{
|
||||
file_print(" -f input file\x0A -o output file\x0A --help for this message\x0A --version for file version\x0A", stdout);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
else if(match(argv[i], "--version"))
|
||||
else if(match(argv[i], "-V") || match(argv[i], "--version"))
|
||||
{
|
||||
file_print("Basic test version 0.0.0.1a\x0A", stderr);
|
||||
exit(EXIT_SUCCESS);
|
||||
|
@ -102,10 +108,11 @@ int main(int argc, char** argv)
|
|||
/* Output the program we have compiled */
|
||||
file_print("\n# Core program\n\n", destination_file);
|
||||
recursive_output(output_list, destination_file);
|
||||
if(DEBUG) file_print("\n:ELF_data\n", destination_file);
|
||||
file_print("\n# Program global variables\n\n", destination_file);
|
||||
recursive_output(globals_list, destination_file);
|
||||
file_print("\n# Program strings\n\n", destination_file);
|
||||
recursive_output(strings_list, destination_file);
|
||||
file_print("\n:ELF_end\n", destination_file);
|
||||
if(!DEBUG) file_print("\n:ELF_end\n", destination_file);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,216 @@
|
|||
### Copyright (C) 2016 Jeremiah Orians
|
||||
### Copyright (C) 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
### This file is part of stage0.
|
||||
###
|
||||
### stage0 is free software: you an 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.
|
||||
###
|
||||
### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
### stage0's hex2 format for x86
|
||||
### !<label> 1 byte relative
|
||||
### $<label> 2 byte address
|
||||
### @<label> 2 byte relative
|
||||
### &<label> 4 byte address
|
||||
### %<label> 4 byte relative
|
||||
### local_<label> function-local
|
||||
### string_<index> string #<index>
|
||||
|
||||
### elf32-header-exit-42.hex2: 32 bit elf header in hex2 for `exit 42'
|
||||
|
||||
:ELF_base
|
||||
7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
|
||||
|
||||
01 # e_ident[EI_CLASS] Indicating 32 bit
|
||||
01 # e_ident[EI_DATA] Indicating little endianness
|
||||
01 # e_ident[EI_VERSION] Indicating original elf
|
||||
|
||||
00 # e_ident[EI_OSABI] Set at 0 because none cares
|
||||
00 # e_ident[EI_ABIVERSION] See above
|
||||
|
||||
00 00 00 00 00 00 00 # e_ident[EI_PAD]
|
||||
|
||||
02 00 # e_type Indicating Executable
|
||||
03 00 # e_machine Indicating AMD64
|
||||
01 00 00 00 # e_version Indicating original elf
|
||||
|
||||
&ELF_text # e_entry Address of the entry point
|
||||
%ELF_program_headers>ELF_base # e_phoff Address of program header table
|
||||
%ELF_section_headers>ELF_base # e_shoff Address of section header table
|
||||
|
||||
00 00 00 00 # e_flags
|
||||
|
||||
34 00 # e_ehsize Indicating our 52 Byte header
|
||||
|
||||
20 00 # e_phentsize size of a program header table
|
||||
02 00 # e_phnum number of entries in program table
|
||||
|
||||
28 00 # e_shentsize size of a section header table
|
||||
07 00 # e_shnum number of entries in section table
|
||||
|
||||
04 00 # e_shstrndx index of the section names
|
||||
|
||||
# @34
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @40
|
||||
:ELF_program_headers
|
||||
:ELF_program_header__text
|
||||
01 00 00 00 # ph_type: PT-LOAD = 1
|
||||
00 00 00 00 # ph_offset
|
||||
&ELF_base # ph_vaddr
|
||||
&ELF_base # ph_physaddr
|
||||
%ELF_end>ELF_base # ph_filesz
|
||||
%ELF_end>ELF_base # ph_memsz
|
||||
07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
|
||||
01 00 00 00 # ph_align
|
||||
|
||||
# @60
|
||||
:ELF_program_header__data
|
||||
01 00 00 00 # ph_type: PT-LOAD = 1
|
||||
00 00 00 00 # ph_offset
|
||||
&ELF_base # ph_vaddr
|
||||
&ELF_base # ph_physaddr
|
||||
%ELF_end>ELF_base # ph_filesz
|
||||
%ELF_end>ELF_base # ph_memsz
|
||||
07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
|
||||
01 00 00 00 # ph_align
|
||||
|
||||
# @80
|
||||
:ELF_comment
|
||||
4d 45 53 00 # MES
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
4d 45 53 00 # MES
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @a0
|
||||
:ELF_shstr
|
||||
00
|
||||
:ELF_shstr__text
|
||||
2e 74 65 78 74 00 # .text
|
||||
:ELF_shstr__data
|
||||
2e 64 61 74 61 00 # .data
|
||||
:ELF_shstr__comment
|
||||
2e 63 6f 6d 6d 65 6e 74 00 # .comment
|
||||
:ELF_shstr__shstr
|
||||
2e 73 68 73 74 72 74 61 62 00 # .shstrtab
|
||||
:ELF_shstr__sym
|
||||
2e 73 79 6d 74 61 62 00 # .symtab
|
||||
:ELF_shstr__str
|
||||
2e 73 74 72 74 61 62 00 # .strtab
|
||||
|
||||
# @d0
|
||||
|
||||
:ELF_section_headers
|
||||
00 00 00 00 # sh_name
|
||||
00 00 00 00 # sh_type
|
||||
00 00 00 00 # sh_flags
|
||||
00 00 00 00 # sh_addr
|
||||
00 00 00 00 # sh_offset
|
||||
00 00 00 00 # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
00 00 00 00 # sh_entsize
|
||||
|
||||
## FIXME: M0 for calculations?
|
||||
:ELF_section_header_text
|
||||
%ELF_shstr__text>ELF_shstr # sh_name
|
||||
01 00 00 00 # sh_type = SHT_PROGBITS = 1
|
||||
06 00 00 00 # sh_flags = SHF-ALLOC|SHF-EXEC =2 | 4 = 6
|
||||
&ELF_text # sh_addr
|
||||
%ELF_text>ELF_base # sh_offset
|
||||
%ELF_data>ELF_text # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_data
|
||||
%ELF_shstr__data>ELF_shstr # sh_name
|
||||
01 00 00 00 # sh_type = SHT_PROGBITS = 1
|
||||
03 00 00 00 # sh_flags = SHF-WRITE|SHF-ALLOC = 1 | 2 = 3
|
||||
&ELF_data # sh_addr
|
||||
%ELF_data>ELF_base # sh_offset
|
||||
%ELF_sym>ELF_data # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_comment
|
||||
%ELF_shstr__comment>ELF_shstr # sh_name
|
||||
01 00 00 00 # sh_type = SHT_PROGBITS = 1
|
||||
00 00 00 00 # sh_flags
|
||||
&ELF_comment # sh_addr
|
||||
%ELF_comment>ELF_base # sh_offset
|
||||
%ELF_shstr>ELF_comment # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_shstr
|
||||
%ELF_shstr__shstr>ELF_shstr # sh_name
|
||||
03 00 00 00 # sh_type: str-sht-strtab
|
||||
00 00 00 00 # sh_flags
|
||||
&ELF_shstr # sh_addr
|
||||
%ELF_shstr>ELF_base # sh_offset
|
||||
%ELF_section_headers>ELF_shstr # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_sym
|
||||
%ELF_shstr__sym>ELF_shstr # sh_name
|
||||
02 00 00 00 # sh_type: str-sht-symtab
|
||||
00 00 00 00 # sh_flags
|
||||
&ELF_sym # sh_addr
|
||||
%ELF_sym>ELF_base # sh_offset
|
||||
%ELF_end>ELF_sym # sh_length
|
||||
06 00 00 00 # sh_link:6
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
10 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_str
|
||||
%ELF_shstr__str>ELF_shstr # sh_name
|
||||
03 00 00 00 # sh_type: str-sht-strtab
|
||||
00 00 00 00 # sh_flags
|
||||
&ELF_str # sh_addr
|
||||
%ELF_str>ELF_base # sh_offset
|
||||
%ELF_sym>ELF_str # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
00 00 00 00 # sh_entsize
|
||||
|
||||
# @1e8
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
|
||||
# @1f0
|
||||
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @200
|
||||
:ELF_text
|
|
@ -9,7 +9,7 @@ d27eb315d694324650b11a421d6990eee60ac5921a5625bbccb43d806f09e156 test/results/t
|
|||
8cc38294fb1261843cfc3956fad5a451c95bbc2ed687435d4e2d59df2c4a8567 test/results/test08-binary
|
||||
cc8f252877a85c0d7832094ff574d7173ac33940917bc1591358b8970651a81c test/results/test09-binary
|
||||
3857aee4183de41bd00b014d616a5d73f4bfc57aa60a6073bb4113d6ff2fb8d5 test/results/test10-binary
|
||||
3a807e11ca778b882e11f301b44833124e820f8012d74a1fe56b909b3b52adec test/results/test100-binary
|
||||
876996566d53244f154bcf1b817be87d288923f3dd888a66b8bf8b098a4692cd test/results/test100-binary
|
||||
dce2f0b35323cf6a2b01f74a9335100f2d8626028af545832dbdb503573db0e5 test/results/test11-binary
|
||||
88602970fa07b5da7a42b4f2b2486fe03accc6796e05453c4ab934e986790bef test/results/test12-binary
|
||||
c85a57b5b1d65288efd47a3b12c6fca1efade9e7ec91e65efda5531d2c40d293 test/results/test13-binary
|
||||
|
@ -20,7 +20,7 @@ ca2c1321cbcbf3f551860fc0857d0a816660ba541987f9ed7f92f8553cd6b06b test/results/t
|
|||
6405e331d3626c0ed1eca16eecc7fb628d8e1dc54dff3a6106e5f5bb063c896c test/results/test18-binary
|
||||
33f7802c581d3b6382a1b63211564529419769a9788b5a5cac856e45b9eac57c test/results/test19-binary
|
||||
6fa44153ee3f27f0df49b282c0bb3017dbfaea906073c8c02b8bf5ad4d4a7860 test/results/test20-binary
|
||||
927094465f6772eaf9cc7d388b351a7e178ea6798476f87776d7dd44e9cfc072 test/results/test21-binary
|
||||
49eaa0c479d2a327d968e78a56baae36f5f18193062e885232727edadc5b7a2d test/results/test22-binary
|
||||
b6b8e340564e04e3bc6ca31ba32deb8ccc385eedf265d18920b86a9b1718d31c test/results/test23-binary
|
||||
782561480823004892208672da16834bd76d622affb493d6a1f34f830890948e test/results/test21-binary
|
||||
a84ac16eef799668eb1fd5c69cbc7cf0c1f053a6d87db43a16f41172ddd375cb test/results/test22-binary
|
||||
1a25d3e0aae5f026e41e47b6f7f7b92b2883c37d55b6c24ba89f4bf8897453ae test/results/test23-binary
|
||||
ba3d9623c6512bc327cf934d994e5327e5fad3f7500896e2d8458467fae9b9e9 test/results/test99-binary
|
||||
|
|
|
@ -1 +1 @@
|
|||
f8d4a2a3c5c46005374f9b4485517dd109437a53bf3e24622897af37c9735d31 test/test100/proof
|
||||
a9ec50a9ccc9cd53afb5db93e8be0014d021d2f12b593fbc4dc3f7f674cae8d9 test/test100/proof
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#! /bin/sh
|
||||
rm -f test/test21/blood-elf.M1
|
||||
rm -f test/test21/blood-elf-footer.M1
|
||||
rm -f test/test21/blood-elf.hex2
|
||||
rm -f test/test21/proof
|
||||
exit 0
|
||||
|
|
|
@ -8,37 +8,43 @@ set -x
|
|||
-f test/functions/calloc.c \
|
||||
-f test/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_x86/x86_defs.M1 \
|
||||
-f test/functions/libc-core.M1 \
|
||||
-f test/test21/blood-elf.M1 \
|
||||
-f test/test21/blood-elf-footer.M1 \
|
||||
--LittleEndian \
|
||||
--Architecture 1 \
|
||||
-o test/test21/blood-elf.hex2 || exit 2
|
||||
-o test/test21/blood-elf.hex2 || exit 3
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/common_x86/ELF-i386.hex2 \
|
||||
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
|
||||
-f test/test21/blood-elf.hex2 \
|
||||
--LittleEndian \
|
||||
--Architecture 1 \
|
||||
--BaseAddress 0x8048000 \
|
||||
-o test/results/test21-binary \
|
||||
--exec_enable || exit 3
|
||||
--exec_enable || exit 4
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine)" = "x86_64" ]
|
||||
then
|
||||
# Verify that the compiled program returns the correct result
|
||||
out=$(./test/results/test21-binary --version 2>&1 )
|
||||
[ 0 = $? ] || exit 4
|
||||
[ 0 = $? ] || exit 5
|
||||
[ "$out" = "blood-elf 0.1
|
||||
(Basically Launches Odd Object Dump ExecutabLe Files" ] || exit 5
|
||||
(Basically Launches Odd Object Dump ExecutabLe Files" ] || exit 6
|
||||
|
||||
# Verify that the resulting file works
|
||||
./test/results/test21-binary -f test/test21/test.M1 -o test/test21/proof || exit 6
|
||||
./test/results/test21-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 7
|
||||
[ "$out" = "test/test21/proof: OK" ] || exit 8
|
||||
fi
|
||||
exit 0
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/* -*- c-file-style: "linux";indent-tabs-mode:t -*- */
|
||||
/* Copyright (C) 2016 Jeremiah Orians
|
||||
* Copyright (C) 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
* This file is part of stage0.
|
||||
*
|
||||
* stage0 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.
|
||||
*
|
||||
* stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
CONSTANT NULL 0
|
||||
CONSTANT stdout 1
|
||||
CONSTANT stderr 2
|
||||
CONSTANT EOF 0xFFFFFFFF
|
||||
CONSTANT EXIT_SUCCESS 0
|
||||
CONSTANT EXIT_FAILURE 1
|
||||
void* calloc(int count, int size);
|
||||
void exit(int value);
|
||||
int fgetc(FILE* f);
|
||||
void fputc(char s, FILE* f);
|
||||
FILE* fopen(char* filename, char* mode);
|
||||
int fclose(FILE* stream);
|
|
@ -1,5 +1,6 @@
|
|||
#! /bin/sh
|
||||
rm -f test/test22/hex2_linker.M1
|
||||
rm -f test/test22/hex2_linker-footer.M1
|
||||
rm -f test/test22/hex2_linker.hex2
|
||||
rm -f test/test22/proof
|
||||
exit 0
|
||||
|
|
|
@ -10,41 +10,47 @@ set -x
|
|||
-f test/functions/numerate_number.c \
|
||||
-f test/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_x86/x86_defs.M1 \
|
||||
-f test/functions/libc-core.M1 \
|
||||
-f test/test22/hex2_linker.M1 \
|
||||
-f test/test22/hex2_linker-footer.M1 \
|
||||
--LittleEndian \
|
||||
--Architecture 1 \
|
||||
-o test/test22/hex2_linker.hex2 || exit 2
|
||||
-o test/test22/hex2_linker.hex2 || exit 3
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/common_x86/ELF-i386.hex2 \
|
||||
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
|
||||
-f test/test22/hex2_linker.hex2 \
|
||||
--LittleEndian \
|
||||
--Architecture 1 \
|
||||
--BaseAddress 0x8048000 \
|
||||
-o test/results/test22-binary \
|
||||
--exec_enable || exit 3
|
||||
--exec_enable || exit 4
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine)" = "x86_64" ]
|
||||
then
|
||||
# Verify that the compiled program returns the correct result
|
||||
out=$(./test/results/test22-binary --version 2>&1 )
|
||||
[ 0 = $? ] || exit 4
|
||||
[ "$out" = "hex2 0.3" ] || exit 5
|
||||
[ 0 = $? ] || exit 5
|
||||
[ "$out" = "hex2 0.3" ] || exit 6
|
||||
|
||||
# Verify that the resulting file works
|
||||
./test/results/test22-binary -f test/common_x86/ELF-i386.hex2 \
|
||||
./test/results/test22-binary -f test/common_x86/ELF-i386-debug.hex2 \
|
||||
-f test/test22/hex2_linker.hex2 \
|
||||
--LittleEndian \
|
||||
--Architecture 1 \
|
||||
--BaseAddress 0x8048000 \
|
||||
-o test/test22/proof || exit 6
|
||||
-o test/test22/proof || exit 7
|
||||
out=$(sha256sum -c test/test22/proof.answer)
|
||||
[ "$out" = "test/test22/proof: OK" ] || exit 7
|
||||
[ "$out" = "test/test22/proof: OK" ] || exit 8
|
||||
fi
|
||||
exit 0
|
||||
|
|
|
@ -1 +1 @@
|
|||
49eaa0c479d2a327d968e78a56baae36f5f18193062e885232727edadc5b7a2d test/test22/proof
|
||||
a84ac16eef799668eb1fd5c69cbc7cf0c1f053a6d87db43a16f41172ddd375cb test/test22/proof
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/* -*- c-file-style: "linux";indent-tabs-mode:t -*- */
|
||||
/* Copyright (C) 2016 Jeremiah Orians
|
||||
* Copyright (C) 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
* This file is part of stage0.
|
||||
*
|
||||
* stage0 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.
|
||||
*
|
||||
* stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
CONSTANT NULL 0
|
||||
CONSTANT stdout 1
|
||||
CONSTANT stderr 2
|
||||
CONSTANT EOF 0xFFFFFFFF
|
||||
CONSTANT EXIT_SUCCESS 0
|
||||
CONSTANT EXIT_FAILURE 1
|
||||
void* calloc(int count, int size);
|
||||
void* memset(void* ptr, int value, int num);
|
||||
void exit(int value);
|
||||
int fgetc(FILE* f);
|
||||
void fputc(char s, FILE* f);
|
||||
FILE* fopen(char* filename, char* mode);
|
||||
int fclose(FILE* stream);
|
||||
int chmod(char *pathname, int mode);
|
|
@ -1,5 +1,6 @@
|
|||
#! /bin/sh
|
||||
rm -f test/test23/M1-macro.M1
|
||||
rm -f test/test23/M1-macro-footer.M1
|
||||
rm -f test/test23/M1-macro.hex2
|
||||
rm -f test/test23/proof
|
||||
exit 0
|
||||
|
|
|
@ -10,32 +10,38 @@ set -x
|
|||
-f test/functions/numerate_number.c \
|
||||
-f test/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_x86/x86_defs.M1 \
|
||||
-f test/functions/libc-core.M1 \
|
||||
-f test/test23/M1-macro.M1 \
|
||||
-f test/test23/M1-macro-footer.M1 \
|
||||
--LittleEndian \
|
||||
--Architecture 1 \
|
||||
-o test/test23/M1-macro.hex2 || exit 2
|
||||
-o test/test23/M1-macro.hex2 || exit 3
|
||||
|
||||
# Resolve all linkages
|
||||
hex2 -f test/common_x86/ELF-i386.hex2 \
|
||||
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
|
||||
-f test/test23/M1-macro.hex2 \
|
||||
--LittleEndian \
|
||||
--Architecture 1 \
|
||||
--BaseAddress 0x8048000 \
|
||||
-o test/results/test23-binary \
|
||||
--exec_enable || exit 3
|
||||
--exec_enable || exit 4
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine)" = "x86_64" ]
|
||||
then
|
||||
# Verify that the compiled program returns the correct result
|
||||
out=$(./test/results/test23-binary --version 2>&1 )
|
||||
[ 0 = $? ] || exit 4
|
||||
[ "$out" = "M1 0.3" ] || exit 5
|
||||
[ 0 = $? ] || exit 5
|
||||
[ "$out" = "M1 0.3" ] || exit 6
|
||||
|
||||
# Verify that the resulting file works
|
||||
./test/results/test23-binary -f \
|
||||
|
@ -44,9 +50,9 @@ then
|
|||
-f test/test21/test.M1 \
|
||||
--LittleEndian \
|
||||
--Architecture 1 \
|
||||
-o test/test23/proof || exit 6
|
||||
-o test/test23/proof || exit 7
|
||||
|
||||
out=$(sha256sum -c test/test23/proof.answer)
|
||||
[ "$out" = "test/test23/proof: OK" ] || exit 7
|
||||
[ "$out" = "test/test23/proof: OK" ] || exit 8
|
||||
fi
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue