diff --git a/hotspot/test/runtime/6929067/Test6929067.sh b/hotspot/test/runtime/6929067/Test6929067.sh
index 90b96d5e9..438a287c8 100644
--- a/hotspot/test/runtime/6929067/Test6929067.sh
+++ b/hotspot/test/runtime/6929067/Test6929067.sh
@@ -101,6 +101,10 @@ case "$ARCH" in
 esac
 
 
+if [ "${VM_CPU}" == "aarch64" ]; then
+    COMP_FLAG="-mabi=lp64"
+fi
+
 # VM type: need to know server or client
 VMTYPE=client
 grep Server vm_version.out > ${NULL}
@@ -128,7 +132,7 @@ echo "VM type: ${VMTYPE}"
 $gcc_cmd -DLINUX ${COMP_FLAG} -o invoke \
     -I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
     -L${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE} \
-    -ljvm -lpthread invoke.c
+    invoke.c -ljvm -lpthread
 
 ./invoke
 exit $?
diff --git a/hotspot/test/runtime/InitialThreadOverflow/testme.sh b/hotspot/test/runtime/InitialThreadOverflow/testme.sh
index abafeef4..f95a2f2c 100644
--- a/hotspot/test/runtime/InitialThreadOverflow/testme.sh
+++ b/hotspot/test/runtime/InitialThreadOverflow/testme.sh
@@ -49,6 +49,10 @@ if [ "x$gcc_cmd" = "x" ]; then
     exit 0;
 fi

+if [ "${VM_CPU}" == "aarch64" ]; then
+    CFLAGS=""
+fi
+
 LD_LIBRARY_PATH=.:${COMPILEJAVA}/jre/lib/${VM_CPU}/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH
 export LD_LIBRARY_PATH

@@ -64,7 +68,7 @@ cp ${TESTCLASSES}${FS}DoOverflow.class .
 $gcc_cmd -DLINUX ${CFLAGBITS} -o invoke \
     -I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
     -L${COMPILEJAVA}/jre/lib/${VM_CPU}/${VM_TYPE} \
-    -ljvm -lpthread invoke.cxx
+    invoke.cxx -ljvm -lpthread

 ./invoke
 exit $?
-- 
2.22.0

