[PATCH] D31695: Windows asan_device_setup.bat port of linux shell script
Steven Winston via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 28 14:57:33 PDT 2017
gpx1000 added a comment.
As an aside, I have found a way to use ASan in devices using wrap.sh. So long as the device has the ability to use su or is a eng dev build the following wrap will work:
#!/system/bin/sh-from-zygote\n
ASAN_OPTIONS=start_deactivated=1,malloc_context_size=0
ASAN_ACTIVATION_OPTIONS=include_if_exists=/data/local/tmp/asan.options.b
LD_PRELOAD=libclang_rt.asan-${abi}-android.so
su -c setenforcing 0
$@
su -c setenforcing 1
I'm using it with this gradle:
static def writeWrapScriptToFullyCompileJavaApp(wrapFile, abi) {
if(abi == "armeabi" || abi == "armeabi-v7a")
abi = "arm"
wrapFile.withWriter { writer ->
writer.write('#!/system/bin/sh-from-zygote\n')
writer.write('ASAN_OPTIONS=start_deactivated=1,malloc_context_size=0\n')
writer.write('ASAN_ACTIVATION_OPTIONS=include_if_exists=/data/local/tmp/asan.options.b\n')
writer.write("LD_PRELOAD=libclang_rt.asan-${abi}-android.so\n")
writer.write('su -c setenforcing 0\n')
writer.write('\$@\n')
writer.write('su -c setenforcing 1\n')
}
}
task createWrapScriptAddDir {
def libDir = file("$rootProject.ext.ndkDir").absolutePath + "/toolchains/llvm/prebuilt/"
if(System.properties['os.name'].toLowerCase(Locale.ROOT).contains('windows'))
libDir += "windows-x86_64/lib64/clang"
else
libDir += "*/lib*/*"
for (String abi : ["armeabi-v7a"]) {
def dir = new File("app/wrap_add_dir/" + abi)
dir.mkdirs()
def wrapFile = new File(dir, "wrap.sh")
writeWrapScriptToFullyCompileJavaApp(wrapFile, abi)
println "write file " + wrapFile.path
println "libdir = " + libDir
if(abi == "armeabi" || abi == "armeabi-v7a")
abi = "arm"
copy {
from fileTree(libDir).files
into dir.absolutePath
include "**/*asan*" + abi + "*.so"
}
}
}
I'd note that with doing this; I'm not entirely sure there's still a need for this script to exist. I'm creating a blog post / tutorial on how to use ASan using the above wrap implementation; complete with example project. However, I'll make the suggested changes and resubmit.
================
Comment at: asan_device_setup.py:259
+
+ def parseArgsLoop(self):
+ argList = sys.argv[1:]
----------------
eugenis wrote:
> Is there a reason you are not using standard python argument parsing libraries?
Not a particularly *good* reason. It's the same reasoning there's no helper class; this started its' life as a monkeyscript. Jython's parsing of args there was a bug so had to get around that. Force of legacy means it survived after I learned that python is used in other NDK scripts and thus would be safe to use everywhere; so it survived my refactor to pure python.
I'll refactor this bit too.
https://reviews.llvm.org/D31695
More information about the llvm-commits
mailing list