Skip to content

Commit

Permalink
GP-4662: Fixing Swift opinion regression
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmkurtz committed Jun 5, 2024
1 parent 13c93a6 commit 87f62b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
*/
public class SwiftUtils {

public static final String SWIFT_COMPILER = "swift";

/**
* A {@link PointerTypedef pointer} to a relative 4-byte offset
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ private String detectCompilerName(MachHeader machHeader) throws IOException {
.flatMap(seg -> seg.getSections().stream())
.map(section -> section.getSectionName())
.toList();
String compiler = SwiftUtils.isSwift(sectionNames) ? "swift" : null;
compiler = compiler == null && GoRttiMapper.hasGolangSections(sectionNames)
? GoConstants.GOLANG_CSPEC_NAME
: null;
return compiler;
if (SwiftUtils.isSwift(sectionNames)) {
return SwiftUtils.SWIFT_COMPILER;
}
if (GoRttiMapper.hasGolangSections(sectionNames)) {
return GoConstants.GOLANG_CSPEC_NAME;
}
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.ByteProvider;
import ghidra.app.util.bin.format.elf.info.ElfInfoItem.ItemWithAddress;
import ghidra.app.util.bin.format.golang.GoBuildInfo;
import ghidra.app.util.bin.format.golang.GoBuildId;
import ghidra.app.util.bin.format.golang.GoBuildInfo;
import ghidra.app.util.bin.format.golang.rtti.GoRttiMapper;
import ghidra.app.util.bin.format.mz.DOSHeader;
import ghidra.app.util.bin.format.pe.*;
Expand Down Expand Up @@ -922,7 +922,7 @@ public enum CompilerEnum {
CLI("cli", "cli"),
Rustc(RustConstants.RUST_COMPILER, RustConstants.RUST_COMPILER),
GOLANG("golang", "golang"),
Swift("swift", "swift"),
Swift(SwiftUtils.SWIFT_COMPILER, SwiftUtils.SWIFT_COMPILER),
Unknown("unknown", "unknown"),

// The following values represent the presence of ambiguous indicators
Expand Down

0 comments on commit 87f62b7

Please sign in to comment.