From 99ae463e5ca0a1ae7d7c6023685f16ade047c29b Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 12 Jul 2013 15:21:51 +0200 Subject: [PATCH] run: zero pad hello.py to succeed on OKL4 Fixes #804. --- libports/run/python.run | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libports/run/python.run b/libports/run/python.run index 2607167096..970beb5c9b 100644 --- a/libports/run/python.run +++ b/libports/run/python.run @@ -52,7 +52,22 @@ install_config $config # Boot modules # -exec cp [genode_dir]/libports/src/test/python/hello.py bin/ +# Fill up hello.py with zeros, otherwise on OKL4 it fails on native machines. +# OKL4 bootstrap procedure loads the script to the designated address but does +# not clear the remainder of the page. Hence, the script is followed by some +# garbage, which the interpreter tries to execute. + +set test_file "[genode_dir]/libports/src/test/python/hello.py" +set file_size [exec du -b $test_file] +set file_size [regexp -inline {[0-9]+} $file_size] +set file_size [expr 4096 - $file_size] +catch { exec dd if=/dev/zero of=bin/hello.py.tmp bs=1 count=$file_size} +exec cp $test_file bin/hello.py +exec cat bin/hello.py.tmp >>bin/hello.py +exec rm bin/hello.py.tmp +set file_size [exec du -b bin/hello.py] +set file_size [regexp -inline {[0-9]+} $file_size] +if {$file_size != 4096 } { puts "hello.py could not be prepared properly"; exit 1 } # generic modules set boot_modules {