#!/bin/sh # This script builds and runs the DEC64 tests for an x64 machine running Linux. ./masm_to_nasm.sh dec64.nasm || exit # Assemble dec64.o. nasm -f elf64 dec64.nasm || exit build_and_run() { # Compile, assemble and link a source file into a binary executable, then # run it. # We opt out of creating a position independent executable (a PIE), because we # depend on absolute addressing. Without passing the the -no-pie flag, we get a # warning like # /usr/bin/ld: dec64.o: warning: relocation in read-only section `.text' # /usr/bin/ld: warning: creating DT_TEXTREL in a PIE # because of lines in dec64.nasm like # mov r10, [r10+r9*8] # We explicitly disable an executable stack to avoid a warning like # /usr/bin/ld: warning: dec64.o: missing .note.GNU-stack section implies executable stack src=$1 bin=$2 gcc \ -no-pie \ -z noexecstack \ -o $bin \ dec64_string.c \ dec64_math.c \ dec64.o \ $src \ && ./$bin } # Build and run the tests. build_and_run dec64_test.c dec64_test \ && build_and_run dec64_string_test.c dec64_string_test \ && build_and_run dec64_math_test.c dec64_math_test \ || exit # This script has been tested on Debian GNU/Linux 12 (Bookworm), using NASM # v2.16.01 and gcc v12.2.0.