diff --git a/ChangeLog b/ChangeLog
index 2d23388..1dd5e62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2013-10-14  Alexander Ivchenko  <alexander.ivchenko@intel.com>
+
+	* baseboards/androideabi.exp (process_multilib_options): Add option.
+	* config/adb.exp: Remove hardcoded -mandroid and -static options.
+	(adb_load): Add the possibility to change the temp directory. Also
+	handle permission potential problems.
+	(adb_exec): Do cd to android_tmp_dir first.
+	* lib/dg.exp (dg-process-target): Add iscross handling.
+	* lib/framework.exp (iscross): New.
+
 2013-06-17  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
 
 	* runtest.exp (libdirs): New global variable.
diff --git a/baseboards/androideabi.exp b/baseboards/androideabi.exp
index 4ba2d63..6c2d61c 100644
--- a/baseboards/androideabi.exp
+++ b/baseboards/androideabi.exp
@@ -16,6 +16,10 @@
 # along with DejaGnu; if not, write to the Free Software Foundation,
 # Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 
+process_multilib_options ""
+
+set cross_target 1
+
 load_generic_config "adb"
 
 # We need this for find_gcc and *_include_flags/*_link_flags.
@@ -23,20 +27,19 @@ load_base_board_description "adb"
 
 set_board_info compiler  "[find_gcc]"
 
-# We may need -mandroid.
-set_board_info cflags  "-mandroid"
-
-# Currently the dynamic linker does not support weak-references in
-# shared libraries.  So we need to workaround using -static
-set_board_info ldflags  "-mandroid -static"
-
 #
 # load PROG to DEST and run it with ARGS using adb
 #
 proc adb_load { dest prog args } {
-    # This directory uses tmpfs, so it is the best place to run
+    # Default directory uses tmpfs, so it is the best place to run
     # tests to avoid excessive wear of flash.
-    set android_tmp_dir "/mnt/sdcard/.android_secure"
+    global android_tmp_dir
+    if { $android_tmp_dir != "" } {
+	verbose -log "android temporary directory is set to $android_tmp_dir" 3
+    } else {
+	set android_tmp_dir "/mnt/sdcard/.android_secure"
+	verbose -log "android temporary directory will be used by default $android_tmp_dir" 3
+    }
 
     if { [llength $args] > 0 } {
 	set pargs [lindex $args 0]
@@ -58,12 +61,22 @@ proc adb_load { dest prog args } {
     }
 
     if [is_remote $dest] {
+	set localfile "./[file tail $prog].[pid]"
 	set remotefile "$android_tmp_dir/[file tail $prog].[pid]"
 	set remotefile [remote_download $dest $prog $remotefile]
 	if { $remotefile == "" } {
 	    verbose -log "Download of $prog to [board_info $dest name] failed." 3
 	    return "unresolved"
 	}
+	set retval [remote_exec $dest "test -x $remotefile"]
+	if { $retval != "0 {}" } {
+	    # Android doesn't support symbolic input for chmod, therefore set executable permission by number
+	    set retval [remote_exec $dest "chmod 755 $remotefile"]
+	    if { $retval != "0 {}" } {
+		verbose -log "Setting executable permissions of $prog on [board_info $dest name] failed." 3
+		return "unresolved"
+	    }
+	}
 	if [board_info $dest exists remote_link] {
 	    if [[board_info $dest remote_link] $remotefile] {
 		verbose -log "Couldn't do remote link"
@@ -73,7 +86,7 @@ proc adb_load { dest prog args } {
 		return "unresolved"
 	    }
 	}
-	set status [remote_exec $dest $remotefile $pargs $inp]
+	set status [remote_exec $dest $localfile $pargs $inp]
 	remote_exec $dest rm $remotefile
     } else {
 	set status [remote_exec $dest $prog $pargs $inp]
diff --git a/config/adb.exp b/config/adb.exp
index a679e6a..496190c 100644
--- a/config/adb.exp
+++ b/config/adb.exp
@@ -128,7 +128,7 @@ proc adb_file {dest op args} {
 }
 
 proc adb_upload {desthost srcfile destfile} {
-    set status [catch "exec adb [adb_serial] pull $srcfile $destfile" output]
+    set status [catch "exec adb [adb_serial] pull $srcfile $destfile |& cat" output]
     if { $status == 0 } {
 	verbose "Copied $srcfile to $destfile" 2
 	return $destfile
@@ -164,8 +164,9 @@ proc adb_exec { boardname cmd args } {
     }
 
     verbose "Executing $boardname:$cmd $pargs < $inp "
-
-    set status [catch "exec cat $inp | adb [adb_serial] shell \( $cmd $pargs \) \\; echo XYZ\\\$\\\{\?\\\}ZYX |& cat" output]
+    # Execute commands only from temporary folder, therefore do "cd" first
+    global android_tmp_dir
+    set status [catch "exec cat $inp | adb [adb_serial] shell cd $android_tmp_dir \&\& \( $cmd $pargs \) \\; echo XYZ\\\$\\\{\?\\\}ZYX |& cat" output]
 
     # `status' doesn't mean much here other than adb worked ok.
     # What we want is whether $cmd ran ok.
diff --git a/lib/dg.exp b/lib/dg.exp
old mode 100644
new mode 100755
index 889585f..6ddcc49
--- a/lib/dg.exp
+++ b/lib/dg.exp
@@ -217,6 +217,7 @@ proc dg-process-target { selector } {
     global target_triplet
 
     set isnative [isnative]
+    set iscross  [iscross]
     set triplet_match 0
 
     #send_user "dg-process-target: $selector\n"
@@ -234,7 +235,7 @@ proc dg-process-target { selector } {
 
     # ??? This should work but it doesn't.  tcl bug?
     #if [regexp "^${what}(( \[^ \]+-\[^ \]+-\[^ \]+)|( native))+$" $selector tmp selector]
-    if {[regexp "^${what}( \[^ \]+-\[^ \]+-\[^ \]+| native)+$" $selector]} {
+    if {[regexp "^${what}( \[^ \]+-\[^ \]+-\[^ \]+| native| cross)+$" $selector]} {
 	regsub "^${what} " $selector "" selector
 	#send_user "selector: $selector\n"
 	foreach triplet $selector {
@@ -242,6 +243,8 @@ proc dg-process-target { selector } {
 		set triplet_match 1
 	    } elseif { $isnative && $triplet == "native" } {
 		set triplet_match 1
+	    } elseif { $iscross  && $triplet == "cross" } {
+		set triplet_match 1
 	    }
 	}
     } else {
diff --git a/lib/framework.exp b/lib/framework.exp
old mode 100644
new mode 100755
index 32aaa74..d22589e
--- a/lib/framework.exp
+++ b/lib/framework.exp
@@ -248,6 +248,13 @@ proc istarget { args } {
     return 0
 }
 
+# Returns 1 if running cross, otherwise 0.
+#
+proc iscross { } {
+    global cross_target
+    return $cross_target
+}
+
 # Check to see if we're running the tests in a native environment
 # Returns 1 if running native, 0 if on a target.
 #
