Update in preperation for mescc-tools 0.6.0 release

This commit is contained in:
Jeremiah Orians 2019-02-23 11:05:20 -05:00
parent 25d57d7d59
commit 0eefa0feb2
No known key found for this signature in database
GPG Key ID: 5410E91C14959E87
38 changed files with 458 additions and 186 deletions

View File

@ -23,11 +23,15 @@ Added support for ~expressions
Added prototype for Slow_Lisp build test
Added Custom type for mes.h
Added support for octal and binary numbers
Added support for \0
** Changed
Converted M2-Planet to use GNU style error message
Seed.M1 when built will now have the same checksum as M2-Planet self-hosted
Harmonized license headers
Updated M1 to current version
Updated hex2 to current version
Updated to mescc-tools 0.6.0 syntax
** Fixed
Fixed typo in file headers

View File

@ -18,6 +18,8 @@
set -eux
stage0_PREFIX=${stage0_PREFIX-../stage0}
[ -e bin/M2-Planet ] && rm bin/M2-Planet
# Refresh stage0's M2-Planet_x86.c
# To execute this block ./bootstrap.sh refresh
if [ "refresh" = "${1-NOPE}" ]
@ -88,14 +90,17 @@ M1 -f test/common_x86/x86_defs.M1 \
-f seed.M1 \
-f bin/seed-footer.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o bin/seed.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
-f bin/seed.hex2 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
--BaseAddress 0x8048000 \
-o bin/M2-Planet \
-o bin/M2-Planet-seed \
--exec_enable || exit 2
# self-host
./test/test100/hello.sh

View File

@ -81,6 +81,7 @@ int escape_lookup(char* c)
int t2 = hexify(c[3], FALSE);
return t1 + t2;
}
else if(c[1] == '0') return 0;
else if(c[1] == 't') return 9;
else if(c[1] == 'n') return 10;
else if(c[1] == 'v') return 11;

View File

@ -19,26 +19,7 @@ VPATH = bin:test:test/results
all: M2-Planet
CC=gcc
CFLAGS=-D_GNU_SOURCE -O0 -std=c99 -ggdb
M2-Planet-gcc: cc_reader.c cc_strings.c cc_core.c cc.c cc_types.c cc.h | bin
$(CC) $(CFLAGS) \
functions/match.c \
functions/in_set.c \
functions/numerate_number.c \
functions/file_print.c \
functions/string.c \
cc_reader.c \
cc_strings.c \
cc_types.c \
cc_core.c \
cc.c \
cc.h \
gcc_req.h \
-o bin/M2-Planet-gcc
M2-Planet: M2-Planet-gcc | bin results
M2-Planet: bin results
./test/test100/hello.sh
# Clean up after ourselves

View File

@ -9,7 +9,7 @@ a9a3e332d13ded5f80d7431f8717f26527b3722b33ea57760a9a5723dffc099c test/results/t
f1c01feb865c4d552033186d9ce50dd39468a7e8aebf762886c13ad3e03b5011 test/results/test08-binary
3b39e72f3de90ed690adfaf6145af46157cef2ec5e72867ac577fa27a0229894 test/results/test09-binary
020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-binary
89c788e3b72c32e16d851a1a00c050435dc5fc457200f0a5cd58ce02dc3fd0e1 test/results/test100-binary
f3377a4a6122cfa499040c1080626eb6ef60603bf6023b83090812d97857bc8c test/results/test100-binary
3fd11bad4a426ce1ff8fd9c6d7d2b943effae9f3f5740b7376e426e9b0555851 test/results/test11-binary
f98ab8e4bb35580e0dde96126d7a56aff66bda208d02c8d89390b40d6cff591c test/results/test12-binary
5051ffca2615144419f8ec1a5d4999486ae81e7781428f59e47e866af97cef92 test/results/test13-binary
@ -21,7 +21,7 @@ d70e072f4f1f077d10ff65e9216ca8b423b996e35d68d208025db7a78b062f50 test/results/t
cefc5a53513abdb9069dc8bdb7b4529307420d5dd412a10112c3253bdcd29c46 test/results/test19-binary
365c96fb8368710d620a76facd6bebcdeeb6f6d30ceaf0a6f1567fc3fcbe9b54 test/results/test20-binary
3c7654eb26247e5f0460dad9e539220a68078cd8c56aae8457b5a97dc6eab892 test/results/test21-binary
79309ff489e04ce7846fa27f3a852b0500a15f491e331f50bc40d64597899629 test/results/test22-binary
496741582b1d1368e3e2a6e8b2b516d468a9f858947d18e0c7bfa06936cc4bbb test/results/test23-binary
3d0a08c9f38b995318f459884880dbcd309930fb9f51de05c83eb1fcc3fa1825 test/results/test22-binary
3060147b0d56e30c6d9a36ed4675feed306c398df365d2c1c9e2d1c88b40cf3e test/results/test23-binary
c080413cdb713618896a73b834fb96ce8dd2c2176a226c0713d9a729bd1aa7f9 test/results/test24-binary
140af7fb3ef89d84b21bd3fe69f0d3260650ec0467c0ffadf9268fad573a397f test/results/test99-binary

View File

@ -25,11 +25,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test00/return.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test00/return.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test00/return.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test00-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test00/return.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test00-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -27,11 +27,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test01/library_call.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test01/library_call.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test01/library_call.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test01-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test01/library_call.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test01-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -27,11 +27,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test02/if.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test02/if.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test02/if.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test02-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test02/if.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test02-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -27,11 +27,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test03/constant.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test03/constant.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test03/constant.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test03-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test03/constant.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test03-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -27,11 +27,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test04/call.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test04/call.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test04/call.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test04-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test04/call.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test04-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -27,11 +27,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test05/string.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test05/string.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test05/string.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test05-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test05/string.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test05-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -26,11 +26,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test06/for.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test06/for.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test06/for.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test06-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test06/for.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test06-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -27,11 +27,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test07/do.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test07/do.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test07/do.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test07-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test07/do.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test07-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -28,11 +28,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test08/struct.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test08/struct.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test08/struct.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test08-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test08/struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test08-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -27,11 +27,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test09/goto.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test09/goto.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test09/goto.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test09-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test09/goto.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test09-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -28,11 +28,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test10/nested_struct.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test10/nested_struct.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test10/nested_struct.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test10-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test10/nested_struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test10-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -36,7 +36,45 @@ then
-f cc.c \
--debug \
-o test/test100/cc.M1 || exit 1
elif [ -f bin/M2-Planet-seed ]
then
[ ! -f test/results ] && mkdir test/results
./bin/M2-Planet-seed -f functions/file.c \
-f functions/malloc.c \
-f functions/calloc.c \
-f functions/exit.c \
-f functions/match.c \
-f functions/in_set.c \
-f functions/numerate_number.c \
-f functions/file_print.c \
-f functions/string.c \
-f cc.h \
-f cc_reader.c \
-f cc_strings.c \
-f cc_types.c \
-f cc_core.c \
-f cc.c \
--debug \
-o test/test100/cc.M1 || exit 1
else
[ -z "${CC+x}" ] && export CC=gcc
[ -z "${CFLAGS+x}" ] && export CFLAGS=" -D_GNU_SOURCE -O0 -std=c99 -ggdb"
${CC} ${CFLAGS} \
functions/match.c \
functions/in_set.c \
functions/numerate_number.c \
functions/file_print.c \
functions/string.c \
cc_reader.c \
cc_strings.c \
cc_types.c \
cc_core.c \
cc.c \
cc.h \
gcc_req.h \
-o bin/M2-Planet-gcc
./bin/M2-Planet-gcc -f functions/file.c \
-f functions/malloc.c \
-f functions/calloc.c \
@ -66,14 +104,14 @@ M1 -f test/common_x86/x86_defs.M1 \
-f test/test100/cc.M1 \
-f test/test100/cc-footer.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test100/cc.hex2 || exit 3
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
-f test/test100/cc.hex2 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
--BaseAddress 0x8048000 \
-o test/results/test100-binary --exec_enable || exit 4

View File

@ -1 +1 @@
b2486e11d917fde17e2b4649238d77724b9fe8623c013ded63a3d991fda24926 test/test100/proof
f1e74d13abdb3c60e531daf18b2a8d6d728c8014ed77a354ec87bf00c5cd0abd test/test100/proof

View File

@ -27,11 +27,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test11/break-do.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test11/break-do.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test11/break-do.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test11-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test11/break-do.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test11-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -27,11 +27,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test12/break-for.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test12/break-for.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test12/break-for.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test12-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test12/break-for.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test12-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -27,11 +27,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test13/break-while.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test13/break-while.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test13/break-while.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test13-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test13/break-while.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test13-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -26,11 +26,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test14/basic_args.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test14/basic_args.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test14/basic_args.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test14-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test14/basic_args.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test14-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -27,11 +27,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test15/file_read.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test15/file_read.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test15/file_read.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test15-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test15/file_read.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test15-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -27,11 +27,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test16/file_write.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test16/file_write.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test16/file_write.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test16-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test16/file_write.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test16-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -28,11 +28,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test17/memset.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test17/memset.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test17/memset.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test17-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test17/memset.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test17-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -28,11 +28,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test18/math.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test18/math.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test18/math.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test18-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test18/math.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test18-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -32,11 +32,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test19/getopt.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test19/getopt.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test19/getopt.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test19-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test19/getopt.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test19-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -28,11 +28,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test20/struct.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test20/struct.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test20/struct.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test20-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test20/struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test20-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]

View File

@ -37,14 +37,14 @@ M1 -f test/common_x86/x86_defs.M1 \
-f test/test21/blood-elf.M1 \
-f test/test21/blood-elf-footer.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test21/blood-elf.hex2 || exit 3
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
-f test/test21/blood-elf.hex2 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
--BaseAddress 0x8048000 \
-o test/results/test21-binary \
--exec_enable || exit 4

View File

@ -40,14 +40,14 @@ M1 -f test/common_x86/x86_defs.M1 \
-f test/test22/hex2_linker.M1 \
-f test/test22/hex2_linker-footer.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test22/hex2_linker.hex2 || exit 3
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
-f test/test22/hex2_linker.hex2 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
--BaseAddress 0x8048000 \
-o test/results/test22-binary \
--exec_enable || exit 4
@ -64,7 +64,7 @@ then
./test/results/test22-binary -f test/common_x86/ELF-i386.hex2 \
-f test/test22/test.hex2 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
--BaseAddress 0x8048000 \
-o test/test22/proof || exit 7
out=$(sha256sum -c test/test22/proof.answer)

View File

@ -23,7 +23,6 @@
#include <unistd.h>
#include <sys/stat.h>
#define max_string 4096
//CONSTANT max_string 4096
#define TRUE 1
@ -35,6 +34,7 @@ void file_print(char* s, FILE* f);
int match(char* a, char* b);
char* numerate_number(int a);
int numerate_string(char *a);
int in_set(int c, char* s);
struct input_files
{
@ -58,22 +58,69 @@ int ByteMode;
int exec_enable;
int ip;
char* scratch;
char* scratch2;
char* filename;
int linenumber;
int ALIGNED;
int consume_token(FILE* source_file, char* s)
void line_error()
{
file_print(filename, stderr);
file_print(":", stderr);
file_print(numerate_number(linenumber), stderr);
file_print(" :", stderr);
}
int consume_token(FILE* source_file)
{
int i = 0;
int c = fgetc(source_file);
do
while(!in_set(c, " \t\n>"))
{
if(NULL != s) s[i] = c;
scratch[i] = c;
i = i + 1;
c = fgetc(source_file);
} while((' ' != c) && ('\t' != c) && ('\n' != c) && '>' != c);
}
return c;
}
int Throwaway_token(FILE* source_file)
{
int c;
do
{
c = fgetc(source_file);
} while(!in_set(c, " \t\n>"));
return c;
}
int length(char* s)
{
int i = 0;
while(0 != s[i]) i = i + 1;
return i;
}
void Clear_Scratch(char* s)
{
do
{
s[0] = 0;
s = s + 1;
} while(0 != s[0]);
}
void Copy_String(char* a, char* b)
{
while(0 != a[0])
{
b[0] = a[0];
a = a + 1;
b = b + 1;
}
}
unsigned GetTarget(char* c)
{
struct entry* i;
@ -94,16 +141,19 @@ int storeLabel(FILE* source_file, int ip)
{
struct entry* entry = calloc(1, sizeof(struct entry));
/* Ensure we have target address */
entry->target = ip;
/* Prepend to list */
entry->next = jump_table;
jump_table = entry;
/* Store string */
entry->name = calloc(max_string + 1, sizeof(char));
int c = consume_token(source_file, entry->name);
int c = consume_token(source_file);
entry->name = calloc(length(scratch) + 1, sizeof(char));
Copy_String(scratch, entry->name);
Clear_Scratch(scratch);
/* Ensure we have target address */
entry->target = ip;
return c;
}
@ -179,61 +229,97 @@ int Architectural_displacement(int target, int base)
if(0 == Architecture) return (target - base);
else if(1 == Architecture) return (target - base);
else if(2 == Architecture) return (target - base);
else if(40 == Architecture) return (target - base);
else if(ALIGNED && (40 == Architecture))
{
ALIGNED = FALSE;
/* Note: Branch displacements on ARM are in number of instructions to skip, basically. */
if (target & 3)
{
line_error();
file_print("error: Unaligned branch target: ", stderr);
file_print(scratch, stderr);
file_print(", aborting\n", stderr);
exit(EXIT_FAILURE);
}
/*
* The "fetch" stage already moved forward by 8 from the
* beginning of the instruction because it is already
* prefetching the next instruction.
* Compensate for it by subtracting the space for
* two instructions (including the branch instruction).
* and the size of the aligned immediate.
*/
return (((target - base + (base & 3)) >> 2) - 2);
}
else if(40 == Architecture)
{
/*
* The size of the offset is 8 according to the spec but that value is
* based on the end of the immediate, which the documentation gets wrong
* and needs to be adjusted to the size of the immediate.
* Eg 1byte immediate => -8 + 1 = -7
*/
return ((target - base) - 8 + (3 & base));
}
file_print("Unknown Architecture, aborting before harm is done\n", stderr);
exit(EXIT_FAILURE);
}
int ConsumePointer(char ch, FILE* source_file, char* s)
void Update_Pointer(char ch)
{
/* Calculate pointer size*/
if((37 == ch) || (38 == ch)) ip = ip + 4; /* Deal with % and & */
else if((64 == ch) || (36 == ch)) ip = ip + 2; /* Deal with @ and $ */
else if(33 == ch) ip = ip + 1; /* Deal with ! */
if(in_set(ch, "%&")) ip = ip + 4; /* Deal with % and & */
else if(in_set(ch, "@$")) ip = ip + 2; /* Deal with @ and $ */
else if('~' == ch) ip = ip + 3; /* Deal with ~ */
else if('!' == ch) ip = ip + 1; /* Deal with ! */
else
{
line_error();
file_print("storePointer given unknown\n", stderr);
exit(EXIT_FAILURE);
}
return consume_token(source_file, s);
}
void storePointer(char ch, FILE* source_file)
{
/* Get string of pointer */
memset (scratch, 0, max_string + 1);
int base_sep_p = (ConsumePointer(ch, source_file, scratch) == 62); /* '>' */
Clear_Scratch(scratch);
Update_Pointer(ch);
int base_sep_p = consume_token(source_file);
/* Lookup token */
int target = GetTarget(scratch);
int displacement;
int base = ip;
/* Change relative base address to :<base> */
if (base_sep_p)
if ('>' == base_sep_p)
{
memset (scratch2, 0, max_string + 1);
consume_token (source_file, scratch2);
base = GetTarget (scratch2);
}
Clear_Scratch(scratch);
consume_token (source_file);
base = GetTarget (scratch);
displacement = Architectural_displacement(target, base);
/* output calculated difference */
if(33 == ch)
{
if(40 == Architecture) outputPointer(displacement - 7, 1); /* Deal with ! */
else outputPointer(displacement, 1); /* Deal with ! */
/* Force universality of behavior */
displacement = (target - base);
}
else if(36 == ch) outputPointer(target, 2); /* Deal with $ */
else if(64 == ch) outputPointer(displacement, 2); /* Deal with @ */
else if(38 == ch) outputPointer(target, 4); /* Deal with & */
else if(37 == ch) outputPointer(displacement, 4); /* Deal with % */
else
{
file_print("storePointer reached impossible case: ch=", stderr);
displacement = Architectural_displacement(target, base);
}
/* output calculated difference */
if('!' == ch) outputPointer(displacement, 1); /* Deal with ! */
else if('$' == ch) outputPointer(target, 2); /* Deal with $ */
else if('@' == ch) outputPointer(displacement, 2); /* Deal with @ */
else if('~' == ch) outputPointer(displacement, 3); /* Deal with ~ */
else if('&' == ch) outputPointer(target, 4); /* Deal with & */
else if('%' == ch) outputPointer(displacement, 4); /* Deal with % */
else
{
line_error();
file_print("error: storePointer reached impossible case: ch=", stderr);
fputc(ch, stderr);
file_print("\n", stderr);
exit(EXIT_FAILURE);
@ -243,32 +329,36 @@ void storePointer(char ch, FILE* source_file)
void line_Comment(FILE* source_file)
{
int c = fgetc(source_file);
while((10 != c) && (13 != c))
while(!in_set(c, "\n\r"))
{
c = fgetc(source_file);
}
linenumber = linenumber + 1;
}
int hex(int c, FILE* source_file)
{
if (c >= '0' && c <= '9') return (c - 48);
else if (c >= 'a' && c <= 'z') return (c - 87);
else if (c >= 'A' && c <= 'Z') return (c - 55);
else if (c == '#' || c == ';') line_Comment(source_file);
if (in_set(c, "0123456789")) return (c - 48);
else if (in_set(c, "abcdef")) return (c - 87);
else if (in_set(c, "ABCDEF")) return (c - 55);
else if (in_set(c, "#;")) line_Comment(source_file);
else if ('\n' == c) linenumber = linenumber + 1;
return -1;
}
int octal(int c, FILE* source_file)
{
if (c >= '0' && c <= '7') return (c - 48);
else if (c == '#' || c == ';') line_Comment(source_file);
if (in_set(c, "01234567")) return (c - 48);
else if (in_set(c, "#;")) line_Comment(source_file);
else if ('\n' == c) linenumber = linenumber + 1;
return -1;
}
int binary(int c, FILE* source_file)
{
if (c == '0' || c == '1') return (c - 48);
else if (c == '#' || c == ';') line_Comment(source_file);
if (in_set(c, "01")) return (c - 48);
else if (in_set(c, "#;")) line_Comment(source_file);
else if ('\n' == c) linenumber = linenumber + 1;
return -1;
}
@ -337,11 +427,34 @@ void process_byte(char c, FILE* source_file, int write)
}
}
void pad_to_align(int write)
{
if(40 == Architecture)
{
if(1 == (ip & 0x1))
{
ip = ip + 1;
if(write) fputc('\0', output);
}
if(2 == (ip & 0x2))
{
ip = ip + 2;
if(write)
{
fputc('\0', output);
fputc('\0', output);
}
}
}
}
void first_pass(struct input_files* input)
{
if(NULL == input) return;
first_pass(input->next);
FILE* source_file = fopen(input->filename, "r");
filename = input->filename;
linenumber = 1;
FILE* source_file = fopen(filename, "r");
if(NULL == source_file)
{
@ -356,20 +469,30 @@ void first_pass(struct input_files* input)
for(c = fgetc(source_file); EOF != c; c = fgetc(source_file))
{
/* Check for and deal with label */
if(58 == c)
if(':' == c)
{
c = storeLabel(source_file, ip);
}
/* check for and deal with relative/absolute pointers to labels */
if((33 == c) || (64 == c) || (36 == c) || (37 == c) || (38 == c))
{ /* deal with 1byte pointer !; 2byte pointers (@ and $); 4byte pointers (% and &) */
c = ConsumePointer(c, source_file, NULL);
if (62 == c)
if(in_set(c, "!@$~%&"))
{ /* deal with 1byte pointer !; 2byte pointers (@ and $); 3byte pointers ~; 4byte pointers (% and &) */
Update_Pointer(c);
c = Throwaway_token(source_file);
if ('>' == c)
{ /* deal with label>base */
c = consume_token (source_file, NULL);
c = Throwaway_token(source_file);
}
}
else if('<' == c)
{
pad_to_align(FALSE);
}
else if('^' == c)
{
/* Just ignore */
continue;
}
else process_byte(c, source_file, FALSE);
}
fclose(source_file);
@ -379,7 +502,9 @@ void second_pass(struct input_files* input)
{
if(NULL == input) return;
second_pass(input->next);
FILE* source_file = fopen(input->filename, "r");
filename = input->filename;
linenumber = 1;
FILE* source_file = fopen(filename, "r");
/* Something that should never happen */
if(NULL == source_file)
@ -396,8 +521,10 @@ void second_pass(struct input_files* input)
int c;
for(c = fgetc(source_file); EOF != c; c = fgetc(source_file))
{
if(58 == c) c = consume_token(source_file, NULL); /* Deal with : */
else if((33 == c) || (64 == c) || (36 == c) || (37 == c) || (38 == c)) storePointer(c, source_file); /* Deal with !, @, $, % and & */
if(':' == c) c = Throwaway_token(source_file); /* Deal with : */
else if(in_set(c, "!@$~%&")) storePointer(c, source_file); /* Deal with !, @, $, ~, % and & */
else if('<' == c) pad_to_align(TRUE);
else if('^' == c) ALIGNED = TRUE;
else process_byte(c, source_file, TRUE);
}
@ -407,6 +534,7 @@ void second_pass(struct input_files* input)
/* Standard C main program */
int main(int argc, char **argv)
{
ALIGNED = FALSE;
BigEndian = TRUE;
jump_table = NULL;
Architecture = 0;
@ -417,7 +545,7 @@ int main(int argc, char **argv)
exec_enable = FALSE;
ByteMode = 16;
scratch = calloc(max_string + 1, sizeof(char));
scratch2 = calloc(max_string + 1, sizeof(char));
char* arch;
int option_index = 1;
while(option_index <= argc)
@ -441,9 +569,19 @@ int main(int argc, char **argv)
exec_enable = TRUE;
option_index = option_index + 1;
}
else if(match(argv[option_index], "-A") || match(argv[option_index], "--Architecture"))
else if(match(argv[option_index], "-A") || match(argv[option_index], "--architecture"))
{
Architecture = numerate_string(argv[option_index + 1]);
arch = argv[option_index + 1];
if(match("knight-native", arch) || match("knight-posix", arch)) Architecture = 0;
else if(match("x86", arch)) Architecture = 1;
else if(match("amd64", arch)) Architecture = 2;
else if(match("armv7l", arch)) Architecture = 40;
else
{
file_print("Unknown architecture: ", stderr);
file_print(arch, stderr);
file_print(" know values are: knight-native, knight-posix, x86, amd64 and armv7l", stderr);
}
option_index = option_index + 2;
}
else if(match(argv[option_index], "-b") || match(argv[option_index], "--binary"))
@ -461,10 +599,9 @@ int main(int argc, char **argv)
file_print("Usage: ", stderr);
file_print(argv[0], stderr);
file_print(" -f FILENAME1 {-f FILENAME2} (--BigEndian|--LittleEndian)", stderr);
file_print(" [--BaseAddress 12345] [--Architecture 12345]\nArchitecture", stderr);
file_print(" 0: Knight; 1: x86; 2: AMD64; 40: armv7", stderr);
file_print("\nTo leverage octal or binary", stderr);
file_print(" input: --octal, --binary\n", stderr);
file_print(" [--BaseAddress 12345] [--architecture name]\nArchitecture", stderr);
file_print(" knight-native, knight-posix, x86, amd64 and armv7\n", stderr);
file_print("To leverage octal or binary input: --octal, --binary\n", stderr);
exit(EXIT_SUCCESS);
}
else if(match(argv[option_index], "-f") || match(argv[option_index], "--file"))

View File

@ -21,16 +21,20 @@
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#define max_string 4096
//CONSTANT max_string 4096
#define MACRO 1
#define max_string 4096
//CONSTANT MACRO 1
#define STR 2
#define MACRO 1
//CONSTANT STR 2
#define TRUE 1
#define STR 2
//CONSTANT NEWLINE 3
#define NEWLINE 3
//CONSTANT TRUE 1
#define FALSE 0
#define TRUE 1
//CONSTANT FALSE 0
#define FALSE 0
void file_print(char* s, FILE* f);
int match(char* a, char* b);
@ -38,6 +42,7 @@ int string_length(char* a);
char* numerate_number(int a);
int numerate_string(char *a);
int hex2char(int c);
int in_set(int c, char* s);
FILE* source_file;
FILE* destination_file;
@ -45,6 +50,15 @@ int BigEndian;
int BigBitEndian;
int ByteMode;
int Architecture;
int linenumber;
void line_error(char* filename, int linenumber)
{
file_print(filename, stderr);
file_print(":", stderr);
file_print(numerate_number(linenumber), stderr);
file_print(" :", stderr);
}
struct Token
{
@ -52,9 +66,11 @@ struct Token
int type;
char* Text;
char* Expression;
char* filename;
int linenumber;
};
struct Token* newToken()
struct Token* newToken(char* filename, int linenumber)
{
struct Token* p;
@ -65,6 +81,9 @@ struct Token* newToken()
exit (EXIT_FAILURE);
}
p->filename = filename;
p->linenumber = linenumber;
return p;
}
@ -84,13 +103,31 @@ struct Token* reverse_list(struct Token* head)
void purge_lineComment()
{
int c = fgetc(source_file);
while((10 != c) && (13 != c))
while(!in_set(c, "\n\r"))
{
c = fgetc(source_file);
}
}
char* store_atom(char c)
struct Token* append_newline(struct Token* head, char* filename)
{
linenumber = linenumber + 1;
if(NULL == head) return NULL;
if(NEWLINE == head->type)
{/* Don't waste whitespace*/
return head;
}
struct Token* lf = newToken(filename, linenumber);
lf->type = NEWLINE;
lf->next = head;
lf->Text = "\n";
lf->Expression = lf->Text;
return lf;
}
struct Token* store_atom(struct Token* head, char c, char* filename)
{
char* store = calloc(max_string + 1, sizeof(char));
if(NULL == store)
@ -105,12 +142,17 @@ char* store_atom(char c)
store[i] = ch;
ch = fgetc(source_file);
i = i + 1;
} while ((9 != ch) && (10 != ch) && (32 != ch) && (i <= max_string));
} while (!in_set(ch, "\t\n ") && (i <= max_string));
return store;
head->Text = store;
if('\n' == ch)
{
return append_newline(head, filename);
}
return head;
}
char* store_string(char c)
char* store_string(char c, char* filename)
{
char* store = calloc(max_string + 1, sizeof(char));
if(NULL == store)
@ -127,11 +169,13 @@ char* store_string(char c)
ch = fgetc(source_file);
if(-1 == ch)
{
line_error(filename, linenumber);
file_print("Unmatched \"!\n", stderr);
exit(EXIT_FAILURE);
}
if(max_string == i)
{
line_error(filename, linenumber);
file_print("String: ", stderr);
file_print(store, stderr);
file_print(" exceeds max string size\n", stderr);
@ -142,44 +186,53 @@ char* store_string(char c)
return store;
}
struct Token* Tokenize_Line(struct Token* head)
struct Token* Tokenize_Line(struct Token* head, char* filename)
{
int c;
struct Token* p;
linenumber = 1;
do
{
restart:
c = fgetc(source_file);
if((35 == c) || (59 == c))
if(in_set(c, ";#"))
{
purge_lineComment();
head = append_newline(head, filename);
goto restart;
}
if((9 == c) || (10 == c) || (32 == c))
if(in_set(c, "\t "))
{
goto restart;
}
if(-1 == c)
if('\n' == c)
{
head = append_newline(head, filename);
goto restart;
}
if(EOF == c)
{
head = append_newline(head, filename);
goto done;
}
p = newToken();
if((34 == c) || (39 == c))
p = newToken(filename, linenumber);
p->next = head;
if(in_set(c, "'\""))
{
p->Text = store_string(c);
p->Text = store_string(c, filename);
p->type = STR;
}
else
{
p->Text = store_atom(c);
p = store_atom(p, c, filename);
}
p->next = head;
head = p;
} while(TRUE);
done:
@ -192,8 +245,16 @@ void setExpression(struct Token* p, char *c, char *Exp)
for(i = p; NULL != i; i = i->next)
{
/* Leave macros alone */
if((i->type & MACRO))
if(MACRO == i->type)
{
if(match(i->Text, c))
{
line_error(i->filename, i->linenumber);
file_print("Multiple definitions for macro ", stderr);
file_print(c, stderr);
file_print("\n", stderr);
exit(EXIT_FAILURE);
}
continue;
}
else if(match(i->Text, c))
@ -212,7 +273,7 @@ void identify_macros(struct Token* p)
{
i->type = MACRO;
i->Text = i->next->Text;
if(i->next->next->type & STR)
if(STR == i->next->next->type)
{
i->Expression = i->next->next->Text + 1;
}
@ -230,7 +291,7 @@ void line_macro(struct Token* p)
struct Token* i;
for(i = p; NULL != i; i = i->next)
{
if(i->type & MACRO)
if(MACRO == i->type)
{
setExpression(i->next, i->Text, i->Expression);
}
@ -248,7 +309,7 @@ void hexify_string(struct Token* p)
while(0 < i)
{
i = i - 1;
d[i] = 0x30;
d[i] = '0';
}
while( i < max_string)
@ -271,7 +332,7 @@ void process_string(struct Token* p)
struct Token* i;
for(i = p; NULL != i; i = i->next)
{
if(i->type & STR)
if(STR == i->type)
{
if('\'' == i->Text[0])
{
@ -285,6 +346,22 @@ void process_string(struct Token* p)
}
}
char* pad_nulls(int size, char* nil)
{
if(0 == size) return nil;
size = size * 2;
char* s = calloc(size + 1, sizeof(char));
int i = 0;
while(i < size)
{
s[i] = '0';
i = i + 1;
}
return s;
}
void preserve_other(struct Token* p)
{
@ -295,12 +372,17 @@ void preserve_other(struct Token* p)
{
char c = i->Text[0];
if(('!' == c) ||('@' == c) ||('$' == c) ||('%' == c) ||('&' == c) ||(':' == c))
if(in_set(c, "!@$~%&:^"))
{
i->Expression = i->Text;
}
else if('<' == c)
{
i->Expression = pad_nulls(numerate_string(i->Text + 1), i->Text);
}
else
{
line_error(i->filename, i->linenumber);
file_print("Recieved invalid other; ", stderr);
file_print(i->Text, stderr);
file_print("\n", stderr);
@ -425,6 +507,11 @@ char* express_number(int value, char c)
number_of_bytes = 2;
value = value & 0xFFFF;
}
else if('~' == c)
{
number_of_bytes = 3;
value = value & 0xFFFFFF;
}
else if('%' == c)
{
number_of_bytes = 4;
@ -475,7 +562,10 @@ void eval_immediates(struct Token* p)
struct Token* i;
for(i = p; NULL != i; i = i->next)
{
if((NULL == i->Expression) && !(i->type & MACRO))
if(MACRO == i->type) continue;
else if(NEWLINE == i->type) continue;
else if('<' == i->Text[0]) continue;
else if(NULL == i->Expression)
{
int value;
if((1 == Architecture) || (2 == Architecture) || (40 == Architecture))
@ -508,14 +598,17 @@ void print_hex(struct Token* p)
struct Token* i;
for(i = p; NULL != i; i = i->next)
{
if(i->type ^ MACRO)
if(NEWLINE == i->type)
{
if(NULL == i->next) fputc('\n', destination_file);
else if((NEWLINE != i->next->type) && (MACRO != i->next->type)) fputc('\n', destination_file);
}
else if(i->type != MACRO)
{
fputc('\n', destination_file);
file_print(i->Expression, destination_file);
if(NEWLINE != i->next->type) fputc(' ', destination_file);
}
}
fputc('\n', destination_file);
}
/* Standard C main program */
@ -527,6 +620,8 @@ int main(int argc, char **argv)
destination_file = stdout;
BigBitEndian = TRUE;
ByteMode = 16;
char* filename;
char* arch;
int option_index = 1;
while(option_index <= argc)
@ -545,9 +640,19 @@ int main(int argc, char **argv)
BigEndian = FALSE;
option_index = option_index + 1;
}
else if(match(argv[option_index], "-A") || match(argv[option_index], "--Architecture"))
else if(match(argv[option_index], "-A") || match(argv[option_index], "--architecture"))
{
Architecture = numerate_string(argv[option_index + 1]);
arch = argv[option_index + 1];
if(match("knight-native", arch) || match("knight-posix", arch)) Architecture = 0;
else if(match("x86", arch)) Architecture = 1;
else if(match("amd64", arch)) Architecture = 2;
else if(match("armv7l", arch)) Architecture = 40;
else
{
file_print("Unknown architecture: ", stderr);
file_print(arch, stderr);
file_print(" know values are: knight-native, knight-posix, x86, amd64 and armv7l", stderr);
}
option_index = option_index + 2;
}
else if(match(argv[option_index], "-b") || match(argv[option_index], "--binary"))
@ -560,12 +665,13 @@ int main(int argc, char **argv)
file_print("Usage: ", stderr);
file_print(argv[0], stderr);
file_print(" -f FILENAME1 {-f FILENAME2} (--BigEndian|--LittleEndian) ", stderr);
file_print("[--Architecture 12345]\nArchitecture 0: Knight; 1: x86; 2: AMD64; 40: armv7", stderr);
file_print("[--architecture name]\nArchitectures: knight-native, knight-posix, x86, amd64 and armv7\n", stderr);
exit(EXIT_SUCCESS);
}
else if(match(argv[option_index], "-f") || match(argv[option_index], "--file"))
{
source_file = fopen(argv[option_index + 1], "r");
filename = argv[option_index + 1];
source_file = fopen(filename, "r");
if(NULL == source_file)
{
@ -575,7 +681,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
head = Tokenize_Line(head);
head = Tokenize_Line(head, filename);
option_index = option_index + 2;
}
else if(match(argv[option_index], "-o") || match(argv[option_index], "--output"))

View File

@ -40,14 +40,14 @@ M1 -f test/common_x86/x86_defs.M1 \
-f test/test23/M1-macro.M1 \
-f test/test23/M1-macro-footer.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test23/M1-macro.hex2 || exit 3
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
-f test/test23/M1-macro.hex2 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
--BaseAddress 0x8048000 \
-o test/results/test23-binary \
--exec_enable || exit 4
@ -66,7 +66,7 @@ then
-f functions/libc-core.M1 \
-f test/test21/test.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test23/proof || exit 7
out=$(sha256sum -c test/test23/proof.answer)

View File

@ -1 +1 @@
16039cd07d755cff62d61efd6945f214a79cbfa07c32386beea9b9f5b771a976 test/test23/proof
7d8c3c0220a44f64fbeaadd4818cab6f9fb3ff679a2e0ac17ef965f3cc5716a1 test/test23/proof

View File

@ -37,14 +37,14 @@ M1 -f test/common_x86/x86_defs.M1 \
-f test/test24/get_machine.M1 \
-f test/test24/get_machine-footer.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test24/get_machine.hex2 || exit 3
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
-f test/test24/get_machine.hex2 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
--BaseAddress 0x8048000 \
-o test/results/test24-binary \
--exec_enable || exit 4

View File

@ -41,14 +41,14 @@ M1 -f test/common_x86/x86_defs.M1 \
-f test/test25/kaem.M1 \
-f test/test25/kaem-footer.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test25/kaem.hex2 || exit 3
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
-f test/test25/kaem.hex2 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
--BaseAddress 0x8048000 \
-o test/results/test25-binary \
--exec_enable || exit 4

View File

@ -44,14 +44,14 @@ M1 -f test/common_x86/x86_defs.M1 \
-f test/test26/lisp.M1 \
-f test/test26/lisp-footer.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test26/lisp.hex2 || exit 3
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
-f test/test26/lisp.hex2 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
--BaseAddress 0x8048000 \
-o test/results/test26-binary \
--exec_enable || exit 4

View File

@ -29,11 +29,11 @@ M1 -f test/common_x86/x86_defs.M1 \
-f functions/libc-core.M1 \
-f test/test99/cc0.M1 \
--LittleEndian \
--Architecture 1 \
--architecture x86 \
-o test/test99/cc0.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test99/cc0.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test99-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test99/cc0.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test99-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ]