Merge branch 'patch'

This commit is contained in:
ghidra1 2019-04-26 14:43:57 -04:00
commit 5fa4e7a225
2 changed files with 56 additions and 30 deletions

View File

@ -39,39 +39,42 @@ ext.getEnvironmentValue = { envLines, name ->
return null
}
project.ext.VISUAL_STUDIO_INSTALL_DIR = "/"
project.ext.VISUAL_STUDIO_VCVARS_CMD = "UNKNOWN"
project.ext.MSVC_SDK_VERSION = "UNKNOWN"
project.ext.MSVC_TOOLS_VERSION = "UNKNOWN"
// Ok, this is stupid, but mac and linux can't handle files paths that start with c:
// These paths are actually only used when running on windows, but the paths gets evaulated
// as a file no matter what platform you run gradle on. So the best solution I can think of is as
// follows.
/*
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
project.ext.VISUAL_STUDIO_INSTALL_DIR = project.ext.VISUAL_STUDIO_BASE_DIR + "\\Professional"
if (!file(project.ext.VISUAL_STUDIO_INSTALL_DIR).exists()) {
project.ext.VISUAL_STUDIO_INSTALL_DIR = project.ext.VISUAL_STUDIO_BASE_DIR + "\\Community"
}
println "Visual Studio Path: ${VISUAL_STUDIO_INSTALL_DIR}"
if (file(project.ext.VISUAL_STUDIO_INSTALL_DIR).exists()) {
project.ext.VISUAL_STUDIO_VCVARS_CMD = "\"${VISUAL_STUDIO_INSTALL_DIR}\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x86_amd64"
println "Visual Studio Path: ${VISUAL_STUDIO_INSTALL_DIR}"
project.ext.VISUAL_STUDIO_VCVARS_CMD = "\"${VISUAL_STUDIO_INSTALL_DIR}\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x86_amd64"
// NOTE: Windows 7 targeting requires the use of the Windows 8.1 SDK and setting the
// WINVER property a value of "0x0601" which may be specified to the compiler/linker.
// If using a VS Solution this must be specified within the project file(s).
project.ext.WINVER = "0x0601"
// NOTE: Windows 7 targeting requires the use of the Windows 8.1 SDK and setting the
// WINVER property a value of "0x0601" which may be specified to the compiler/linker.
// If using a VS Solution this must be specified within the project file(s).
project.ext.WINVER = "0x0601"
// Rely on vcvars script to supply SDK versions
def c = VISUAL_STUDIO_VCVARS_CMD + " && env"
String envText = c.execute().text
String[] envLines = c.execute().text.split("\n")
project.ext.MSVC_SDK_VERSION = getEnvironmentValue(envLines, "WINDOWSSDKVERSION")
println "Visual Studio SDK Version: ${MSVC_SDK_VERSION}"
project.ext.MSVC_TOOLS_VERSION = getEnvironmentValue(envLines, "VCTOOLSVERSION")
println "Visual Studio VCTools Version: ${MSVC_TOOLS_VERSION}"
}
else {
project.ext.VISUAL_STUDIO_INSTALL_DIR = "/"
project.ext.VISUAL_STUDIO_VCVARS_CMD = "NA"
project.ext.MSVC_SDK_VERSION = "?"
project.ext.MSVC_TOOLS_VERSION = "?"
// Rely on vcvars script to supply SDK versions
def c = VISUAL_STUDIO_VCVARS_CMD + " && env"
String envText = c.execute().text
String[] envLines = c.execute().text.split("\n")
project.ext.MSVC_SDK_VERSION = getEnvironmentValue(envLines, "WINDOWSSDKVERSION")
println "Visual Studio SDK Version: ${MSVC_SDK_VERSION}"
project.ext.MSVC_TOOLS_VERSION = getEnvironmentValue(envLines, "VCTOOLSVERSION")
println "Visual Studio VCTools Version: ${MSVC_TOOLS_VERSION}"
}
}
/****************************************************************************
@ -101,6 +104,21 @@ model {
}
}
/*******************************************************************************************
* Task: verify presence of correct tool chain version for current platform
******************************************************************************************/
task CheckToolChain {
doFirst {
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
// ensure that required MS Visual Studio is installed where expected
String msg = "Microsoft Visual Studio install not found: ${project.ext.VISUAL_STUDIO_BASE_DIR}\n" +
"Adjust path in Ghidra/GPL/nativeBuildProperties.gradle if needed."
assert file(project.ext.VISUAL_STUDIO_BASE_DIR).exists() : msg
assert file(project.ext.VISUAL_STUDIO_INSTALL_DIR).exists() : msg
}
}
}
/*******************************************************************************************
* If task1 contains the given platform name, then it needs to be executed before
* task2. The task1 must be of type LinkExecutable or LinkSharedLibrary so that the
@ -110,6 +128,7 @@ model {
def addTaskDependencyForMyPlatform(task1, task2, platform) {
if (platform.equals(task1.targetPlatform.get().name)) {
task2.dependsOn task1.path
task1.dependsOn CheckToolChain
}
}
@ -141,6 +160,7 @@ tasks.addRule("Pattern: buildNatives_<platform name>]: build all natives for giv
String platform = taskName - "buildNatives_"
task(taskName) { myTask ->
project.tasks.withType(LinkExecutable) { t ->
addTaskDependencyForMyPlatform(t, myTask, platform)
}
@ -150,6 +170,7 @@ tasks.addRule("Pattern: buildNatives_<platform name>]: build all natives for giv
project.tasks.each { t ->
if (isNativeBinaryMakeTask(t, platform)) {
myTask.dependsOn t.path
t.dependsOn CheckToolChain
}
}
@ -163,15 +184,7 @@ tasks.addRule("Pattern: buildNatives_<platform name>]: build all natives for giv
project.tasks.whenTaskAdded { t ->
if (isNativeBinaryMakeTask(t, platform)) {
myTask.dependsOn t.path
}
}
doFirst {
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
// ensure that required MS Visual Studio is installed where expected
String msg = "Microsoft Visual Studio install not found: ${project.ext.VISUAL_STUDIO_BASE_DIR}\n" +
"Adjust path in Ghidra/GPL/nativeBuildProperties.gradle if needed."
assert file(project.ext.VISUAL_STUDIO_BASE_DIR).exists() : msg
assert file(project.ext.VISUAL_STUDIO_INSTALL_DIR).exists() : msg
t.dependsOn CheckToolChain
}
}
}
@ -229,3 +242,10 @@ gradle.taskGraph.whenReady {
t.linkedFile = p.file("build/os/${osName}/$filename")
}
}
/*****************************************************************************************
* The following block of code ensures that the buildNatives_<platform> task is used
* during assembly to ensure that missing toolchain generates an appropriate error
****************************************************************************************/
def currentPlatform = getCurrentPlatformName()
assemble.dependsOn "buildNatives_$currentPlatform"

View File

@ -3192,7 +3192,13 @@ int4 RuleShiftPiece::applyOp(PcodeOp *op,Funcdata &data)
(zexthiop->code()!= CPUI_INT_SEXT))
return 0;
vn1 = zexthiop->getIn(0);
if (vn1->isFree()) return 0;
if (vn1->isConstant()) {
if (vn1->getSize() < sizeof(uintb))
return 0; // Normally we let ZEXT of a constant collapse naturally
// But if the ZEXTed constant is too big, this won't happen
}
else if (vn1->isFree())
return 0;
int4 sa = shiftop->getIn(1)->getOffset();
int4 concatsize = sa + 8*vn1->getSize();
if (op->getOut()->getSize() * 8 < concatsize) return 0;