diff --git a/GPL/nativeBuildProperties.gradle b/GPL/nativeBuildProperties.gradle index 36b9a07875..6ddc826059 100644 --- a/GPL/nativeBuildProperties.gradle +++ b/GPL/nativeBuildProperties.gradle @@ -87,6 +87,16 @@ def isNativeBinaryMakeTask(Task task, String platform) { return false } +/******************************************************************************************* + * Returns true if the native binaries for the given task should be skipped during build. + * + * NOTE: Some native binaries are test-only and should not be built for a distribution. + * + ******************************************************************************************/ +def shouldSkipNative(task) { + return task.ext.has("skipNative") && task.ext.get("skipNative") +} + /******************************************************************************************* * Task Rule : builds all the natives in this module for a given platform. * @@ -113,6 +123,11 @@ tasks.addRule("Pattern: buildNatives_]: build all natives for giv myTask.dependsOn t.path t.dependsOn CheckToolChain } + + // buildNatives task natives end up in the distribution...mark test natives as "skip" + if (project.findProperty("nativesTestOnly") ?: false) { + t.ext.set("skipNative", true) + } } // add callbacks to look for native build tasks when new tasks are added later @@ -169,18 +184,22 @@ tasks.addRule("Pattern: prebuildNatives_]: build all natives for gradle.taskGraph.whenReady { def p = this.project p.tasks.withType(LinkExecutable).each { t -> - File f = t.linkedFile.getAsFile().get() - String filename = f.getName() - NativePlatform platform = t.targetPlatform.get() - String osName = platform.getName() - t.linkedFile = p.file("build/os/${osName}/$filename") + if (!shouldSkipNative(t)) { + File f = t.linkedFile.getAsFile().get() + String filename = f.getName() + NativePlatform platform = t.targetPlatform.get() + String osName = platform.getName() + t.linkedFile = p.file("build/os/${osName}/$filename") + } } p.tasks.withType(LinkSharedLibrary).each { t -> - File f = t.linkedFile.getAsFile().get() - String filename = f.getName() - NativePlatform platform = t.targetPlatform.get() - String osName = platform.getName() - t.linkedFile = p.file("build/os/${osName}/$filename") + if (!shouldSkipNative(t)) { + File f = t.linkedFile.getAsFile().get() + String filename = f.getName() + NativePlatform platform = t.targetPlatform.get() + String osName = platform.getName() + t.linkedFile = p.file("build/os/${osName}/$filename") + } } } diff --git a/Ghidra/Debug/Framework-Debugging/build.gradle b/Ghidra/Debug/Framework-Debugging/build.gradle index 6031083387..841b955a24 100644 --- a/Ghidra/Debug/Framework-Debugging/build.gradle +++ b/Ghidra/Debug/Framework-Debugging/build.gradle @@ -31,6 +31,9 @@ dependencies { testImplementation project(path: ':Framework-AsyncComm', configuration: 'testArtifacts') } +// Ensure the below native test binaries don't get built for a distribution +ext.nativesTestOnly = true + task testSpecimenWin64 { dependsOn 'expCreateProcessWin64Executable' dependsOn 'expCreateThreadExitWin64Executable' diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/AbstractLoaderExporter.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/AbstractLoaderExporter.java index 4645369886..7c02b3d7bc 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/AbstractLoaderExporter.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/AbstractLoaderExporter.java @@ -89,25 +89,25 @@ public abstract class AbstractLoaderExporter extends Exporter { } // Undo relocations in the temp file + // NOTE: not all relocations are file-backed String error = null; try (RandomAccessFile fout = new RandomAccessFile(tempFile, "rw")) { Iterable relocs = () -> program.getRelocationTable().getRelocations(); for (Relocation reloc : relocs) { AddressSourceInfo info = memory.getAddressSourceInfo(reloc.getAddress()); if (info == null) { - error = "Failed to get relocation address source"; - break; + continue; } - if (info.getFileOffset() < 0) { - error = "Failed to get relocation file offset"; - break; + long offset = info.getFileOffset(); + byte[] bytes = reloc.getBytes(); + if (offset >= 0) { + if (offset + bytes.length > fout.length()) { + error = "Relocation at " + reloc.getAddress() + " exceeds file length"; + break; + } + fout.seek(offset); + fout.write(bytes); } - if (info.getFileOffset() >= fout.length()) { - error = "Relocation file offset exceeds file length"; - break; - } - fout.seek(info.getFileOffset()); - fout.write(reloc.getBytes()); } } diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.cc index 670d94c9f7..a3b4612e87 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.cc @@ -144,6 +144,8 @@ void Funcdata::startProcessing(void) if (funcp.isInline()) warningHeader("This is an inlined function"); + localmap->clearUnlocked(); + funcp.clearUnlockedOutput(); Address baddr(baseaddr.getSpace(),0); Address eaddr(baseaddr.getSpace(),~((uintb)0)); followFlow(baddr,eaddr); diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc index 028a316f9a..56ce320bc4 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc @@ -815,7 +815,8 @@ Datatype *TypeOpReturn::getInputLocal(const PcodeOp *op,int4 slot) const // if (!fp->isOutputLocked()) return TypeOp::getInputLocal(op,slot); ct = fp->getOutputType(); - if (ct->getMetatype() == TYPE_VOID) return TypeOp::getInputLocal(op,slot); + if (ct->getMetatype() == TYPE_VOID || (ct->getSize() != op->getIn(slot)->getSize())) + return TypeOp::getInputLocal(op,slot); return ct; }