>From 0cfb6e075f0368f4cae0e9fb1b5a957044b86531 Mon Sep 17 00:00:00 2001
From: Rafal Krypa <[email protected]>
Date: Mon, 11 Apr 2011 18:59:35 +0200
Subject: [PATCH 1/9] Add support for "cpu transparency" for native
 architecture.

- This feature can be used to safely run statically linked native binaries.
- Rule file interface version was incremented to 26.

Change-Id: I9ebc0beb1cec88d6851064cefdeddc911aef75cb
---
 docs/sb2-init.1                                  |    3 +
 lua_scripts/argvenvp.lua                         |   57 +++++++++-------
 lua_scripts/mapping.lua                          |   10 +++-
 lua_scripts/pathmaps/accel/00_default.lua        |    2 +-
 lua_scripts/pathmaps/devel/00_default.lua        |    2 +-
 lua_scripts/pathmaps/emulate/00_default.lua      |    5 +-
 lua_scripts/pathmaps/maemo_simple/00_default.lua |   76 +++++++++++----------
 lua_scripts/pathmaps/nomap/00_default.lua        |    2 +-
 lua_scripts/pathmaps/simple/00_default.lua       |   72 +++++++++++----------
 lua_scripts/pathmaps/tools/00_default.lua        |    5 +-
 preload/sb_exec.c                                |    3 +-
 utils/sb2                                        |   60 ++++++++++++++---
 utils/sb2-init                                   |    3 +
 utils/sb2-parse-sb2-init-args                    |    4 +-
 14 files changed, 190 insertions(+), 114 deletions(-)

diff --git a/docs/sb2-init.1 b/docs/sb2-init.1
index 7d901a5..7cc87a8 100644
--- a/docs/sb2-init.1
+++ b/docs/sb2-init.1
@@ -47,6 +47,9 @@ specify cpu transparency command, for example:
 CPU transparency method is the program which is used to execute
 foreign binaries, that the host computer can not execute directly.
 .TP
+\-p "command"
+specify cpu transparency command for staticly linked native binaries.
+.TP
 \-r [hostname]
 generate sbrsh config using remote device address
 .TP
diff --git a/lua_scripts/argvenvp.lua b/lua_scripts/argvenvp.lua
index 61d207b..c95c2b2 100644
--- a/lua_scripts/argvenvp.lua
+++ b/lua_scripts/argvenvp.lua
@@ -551,11 +551,13 @@ function sb_execve_postprocess_native_executable(rule, exec_policy,
 	return 1, mapped_file, filename, #argv, argv, #envp, envp
 end
 
-if string.match(sbox_cputransparency_cmd, "qemu") then
-	cputransparency_method_is_qemu = true
-end
-if string.match(sbox_cputransparency_cmd, "sbrsh") then
-	cputransparency_method_is_sbrsh = true
+for k, v in pairs({conf_cputransparency_target, conf_cputransparency_native}) do
+	if string.match(v.cmd, "qemu") then
+		v.method_is_qemu = true
+	end
+	if string.match(v.cmd, "sbrsh") then
+		v.method_is_sbrsh = true
+	end
 end
 
 function split_to_tokens(text,delim)
@@ -696,28 +698,28 @@ function sb_execve_postprocess_sbrsh(rule, exec_policy,
 end
 
 function sb_execve_postprocess_cpu_transparency_executable(rule, exec_policy,
-    exec_type, mapped_file, filename, argv, envp)
+    exec_type, mapped_file, filename, argv, envp, conf_cputransparency)
 
 	sb.log("debug", "postprocessing cpu_transparency for " .. filename)
 
-	if cputransparency_method_is_qemu then
+	if conf_cputransparency.method_is_qemu then
 		local new_envp = {}
 		local new_argv = {}
 		local new_filename
 
-		if conf_cputransparency_qemu_argv == nil then
-			table.insert(new_argv, sbox_cputransparency_cmd)
-			new_filename = sbox_cputransparency_cmd
+		if conf_cputransparency.qemu_argv == nil then
+			table.insert(new_argv, conf_cputransparency.cmd)
+			new_filename = conf_cputransparency.cmd
 		else
-			for i = 1, table.maxn(conf_cputransparency_qemu_argv) do
-				table.insert(new_argv, conf_cputransparency_qemu_argv[i])
+			for i = 1, table.maxn(conf_cputransparency.qemu_argv) do
+				table.insert(new_argv, conf_cputransparency.qemu_argv[i])
 			end
-			new_filename = conf_cputransparency_qemu_argv[1]
+			new_filename = conf_cputransparency.qemu_argv[1]
 		end
 
-		if conf_cputransparency_qemu_env ~= nil then
-			for i = 1, table.maxn(conf_cputransparency_qemu_env) do
-				table.insert(new_envp, conf_cputransparency_qemu_env[i])
+		if conf_cputransparency.qemu_env ~= nil then
+			for i = 1, table.maxn(conf_cputransparency.qemu_env) do
+				table.insert(new_envp, conf_cputransparency.qemu_env[i])
 			end
 		end
 
@@ -725,13 +727,13 @@ function sb_execve_postprocess_cpu_transparency_executable(rule, exec_policy,
 		table.insert(new_argv, "-L")
 		table.insert(new_argv, "/")
 
-		if conf_cputransparency_has_argv0_flag then
+		if conf_cputransparency.has_argv0_flag then
 			-- set target argv[0]
 			table.insert(new_argv, "-0")
 			table.insert(new_argv, argv[1])
 		end
 
-		if conf_cputransparency_qemu_has_libattr_hack_flag then
+		if conf_cputransparency.qemu_has_libattr_hack_flag then
 			-- For ARM emulation:
 			-- a nasty bug exists in some older libattr library
 			-- version (e.g. it causes "ls -l" to crash), this
@@ -746,7 +748,7 @@ function sb_execve_postprocess_cpu_transparency_executable(rule, exec_policy,
 			needs_libfakeroot = true
 		end
 
-		if conf_cputransparency_qemu_has_env_control_flags then
+		if conf_cputransparency.qemu_has_env_control_flags then
 			for i = 1, #envp do
 				-- drop LD_TRACE_* from target environment
 				if string.match(envp[i], "^LD_TRACE_.*") then
@@ -793,15 +795,15 @@ function sb_execve_postprocess_cpu_transparency_executable(rule, exec_policy,
 		-- Fortunately that is easy: 
 		local qemu_ldlibpath
 		local qemu_ldpreload
-		if conf_cputransparency_qemu_ld_library_path == "" then
+		if conf_cputransparency.qemu_ld_library_path == "" then
 			qemu_ldlibpath = "LD_LIBRARY_PATH=" .. host_ld_library_path
 		else
-			qemu_ldlibpath = conf_cputransparency_qemu_ld_library_path
+			qemu_ldlibpath = conf_cputransparency.qemu_ld_library_path
 		end
-		if conf_cputransparency_qemu_ld_preload == "" then
+		if conf_cputransparency.qemu_ld_preload == "" then
 			qemu_ldpreload = "LD_PRELOAD=" ..  host_ld_preload
 		else
-			qemu_ldpreload = conf_cputransparency_qemu_ld_preload
+			qemu_ldpreload = conf_cputransparency.qemu_ld_preload
 		end
 
 		-- NOTE/FIXME: This still assumes that the name of the libfakeroot
@@ -832,7 +834,7 @@ function sb_execve_postprocess_cpu_transparency_executable(rule, exec_policy,
 		-- environment&args were changed
 		return 0, new_filename, filename, #new_argv, new_argv,
 			#new_envp, new_envp
-	elseif cputransparency_method_is_sbrsh then
+	elseif conf_cputransparency.method_is_sbrsh then
 		return sb_execve_postprocess_sbrsh(rule, exec_policy,
     			exec_type, mapped_file, filename, argv, envp)
 	end
@@ -890,8 +892,13 @@ function sb_execve_postprocess(rule, exec_policy, exec_type,
 	elseif (exec_type == "cpu_transparency") then
 		return sb_execve_postprocess_cpu_transparency_executable(rule,
 			exec_policy, exec_type, mapped_file,
-			filename, argv, envp)
+			filename, argv, envp, conf_cputransparency_target)
 	elseif (exec_type == "static") then
+		if (conf_cputransparency_native.cmd ~= "") then
+			return sb_execve_postprocess_cpu_transparency_executable(rule,
+				exec_policy, exec_type, mapped_file,
+				filename, argv, envp, conf_cputransparency_native)
+		end
 		-- [see comment in sb_exec.c]
 		local ldlibpath
 		local ldpreload
diff --git a/lua_scripts/mapping.lua b/lua_scripts/mapping.lua
index de1f9fa..03e7c7d 100644
--- a/lua_scripts/mapping.lua
+++ b/lua_scripts/mapping.lua
@@ -167,6 +167,14 @@ function load_and_check_rules()
 	-- exec mapping code (argvenp.lua) and the
 	-- rule files:
 	--
+	-- Version 26:
+	-- - CPU Transparency for native architecture is implemented:
+	--    - sbox_cputransparency_native_method - defined by the '-p'
+	--      option of sb2-init,
+	--    - sbox_cputransparency_native_cmd,
+	--    - sbox_cputransparency_native_args,
+	--    All of the above are equivalent to sbox_cputransparency_*
+	--    variables.
 	-- Version 25:
 	-- - CPU Transparency is now defined by three variables:
 	--    - sbox_cputransparency_method is the complete string,
@@ -212,7 +220,7 @@ function load_and_check_rules()
 	--   (previously only one was expected)
 	-- - variables "esc_tools_root" and "esc_target_root"
 	--   were removed
-	local current_rule_interface_version = "25"
+	local current_rule_interface_version = "26"
 
 	do_file(rule_file_path)
 	export_chains = override_export_chains()
diff --git a/lua_scripts/pathmaps/accel/00_default.lua b/lua_scripts/pathmaps/accel/00_default.lua
index 73ad3aa..fa872c4 100644
--- a/lua_scripts/pathmaps/accel/00_default.lua
+++ b/lua_scripts/pathmaps/accel/00_default.lua
@@ -11,7 +11,7 @@
 
 -- Rule file interface version, mandatory.
 --
-rule_file_interface_version = "25"
+rule_file_interface_version = "26"
 ----------------------------------
 
 tools = tools_root
diff --git a/lua_scripts/pathmaps/devel/00_default.lua b/lua_scripts/pathmaps/devel/00_default.lua
index 88fe527..b261a9e 100644
--- a/lua_scripts/pathmaps/devel/00_default.lua
+++ b/lua_scripts/pathmaps/devel/00_default.lua
@@ -8,7 +8,7 @@
 
 -- Rule file interface version, mandatory.
 --
-rule_file_interface_version = "25"
+rule_file_interface_version = "26"
 ----------------------------------
 
 tools = tools_root
diff --git a/lua_scripts/pathmaps/emulate/00_default.lua b/lua_scripts/pathmaps/emulate/00_default.lua
index 4727cae..83c12d7 100644
--- a/lua_scripts/pathmaps/emulate/00_default.lua
+++ b/lua_scripts/pathmaps/emulate/00_default.lua
@@ -3,7 +3,7 @@
 
 -- Rule file interface version, mandatory.
 --
-rule_file_interface_version = "25"
+rule_file_interface_version = "26"
 ----------------------------------
 
 sb1_compat_dir = sbox_target_root .. "/scratchbox1-compat"
@@ -78,6 +78,9 @@ mapall_chain = {
 		{path = sbox_cputransparency_cmd, use_orig_path = true,
 		 readonly = true},
 
+		{path = sbox_cputransparency_native_cmd, use_orig_path = true,
+		 readonly = true},
+
 		{path = "/usr/bin/sb2-show", use_orig_path = true,
 		 readonly = true},
 		{path = "/usr/bin/sb2-qemu-gdbserver-prepare",
diff --git a/lua_scripts/pathmaps/maemo_simple/00_default.lua b/lua_scripts/pathmaps/maemo_simple/00_default.lua
index c47f616..0983ba7 100644
--- a/lua_scripts/pathmaps/maemo_simple/00_default.lua
+++ b/lua_scripts/pathmaps/maemo_simple/00_default.lua
@@ -89,45 +89,49 @@ simple_chain = {
 	}
 }
 
-qemu_chain = {
-	next_chain = nil,
-	binary = basename(sbox_cputransparency_cmd),
-	rules = {
-		{prefix = session_dir, use_orig_path = true},
-
-		{prefix = "/lib", map_to = target_root},
-		{prefix = "/usr/lib", map_to = target_root},
-		{prefix = "/usr/local/lib", map_to = target_root},
-
-		{prefix = "/tmp", map_to = session_dir},
-
-		{prefix = "/dev", use_orig_path = true},
-		{dir = "/proc", custom_map_funct = sb2_procfs_mapper,
-		 virtual_path = true},
-		{prefix = "/sys", use_orig_path = true},
-
-		--
-		-- Following 3 rules are needed because package
-		-- "resolvconf" makes resolv.conf to be symlink that
-		-- points to /etc/resolvconf/run/resolv.conf and
-		-- we want them all to come from host.
-		--
-		{prefix = "/var/run/resolvconf", force_orig_path = true,
-		 readonly = true},
-		{prefix = "/etc/resolvconf", force_orig_path = true,
-		 readonly = true},
-		{prefix = "/etc/resolv.conf", force_orig_path = true,
-		 readonly = true},
-		--
-
-		{prefix = tools, use_orig_path = true},
-		{path = "/", use_orig_path = true},
-		{prefix = "/", map_to = tools}
+function qemu_chain(cputransparency_cmd)
+	local chain = {
+		next_chain = nil,
+		binary = basename(cputransparency_cmd),
+		rules = {
+			{prefix = session_dir, use_orig_path = true},
+
+			{prefix = "/lib", map_to = target_root},
+			{prefix = "/usr/lib", map_to = target_root},
+			{prefix = "/usr/local/lib", map_to = target_root},
+
+			{prefix = "/tmp", map_to = session_dir},
+
+			{prefix = "/dev", use_orig_path = true},
+			{dir = "/proc", custom_map_funct = sb2_procfs_mapper,
+			 virtual_path = true},
+			{prefix = "/sys", use_orig_path = true},
+
+			--
+			-- Following 3 rules are needed because package
+			-- "resolvconf" makes resolv.conf to be symlink that
+			-- points to /etc/resolvconf/run/resolv.conf and
+			-- we want them all to come from host.
+			--
+			{prefix = "/var/run/resolvconf", force_orig_path = true,
+			 readonly = true},
+			{prefix = "/etc/resolvconf", force_orig_path = true,
+			 readonly = true},
+			{prefix = "/etc/resolv.conf", force_orig_path = true,
+			 readonly = true},
+			--
+
+			{prefix = tools, use_orig_path = true},
+			{path = "/", use_orig_path = true},
+			{prefix = "/", map_to = tools}
+		}
 	}
-}
+	return chain
+end
 
 export_chains = {
-	qemu_chain,
+	qemu_chain(sbox_cputransparency_cmd),
+	qemu_chain(sbox_cputransparency_native_cmd),
 	simple_chain
 }
 
diff --git a/lua_scripts/pathmaps/nomap/00_default.lua b/lua_scripts/pathmaps/nomap/00_default.lua
index 77069f4..93055af 100644
--- a/lua_scripts/pathmaps/nomap/00_default.lua
+++ b/lua_scripts/pathmaps/nomap/00_default.lua
@@ -21,7 +21,7 @@
 
 -- Rule file interface version, mandatory.
 --
-rule_file_interface_version = "25"
+rule_file_interface_version = "26"
 ----------------------------------
 
 -- disable the gcc toolchain tricks.
diff --git a/lua_scripts/pathmaps/simple/00_default.lua b/lua_scripts/pathmaps/simple/00_default.lua
index 9f1e821..debcf1a 100644
--- a/lua_scripts/pathmaps/simple/00_default.lua
+++ b/lua_scripts/pathmaps/simple/00_default.lua
@@ -7,7 +7,7 @@
 
 -- Rule file interface version, mandatory.
 --
-rule_file_interface_version = "25"
+rule_file_interface_version = "26"
 ----------------------------------
 
 tools = tools_root
@@ -85,42 +85,46 @@ simple_chain = {
 	}
 }
 
-qemu_chain = {
-	next_chain = nil,
-	binary = basename(sbox_cputransparency_cmd),
-	rules = {
-		{prefix = "/usr/lib", map_to = target_root},
-		{prefix = "/usr/local/lib", map_to = target_root},
-		{prefix = "/tmp", use_orig_path = true},
-		{prefix = "/dev", use_orig_path = true},
-		{dir = "/proc", custom_map_funct = sb2_procfs_mapper,
-		 virtual_path = true},
-		{prefix = "/sys", use_orig_path = true},
-
-		--
-		-- Following 3 rules are needed because package
-		-- "resolvconf" makes resolv.conf to be symlink that
-		-- points to /etc/resolvconf/run/resolv.conf and
-		-- we want them all to come from host.
-		--
-		{prefix = "/var/run/resolvconf", force_orig_path = true,
-		 readonly = true},
-		{prefix = "/etc/resolvconf", force_orig_path = true,
-		 readonly = true},
-		{prefix = "/etc/resolv.conf", force_orig_path = true,
-		 readonly = true},
-
-		{prefix = "/lib", map_to = target_root},
-		--
-
-		{prefix = tools, use_orig_path = true},
-		{path = "/", use_orig_path = true},
-		{prefix = "/", map_to = tools}
+function qemu_chain(cputransparency_cmd)
+	local chain = {
+		next_chain = nil,
+		binary = basename(cputransparency_cmd),
+		rules = {
+			{prefix = "/usr/lib", map_to = target_root},
+			{prefix = "/usr/local/lib", map_to = target_root},
+			{prefix = "/tmp", use_orig_path = true},
+			{prefix = "/dev", use_orig_path = true},
+			{dir = "/proc", custom_map_funct = sb2_procfs_mapper,
+			 virtual_path = true},
+			{prefix = "/sys", use_orig_path = true},
+
+			--
+			-- Following 3 rules are needed because package
+			-- "resolvconf" makes resolv.conf to be symlink that
+			-- points to /etc/resolvconf/run/resolv.conf and
+			-- we want them all to come from host.
+			--
+			{prefix = "/var/run/resolvconf", force_orig_path = true,
+			 readonly = true},
+			{prefix = "/etc/resolvconf", force_orig_path = true,
+			 readonly = true},
+			{prefix = "/etc/resolv.conf", force_orig_path = true,
+			 readonly = true},
+
+			{prefix = "/lib", map_to = target_root},
+			--
+
+			{prefix = tools, use_orig_path = true},
+			{path = "/", use_orig_path = true},
+			{prefix = "/", map_to = tools}
+		}
 	}
-}
+	return chain
+end
 
 export_chains = {
-	qemu_chain,
+	qemu_chain(sbox_cputransparency_cmd),
+	qemu_chain(sbox_cputransparency_native_cmd),
 	simple_chain
 }
 
diff --git a/lua_scripts/pathmaps/tools/00_default.lua b/lua_scripts/pathmaps/tools/00_default.lua
index 254b399..49d1761 100644
--- a/lua_scripts/pathmaps/tools/00_default.lua
+++ b/lua_scripts/pathmaps/tools/00_default.lua
@@ -6,7 +6,7 @@
 
 -- Rule file interface version, mandatory.
 --
-rule_file_interface_version = "25"
+rule_file_interface_version = "26"
 ----------------------------------
 
 tools = tools_root
@@ -55,6 +55,9 @@ mapall_chain = {
 		{path = sbox_cputransparency_cmd, use_orig_path = true,
 		 readonly = true},
 
+		{path = sbox_cputransparency_native_cmd, use_orig_path = true,
+		 readonly = true},
+
 		{path = "/usr/bin/sb2-show", use_orig_path = true,
 		 readonly = true},
 
diff --git a/preload/sb_exec.c b/preload/sb_exec.c
index 95f76ec..a9c109f 100644
--- a/preload/sb_exec.c
+++ b/preload/sb_exec.c
@@ -1138,7 +1138,8 @@ static int prepare_exec(const char *exec_fn_name,
 				allow_static_bin = getenv(
 					"SBOX_ALLOW_STATIC_BINARY");
 				if (allow_static_bin &&
-				    !strcmp(allow_static_bin, mapped_file)) {
+				    !strcmp(allow_static_bin, mapped_file)
+				    || getenv("SBOX_NATIVE_HAS_CPUTRANSP") != NULL) {
 					/* no warnning, just debug */
 					SB_LOG(SB_LOGLEVEL_DEBUG,
 						"statically linked "
diff --git a/utils/sb2 b/utils/sb2
index 17c00d2..6d661a3 100755
--- a/utils/sb2
+++ b/utils/sb2
@@ -313,6 +313,25 @@ function load_configuration()
 		fi
 	fi
 
+	SBOX_CPUTRANSPARENCY_NATIVE_CMD=""
+	SBOX_CPUTRANSPARENCY_NATIVE_ARGS=""
+	if [ -n "$SBOX_CPUTRANSPARENCY_NATIVE_METHOD" ]; then
+		# $SBOX_CPUTRANSPARENCY_NATIVE_METHOD may contain options.
+		set $SBOX_CPUTRANSPARENCY_NATIVE_METHOD
+		SBOX_CPUTRANSPARENCY_NATIVE_CMD="$1"
+		shift
+		SBOX_CPUTRANSPARENCY_NATIVE_ARGS="$*"
+		_cputransp=$(which $SBOX_CPUTRANSPARENCY_NATIVE_CMD)
+		if [ -z "$_cputransp" ]; then
+			echo "Fatal: Native CPU transparency method not found ($SBOX_CPUTRANSPARENCY_NATIVE_METHOD)"
+			exit 1
+		fi
+		if [ -e "$_cputransp" ]; then
+			SBOX_CPUTRANSPARENCY_NATIVE_CMD=$(realpath $_cputransp)
+			export SBOX_NATIVE_HAS_CPUTRANSP=1
+		fi
+	fi
+
 	#-----------
 	# Time to set LD_LIBRARY_PATH for host-compatible programs:
 
@@ -532,6 +551,9 @@ sbox_cpu="$SBOX_CPU"
 sbox_cputransparency_method="$SBOX_CPUTRANSPARENCY_METHOD"
 sbox_cputransparency_cmd="$SBOX_CPUTRANSPARENCY_CMD"
 sbox_cputransparency_args="$SBOX_CPUTRANSPARENCY_ARGS"
+sbox_cputransparency_native_method="$SBOX_CPUTRANSPARENCY_NATIVE_METHOD"
+sbox_cputransparency_native_cmd="$SBOX_CPUTRANSPARENCY_NATIVE_CMD"
+sbox_cputransparency_native_args="$SBOX_CPUTRANSPARENCY_NATIVE_ARGS"
 sbox_sbrsh_config="$SBRSH_CONFIG"
 
 sbox_host_gcc_prefix_list="$SBOX_HOST_GCC_PREFIX_LIST"
@@ -1135,6 +1157,19 @@ END
 
 function add_cputransparency_settings_to_exec_config_file()
 {
+	type="$1"
+
+	case "$type" in
+	target)	conf='conf_cputransparency_target'
+		sbox_cputransparency_cmd="$SBOX_CPUTRANSPARENCY_CMD"
+		sbox_cputransparency_method="$SBOX_CPUTRANSPARENCY_METHOD"
+		;;
+	native)	conf='conf_cputransparency_native'
+		sbox_cputransparency_cmd="$SBOX_CPUTRANSPARENCY_NATIVE_CMD"
+		sbox_cputransparency_method="$SBOX_CPUTRANSPARENCY_NATIVE_METHOD"
+		;;
+	esac
+
 	conf_cputransparency_has_argv0_flag="false"
 	conf_cputransparency_qemu_has_env_control_flags="false"
 	conf_cputransparency_qemu_has_libattr_hack_flag="false"
@@ -1143,20 +1178,22 @@ function add_cputransparency_settings_to_exec_config_file()
 	conf_cputransparency_qemu_argv="nil"
 	conf_cputransparency_qemu_env="nil"
 
-	case "$SBOX_CPUTRANSPARENCY_CMD" in	
-	*qemu*)	check_qemu_features $SBOX_CPUTRANSPARENCY_METHOD
+	case "$sbox_cputransparency_cmd" in
+	*qemu*)	check_qemu_features $sbox_cputransparency_method
 		;;
 	esac
 
 	cat <<END >>$SBOX_SESSION_DIR/exec_config.lua
-
-conf_cputransparency_has_argv0_flag=$conf_cputransparency_has_argv0_flag
-conf_cputransparency_qemu_has_env_control_flags=$conf_cputransparency_qemu_has_env_control_flags
-conf_cputransparency_qemu_has_libattr_hack_flag=$conf_cputransparency_qemu_has_libattr_hack_flag
-conf_cputransparency_qemu_ld_library_path="$conf_cputransparency_qemu_ld_library_path"
-conf_cputransparency_qemu_ld_preload="$conf_cputransparency_qemu_ld_preload"
-conf_cputransparency_qemu_argv=$conf_cputransparency_qemu_argv
-conf_cputransparency_qemu_env=$conf_cputransparency_qemu_env
+$conf = {
+	cmd="$sbox_cputransparency_cmd",
+	has_argv0_flag=$conf_cputransparency_has_argv0_flag,
+	qemu_has_env_control_flags=$conf_cputransparency_qemu_has_env_control_flags,
+	qemu_has_libattr_hack_flag=$conf_cputransparency_qemu_has_libattr_hack_flag,
+	qemu_ld_library_path="$conf_cputransparency_qemu_ld_library_path",
+	qemu_ld_preload="$conf_cputransparency_qemu_ld_preload",
+	qemu_argv=$conf_cputransparency_qemu_argv,
+	qemu_env=$conf_cputransparency_qemu_env,
+}
 END
 }
 
@@ -1575,7 +1612,8 @@ export LD_LIBRARY_PATH
 # existing session.
 
 if [ -z "$SBOX_JOIN_SESSION_FILE" ]; then
-	add_cputransparency_settings_to_exec_config_file
+	add_cputransparency_settings_to_exec_config_file 'target'
+	add_cputransparency_settings_to_exec_config_file 'native'
 fi
 
 # ------------
diff --git a/utils/sb2-init b/utils/sb2-init
index dee739f..d978a8b 100755
--- a/utils/sb2-init
+++ b/utils/sb2-init
@@ -70,6 +70,8 @@ are available by version number (e.g. if the primary is known as
 Options:
     -c "command"      specify cpu transparency command, for example:
                       "qemu-arm", "sbrsh" or "qemu-arm -m 512"
+    -p "command"      specify cpu transparency command for staticly linked
+                      native binaries
     -r [hostname]     generate sbrsh config using remote device address
     -l [hostname]     NFS server/localhost address seen by remote device
     -d                set target as default scratchbox2 target
@@ -120,6 +122,7 @@ SBOX_TARGET_ROOT=$SBOX_TARGET_ROOT
 
 SBOX_CPU=$ARCH
 SBOX_CPUTRANSPARENCY_METHOD="$SB2INIT_CPUTRANSP"
+SBOX_CPUTRANSPARENCY_NATIVE_METHOD="$SB2INIT_CPUTRANSP_NATIVE"
 SBOX_UNAME_MACHINE=$MACHINE_ARCH
 
 SBOX_HOST_GCC_NAME=host-gcc
diff --git a/utils/sb2-parse-sb2-init-args b/utils/sb2-parse-sb2-init-args
index a50a56a..bf6e439 100755
--- a/utils/sb2-parse-sb2-init-args
+++ b/utils/sb2-parse-sb2-init-args
@@ -40,12 +40,13 @@ SB2INIT_SHOW_VERSION=0
 SB2INIT_ERROR=0
 
 # Parse the same options what sb2-init uses:
-while getopts A:M:c:C:r:l:m:dhnNst:v foo
+while getopts A:M:c:C:r:l:m:p:dhnNst:v foo
 do
 	case $foo in
 	(A) SB2INIT_ARCH=$OPTARG ;;
 	(M) SB2INIT_MACHINE_ARCH=$OPTARG ;;
 	(c) SB2INIT_CPUTRANSP=$OPTARG ;;
+	(p) SB2INIT_CPUTRANSP_NATIVE=$OPTARG ;;
 	(r) SB2INIT_REMOTEHOST=$OPTARG ;;
 	(l) SB2INIT_LOCALHOST=$OPTARG ;;
 	(d) SB2INIT_SET_AS_DEFAULT=1 ;;
@@ -89,6 +90,7 @@ SB2INIT_TARGET_ROOT="$SB2INIT_TARGET_ROOT"
 SB2INIT_ARCH="$SB2INIT_ARCH"
 SB2INIT_MACHINE_ARCH="$SB2INIT_MACHINE_ARCH"
 SB2INIT_CPUTRANSP="$SB2INIT_CPUTRANSP"
+SB2INIT_CPUTRANSP_NATIVE="$SB2INIT_CPUTRANSP_NATIVE"
 SB2INIT_REMOTEHOST="$SB2INIT_REMOTEHOST"
 SB2INIT_LOCALHOST="$SB2INIT_LOCALHOST"
 SB2INIT_SET_AS_DEFAULT="$SB2INIT_SET_AS_DEFAULT"
-- 
1.7.9.1



_______________________________________________
Scratchbox-devel mailing list
[email protected]
http://lists.scratchbox.org/cgi-bin/mailman/listinfo/scratchbox-devel

Reply via email to