Ghidra is a software reverse engineering (SRE) framework
GP-6347: SourceLanguage modules and new extension points
Ryan Kurtz3a479c9f7ebe
diff --git a/Ghidra/Features/Base/certification.manifest b/Ghidra/Features/Base/certification.manifestindex b35d3593a3..0b1abbf054 100644--- a/Ghidra/Features/Base/certification.manifest+++ b/Ghidra/Features/Base/certification.manifest@@ -236,7 +236,6 @@ data/typeinfo/golang/patchverdiffs/go1.24.4.json.diff||GHIDRA||||END|data/typeinfo/golang/patchverdiffs/go1.24.5.json.diff||GHIDRA||||END|data/typeinfo/golang/patchverdiffs/go1.24.6.json.diff||GHIDRA||||END|data/typeinfo/mac_10.9/mac_osx.gdt||GHIDRA||||END|-data/typeinfo/rust/rust-common.gdt||GHIDRA||||END|data/typeinfo/win32/msvcrt/clsids.txt||GHIDRA||reviewed||END|data/typeinfo/win32/msvcrt/guids.txt||GHIDRA||reviewed||END|data/typeinfo/win32/msvcrt/iids.txt||GHIDRA||||END|diff --git a/Ghidra/Features/Base/data/ExtensionPoint.manifest b/Ghidra/Features/Base/data/ExtensionPoint.manifestindex cdcb72472e..711f68ce96 100644--- a/Ghidra/Features/Base/data/ExtensionPoint.manifest+++ b/Ghidra/Features/Base/data/ExtensionPoint.manifest@@ -5,6 +5,9 @@ FieldFactoryFieldMouseHandlerStringHandlerLoader+SourceLanguage+SourceLanguageDataArchive+SourceLanguageSpecExtensionTableRowMapperScriptProviderRecognizerdiff --git a/Ghidra/Features/Base/ghidra_scripts/RemoveSourceLanguage.java b/Ghidra/Features/Base/ghidra_scripts/RemoveSourceLanguage.javanew file mode 100644index 0000000000..5a5197098e--- /dev/null+++ b/Ghidra/Features/Base/ghidra_scripts/RemoveSourceLanguage.java@@ -0,0 +1,49 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+//Removes a source language from the program+//@category Program++import java.util.*;++import ghidra.app.script.GhidraScript;+import ghidra.app.util.sourcelanguage.SourceLanguageID;++public class RemoveSourceLanguage extends GhidraScript {++ @Override+ public void run() throws Exception {+ if (currentProgram == null) {+ return;+ }++ Set<SourceLanguageID> idSet = currentProgram.getSourceLanguageIDs();+ if (idSet.isEmpty()) {+ println("No source languages found in " + currentProgram);+ }++ Set<SourceLanguageID> selected = new HashSet<>(askChoices("Remove Source Language(s)",+ "Select source languages to remove from the program", new ArrayList<>(idSet)));++ // Remove from the "Source Language" program property+ idSet.removeIf(selected::contains);+ currentProgram.setSourceLanguageIDs(idSet);++ // Future: Remove associated spec extensions if possible++ // Future: Remove associated data archives if possible+ }++}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/ApplyDataArchiveAnalyzer.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/ApplyDataArchiveAnalyzer.javaindex b300fbb549..a4f5b4b601 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/ApplyDataArchiveAnalyzer.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/ApplyDataArchiveAnalyzer.java@@ -27,6 +27,7 @@ import ghidra.app.plugin.core.datamgr.util.DataTypeArchiveUtility;import ghidra.app.services.*;import ghidra.app.util.bin.format.golang.rtti.GoRttiMapper;import ghidra.app.util.importer.MessageLog;+import ghidra.app.util.sourcelanguage.SourceLanguageService;import ghidra.framework.Application;import ghidra.framework.model.*;import ghidra.framework.options.OptionType;@@ -194,6 +195,38 @@ public class ApplyDataArchiveAnalyzer extends AbstractAnalyzer {}}}++ // Add source language data archives+ result.addAll(getSourceLanguageDTMs(program, log, monitor));++ return result;+ }++ private List<DataTypeManager> getSourceLanguageDTMs(Program program, MessageLog log,+ TaskMonitor monitor) {+ List<DataTypeManager> result = new ArrayList<>();+ for (ResourceFile file : SourceLanguageService.getDataArchives(program,+ program.getSourceLanguageIDs(), log, monitor)) {+ if (monitor.isCancelled()) {+ break;+ }+ try {+ DataTypeManager dtm = dtmService.openArchive(file, false);+ result.add(dtm);+ }+ catch (Exception e) {+ Throwable cause = e.getCause();+ if (cause instanceof VersionException) {+ log.appendMsg("Apply Data Archives",+ "Unable to open archive %s: %s".formatted(file, cause.toString()));+ }+ else {+ String msg = Objects.requireNonNullElse(e.getMessage(), e.toString());+ log.appendMsg("Apply Data Archives",+ "Unexpected Error opening archive %s: %s".formatted(file, msg));+ }+ }+ }return result;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/SourceLanguageAnalyzer.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/SourceLanguageAnalyzer.javanew file mode 100644index 0000000000..4f01109807--- /dev/null+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/SourceLanguageAnalyzer.java@@ -0,0 +1,102 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.plugin.core.analysis;++import java.util.Set;+import java.util.concurrent.atomic.AtomicBoolean;++import ghidra.app.services.*;+import ghidra.app.util.importer.MessageLog;+import ghidra.app.util.sourcelanguage.SourceLanguageID;+import ghidra.app.util.sourcelanguage.SourceLanguageService;+import ghidra.framework.options.Options;+import ghidra.program.model.address.AddressSetView;+import ghidra.program.model.listing.Program;+import ghidra.util.exception.CancelledException;+import ghidra.util.task.TaskMonitor;++/**+ * Adds/updates source language-specific support to the program+ */+public class SourceLanguageAnalyzer extends AbstractAnalyzer {++ private final static String NAME = "Source Language Support";+ private final static String DESCRIPTION =+ "Adds/updates source language-specific support to the program";++ private static String OPTION_NAME_SPEC_EXTENSIONS = "Add specification extensions";+ private static String OPTION_DESC_SPEC_EXTENSIONS =+ "Add any source language-specific specification extensions to the program.";+ private static boolean OPTION_DEFAULT_SPEC_EXTENSIONS = true;++ private AtomicBoolean analysisStarted = new AtomicBoolean(false);+ private boolean addSpecExtensions = OPTION_DEFAULT_SPEC_EXTENSIONS;++ /**+ * Creates a new {@link SourceLanguageAnalyzer}+ */+ public SourceLanguageAnalyzer() {+ super(NAME, DESCRIPTION, AnalyzerType.BYTE_ANALYZER);+ setPriority(AnalysisPriority.FORMAT_ANALYSIS.before().before().before().before().before());+ setDefaultEnablement(true);+ }++ @Override+ public boolean added(Program program, AddressSetView set, TaskMonitor monitor, MessageLog log)+ throws CancelledException {++ // Enforce that the below code only executes once per analysis session+ if (analysisStarted.getAndSet(true)) {+ return true;+ }++ // Look for new source languages in the program+ Set<SourceLanguageID> ids = SourceLanguageService.find(program, log, monitor);++ // Update the "Source Languages" program property+ program.setSourceLanguageIDs(ids);++ // Optionally add source language spec extensions+ if (addSpecExtensions) {+ if (program.hasExclusiveAccess()) {+ SourceLanguageService.addSpecExtensions(program, ids, log, monitor);+ }+ else {+ log.appendMsg(+ NAME + ": Cannot add spec extensions without exclusive access to program.");+ }+ }++ return true;+ }++ @Override+ public void registerOptions(Options options, Program program) {+ options.registerOption(OPTION_NAME_SPEC_EXTENSIONS, OPTION_DEFAULT_SPEC_EXTENSIONS, null,+ OPTION_DESC_SPEC_EXTENSIONS);+ }++ @Override+ public void optionsChanged(Options options, Program program) {+ addSpecExtensions =+ options.getBoolean(OPTION_NAME_SPEC_EXTENSIONS, OPTION_DEFAULT_SPEC_EXTENSIONS);+ }++ @Override+ public void analysisEnded(Program program) {+ analysisStarted.set(false);+ }+}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/RustUtilities.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/RustUtilities.javadeleted file mode 100644index 2fe10fed5c..0000000000--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/RustUtilities.java+++ /dev/null@@ -1,150 +0,0 @@-/* ###- * IP: GHIDRA- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */-package ghidra.app.plugin.core.analysis.rust;--import java.io.IOException;-import java.io.InputStream;-import java.util.concurrent.atomic.AtomicBoolean;--import org.xml.sax.SAXException;--import generic.jar.ResourceFile;-import ghidra.app.plugin.processors.sleigh.SleighException;-import ghidra.app.util.bin.format.elf.info.ElfComment;-import ghidra.app.util.opinion.ElfLoader;-import ghidra.framework.Application;-import ghidra.framework.store.LockException;-import ghidra.program.database.SpecExtension;-import ghidra.program.model.address.Address;-import ghidra.program.model.address.AddressSet;-import ghidra.program.model.lang.Language;-import ghidra.program.model.lang.Processor;-import ghidra.program.model.listing.Program;-import ghidra.program.model.mem.MemoryBlock;-import ghidra.util.Msg;-import ghidra.util.bytesearch.*;-import ghidra.util.exception.CancelledException;-import ghidra.util.task.TaskMonitor;-import ghidra.xml.XmlParseException;--/**- * Rust utility functions- */-public class RustUtilities {-- private static final java.util.regex.Pattern ELF_COMMENT_REGEX =- java.util.regex.Pattern.compile("^rustc version .*$");-- /**- * Checks if the specified program contains Rust stuff, either by metadata or by searching- * the specified {@link MemoryBlock} for byte pattern signatures.- * <p>- * This may be used by loaders to determine if a program was compiled with rust.- * If the program is determined to be rust, then the compiler property is set to- * {@link RustConstants#RUST_COMPILER}.- *- * @param program The {@link Program}- * @param block The {@link MemoryBlock} to scan for Rust signatures- * @param monitor The monitor- * @return True if the given {@link MemoryBlock} is not null and contains a Rust signature;- * otherwise, false- * @throws IOException if there was an IO-related error- * @throws CancelledException if the user cancelled the operation- */- public static boolean isRust(Program program, MemoryBlock block, TaskMonitor monitor)- throws IOException, CancelledException {-- if ( ElfLoader.isElf(program)) {- // ELF binaries can contain a ".comment" section that records the toolchains that- // produced the binary. Search this first as its quick and easy.- ElfComment elfComments = ElfComment.fromProgram(program);- if ( elfComments != null ) {- for(String s : elfComments.getCommentStrings() ) {- if (ELF_COMMENT_REGEX.matcher(s).matches()) {- return true;- }- }- }- }-- if (block == null) {- return false;- }-- // Use a MemoryBytePatternSearch for more efficient byte searching over a list of potential- // byte signatures. The below action sets our supplied boolean to true on a match, which we- // can later query and use as a return value for this method.- GenericMatchAction<AtomicBoolean> action =- new GenericMatchAction<AtomicBoolean>(new AtomicBoolean()) {- @Override- public void apply(Program prog, Address addr, Match match) {- getMatchValue().set(true);- }- };- MemoryBytePatternSearcher searcher = new MemoryBytePatternSearcher("Rust signatures");- for (byte[] sig : RustConstants.RUST_SIGNATURES) {- searcher.addPattern(new GenericByteSequencePattern<AtomicBoolean>(sig, action));- }-- searcher.search(program, new AddressSet(block.getAddressRange()), monitor);-- return action.getMatchValue().get();- }-- /**- * Returns true if the given program has earlier been tagged as having a Rust compiler by- * the loader.- *- * @param program {@link Program}- * @return boolean true if program's compiler property includes rust- */- public static boolean isRustProgram(Program program) {- String name = program.getCompiler();- return name != null && name.contains(RustConstants.RUST_COMPILER);- }-- public static int addExtensions(Program program, TaskMonitor monitor, String subPath)- throws IOException {- Language language = program.getLanguageCompilerSpecPair().getLanguage();- Processor processor = language.getProcessor();- int bitSize = language.getLanguageDescription().getSize();- String spath = RustConstants.RUST_EXTENSIONS_PATH + subPath + bitSize;- ResourceFile module = Application.getModuleDataSubDirectory(processor.toString(), spath);-- int extensionCount = 0;-- ResourceFile[] files = module.listFiles();- if (files != null) {- for (ResourceFile file : files) {- InputStream stream = file.getInputStream();- byte[] bytes = stream.readAllBytes();- String xml = new String(bytes);-- try {- SpecExtension extension = new SpecExtension(program);- extension.addReplaceCompilerSpecExtension(xml, monitor);- extensionCount++;- }- catch (SleighException | SAXException | XmlParseException | LockException e) {- Msg.error(RustUtilities.class,- "Failed to load Rust cspec extension: " + file.getAbsolutePath(), e);- }- }- }-- return extensionCount;- }-}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/util/DataTypeArchiveUtility.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/util/DataTypeArchiveUtility.javaindex 733cda8895..98d23a5cd2 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/util/DataTypeArchiveUtility.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/util/DataTypeArchiveUtility.java@@ -18,7 +18,6 @@ package ghidra.app.plugin.core.datamgr.util;import java.util.*;import generic.jar.ResourceFile;-import ghidra.app.plugin.core.analysis.rust.RustConstants;import ghidra.app.plugin.core.datamgr.archive.DataTypeManagerHandler;import ghidra.app.util.opinion.*;import ghidra.framework.Application;@@ -143,10 +142,6 @@ public class DataTypeArchiveUtility {list.add("generic_clib");}- if (program.getCompiler().contains(RustConstants.RUST_COMPILER)) {- list.add("rust-common");- }-return list;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfLoader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfLoader.javaindex ba73124d73..dd341a4e76 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfLoader.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfLoader.java@@ -23,7 +23,6 @@ import ghidra.app.util.bin.ByteProvider;import ghidra.app.util.bin.format.elf.*;import ghidra.app.util.bin.format.golang.GoConstants;import ghidra.app.util.bin.format.golang.rtti.GoRttiMapper;-import ghidra.app.util.bin.format.swift.SwiftUtils;import ghidra.framework.model.DomainObject;import ghidra.framework.model.ProjectData;import ghidra.framework.options.Options;@@ -206,9 +205,6 @@ public class ElfLoader extends AbstractLibrarySupportLoader {List<String> sectionNames = Arrays.stream(elf.getSections()).map(ElfSectionHeader::getNameAsString).toList();- if (SwiftUtils.isSwift(sectionNames)) {- return SwiftUtils.SWIFT_COMPILER;- }if (GoRttiMapper.hasGolangSections(sectionNames)) {return GoConstants.GOLANG_CSPEC_NAME;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfProgramBuilder.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfProgramBuilder.javaindex 9d5f07d62b..28ead6ffa3 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfProgramBuilder.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfProgramBuilder.java@@ -25,8 +25,6 @@ import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;import org.apache.commons.lang3.StringUtils;import ghidra.app.cmd.label.SetLabelPrimaryCmd;-import ghidra.app.plugin.core.analysis.rust.RustConstants;-import ghidra.app.plugin.core.analysis.rust.RustUtilities;import ghidra.app.util.*;import ghidra.app.util.bin.*;import ghidra.app.util.bin.format.MemoryLoadable;@@ -188,8 +186,6 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {markupElfInfoProducers(monitor);- setCompiler(monitor);-success = true;}finally {@@ -2464,22 +2460,6 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {}}- private void setCompiler(TaskMonitor monitor) throws CancelledException {- // Check for Rust- try {- if (RustUtilities.isRust(program, memory.getBlock(ElfSectionHeaderConstants.dot_rodata),- monitor)) {- program.setCompiler(RustConstants.RUST_COMPILER);- int extensionCount = RustUtilities.addExtensions(program, monitor,- RustConstants.RUST_EXTENSIONS_UNIX);- log.appendMsg("Installed " + extensionCount + " Rust cspec extensions");- }- }- catch (IOException e) {- log.appendMsg("Rust error: " + e.getMessage());- }- }-private void markupHashTable(TaskMonitor monitor) {ElfDynamicTable dynamicTable = elf.getDynamicTable();diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoLoader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoLoader.javaindex f554812e25..cc0923a054 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoLoader.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoLoader.java@@ -28,7 +28,6 @@ import ghidra.app.util.bin.format.macho.*;import ghidra.app.util.bin.format.macho.commands.*;import ghidra.app.util.bin.format.macho.dyld.DyldArchitecture;import ghidra.app.util.bin.format.macho.dyld.DyldCacheHeader;-import ghidra.app.util.bin.format.swift.SwiftUtils;import ghidra.app.util.bin.format.ubi.*;import ghidra.app.util.importer.MessageLog;import ghidra.formats.gfilesystem.*;@@ -543,9 +542,6 @@ public class MachoLoader extends AbstractLibrarySupportLoader {.flatMap(seg -> seg.getSections().stream()).map(section -> section.getSectionName()).toList();- if (SwiftUtils.isSwift(sectionNames)) {- return SwiftUtils.SWIFT_COMPILER;- }if (GoRttiMapper.hasGolangSections(sectionNames)) {return GoConstants.GOLANG_CSPEC_NAME;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoPrelinkProgramBuilder.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoPrelinkProgramBuilder.javaindex de98e133bc..ab365928a8 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoPrelinkProgramBuilder.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoPrelinkProgramBuilder.java@@ -30,7 +30,8 @@ import ghidra.app.util.importer.MessageLog;import ghidra.program.database.mem.FileBytes;import ghidra.program.model.address.Address;import ghidra.program.model.listing.*;-import ghidra.util.exception.*;+import ghidra.util.exception.CancelledException;+import ghidra.util.exception.DuplicateNameException;import ghidra.util.task.TaskMonitor;/**@@ -173,12 +174,6 @@ public class MachoPrelinkProgramBuilder extends MachoProgramBuilder {return machoInfoList;}- @Override- protected void renameObjMsgSendRtpSymbol()- throws DuplicateNameException, InvalidInputException {- // Do nothing. This is not applicable for a PRELINK Mach-O.- }-@Overrideprotected void markupChainedFixups(MachHeader header, List<Address> fixups)throws CancelledException {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.javaindex 20680e2840..9fe79ff434 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java@@ -15,14 +15,11 @@*/package ghidra.app.util.opinion;-import java.io.IOException;import java.math.BigInteger;import java.util.*;import org.apache.commons.collections4.map.LazySortedMap;-import ghidra.app.plugin.core.analysis.rust.RustConstants;-import ghidra.app.plugin.core.analysis.rust.RustUtilities;import ghidra.app.util.MemoryBlockUtils;import ghidra.app.util.bin.*;import ghidra.app.util.bin.format.RelocationException;@@ -40,8 +37,6 @@ import ghidra.app.util.bin.format.macho.dyld.DyldChainedPtr.DyldChainType;import ghidra.app.util.bin.format.macho.dyld.DyldFixup;import ghidra.app.util.bin.format.macho.relocation.*;import ghidra.app.util.bin.format.macho.threadcommand.ThreadCommand;-import ghidra.app.util.bin.format.objc.ObjcUtils;-import ghidra.app.util.bin.format.objc.objc1.Objc1Constants;import ghidra.app.util.importer.MessageLog;import ghidra.framework.options.Options;import ghidra.program.database.function.OverlappingFunctionException;@@ -173,9 +168,7 @@ public class MachoProgramBuilder {}// Perform additional actions- renameObjMsgSendRtpSymbol();fixupProgramTree(null); // should be done last to account for new memory blocks- setCompiler(provider.getName());}/**@@ -1808,53 +1801,6 @@ public class MachoProgramBuilder {}}- protected void setCompiler(String source) throws CancelledException {- if (ObjcUtils.isObjc(program)) {- try {- program.setCompiler(ObjcUtils.OBJC_COMPILER);- int count = ObjcUtils.addExtensions(program, monitor);- if (count > 0) {- log.appendMsg("%s: installed %d objc SpecExtensions".formatted(source, count));- }- }- catch (IOException e) {- log.appendMsg("%s: objc error - %s".formatted(source, e.getMessage()));- }- return;- }-- try {- Section section =- machoHeader.getSection(SegmentNames.SEG_TEXT, SectionNames.TEXT_CONST);- if (section != null && RustUtilities.isRust(program,- memory.getBlock(space.getAddress(section.getAddress())), monitor)) {- program.setCompiler(RustConstants.RUST_COMPILER);- int count = RustUtilities.addExtensions(program, monitor,- RustConstants.RUST_EXTENSIONS_UNIX);- if (count > 0) {- log.appendMsg("%s: installed %d rust SpecExtensions".formatted(source, count));- }- }- }- catch (IOException e) {- log.appendMsg("%s: Rust error - %s".formatted(source, e.getMessage()));- }- }-- protected void renameObjMsgSendRtpSymbol()- throws DuplicateNameException, InvalidInputException {- Address address = space.getAddress(Objc1Constants.OBJ_MSGSEND_RTP);- Symbol symbol = program.getSymbolTable().getPrimarySymbol(address);- if (symbol != null && symbol.isDynamic()) {- symbol.setName(Objc1Constants.OBJC_MSG_SEND_RTP_NAME, SourceType.IMPORTED);- }- else {- program.getSymbolTable()- .createLabel(address, Objc1Constants.OBJC_MSG_SEND_RTP_NAME,- SourceType.IMPORTED);- }- }-/*** Associates the given {@link Symbol} with the correct external {@link Library} (fixing* the {@code <EXTERNAL>} association)diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/PeLoader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/PeLoader.javaindex db63ddf73d..1d3c866289 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/PeLoader.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/PeLoader.java@@ -23,8 +23,6 @@ import org.apache.commons.io.FilenameUtils;import com.google.common.primitives.Bytes;-import ghidra.app.plugin.core.analysis.rust.RustConstants;-import ghidra.app.plugin.core.analysis.rust.RustUtilities;import ghidra.app.util.MemoryBlockUtils;import ghidra.app.util.Option;import ghidra.app.util.bin.BinaryReader;@@ -39,7 +37,6 @@ import ghidra.app.util.bin.format.pe.ImageCor20Header.ImageCor20Flags;import ghidra.app.util.bin.format.pe.PortableExecutable.SectionLayout;import ghidra.app.util.bin.format.pe.debug.DebugCOFFSymbol;import ghidra.app.util.bin.format.pe.debug.DebugDirectoryParser;-import ghidra.app.util.bin.format.swift.SwiftUtils;import ghidra.app.util.importer.MessageLog;import ghidra.framework.model.DomainObject;import ghidra.framework.options.Options;@@ -925,9 +922,7 @@ public class PeLoader extends AbstractPeDebugLoader {BorlandCpp("borland:c++", "borlandcpp"),BorlandUnk("borland:unknown", "borlandcpp"),CLI("cli", "cli"),- Rustc(RustConstants.RUST_COMPILER, RustConstants.RUST_COMPILER),GOLANG("golang", "golang"),- Swift(SwiftUtils.SWIFT_COMPILER, SwiftUtils.SWIFT_COMPILER),Unknown("unknown", "unknown"),// The following values represent the presence of ambiguous indicators@@ -981,34 +976,6 @@ public class PeLoader extends AbstractPeDebugLoader {DOSHeader dh = pe.getDOSHeader();- // Check for Rust. Program object is required, which may be null.- try {- if (program != null && RustUtilities.isRust(program,- program.getMemory().getBlock(".rdata"), monitor)) {- try {- int extensionCount = RustUtilities.addExtensions(program, monitor,- RustConstants.RUST_EXTENSIONS_WINDOWS);- log.appendMsg("Installed " + extensionCount + " Rust cspec extensions");- }- catch (IOException e) {- log.appendMsg("Rust error: " + e.getMessage());- }- return CompilerEnum.Rustc;- }- }- catch (CancelledException e) {- // Move on- }-- // Check for Swift- List<String> sectionNames =- Arrays.stream(pe.getNTHeader().getFileHeader().getSectionHeaders())- .map(section -> section.getName())- .toList();- if (SwiftUtils.isSwift(sectionNames)) {- return CompilerEnum.Swift;- }-// Check for managed code (.NET)if (pe.getNTHeader().getOptionalHeader().isCLI()) {return CompilerEnum.CLI;diff --git a/Ghidra/Features/SwiftDemangler/Module.manifest b/Ghidra/Features/Objective-C/Module.manifestsimilarity index 100%rename from Ghidra/Features/SwiftDemangler/Module.manifestrename to Ghidra/Features/Objective-C/Module.manifestdiff --git a/Ghidra/Features/Objective-C/README.md b/Ghidra/Features/Objective-C/README.mdnew file mode 100644index 0000000000..6d6c37b186--- /dev/null+++ b/Ghidra/Features/Objective-C/README.md@@ -0,0 +1,3 @@+# Objective-C++The module provides improved support for binaries written in the Objective-C programming language.\ No newline at end of filediff --git a/Ghidra/Features/Objective-C/build.gradle b/Ghidra/Features/Objective-C/build.gradlenew file mode 100644index 0000000000..13b0a437a0--- /dev/null+++ b/Ghidra/Features/Objective-C/build.gradle@@ -0,0 +1,25 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle"+apply from: "$rootProject.projectDir/gradle/javaProject.gradle"+apply plugin: 'eclipse'++eclipse.project.name = 'Features Objective-C'++dependencies {+ api project(":Base")+ api project(":Decompiler")+}diff --git a/Ghidra/Features/Objective-C/certification.manifest b/Ghidra/Features/Objective-C/certification.manifestnew file mode 100644index 0000000000..f113bb0589--- /dev/null+++ b/Ghidra/Features/Objective-C/certification.manifest@@ -0,0 +1,12 @@+##VERSION: 2.0+Module.manifest||GHIDRA||||END|+README.md||GHIDRA||||END|+data/extensions.json||GHIDRA||||END|+data/extensions/aarch64/chkstk_darwin_fixup.xml||GHIDRA||||END|+data/extensions/aarch64/objc_getProperty_fixup.xml||GHIDRA||||END|+data/extensions/aarch64/objc_load_fixup.xml||GHIDRA||||END|+data/extensions/aarch64/objc_msgSend_stub.xml||GHIDRA||||END|+data/extensions/aarch64/objc_release_fixup.xml||GHIDRA||||END|+data/extensions/aarch64/objc_retain_fixup.xml||GHIDRA||||END|+data/extensions/aarch64/objc_setProperty_fixup.xml||GHIDRA||||END|+data/extensions/aarch64/objc_store_fixup.xml||GHIDRA||||END|diff --git a/Ghidra/Features/Objective-C/data/extensions.json b/Ghidra/Features/Objective-C/data/extensions.jsonnew file mode 100644index 0000000000..b534057d01--- /dev/null+++ b/Ghidra/Features/Objective-C/data/extensions.json@@ -0,0 +1,8 @@+[+ {+ "processor": "AARCH64",+ "endian": "little",+ "size": "64",+ "directory": "extensions/aarch64"+ }+]diff --git a/Ghidra/Processors/AARCH64/data/extensions/objc/chkstk_darwin_fixup.xml b/Ghidra/Features/Objective-C/data/extensions/aarch64/chkstk_darwin_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/AARCH64/data/extensions/objc/chkstk_darwin_fixup.xmlrename to Ghidra/Features/Objective-C/data/extensions/aarch64/chkstk_darwin_fixup.xmldiff --git a/Ghidra/Processors/AARCH64/data/extensions/objc/objc_getProperty_fixup.xml b/Ghidra/Features/Objective-C/data/extensions/aarch64/objc_getProperty_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/AARCH64/data/extensions/objc/objc_getProperty_fixup.xmlrename to Ghidra/Features/Objective-C/data/extensions/aarch64/objc_getProperty_fixup.xmldiff --git a/Ghidra/Processors/AARCH64/data/extensions/objc/objc_load_fixup.xml b/Ghidra/Features/Objective-C/data/extensions/aarch64/objc_load_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/AARCH64/data/extensions/objc/objc_load_fixup.xmlrename to Ghidra/Features/Objective-C/data/extensions/aarch64/objc_load_fixup.xmldiff --git a/Ghidra/Processors/AARCH64/data/extensions/objc/objc_msgSend_stub.xml b/Ghidra/Features/Objective-C/data/extensions/aarch64/objc_msgSend_stub.xmlsimilarity index 100%rename from Ghidra/Processors/AARCH64/data/extensions/objc/objc_msgSend_stub.xmlrename to Ghidra/Features/Objective-C/data/extensions/aarch64/objc_msgSend_stub.xmldiff --git a/Ghidra/Processors/AARCH64/data/extensions/objc/objc_release_fixup.xml b/Ghidra/Features/Objective-C/data/extensions/aarch64/objc_release_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/AARCH64/data/extensions/objc/objc_release_fixup.xmlrename to Ghidra/Features/Objective-C/data/extensions/aarch64/objc_release_fixup.xmldiff --git a/Ghidra/Processors/AARCH64/data/extensions/objc/objc_retain_fixup.xml b/Ghidra/Features/Objective-C/data/extensions/aarch64/objc_retain_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/AARCH64/data/extensions/objc/objc_retain_fixup.xmlrename to Ghidra/Features/Objective-C/data/extensions/aarch64/objc_retain_fixup.xmldiff --git a/Ghidra/Processors/AARCH64/data/extensions/objc/objc_setProperty_fixup.xml b/Ghidra/Features/Objective-C/data/extensions/aarch64/objc_setProperty_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/AARCH64/data/extensions/objc/objc_setProperty_fixup.xmlrename to Ghidra/Features/Objective-C/data/extensions/aarch64/objc_setProperty_fixup.xmldiff --git a/Ghidra/Processors/AARCH64/data/extensions/objc/objc_store_fixup.xml b/Ghidra/Features/Objective-C/data/extensions/aarch64/objc_store_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/AARCH64/data/extensions/objc/objc_store_fixup.xmlrename to Ghidra/Features/Objective-C/data/extensions/aarch64/objc_store_fixup.xmldiff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/analysis/ObjcMessageAnalyzer.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/plugin/core/analysis/ObjcMessageAnalyzer.javasimilarity index 99%rename from Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/analysis/ObjcMessageAnalyzer.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/plugin/core/analysis/ObjcMessageAnalyzer.javaindex f2f594b55a..ded91bf1f1 100644--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/analysis/ObjcMessageAnalyzer.java+++ b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/plugin/core/analysis/ObjcMessageAnalyzer.java@@ -32,6 +32,7 @@ import ghidra.app.util.bin.format.objc.objc2.*;import ghidra.app.util.importer.MessageLog;import ghidra.app.util.opinion.MachoLoader;import ghidra.app.util.opinion.MachoProgramBuilder;+import ghidra.app.util.sourcelanguage.ObjcSourceLanguageSpecExtension;import ghidra.framework.options.OptionType;import ghidra.framework.options.Options;import ghidra.program.model.address.*;@@ -275,8 +276,9 @@ public class ObjcMessageAnalyzer extends AbstractAnalyzer {String cc = CompilerSpec.CALLING_CONVENTION_unknown;if (isStub) {if (program.getDataTypeManager()- .getCallingConvention(ObjcUtils.OBJC_MSGSEND_STUBS_CC) != null) {- cc = ObjcUtils.OBJC_MSGSEND_STUBS_CC;+ .getCallingConvention(+ ObjcSourceLanguageSpecExtension.OBJC_MSGSEND_STUBS) != null) {+ cc = ObjcSourceLanguageSpecExtension.OBJC_MSGSEND_STUBS;}}@@ -998,7 +1000,8 @@ public class ObjcMessageAnalyzer extends AbstractAnalyzer {if (args.length >= 2 && args[1].getDataType().equals(dataTypes.sel)) {signature.setArguments(ArrayUtils.remove(args, 1));}- signature.setCallingConvention(ObjcUtils.OBJC_MSGSEND_STUBS_CC);+ signature.setCallingConvention(+ ObjcSourceLanguageSpecExtension.OBJC_MSGSEND_STUBS);HighFunctionDBUtil.writeOverride(funcMgr.getFunctionContaining(fromAddress),fromAddress, signature);}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/ObjcTypeMetadataAnalyzer.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/plugin/core/analysis/ObjcTypeMetadataAnalyzer.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/ObjcTypeMetadataAnalyzer.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/plugin/core/analysis/ObjcTypeMetadataAnalyzer.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/AbstractObjcTypeMetadata.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/AbstractObjcTypeMetadata.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/AbstractObjcTypeMetadata.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/AbstractObjcTypeMetadata.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcMethod.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcMethod.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcMethod.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcMethod.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcMethodList.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcMethodList.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcMethodList.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcMethodList.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcMethodType.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcMethodType.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcMethodType.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcMethodType.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcState.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcState.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcState.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcState.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcTypeMetadataStructure.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcTypeMetadataStructure.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcTypeMetadataStructure.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcTypeMetadataStructure.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcUtils.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcUtils.javasimilarity index 84%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcUtils.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcUtils.javaindex 15c736f2e0..a7fb3baf9e 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/ObjcUtils.java+++ b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/ObjcUtils.java@@ -15,32 +15,25 @@*/package ghidra.app.util.bin.format.objc;-import java.io.*;+import java.io.IOException;import java.math.BigInteger;import java.util.*;-import org.xml.sax.SAXException;--import generic.jar.ResourceFile;import ghidra.app.cmd.data.CreateDataCmd;import ghidra.app.cmd.disassemble.DisassembleCommand;import ghidra.app.cmd.function.CreateFunctionCmd;import ghidra.app.cmd.register.SetRegisterCmd;-import ghidra.app.plugin.processors.sleigh.SleighException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.objc.objc2.Objc2Constants;import ghidra.app.util.importer.MessageLog;-import ghidra.framework.Application;import ghidra.framework.cmd.BackgroundCommand;import ghidra.framework.cmd.Command;-import ghidra.framework.store.LockException;-import ghidra.program.database.SpecExtension;-import ghidra.program.database.SpecExtension.DocInfo;import ghidra.program.database.symbol.ClassSymbol;import ghidra.program.model.address.*;import ghidra.program.model.data.*;import ghidra.program.model.data.DataUtilities.ClearDataMode;-import ghidra.program.model.lang.*;+import ghidra.program.model.lang.Processor;+import ghidra.program.model.lang.Register;import ghidra.program.model.listing.Data;import ghidra.program.model.listing.Program;import ghidra.program.model.mem.Memory;@@ -51,24 +44,12 @@ import ghidra.util.Msg;import ghidra.util.exception.DuplicateNameException;import ghidra.util.exception.InvalidInputException;import ghidra.util.task.TaskMonitor;-import ghidra.xml.XmlParseException;/*** Objective-C utilities*/public final class ObjcUtils {- /**- * The Objective-C compiler name, used by {@link Program#setCompiler(String)}- */- public static final String OBJC_COMPILER = "objc";-- /**- * The Objective-C {@code _objc_msgSend} stub calling convention name (added with processor- * extension)- */- public static final String OBJC_MSGSEND_STUBS_CC = "__objc_msgSend_stub";-/*** String that prefixes Objective-C class symbols*/@@ -446,56 +427,4 @@ public final class ObjcUtils {}return name;}-- /**- * Adds Objective-C processor extensions to the {@link Program}, which include:- * <ul>- * <li>A special calling convention used by objc_msgSend stubs</li>- * <li>Call fixups to clear out a lot of Objective-C Automatic Reference Counting (ARC) clutter</li>- * </ul>- *- * @param program The {@link Program} to add the extensions to- * @param monitor A cancelable task monitor- * @return The number of extensions successfully added- * @throws IOException if an IO-related error occurred- * @see <a href="https://doi.org/10.1109/STATIC66697.2025.00005">Heros in Action: Analyzing Objective-C Binaries through Decompilation and IFDS</a>- * @see <a href="https://youtu.be/ojXI7Gio8Pg?si=zcAaZ2KGeBFcAabn">RE//verse 2025: Langs Beyond The C</a>- */- public static int addExtensions(Program program, TaskMonitor monitor) throws IOException {- Language language = program.getLanguageCompilerSpecPair().getLanguage();- Processor processor = language.getProcessor();- String spath = "extensions/" + OBJC_COMPILER;-- int extensionCount = 0;-- try {- ResourceFile module =- Application.getModuleDataSubDirectory(processor.toString(), spath);- ResourceFile[] files = module.listFiles();- if (files != null) {- for (ResourceFile file : files) {- InputStream stream = file.getInputStream();- byte[] bytes = stream.readAllBytes();- String xml = new String(bytes);- try {- SpecExtension extension = new SpecExtension(program);- DocInfo docInfo = extension.testExtensionDocument(xml);- if (SpecExtension.getCompilerSpecExtension(program, docInfo) == null) {- extension.addReplaceCompilerSpecExtension(xml, monitor);- extensionCount++;- }- }- catch (SleighException | SAXException | XmlParseException | LockException e) {- Msg.error(ObjcUtils.class,- "Failed to load Objective-C cspec extension: " + file, e);- }- }- }- }- catch (FileNotFoundException e) {- // fall thru- }-- return extensionCount;- }}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Category.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Category.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Category.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Category.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Class.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Class.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Class.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Class.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Constants.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Constants.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Constants.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Constants.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1InstanceVariable.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1InstanceVariable.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1InstanceVariable.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1InstanceVariable.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1InstanceVariableList.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1InstanceVariableList.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1InstanceVariableList.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1InstanceVariableList.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1MetaClass.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1MetaClass.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1MetaClass.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1MetaClass.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Method.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Method.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Method.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Method.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1MethodList.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1MethodList.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1MethodList.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1MethodList.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Module.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Module.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Module.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Module.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Protocol.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Protocol.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Protocol.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1Protocol.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1ProtocolList.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1ProtocolList.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1ProtocolList.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1ProtocolList.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1ProtocolMethod.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1ProtocolMethod.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1ProtocolMethod.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1ProtocolMethod.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1ProtocolMethodList.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1ProtocolMethodList.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1ProtocolMethodList.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1ProtocolMethodList.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1SymbolTable.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1SymbolTable.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1SymbolTable.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1SymbolTable.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1TypeEncodings.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1TypeEncodings.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1TypeEncodings.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1TypeEncodings.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1TypeMetadata.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1TypeMetadata.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1TypeMetadata.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1TypeMetadata.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Cache.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Cache.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Cache.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Cache.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Category.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Category.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Category.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Category.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Class.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Class.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Class.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Class.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2ClassRW.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2ClassRW.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2ClassRW.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2ClassRW.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Constants.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Constants.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Constants.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Constants.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2ImageInfo.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2ImageInfo.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2ImageInfo.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2ImageInfo.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Implementation.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Implementation.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Implementation.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Implementation.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2InstanceVariable.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2InstanceVariable.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2InstanceVariable.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2InstanceVariable.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2InstanceVariableList.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2InstanceVariableList.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2InstanceVariableList.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2InstanceVariableList.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2MessageReference.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2MessageReference.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2MessageReference.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2MessageReference.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Method.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Method.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Method.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Method.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2MethodList.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2MethodList.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2MethodList.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2MethodList.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Property.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Property.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Property.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Property.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2PropertyList.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2PropertyList.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2PropertyList.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2PropertyList.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Protocol.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Protocol.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Protocol.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2Protocol.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2ProtocolList.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2ProtocolList.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2ProtocolList.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2ProtocolList.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2TypeMetadata.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2TypeMetadata.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2TypeMetadata.javarename to Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2TypeMetadata.javadiff --git a/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/sourcelanguage/MachoObjcSourceLanguage.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/sourcelanguage/MachoObjcSourceLanguage.javanew file mode 100644index 0000000000..27b2af87c7--- /dev/null+++ b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/sourcelanguage/MachoObjcSourceLanguage.java@@ -0,0 +1,40 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.util.Arrays;++import ghidra.app.util.bin.format.objc.objc2.Objc2Constants;+import ghidra.app.util.opinion.MachoLoader;+import ghidra.program.model.listing.Program;+import ghidra.program.model.mem.MemoryBlock;+import ghidra.util.task.TaskMonitor;++/**+ * The Mach-O Objective-C {@link SourceLanguage} class+ */+public class MachoObjcSourceLanguage extends ObjcSourceLanguage {++ @Override+ public boolean existsIn(Program program, TaskMonitor monitor) {+ if (!program.getExecutableFormat().equals(MachoLoader.MACH_O_NAME)) {+ return false;+ }+ return Arrays.stream(program.getMemory().getBlocks())+ .map(MemoryBlock::getName)+ .anyMatch(n -> n.startsWith(Objc2Constants.OBJC2_PREFIX));+ }+}diff --git a/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/sourcelanguage/ObjcSourceLanguage.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/sourcelanguage/ObjcSourceLanguage.javanew file mode 100644index 0000000000..483d8247b0--- /dev/null+++ b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/sourcelanguage/ObjcSourceLanguage.java@@ -0,0 +1,29 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++/**+ * The base Objective-C {@link SourceLanguage} class+ */+public abstract class ObjcSourceLanguage implements SourceLanguage {++ public static final SourceLanguageID OBJC_ID = new SourceLanguageID("Objective-C");++ @Override+ public SourceLanguageID getID() {+ return OBJC_ID;+ }+}diff --git a/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/sourcelanguage/ObjcSourceLanguageSpecExtension.java b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/sourcelanguage/ObjcSourceLanguageSpecExtension.javanew file mode 100644index 0000000000..df15b2ee09--- /dev/null+++ b/Ghidra/Features/Objective-C/src/main/java/ghidra/app/util/sourcelanguage/ObjcSourceLanguageSpecExtension.java@@ -0,0 +1,61 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.io.FileNotFoundException;+import java.io.IOException;+import java.util.List;++import generic.jar.ResourceFile;+import ghidra.app.util.importer.MessageLog;+import ghidra.framework.Application;+import ghidra.program.database.SpecExtension;+import ghidra.program.model.listing.Program;+import ghidra.util.task.TaskMonitor;++/**+ * Objective-C {@link SpecExtension spec extensions}+ */+public class ObjcSourceLanguageSpecExtension implements SourceLanguageSpecExtension {++ /**+ * The Objective-C {@code _objc_msgSend} stub calling convention name+ */+ public static final String OBJC_MSGSEND_STUBS = "__objc_msgSend_stub";++ @Override+ public SourceLanguageID getCompatibleSourceLanguage() {+ return ObjcSourceLanguage.OBJC_ID;+ }++ @Override+ public List<SpecExtensionRule> getSpecExtensionRules(Program program, MessageLog log,+ TaskMonitor monitor) {+ final String filename = "extensions.json";+ try {+ ResourceFile extensionConfigFile = Application.getModuleDataFile(filename);+ return SpecExtensionUtils.readSpecExtensionJsonConfig(extensionConfigFile, program, log,+ monitor);+ }+ catch (FileNotFoundException e) {+ log.appendMsg("Failed to find module data file: " + filename);+ }+ catch (IOException e) {+ log.appendException(e);+ }+ return List.of();+ }+}diff --git a/Ghidra/Features/Rust/Module.manifest b/Ghidra/Features/Rust/Module.manifestnew file mode 100644index 0000000000..e69de29bb2diff --git a/Ghidra/Features/Rust/README.md b/Ghidra/Features/Rust/README.mdnew file mode 100644index 0000000000..3e0007b8ee--- /dev/null+++ b/Ghidra/Features/Rust/README.md@@ -0,0 +1,3 @@+# Rust++The module provides improved support for binaries written in the Rust programming language.diff --git a/Ghidra/Features/Rust/build.gradle b/Ghidra/Features/Rust/build.gradlenew file mode 100644index 0000000000..76407104ab--- /dev/null+++ b/Ghidra/Features/Rust/build.gradle@@ -0,0 +1,26 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle"+apply from: "$rootProject.projectDir/gradle/javaProject.gradle"+apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle"+apply plugin: 'eclipse'++eclipse.project.name = 'Features Rust'++dependencies {+ api project(":Base")+ api project(":Decompiler")+}diff --git a/Ghidra/Features/Rust/certification.manifest b/Ghidra/Features/Rust/certification.manifestnew file mode 100644index 0000000000..1104fd1b36--- /dev/null+++ b/Ghidra/Features/Rust/certification.manifest@@ -0,0 +1,16 @@+##VERSION: 2.0+Module.manifest||GHIDRA||||END|+README.md||GHIDRA||||END|+data/extensions.json||GHIDRA||||END|+data/extensions/unix32/cc.xml||GHIDRA||||END|+data/extensions/unix32/probe_fixup.xml||GHIDRA||||END|+data/extensions/unix32/try_fixup.xml||GHIDRA||||END|+data/extensions/unix64/cc.xml||GHIDRA||||END|+data/extensions/unix64/probe_fixup.xml||GHIDRA||||END|+data/extensions/unix64/try_fixup.xml||GHIDRA||||END|+data/extensions/windows32/probe_fixup.xml||GHIDRA||||END|+data/extensions/windows32/try_fixup.xml||GHIDRA||||END|+data/extensions/windows64/probe_fixup.xml||GHIDRA||||END|+data/extensions/windows64/try_fixup.xml||GHIDRA||||END|+data/typeinfo/rust-common.gdt||GHIDRA||||END|+data/types.json||GHIDRA||||END|diff --git a/Ghidra/Features/Rust/data/extensions.json b/Ghidra/Features/Rust/data/extensions.jsonnew file mode 100644index 0000000000..e8e0aff999--- /dev/null+++ b/Ghidra/Features/Rust/data/extensions.json@@ -0,0 +1,40 @@+[+ {+ "processor": "x86",+ "endian": "little",+ "size": "32",+ "formats": [+ "Mac OS X Mach-O",+ "Executable and Linking Format (ELF)"+ ],+ "directory": "extensions/unix32"+ },+ {+ "processor": "x86",+ "endian": "little",+ "size": "64",+ "formats": [+ "Mac OS X Mach-O",+ "Executable and Linking Format (ELF)"+ ],+ "directory": "extensions/unix64"+ },+ {+ "processor": "x86",+ "endian": "little",+ "size": "32",+ "formats": [+ "Portable Executable (PE)"+ ],+ "directory": "extensions/windows32"+ },+ {+ "processor": "x86",+ "endian": "little",+ "size": "64",+ "formats": [+ "Portable Executable (PE)"+ ],+ "directory": "extensions/windows64"+ }+]diff --git a/Ghidra/Processors/x86/data/extensions/rust/unix32/cc.xml b/Ghidra/Features/Rust/data/extensions/unix32/cc.xmlsimilarity index 100%rename from Ghidra/Processors/x86/data/extensions/rust/unix32/cc.xmlrename to Ghidra/Features/Rust/data/extensions/unix32/cc.xmldiff --git a/Ghidra/Processors/x86/data/extensions/rust/unix32/probe_fixup.xml b/Ghidra/Features/Rust/data/extensions/unix32/probe_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/x86/data/extensions/rust/unix32/probe_fixup.xmlrename to Ghidra/Features/Rust/data/extensions/unix32/probe_fixup.xmldiff --git a/Ghidra/Processors/x86/data/extensions/rust/unix32/try_fixup.xml b/Ghidra/Features/Rust/data/extensions/unix32/try_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/x86/data/extensions/rust/unix32/try_fixup.xmlrename to Ghidra/Features/Rust/data/extensions/unix32/try_fixup.xmldiff --git a/Ghidra/Processors/x86/data/extensions/rust/unix64/cc.xml b/Ghidra/Features/Rust/data/extensions/unix64/cc.xmlsimilarity index 100%rename from Ghidra/Processors/x86/data/extensions/rust/unix64/cc.xmlrename to Ghidra/Features/Rust/data/extensions/unix64/cc.xmldiff --git a/Ghidra/Processors/x86/data/extensions/rust/unix64/probe_fixup.xml b/Ghidra/Features/Rust/data/extensions/unix64/probe_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/x86/data/extensions/rust/unix64/probe_fixup.xmlrename to Ghidra/Features/Rust/data/extensions/unix64/probe_fixup.xmldiff --git a/Ghidra/Processors/x86/data/extensions/rust/unix64/try_fixup.xml b/Ghidra/Features/Rust/data/extensions/unix64/try_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/x86/data/extensions/rust/unix64/try_fixup.xmlrename to Ghidra/Features/Rust/data/extensions/unix64/try_fixup.xmldiff --git a/Ghidra/Processors/x86/data/extensions/rust/windows32/probe_fixup.xml b/Ghidra/Features/Rust/data/extensions/windows32/probe_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/x86/data/extensions/rust/windows32/probe_fixup.xmlrename to Ghidra/Features/Rust/data/extensions/windows32/probe_fixup.xmldiff --git a/Ghidra/Processors/x86/data/extensions/rust/windows32/try_fixup.xml b/Ghidra/Features/Rust/data/extensions/windows32/try_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/x86/data/extensions/rust/windows32/try_fixup.xmlrename to Ghidra/Features/Rust/data/extensions/windows32/try_fixup.xmldiff --git a/Ghidra/Processors/x86/data/extensions/rust/windows64/probe_fixup.xml b/Ghidra/Features/Rust/data/extensions/windows64/probe_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/x86/data/extensions/rust/windows64/probe_fixup.xmlrename to Ghidra/Features/Rust/data/extensions/windows64/probe_fixup.xmldiff --git a/Ghidra/Processors/x86/data/extensions/rust/windows64/try_fixup.xml b/Ghidra/Features/Rust/data/extensions/windows64/try_fixup.xmlsimilarity index 100%rename from Ghidra/Processors/x86/data/extensions/rust/windows64/try_fixup.xmlrename to Ghidra/Features/Rust/data/extensions/windows64/try_fixup.xmldiff --git a/Ghidra/Features/Base/data/typeinfo/rust/rust-common.gdt b/Ghidra/Features/Rust/data/typeinfo/rust-common.gdtsimilarity index 100%rename from Ghidra/Features/Base/data/typeinfo/rust/rust-common.gdtrename to Ghidra/Features/Rust/data/typeinfo/rust-common.gdtdiff --git a/Ghidra/Features/Rust/data/types.json b/Ghidra/Features/Rust/data/types.jsonnew file mode 100644index 0000000000..fd45d4d68e--- /dev/null+++ b/Ghidra/Features/Rust/data/types.json@@ -0,0 +1,5 @@+[+ {+ "file": "typeinfo/rust-common.gdt"+ }+]diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/RustConstants.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/RustConstants.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/RustConstants.javarename to Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/RustConstants.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/RustDemanglerAnalyzer.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/RustDemanglerAnalyzer.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/RustDemanglerAnalyzer.javarename to Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/RustDemanglerAnalyzer.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/RustStringAnalyzer.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/RustStringAnalyzer.javasimilarity index 96%rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/RustStringAnalyzer.javarename to Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/RustStringAnalyzer.javaindex 9ab182a422..3fca155a41 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/RustStringAnalyzer.java+++ b/Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/RustStringAnalyzer.java@@ -17,6 +17,7 @@ package ghidra.app.plugin.core.analysis.rust;import ghidra.app.services.*;import ghidra.app.util.importer.MessageLog;+import ghidra.app.util.sourcelanguage.RustSourceLanguage;import ghidra.framework.options.Options;import ghidra.program.model.address.*;import ghidra.program.model.data.DataUtilities;@@ -44,8 +45,7 @@ public class RustStringAnalyzer extends AbstractAnalyzer {@Overridepublic boolean canAnalyze(Program program) {- String name = program.getCompiler();- return name.contains(RustConstants.RUST_COMPILER);+ return program.getSourceLanguageIDs().contains(RustSourceLanguage.RUST_ID);}@Overridediff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemangler.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemangler.javasimilarity index 92%rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemangler.javarename to Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemangler.javaindex c87a41be09..256ee07555 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemangler.java+++ b/Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemangler.java@@ -15,9 +15,9 @@*/package ghidra.app.plugin.core.analysis.rust.demangler;-import ghidra.app.plugin.core.analysis.rust.RustUtilities;import ghidra.app.util.demangler.*;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.RustSourceLanguage;+import ghidra.app.util.sourcelanguage.RustSourceLanguageSpecExtension;import ghidra.program.model.listing.Program;/**@@ -36,7 +36,7 @@ public class RustDemangler implements Demangler {@Overridepublic boolean canDemangle(Program program) {- return RustUtilities.isRustProgram(program);+ return program.getSourceLanguageIDs().contains(RustSourceLanguage.RUST_ID);}@Override@@ -70,7 +70,7 @@ public class RustDemangler implements Demangler {if (options.applyCallingConvention() &&demangledObject instanceof DemangledFunction demangledFunction) {- demangledFunction.setCallingConvention(CompilerSpec.CALLING_CONVENTION_rustcall);+ demangledFunction.setCallingConvention(RustSourceLanguageSpecExtension.RUSTCALL);}demangledObject.setMangledContext(context);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerFormat.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerFormat.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerFormat.javarename to Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerFormat.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerLegacy.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerLegacy.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerLegacy.javarename to Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerLegacy.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerOptions.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerOptions.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerOptions.javarename to Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerOptions.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerParser.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerParser.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerParser.javarename to Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerParser.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerV0.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerV0.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerV0.javarename to Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerV0.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/funcfixup/RustDWARFFunctionFixup.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/bin/format/dwarf/funcfixup/RustDWARFFunctionFixup.javasimilarity index 92%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/funcfixup/RustDWARFFunctionFixup.javarename to Ghidra/Features/Rust/src/main/java/ghidra/app/util/bin/format/dwarf/funcfixup/RustDWARFFunctionFixup.javaindex 871e766455..e9c50714f1 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/funcfixup/RustDWARFFunctionFixup.java+++ b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/bin/format/dwarf/funcfixup/RustDWARFFunctionFixup.java@@ -19,8 +19,8 @@ import java.io.IOException;import ghidra.app.util.bin.format.dwarf.*;import ghidra.app.util.bin.format.dwarf.DWARFFunction.CommitMode;+import ghidra.app.util.sourcelanguage.RustSourceLanguageSpecExtension;import ghidra.program.database.data.ProgramBasedDataTypeManagerDB;-import ghidra.program.model.lang.CompilerSpec;import ghidra.program.model.listing.Program;import ghidra.util.classfinder.ExtensionPointProperties;import ghidra.util.exception.InvalidInputException;@@ -54,12 +54,12 @@ public class RustDWARFFunctionFixup implements DWARFFunctionFixup {private String getRustCC(Program program) throws DWARFException {if (rustCC == null) {- rustCC = CompilerSpec.CALLING_CONVENTION_rustcall;+ rustCC = RustSourceLanguageSpecExtension.RUSTCALL;try {// NOTE: this has a side effect of ensuring the rust cc is present in the programProgramBasedDataTypeManagerDB dtm =(ProgramBasedDataTypeManagerDB) program.getDataTypeManager();- dtm.getCallingConventionID(CompilerSpec.CALLING_CONVENTION_rustcall, false);+ dtm.getCallingConventionID(RustSourceLanguageSpecExtension.RUSTCALL, false);}catch (InvalidInputException | IOException e) {throw new DWARFException("Unable to get Rust calling convention");diff --git a/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/ElfRustSourceLanguage.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/ElfRustSourceLanguage.javanew file mode 100644index 0000000000..015901f8ad--- /dev/null+++ b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/ElfRustSourceLanguage.java@@ -0,0 +1,62 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.io.IOException;+import java.util.regex.Pattern;++import ghidra.app.util.bin.format.elf.ElfSectionHeaderConstants;+import ghidra.app.util.bin.format.elf.info.ElfComment;+import ghidra.app.util.opinion.ElfLoader;+import ghidra.program.model.listing.Program;+import ghidra.program.model.mem.MemoryBlock;+import ghidra.util.exception.CancelledException;+import ghidra.util.task.TaskMonitor;++/**+ * The Elf Rust {@link SourceLanguage} class+ */+public class ElfRustSourceLanguage extends RustSourceLanguage {++ private static final Pattern ELF_COMMENT_REGEX = Pattern.compile("^rustc version .*$");++ @Override+ public boolean existsIn(Program program, TaskMonitor monitor)+ throws IOException, CancelledException {+ if (!program.getExecutableFormat().equals(ElfLoader.ELF_NAME)) {+ return false;+ }++ // ELF binaries can contain a ".comment" section that records the toolchains that+ // produced the binary. Search this first as its quick and easy.+ ElfComment elfComments = ElfComment.fromProgram(program);+ if (elfComments != null) {+ for (String s : elfComments.getCommentStrings()) {+ if (ELF_COMMENT_REGEX.matcher(s).matches()) {+ return true;+ }+ }+ }++ for (MemoryBlock block : program.getMemory().getBlocks()) {+ if (block.getName().equals(ElfSectionHeaderConstants.dot_rodata) &&+ isRust(program, block, monitor)) {+ return true;+ }+ }+ return false;+ }+}diff --git a/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/MachoRustSourceLanguage.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/MachoRustSourceLanguage.javanew file mode 100644index 0000000000..53f033bc92--- /dev/null+++ b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/MachoRustSourceLanguage.java@@ -0,0 +1,48 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.io.IOException;++import ghidra.app.util.bin.format.macho.SectionNames;+import ghidra.app.util.bin.format.macho.commands.SegmentNames;+import ghidra.app.util.opinion.MachoLoader;+import ghidra.program.model.listing.Program;+import ghidra.program.model.mem.MemoryBlock;+import ghidra.util.exception.CancelledException;+import ghidra.util.task.TaskMonitor;++/**+ * The Mach-O Rust {@link SourceLanguage} class+ */+public class MachoRustSourceLanguage extends RustSourceLanguage {++ @Override+ public boolean existsIn(Program program, TaskMonitor monitor)+ throws IOException, CancelledException {+ if (!program.getExecutableFormat().equals(MachoLoader.MACH_O_NAME)) {+ return false;+ }+ for (MemoryBlock block : program.getMemory().getBlocks()) {+ if (block.getName().equals(SectionNames.TEXT_CONST) &&+ block.getComment().equals(SegmentNames.SEG_TEXT) &&+ isRust(program, block, monitor)) {+ return true;+ }+ }+ return false;+ }+}diff --git a/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/PeRustSourceLanguage.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/PeRustSourceLanguage.javanew file mode 100644index 0000000000..fdbf3e53b5--- /dev/null+++ b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/PeRustSourceLanguage.java@@ -0,0 +1,45 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.io.IOException;++import ghidra.app.util.opinion.PeLoader;+import ghidra.program.model.listing.Program;+import ghidra.program.model.mem.MemoryBlock;+import ghidra.util.exception.CancelledException;+import ghidra.util.task.TaskMonitor;++/**+ * The PE Rust {@link SourceLanguage} class+ */+public class PeRustSourceLanguage extends RustSourceLanguage {++ @Override+ public boolean existsIn(Program program, TaskMonitor monitor)+ throws IOException, CancelledException {+ if (!program.getExecutableFormat().equals(PeLoader.PE_NAME)) {+ return false;+ }+ for (MemoryBlock block : program.getMemory().getBlocks()) {+ if (block.getName().equals(".rdata") &&+ isRust(program, block, monitor)) {+ return true;+ }+ }+ return false;+ }+}diff --git a/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/RustSourceLanguage.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/RustSourceLanguage.javanew file mode 100644index 0000000000..52da3e1079--- /dev/null+++ b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/RustSourceLanguage.java@@ -0,0 +1,84 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.io.IOException;+import java.util.concurrent.atomic.AtomicBoolean;++import ghidra.app.plugin.core.analysis.rust.RustConstants;+import ghidra.program.model.address.Address;+import ghidra.program.model.address.AddressSet;+import ghidra.program.model.listing.Program;+import ghidra.program.model.mem.MemoryBlock;+import ghidra.util.bytesearch.*;+import ghidra.util.exception.CancelledException;+import ghidra.util.task.TaskMonitor;++/**+ * The base Rust {@link SourceLanguage} class+ */+public abstract class RustSourceLanguage implements SourceLanguage {++ public static final SourceLanguageID RUST_ID = new SourceLanguageID("Rust");++ @Override+ public SourceLanguageID getID() {+ return RUST_ID;+ }++ /**+ * Checks if the specified program contains Rust stuff, either by metadata or by searching+ * the specified {@link MemoryBlock} for byte pattern signatures.+ * <p>+ * This may be used by loaders to determine if a program was compiled with rust.+ * If the program is determined to be rust, then the compiler property is set to+ * {@link RustConstants#RUST_COMPILER}.+ *+ * @param program The {@link Program}+ * @param block The {@link MemoryBlock} to scan for Rust signatures+ * @param monitor The monitor+ * @return True if the given {@link MemoryBlock} is not null and contains a Rust signature;+ * otherwise, false+ * @throws IOException if there was an IO-related error+ * @throws CancelledException if the user cancelled the operation+ */+ public boolean isRust(Program program, MemoryBlock block, TaskMonitor monitor)+ throws IOException, CancelledException {++ if (block == null) {+ return false;+ }++ // Use a MemoryBytePatternSearch for more efficient byte searching over a list of potential+ // byte signatures. The below action sets our supplied boolean to true on a match, which we+ // can later query and use as a return value for this method.+ GenericMatchAction<AtomicBoolean> action =+ new GenericMatchAction<AtomicBoolean>(new AtomicBoolean()) {+ @Override+ public void apply(Program prog, Address addr, Match match) {+ getMatchValue().set(true);+ }+ };+ MemoryBytePatternSearcher searcher = new MemoryBytePatternSearcher("Rust signatures");+ for (byte[] sig : RustConstants.RUST_SIGNATURES) {+ searcher.addPattern(new GenericByteSequencePattern<AtomicBoolean>(sig, action));+ }++ searcher.search(program, new AddressSet(block.getAddressRange()), monitor);++ return action.getMatchValue().get();+ }+}diff --git a/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/RustSourceLanguageDataArchive.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/RustSourceLanguageDataArchive.javanew file mode 100644index 0000000000..2afc4d583e--- /dev/null+++ b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/RustSourceLanguageDataArchive.java@@ -0,0 +1,55 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.io.FileNotFoundException;+import java.io.IOException;+import java.util.List;++import generic.jar.ResourceFile;+import ghidra.app.util.importer.MessageLog;+import ghidra.framework.Application;+import ghidra.program.model.listing.Program;+import ghidra.util.task.TaskMonitor;++/**+ * Rust data archives+ */+public class RustSourceLanguageDataArchive implements SourceLanguageDataArchive {++ @Override+ public SourceLanguageID getCompatibleSourceLanguage() {+ return RustSourceLanguage.RUST_ID;+ }++ @Override+ public List<DataArchiveRule> getDataArchiveRules(Program program, MessageLog log,+ TaskMonitor monitor) {+ final String filename = "types.json";+ try {+ ResourceFile dataArchiveConfileFile = Application.getModuleDataFile(filename);+ return DataArchiveUtils.readDataArchiveJsonConfig(dataArchiveConfileFile, program, log,+ monitor);+ }+ catch (FileNotFoundException e) {+ log.appendMsg("Failed to find module data file: " + filename);+ }+ catch (IOException e) {+ log.appendException(e);+ }+ return List.of();+ }+}diff --git a/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/RustSourceLanguageSpecExtension.java b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/RustSourceLanguageSpecExtension.javanew file mode 100644index 0000000000..0b1f67eccb--- /dev/null+++ b/Ghidra/Features/Rust/src/main/java/ghidra/app/util/sourcelanguage/RustSourceLanguageSpecExtension.java@@ -0,0 +1,61 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.io.FileNotFoundException;+import java.io.IOException;+import java.util.List;++import generic.jar.ResourceFile;+import ghidra.app.util.importer.MessageLog;+import ghidra.framework.Application;+import ghidra.program.database.SpecExtension;+import ghidra.program.model.listing.Program;+import ghidra.util.task.TaskMonitor;++/**+ * Rust {@link SpecExtension spec extensions}+ */+public class RustSourceLanguageSpecExtension implements SourceLanguageSpecExtension {++ /**+ * The Rust calling convention defined in the spec extension+ */+ public static final String RUSTCALL = "__rustcall";++ @Override+ public SourceLanguageID getCompatibleSourceLanguage() {+ return RustSourceLanguage.RUST_ID;+ }++ @Override+ public List<SpecExtensionRule> getSpecExtensionRules(Program program, MessageLog log,+ TaskMonitor monitor) {+ final String filename = "extensions.json";+ try {+ ResourceFile extensionConfigFile = Application.getModuleDataFile(filename);+ return SpecExtensionUtils.readSpecExtensionJsonConfig(extensionConfigFile, program, log,+ monitor);+ }+ catch (FileNotFoundException e) {+ log.appendMsg("Failed to find module data file: " + filename);+ }+ catch (IOException e) {+ log.appendException(e);+ }+ return List.of();+ }+}diff --git a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerLegacyTest.java b/Ghidra/Features/Rust/src/test/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerLegacyTest.javasimilarity index 95%rename from Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerLegacyTest.javarename to Ghidra/Features/Rust/src/test/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerLegacyTest.javaindex ca40f1b8ed..56d3ec8915 100644--- a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerLegacyTest.java+++ b/Ghidra/Features/Rust/src/test/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerLegacyTest.java@@ -21,11 +21,11 @@ import org.junit.Test;import ghidra.app.util.demangler.DemangledException;import ghidra.app.util.demangler.DemangledObject;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.RustSourceLanguageSpecExtension;public class RustDemanglerLegacyTest {- private static final String RUSTCALL = CompilerSpec.CALLING_CONVENTION_rustcall;+ private static final String RUSTCALL = RustSourceLanguageSpecExtension.RUSTCALL;private static String[] symbols ={ "_ZN43_$LT$char$u20$as$u20$core..fmt..Display$GT$3fmt17h31c4c24bbd08aa24E",diff --git a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerV0Test.java b/Ghidra/Features/Rust/src/test/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerV0Test.javasimilarity index 100%rename from Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerV0Test.javarename to Ghidra/Features/Rust/src/test/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerV0Test.javadiff --git a/Ghidra/Features/Swift/Module.manifest b/Ghidra/Features/Swift/Module.manifestnew file mode 100644index 0000000000..e69de29bb2diff --git a/Ghidra/Features/SwiftDemangler/README.md b/Ghidra/Features/Swift/README.mdsimilarity index 100%rename from Ghidra/Features/SwiftDemangler/README.mdrename to Ghidra/Features/Swift/README.mddiff --git a/Ghidra/Features/SwiftDemangler/build.gradle b/Ghidra/Features/Swift/build.gradlesimilarity index 94%rename from Ghidra/Features/SwiftDemangler/build.gradlerename to Ghidra/Features/Swift/build.gradleindex 71ba191112..c69ae587be 100644--- a/Ghidra/Features/SwiftDemangler/build.gradle+++ b/Ghidra/Features/Swift/build.gradle@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -19,7 +19,7 @@ apply from: "$rootProject.projectDir/gradle/jacocoProject.gradle"apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle"apply plugin: 'eclipse'-eclipse.project.name = 'Features SwiftDemangler'+eclipse.project.name = 'Features Swift'dependencies {api project(":Base")diff --git a/Ghidra/Features/Swift/certification.manifest b/Ghidra/Features/Swift/certification.manifestnew file mode 100644index 0000000000..d2aa9bf5d8--- /dev/null+++ b/Ghidra/Features/Swift/certification.manifest@@ -0,0 +1,8 @@+##VERSION: 2.0+Module.manifest||GHIDRA||||END|+README.md||GHIDRA||||END|+data/extensions.json||GHIDRA||||END|+data/extensions/aarch64/swift_stdcall.xml||GHIDRA||||END|+data/extensions/aarch64/swift_thiscall.xml||GHIDRA||||END|+data/extensions/x86_64/swift_stdcall.xml||GHIDRA||||END|+data/extensions/x86_64/swift_thiscall.xml||GHIDRA||||END|diff --git a/Ghidra/Features/Swift/data/extensions.json b/Ghidra/Features/Swift/data/extensions.jsonnew file mode 100644index 0000000000..b7cef154e6--- /dev/null+++ b/Ghidra/Features/Swift/data/extensions.json@@ -0,0 +1,14 @@+[+ {+ "processor": "AARCH64",+ "endian": "little",+ "size": "64",+ "directory": "extensions/aarch64"+ },+ {+ "processor": "x86",+ "endian": "little",+ "size": "64",+ "directory": "extensions/x86_64"+ }+]diff --git a/Ghidra/Features/Swift/data/extensions/aarch64/swift_stdcall.xml b/Ghidra/Features/Swift/data/extensions/aarch64/swift_stdcall.xmlnew file mode 100644index 0000000000..32a88e6499--- /dev/null+++ b/Ghidra/Features/Swift/data/extensions/aarch64/swift_stdcall.xml@@ -0,0 +1,161 @@+<prototype name="__swift_stdcall" extrapop="0" stackshift="0">+ <!-- https://github.com/swiftlang/swift/blob/main/docs/ABI/CallingConventionSummary.rst#arm64 -->+ <input>+ <pentry minsize="8" maxsize="8" storage="hiddenret">+ <register name="x8"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d0"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d1"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d2"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d3"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d4"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d5"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d6"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d7"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x0"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x1"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x2"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x3"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x4"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x5"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x6"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x7"/>+ </pentry>+ <pentry minsize="1" maxsize="500" align="4">+ <addr offset="0" space="stack"/>+ </pentry>+ <rule>+ <datatype name="struct" minsize="9"/>+ <join/>+ </rule>+ </input>+ <output>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d0"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d1"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d2"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d3"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="x0"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="x1"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="x2"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="x3"/>+ </pentry>+ <rule>+ <datatype name="homogeneous-float-aggregate"/>+ <join_per_primitive storage="float"/>+ </rule>+ <rule>+ <datatype name="float"/>+ <consume storage="float"/>+ </rule>+ <rule>+ <datatype name="any" minsize="1" maxsize="32"/>+ <join/>+ </rule>+ <rule>+ <datatype name="any" minsize="33"/>+ <hidden_return voidlock="true"/>+ </rule>+ </output>+ <unaffected>+ <register name="x19"/>+ <register name="x20"/>+ <register name="x21"/>+ <register name="x22"/>+ <register name="x23"/>+ <register name="x24"/>+ <register name="x25"/>+ <register name="x26"/>+ <register name="x27"/>+ <register name="x28"/>+ <register name="x29"/>+ <register name="x30"/>+ <register name="sp"/>+ <!-- vectors -->+ <register name="d8"/>+ <register name="d9"/>+ <register name="d10"/>+ <register name="d11"/>+ <register name="d12"/>+ <register name="d13"/>+ <register name="d14"/>+ <register name="d15"/>+ </unaffected>+ <killedbycall>+ <!-- x8: indirect result location register, which is not+ reflected in the pentry list -->+ <register name="x8"/>+ <register name="x9"/>+ <register name="x10"/>+ <register name="x11"/>+ <register name="x12"/>+ <register name="x13"/>+ <register name="x14"/>+ <register name="x15"/>+ <register name="x16"/>+ <register name="x17"/>+ <register name="x18"/>+ <!-- vectors -->+ <register name="d16"/>+ <register name="d17"/>+ <register name="d18"/>+ <register name="d19"/>+ <register name="d20"/>+ <register name="d21"/>+ <register name="d22"/>+ <register name="d23"/>+ <register name="d24"/>+ <register name="d25"/>+ <register name="d26"/>+ <register name="d27"/>+ <register name="d28"/>+ <register name="d29"/>+ <register name="d30"/>+ <register name="d31"/>+ </killedbycall>+</prototype>diff --git a/Ghidra/Features/Swift/data/extensions/aarch64/swift_thiscall.xml b/Ghidra/Features/Swift/data/extensions/aarch64/swift_thiscall.xmlnew file mode 100644index 0000000000..1a0130a647--- /dev/null+++ b/Ghidra/Features/Swift/data/extensions/aarch64/swift_thiscall.xml@@ -0,0 +1,163 @@+<prototype name="__swift_thiscall" hasthis="true" extrapop="0" stackshift="0">+ <!-- https://github.com/swiftlang/swift/blob/main/docs/ABI/CallingConventionSummary.rst#arm64 -->+ <input>+ <pentry minsize="8" maxsize="8" storage="hiddenret">+ <register name="x8"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d0"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d1"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d2"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d3"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d4"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d5"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d6"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d7"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x20"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x0"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x1"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x2"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x3"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x4"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x5"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x6"/>+ </pentry>+ <pentry minsize="1" maxsize="8" extension="zero">+ <register name="x7"/>+ </pentry>+ <pentry minsize="1" maxsize="500" align="4">+ <addr offset="0" space="stack"/>+ </pentry>+ <rule>+ <datatype name="struct" minsize="9"/>+ <join/>+ </rule>+ </input>+ <output>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d0"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d1"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d2"/>+ </pentry>+ <pentry minsize="2" maxsize="8" metatype="float">+ <register name="d3"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="x0"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="x1"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="x2"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="x3"/>+ </pentry>+ <rule>+ <datatype name="homogeneous-float-aggregate"/>+ <join_per_primitive storage="float"/>+ </rule>+ <rule>+ <datatype name="float"/>+ <consume storage="float"/>+ </rule>+ <rule>+ <datatype name="any" minsize="1" maxsize="32"/>+ <join/>+ </rule>+ <rule>+ <datatype name="any" minsize="33"/>+ <hidden_return voidlock="true"/>+ </rule>+ </output>+ <unaffected>+ <register name="x19"/>+ <register name="x21"/>+ <register name="x22"/>+ <register name="x23"/>+ <register name="x24"/>+ <register name="x25"/>+ <register name="x26"/>+ <register name="x27"/>+ <register name="x28"/>+ <register name="x29"/>+ <register name="x30"/>+ <register name="sp"/>+ <!-- vectors -->+ <register name="d8"/>+ <register name="d9"/>+ <register name="d10"/>+ <register name="d11"/>+ <register name="d12"/>+ <register name="d13"/>+ <register name="d14"/>+ <register name="d15"/>+ </unaffected>+ <killedbycall>+ <!-- x8: indirect result location register, which is not+ reflected in the pentry list -->+ <register name="x8"/>+ <register name="x9"/>+ <register name="x10"/>+ <register name="x11"/>+ <register name="x12"/>+ <register name="x13"/>+ <register name="x14"/>+ <register name="x15"/>+ <register name="x16"/>+ <register name="x17"/>+ <register name="x18"/>+ <!-- vectors -->+ <register name="d16"/>+ <register name="d17"/>+ <register name="d18"/>+ <register name="d19"/>+ <register name="d20"/>+ <register name="d21"/>+ <register name="d22"/>+ <register name="d23"/>+ <register name="d24"/>+ <register name="d25"/>+ <register name="d26"/>+ <register name="d27"/>+ <register name="d28"/>+ <register name="d29"/>+ <register name="d30"/>+ <register name="d31"/>+ </killedbycall>+</prototype>diff --git a/Ghidra/Features/Swift/data/extensions/x86_64/swift_stdcall.xml b/Ghidra/Features/Swift/data/extensions/x86_64/swift_stdcall.xmlnew file mode 100644index 0000000000..1021f7b980--- /dev/null+++ b/Ghidra/Features/Swift/data/extensions/x86_64/swift_stdcall.xml@@ -0,0 +1,113 @@+<prototype name="__swift_stdcall" extrapop="8" stackshift="8">+ <!-- https://github.com/swiftlang/swift/blob/main/docs/ABI/CallingConventionSummary.rst#x86-64 -->+ <input>+ <pentry minsize="8" maxsize="8" storage="hiddenret">+ <register name="RAX"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM0_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM1_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM2_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM3_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM4_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM5_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM6_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM7_Qa"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RDI"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RSI"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RDX"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RCX"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="R8"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="R9"/>+ </pentry>+ <pentry minsize="1" maxsize="500" align="8">+ <addr offset="8" space="stack"/>+ </pentry>+ <rule>+ <datatype name="struct" minsize="9"/>+ <join/>+ </rule>+ </input>+ <output>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM0_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM1_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM2_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM3_Qa"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RAX"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RDX"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RCX"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="R8"/>+ </pentry>+ <rule>+ <datatype name="homogeneous-float-aggregate"/>+ <join_per_primitive storage="float"/>+ </rule>+ <rule>+ <datatype name="float"/>+ <consume storage="float"/>+ </rule>+ <rule>+ <datatype name="any" minsize="1" maxsize="32"/>+ <join/>+ </rule>+ <rule>+ <datatype name="any" minsize="33"/>+ <hidden_return voidlock="true"/>+ </rule>+ </output>+ <killedbycall>+ <register name="RAX"/>+ <register name="RDX"/>+ <register name="XMM0"/>+ </killedbycall>+ <unaffected>+ <register name="RBX"/>+ <register name="RSP"/>+ <register name="RBP"/>+ <register name="R12"/>+ <register name="R13"/>+ <register name="R14"/>+ <register name="R15"/>+ </unaffected>+</prototype>\ No newline at end of filediff --git a/Ghidra/Features/Swift/data/extensions/x86_64/swift_thiscall.xml b/Ghidra/Features/Swift/data/extensions/x86_64/swift_thiscall.xmlnew file mode 100644index 0000000000..45c6333960--- /dev/null+++ b/Ghidra/Features/Swift/data/extensions/x86_64/swift_thiscall.xml@@ -0,0 +1,115 @@+<prototype name="__swift_thiscall" hasthis="true" extrapop="8" stackshift="8">+ <!-- https://github.com/swiftlang/swift/blob/main/docs/ABI/CallingConventionSummary.rst#x86-64 -->+ <input>+ <pentry minsize="8" maxsize="8" storage="hiddenret">+ <register name="RAX"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM0_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM1_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM2_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM3_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM4_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM5_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM6_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM7_Qa"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="R13"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RDI"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RSI"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RDX"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RCX"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="R8"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="R9"/>+ </pentry>+ <pentry minsize="1" maxsize="500" align="8">+ <addr offset="8" space="stack"/>+ </pentry>+ <rule>+ <datatype name="struct" minsize="9"/>+ <join/>+ </rule>+ </input>+ <output>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM0_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM1_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM2_Qa"/>+ </pentry>+ <pentry minsize="4" maxsize="8" metatype="float">+ <register name="XMM3_Qa"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RAX"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RDX"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="RCX"/>+ </pentry>+ <pentry minsize="1" maxsize="8">+ <register name="R8"/>+ </pentry>+ <rule>+ <datatype name="homogeneous-float-aggregate"/>+ <join_per_primitive storage="float"/>+ </rule>+ <rule>+ <datatype name="float"/>+ <consume storage="float"/>+ </rule>+ <rule>+ <datatype name="any" minsize="1" maxsize="32"/>+ <join/>+ </rule>+ <rule>+ <datatype name="any" minsize="33"/>+ <hidden_return voidlock="true"/>+ </rule>+ </output>+ <killedbycall>+ <register name="RAX"/>+ <register name="RDX"/>+ <register name="XMM0"/>+ </killedbycall>+ <unaffected>+ <register name="RBX"/>+ <register name="RSP"/>+ <register name="RBP"/>+ <register name="R12"/>+ <register name="R14"/>+ <register name="R15"/>+ </unaffected>+</prototype>\ No newline at end of filediff --git a/Ghidra/Features/SwiftDemangler/ghidra_scripts/SwiftDemanglerScript.java b/Ghidra/Features/Swift/ghidra_scripts/SwiftDemanglerScript.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/ghidra_scripts/SwiftDemanglerScript.javarename to Ghidra/Features/Swift/ghidra_scripts/SwiftDemanglerScript.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/plugin/core/analysis/SwiftDemanglerAnalyzer.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/plugin/core/analysis/SwiftDemanglerAnalyzer.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/plugin/core/analysis/SwiftDemanglerAnalyzer.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/plugin/core/analysis/SwiftDemanglerAnalyzer.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/SwiftTypeMetadataAnalyzer.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/plugin/core/analysis/SwiftTypeMetadataAnalyzer.javasimilarity index 92%rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/SwiftTypeMetadataAnalyzer.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/plugin/core/analysis/SwiftTypeMetadataAnalyzer.javaindex fef5b75c75..e5147b3797 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/SwiftTypeMetadataAnalyzer.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/plugin/core/analysis/SwiftTypeMetadataAnalyzer.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -19,8 +19,8 @@ import java.io.IOException;import ghidra.app.services.*;import ghidra.app.util.bin.format.swift.SwiftTypeMetadata;-import ghidra.app.util.bin.format.swift.SwiftUtils;import ghidra.app.util.importer.MessageLog;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguage;import ghidra.program.model.address.AddressSetView;import ghidra.program.model.listing.Program;import ghidra.util.exception.CancelledException;@@ -41,7 +41,7 @@ public class SwiftTypeMetadataAnalyzer extends AbstractAnalyzer {@Overridepublic boolean canAnalyze(Program program) {- return SwiftUtils.isSwift(program);+ return program.getSourceLanguageIDs().contains(SwiftSourceLanguage.SWIFT_ID);}@Overridediff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/SwiftSection.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/SwiftSection.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/SwiftSection.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/SwiftSection.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadata.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadata.javasimilarity index 97%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadata.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadata.javaindex 55e21a3bba..3aade3a562 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadata.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadata.java@@ -168,7 +168,7 @@ public class SwiftTypeMetadata {throws CancelledException {monitor.setMessage("Parsing Swift entry point(s)...");monitor.setIndeterminate(true);- for (MemoryBlock block : SwiftUtils.getSwiftBlocks(section, program)) {+ for (MemoryBlock block : SwiftTypeMetadataUtils.getSwiftBlocks(section, program)) {monitor.checkCancelled();Address blockStart = block.getStart();try {@@ -196,7 +196,7 @@ public class SwiftTypeMetadata {monitor.setMessage("Parsing Swift builtin type descriptors...");monitor.setIndeterminate(true);try {- for (MemoryBlock block : SwiftUtils.getSwiftBlocks(section, program)) {+ for (MemoryBlock block : SwiftTypeMetadataUtils.getSwiftBlocks(section, program)) {Address blockStart = block.getStart();reader.setPointerIndex(blockStart.getOffset());int i = skipZeroEntries(reader, 0, block.getSize());@@ -228,7 +228,7 @@ public class SwiftTypeMetadata {monitor.setMessage("Parsing Swift field descriptors...");monitor.setIndeterminate(true);try {- for (MemoryBlock block : SwiftUtils.getSwiftBlocks(section, program)) {+ for (MemoryBlock block : SwiftTypeMetadataUtils.getSwiftBlocks(section, program)) {Address blockStart = block.getStart();reader.setPointerIndex(blockStart.getOffset());int i = skipZeroEntries(reader, 0, block.getSize());@@ -268,7 +268,7 @@ public class SwiftTypeMetadata {monitor.setMessage("Parsing Swift associated type descriptors...");monitor.setIndeterminate(true);try {- for (MemoryBlock block : SwiftUtils.getSwiftBlocks(section, program)) {+ for (MemoryBlock block : SwiftTypeMetadataUtils.getSwiftBlocks(section, program)) {Address blockStart = block.getStart();reader.setPointerIndex(blockStart.getOffset());int i = skipZeroEntries(reader, 0, block.getSize());@@ -308,7 +308,7 @@ public class SwiftTypeMetadata {monitor.setMessage("Parsing Swift capture descriptors...");monitor.setIndeterminate(true);try {- for (MemoryBlock block : SwiftUtils.getSwiftBlocks(section, program)) {+ for (MemoryBlock block : SwiftTypeMetadataUtils.getSwiftBlocks(section, program)) {Address blockStart = block.getStart();reader.setPointerIndex(blockStart.getOffset());int i = skipZeroEntries(reader, 0, block.getSize());@@ -357,7 +357,7 @@ public class SwiftTypeMetadata {monitor.setMessage("Parsing Swift multipayload enum descriptors...");monitor.setIndeterminate(true);try {- for (MemoryBlock block : SwiftUtils.getSwiftBlocks(section, program)) {+ for (MemoryBlock block : SwiftTypeMetadataUtils.getSwiftBlocks(section, program)) {Address blockStart = block.getStart();reader.setPointerIndex(blockStart.getOffset());int i = skipZeroEntries(reader, 0, block.getSize());@@ -492,7 +492,7 @@ public class SwiftTypeMetadata {monitor.setMessage("Parsing Swift protocol conformance descriptors...");monitor.setIndeterminate(true);try {- for (MemoryBlock block : SwiftUtils.getSwiftBlocks(section, program)) {+ for (MemoryBlock block : SwiftTypeMetadataUtils.getSwiftBlocks(section, program)) {Address blockAddr = block.getStart();for (int i = 0; i < block.getSize(); i += POINTER_SIZE) {monitor.checkCancelled();diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadataStructure.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadataStructure.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadataStructure.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadataStructure.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/SwiftUtils.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadataUtils.javasimilarity index 73%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/SwiftUtils.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadataUtils.javaindex dc43e0ae4e..0f01e775fb 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/SwiftUtils.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/SwiftTypeMetadataUtils.java@@ -27,9 +27,7 @@ import ghidra.program.model.mem.MemoryBlock;/*** Swift-related utility methods*/-public class SwiftUtils {-- public static final String SWIFT_COMPILER = "swift";+public class SwiftTypeMetadataUtils {/*** A {@link TypeDef pointer} to a relative 4-byte offset@@ -54,37 +52,6 @@ public class SwiftUtils {public static final PointerTypedef PTR_STRING =new PointerTypedef(null, StringDataType.dataType, 4, null, PointerType.RELATIVE);- /**- * {@return true if the given {@link Program} is a Swift program; otherwise, false}- *- * @param program The {@link Program} to check- */- public static boolean isSwift(Program program) {- List<String> prefixes = List.of("__swift", "swift", ".sw5");- for (MemoryBlock block : program.getMemory().getBlocks()) {- if (prefixes.stream().anyMatch(prefix -> block.getName().startsWith(prefix))) {- return true;- }- }- return false;- }-- /**- * {@return true if the given {@link List} of section names contains a Swift section name;- * otherwise, false}- *- * @param sectionNames The {@link List} of section names to check- */- public static boolean isSwift(List<String> sectionNames) {- List<String> prefixes = List.of("__swift", "swift", ".sw5");- for (String sectionName : sectionNames) {- if (prefixes.stream().anyMatch(prefix -> sectionName.startsWith(prefix))) {- return true;- }- }- return false;- }-/*** {@return a {@link List} of {@link MemoryBlock}s that match the given {@link SwiftSection}}*diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeDescriptor.javasimilarity index 90%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeDescriptor.javaindex 96e9c58575..13b2836fa7 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeDescriptor.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeDescriptor.java@@ -21,7 +21,7 @@ import java.util.List;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -53,8 +53,8 @@ public final class AssociatedTypeDescriptor extends SwiftTypeMetadataStructure {*/public AssociatedTypeDescriptor(BinaryReader reader) throws IOException {super(reader.getPointerIndex());- conformingTypeName = reader.readNext(SwiftUtils::relativeString);- protocolTypeName = reader.readNext(SwiftUtils::relativeString);+ conformingTypeName = reader.readNext(SwiftTypeMetadataUtils::relativeString);+ protocolTypeName = reader.readNext(SwiftTypeMetadataUtils::relativeString);numAssociatedTypes = reader.readNextInt();associatedTypeRecordSize = reader.readNextInt();@@ -111,8 +111,8 @@ public final class AssociatedTypeDescriptor extends SwiftTypeMetadataStructure {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);- struct.add(SwiftUtils.PTR_STRING, "ConformingTypeName", "");- struct.add(SwiftUtils.PTR_STRING, "ProtocolTypeName", "");+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "ConformingTypeName", "");+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "ProtocolTypeName", "");struct.add(DWORD, "NumAssociatedTypes", "");struct.add(DWORD, "AssociatedTypeRecordSize", "");return struct;diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeRecord.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeRecord.javasimilarity index 86%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeRecord.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeRecord.javaindex 130d9e4992..62cba3c6cb 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeRecord.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/AssociatedTypeRecord.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -47,8 +47,8 @@ public final class AssociatedTypeRecord extends SwiftTypeMetadataStructure {*/public AssociatedTypeRecord(BinaryReader reader) throws IOException {super(reader.getPointerIndex());- name = reader.readNext(SwiftUtils::relativeString);- substitutedTypeName = reader.readNext(SwiftUtils::relativeString);+ name = reader.readNext(SwiftTypeMetadataUtils::relativeString);+ substitutedTypeName = reader.readNext(SwiftTypeMetadataUtils::relativeString);}/**@@ -78,8 +78,8 @@ public final class AssociatedTypeRecord extends SwiftTypeMetadataStructure {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);- struct.add(SwiftUtils.PTR_STRING, "Name", "");- struct.add(SwiftUtils.PTR_STRING, "SubstitutedTypeName", "");+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "Name", "");+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "SubstitutedTypeName", "");return struct;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/BuiltinTypeDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/BuiltinTypeDescriptor.javasimilarity index 93%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/BuiltinTypeDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/BuiltinTypeDescriptor.javaindex a52c2f2650..b1c7889c7f 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/BuiltinTypeDescriptor.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/BuiltinTypeDescriptor.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -50,7 +50,7 @@ public final class BuiltinTypeDescriptor extends SwiftTypeMetadataStructure {*/public BuiltinTypeDescriptor(BinaryReader reader) throws IOException {super(reader.getPointerIndex());- typeName = reader.readNext(SwiftUtils::relativeString);+ typeName = reader.readNext(SwiftTypeMetadataUtils::relativeString);size = reader.readNextInt();alignmentAndFlags = reader.readNextInt();stride = reader.readNextInt();@@ -105,7 +105,7 @@ public final class BuiltinTypeDescriptor extends SwiftTypeMetadataStructure {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);- struct.add(SwiftUtils.PTR_STRING, "TypeName", "");+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "TypeName", "");struct.add(DWORD, "Size", "");struct.add(DWORD, "AlignmentAndFlags", "");struct.add(DWORD, "Stride", "");diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureDescriptor.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureDescriptor.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureTypeRecord.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureTypeRecord.javasimilarity index 91%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureTypeRecord.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureTypeRecord.javaindex 8a2659929e..70df2c5b0f 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureTypeRecord.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/CaptureTypeRecord.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -46,7 +46,7 @@ public final class CaptureTypeRecord extends SwiftTypeMetadataStructure {*/public CaptureTypeRecord(BinaryReader reader) throws IOException {super(reader.getPointerIndex());- mangledTypeName = reader.readNext(SwiftUtils::relativeString);+ mangledTypeName = reader.readNext(SwiftTypeMetadataUtils::relativeString);}@@ -70,7 +70,7 @@ public final class CaptureTypeRecord extends SwiftTypeMetadataStructure {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);- struct.add(SwiftUtils.PTR_STRING, "MangledTypeName", "");+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "MangledTypeName", "");return struct;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ConformanceFlags.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/ConformanceFlags.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ConformanceFlags.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/ConformanceFlags.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ContextDescriptorFlags.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/ContextDescriptorFlags.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ContextDescriptorFlags.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/ContextDescriptorFlags.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ContextDescriptorKind.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/ContextDescriptorKind.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ContextDescriptorKind.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/ContextDescriptorKind.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/EntryPoint.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/EntryPoint.javasimilarity index 94%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/EntryPoint.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/EntryPoint.javaindex 78d41cd13e..19aea48e09 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/EntryPoint.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/EntryPoint.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.util.exception.DuplicateNameException;@@ -65,7 +65,7 @@ public final class EntryPoint extends SwiftTypeMetadataStructure {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {- return SwiftUtils.PTR_RELATIVE;+ return SwiftTypeMetadataUtils.PTR_RELATIVE;}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ExtraClassDescriptorFlags.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/ExtraClassDescriptorFlags.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ExtraClassDescriptorFlags.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/ExtraClassDescriptorFlags.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/FieldDescriptor.javasimilarity index 92%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/FieldDescriptor.javaindex f05afab422..3ae92dced7 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldDescriptor.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/FieldDescriptor.java@@ -21,7 +21,7 @@ import java.util.List;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -54,7 +54,7 @@ public final class FieldDescriptor extends SwiftTypeMetadataStructure {*/public FieldDescriptor(BinaryReader reader) throws IOException {super(reader.getPointerIndex());- mangledTypeName = reader.readNext(SwiftUtils::relativeString);+ mangledTypeName = reader.readNext(SwiftTypeMetadataUtils::relativeString);superclass = reader.readNextInt();kind = reader.readNextUnsignedShort();fieldRecordSize = reader.readNextUnsignedShort();@@ -120,8 +120,8 @@ public final class FieldDescriptor extends SwiftTypeMetadataStructure {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);- struct.add(SwiftUtils.PTR_STRING, "MangledTypeName", "");- struct.add(SwiftUtils.PTR_RELATIVE, "Superclass", "");+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "MangledTypeName", "");+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "Superclass", "");struct.add(WORD, "Kind", "");struct.add(WORD, "FieldRecordSize", "");struct.add(DWORD, "NumFields", "");diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldRecord.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/FieldRecord.javasimilarity index 87%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldRecord.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/FieldRecord.javaindex e4c6511bda..86ca4835f7 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/FieldRecord.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/FieldRecord.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -49,8 +49,8 @@ public final class FieldRecord extends SwiftTypeMetadataStructure {public FieldRecord(BinaryReader reader) throws IOException {super(reader.getPointerIndex());flags = reader.readNextInt();- mangledTypeName = reader.readNext(SwiftUtils::relativeString);- fieldName = reader.readNext(SwiftUtils::relativeString);+ mangledTypeName = reader.readNext(SwiftTypeMetadataUtils::relativeString);+ fieldName = reader.readNext(SwiftTypeMetadataUtils::relativeString);}/**@@ -88,8 +88,8 @@ public final class FieldRecord extends SwiftTypeMetadataStructure {public DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);struct.add(DWORD, "Flags", "");- struct.add(SwiftUtils.PTR_STRING, "MangledTypeName", "");- struct.add(SwiftUtils.PTR_STRING, "FieldName", "");+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "MangledTypeName", "");+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "FieldName", "");return struct;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/GenericContextDescriptorFlags.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/GenericContextDescriptorFlags.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/GenericContextDescriptorFlags.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/GenericContextDescriptorFlags.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/GenericParamDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/GenericParamDescriptor.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/GenericParamDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/GenericParamDescriptor.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/GenericParamKind.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/GenericParamKind.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/GenericParamKind.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/GenericParamKind.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/GenericRequirementFlags.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/GenericRequirementFlags.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/GenericRequirementFlags.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/GenericRequirementFlags.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/GenericRequirementKind.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/GenericRequirementKind.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/GenericRequirementKind.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/GenericRequirementKind.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/GenericRequirementLayoutKind.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/GenericRequirementLayoutKind.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/GenericRequirementLayoutKind.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/GenericRequirementLayoutKind.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/InvertibleProtocolKind.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/InvertibleProtocolKind.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/InvertibleProtocolKind.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/InvertibleProtocolKind.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/InvertibleProtocolSet.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/InvertibleProtocolSet.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/InvertibleProtocolSet.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/InvertibleProtocolSet.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataInitializationKind.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataInitializationKind.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataInitializationKind.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataInitializationKind.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataSourceRecord.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataSourceRecord.javasimilarity index 86%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataSourceRecord.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataSourceRecord.javaindex 7e42a69ebc..c16f3b188d 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataSourceRecord.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/MetadataSourceRecord.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -47,8 +47,8 @@ public final class MetadataSourceRecord extends SwiftTypeMetadataStructure {*/public MetadataSourceRecord(BinaryReader reader) throws IOException {super(reader.getPointerIndex());- mangledTypeName = reader.readNext(SwiftUtils::relativeString);- mangledMetadataSource = reader.readNext(SwiftUtils::relativeString);+ mangledTypeName = reader.readNext(SwiftTypeMetadataUtils::relativeString);+ mangledMetadataSource = reader.readNext(SwiftTypeMetadataUtils::relativeString);}/**@@ -78,8 +78,8 @@ public final class MetadataSourceRecord extends SwiftTypeMetadataStructure {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);- struct.add(SwiftUtils.PTR_STRING, "MangledTypeName", "");- struct.add(SwiftUtils.PTR_STRING, "MangledMetadataSource", "");+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "MangledTypeName", "");+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "MangledMetadataSource", "");return struct;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MethodDescriptorFlags.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/MethodDescriptorFlags.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MethodDescriptorFlags.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/MethodDescriptorFlags.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MethodDescriptorKind.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/MethodDescriptorKind.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MethodDescriptorKind.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/MethodDescriptorKind.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MultiPayloadEnumDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/MultiPayloadEnumDescriptor.javasimilarity index 93%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MultiPayloadEnumDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/MultiPayloadEnumDescriptor.javaindex 09e9bae54d..dcf9fdb495 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/MultiPayloadEnumDescriptor.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/MultiPayloadEnumDescriptor.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.util.exception.DuplicateNameException;@@ -54,7 +54,7 @@ public final class MultiPayloadEnumDescriptor extends SwiftTypeMetadataStructure*/public MultiPayloadEnumDescriptor(BinaryReader reader) throws IOException {super(reader.getPointerIndex());- typeName = reader.readNext(SwiftUtils::relativeString);+ typeName = reader.readNext(SwiftTypeMetadataUtils::relativeString);int size = (reader.readNextInt() >> 16) & 0xffff;reader.setPointerIndex(reader.getPointerIndex() - 4);contents = reader.readNextIntArray(size);@@ -92,7 +92,7 @@ public final class MultiPayloadEnumDescriptor extends SwiftTypeMetadataStructurepublic static int peekContentsSize(BinaryReader reader) throws IOException {long origIndex = reader.getPointerIndex();try {- reader.readNext(SwiftUtils::relativeString);+ reader.readNext(SwiftTypeMetadataUtils::relativeString);return (reader.readNextInt() >> 16) & 0xffff;}finally {@@ -112,6 +112,6 @@ public final class MultiPayloadEnumDescriptor extends SwiftTypeMetadataStructure@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {- return SwiftUtils.PTR_STRING;+ return SwiftTypeMetadataUtils.PTR_STRING;}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ProtocolRequirementFlags.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/ProtocolRequirementFlags.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ProtocolRequirementFlags.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/ProtocolRequirementFlags.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ProtocolRequirementKind.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/ProtocolRequirementKind.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/ProtocolRequirementKind.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/ProtocolRequirementKind.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetClassDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetClassDescriptor.javasimilarity index 98%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetClassDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetClassDescriptor.javaindex 4f9719ea4e..9f77995b0c 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetClassDescriptor.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetClassDescriptor.java@@ -21,7 +21,7 @@ import java.util.List;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.*;import ghidra.util.exception.DuplicateNameException;@@ -313,7 +313,7 @@ public final class TargetClassDescriptor extends TargetTypeContextDescriptor {"Union_MetadataNegativeSizeInWords_ResilientMetadataBounds");union1.add(DWORD, "MetadataNegativeSizeInWords","If this descriptor does not have a resilient superclass, this is the negative size of metadata objects of this class (in words)");- union1.add(SwiftUtils.PTR_RELATIVE, "ResilientMetadataBounds",+ union1.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "ResilientMetadataBounds","If this descriptor has a resilient superclass, this is a reference to a cache holding the metadata's extends.");UnionDataType union2 =@@ -325,7 +325,7 @@ public final class TargetClassDescriptor extends TargetTypeContextDescriptor {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);struct.add(super.toDataType(), super.getStructureName(), "");- struct.add(SwiftUtils.PTR_STRING, "SuperclassType",+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "SuperclassType","The type of the superclass, expressed as a mangled type name that can refer to the generic arguments of the subclass type");struct.add(union1, "MetadataNegativeSizeInWords/ResilientMetadataBounds", null);struct.add(union2, "MetadataPositiveSizeInWords/ExtraClassFlags", null);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetContextDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetContextDescriptor.javasimilarity index 95%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetContextDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetContextDescriptor.javaindex 7d3a107376..9ea7ae1a24 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetContextDescriptor.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetContextDescriptor.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -87,7 +87,7 @@ public class TargetContextDescriptor extends SwiftTypeMetadataStructure {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getMyStructureName(), 0);struct.add(flags.toDataType(), "Flags","Flags describing the context, including its kind and format version");- struct.add(SwiftUtils.PTR_RELATIVE_MASKED, "Parent",+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE_MASKED, "Parent","The parent context, or null if this is a top-level context");return struct;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetEnumDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetEnumDescriptor.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetEnumDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetEnumDescriptor.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetForeignMetadataInitialization.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetForeignMetadataInitialization.javasimilarity index 94%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetForeignMetadataInitialization.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetForeignMetadataInitialization.javaindex 729984a67c..e5cf3f7c33 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetForeignMetadataInitialization.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetForeignMetadataInitialization.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -64,7 +64,7 @@ public class TargetForeignMetadataInitialization extends SwiftTypeMetadataStruct@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);- struct.add(SwiftUtils.PTR_RELATIVE, "CompletionFunction",+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "CompletionFunction","The completion function. The pattern will always be null.");return struct;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericContextDescriptorHeader.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericContextDescriptorHeader.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericContextDescriptorHeader.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericContextDescriptorHeader.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericRequirementsDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericRequirementsDescriptor.javasimilarity index 89%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericRequirementsDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericRequirementsDescriptor.javaindex a202e645ed..7b9840c6f5 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericRequirementsDescriptor.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericRequirementsDescriptor.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.*;import ghidra.util.exception.DuplicateNameException;@@ -115,16 +115,16 @@ public class TargetGenericRequirementsDescriptor extends SwiftTypeMetadataStructUnionDataType union =new UnionDataType(CATEGORY_PATH, "Union_TargetGenericRequirementsDescriptor");- union.add(SwiftUtils.PTR_RELATIVE, "Type", "A mangled representation of the same-type or base class the param is constrained to.");- union.add(SwiftUtils.PTR_RELATIVE, "Protocol", "The protocol the param is constrained to.");- union.add(SwiftUtils.PTR_RELATIVE, "Conformance", "The conformance the param is constrained to use.");+ union.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "Type", "A mangled representation of the same-type or base class the param is constrained to.");+ union.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "Protocol", "The protocol the param is constrained to.");+ union.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "Conformance", "The conformance the param is constrained to use.");union.add(GenericRequirementLayoutKind.values()[0].toDataType(), "Layout","The kind of layout constraint.");union.add(invertedProtocolsStruct, invertedProtocolsStruct.getName(), null);StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);struct.add(flags.toDataType(), "Flags", null);- struct.add(SwiftUtils.PTR_RELATIVE, "Param",+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "Param","The type that's constrained, described as a mangled name.");struct.add(union, union.getName(), null);return struct;diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericWitnessTable.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericWitnessTable.javasimilarity index 93%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericWitnessTable.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericWitnessTable.javaindex ae41b7efae..d0884932be 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericWitnessTable.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetGenericWitnessTable.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -96,9 +96,9 @@ public class TargetGenericWitnessTable extends SwiftTypeMetadataStructure {struct.add(WORD, "WitnessTableSizeInWords", "The size of the witness table in words.");struct.add(WORD, "WitnessTablePrivateSizeInWordsAndRequiresInstantiation","The amount of private storage to allocate before the address point, in words.");- struct.add(SwiftUtils.PTR_RELATIVE, "Instantiator",+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "Instantiator","The instantiation function, which is called after the template is copied.");- struct.add(SwiftUtils.PTR_RELATIVE, "PrivateData", "Private data for the instantiator.");+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "PrivateData", "Private data for the instantiator.");return struct;}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetMethodDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetMethodDescriptor.javasimilarity index 94%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetMethodDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetMethodDescriptor.javaindex e0160a6b2b..46a00a42c8 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetMethodDescriptor.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetMethodDescriptor.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -79,7 +79,7 @@ public class TargetMethodDescriptor extends SwiftTypeMetadataStructure {public DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);struct.add(flags.toDataType(), "Flags", "Flags describing the method");- struct.add(SwiftUtils.PTR_RELATIVE, "Impl", "The method implementation");+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "Impl", "The method implementation");return struct;}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetMethodOverrideDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetMethodOverrideDescriptor.javasimilarity index 89%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetMethodOverrideDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetMethodOverrideDescriptor.javaindex aedab51ed0..b6c1d8a6a5 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetMethodOverrideDescriptor.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetMethodOverrideDescriptor.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -87,10 +87,10 @@ public class TargetMethodOverrideDescriptor extends SwiftTypeMetadataStructure {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);- struct.add(SwiftUtils.PTR_RELATIVE_MASKED, "Class",+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE_MASKED, "Class","The class containing the base method.");- struct.add(SwiftUtils.PTR_RELATIVE_MASKED, "Method", "The base method.");- struct.add(SwiftUtils.PTR_RELATIVE, "Impl", "The implementation of the override");+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE_MASKED, "Method", "The base method.");+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "Impl", "The implementation of the override");return struct;}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetObjCResilientClassStubInfo.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetObjCResilientClassStubInfo.javasimilarity index 95%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetObjCResilientClassStubInfo.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetObjCResilientClassStubInfo.javaindex 322d22b7ab..9b47b29cc3 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetObjCResilientClassStubInfo.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetObjCResilientClassStubInfo.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -71,7 +71,7 @@ public class TargetObjCResilientClassStubInfo extends SwiftTypeMetadataStructure@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getMyStructureName(), 0);- struct.add(SwiftUtils.PTR_RELATIVE, "Stub",+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "Stub","A relative pointer to an Objective-C resilient class stub.");return struct;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetOverrideTableHeader.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetOverrideTableHeader.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetOverrideTableHeader.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetOverrideTableHeader.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolConformanceDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolConformanceDescriptor.javasimilarity index 95%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolConformanceDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolConformanceDescriptor.javaindex 05c6b50330..5f436b11c3 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolConformanceDescriptor.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolConformanceDescriptor.java@@ -21,7 +21,7 @@ import java.util.List;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -159,8 +159,8 @@ public final class TargetProtocolConformanceDescriptor extends SwiftTypeMetadata@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);- struct.add(SwiftUtils.PTR_RELATIVE_MASKED, "Protocol", "The protocol being conformed to");- struct.add(SwiftUtils.PTR_RELATIVE, "TypeRef",+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE_MASKED, "Protocol", "The protocol being conformed to");+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "TypeRef","Some description of the type that conforms to the protocol");struct.add(DWORD, "WitnessTablePattern","The witness table pattern, which may also serve as the witness table");diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolDescriptor.javasimilarity index 93%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolDescriptor.javaindex e969e082ed..65bfa593e3 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolDescriptor.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolDescriptor.java@@ -21,7 +21,7 @@ import java.util.List;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -49,7 +49,7 @@ public final class TargetProtocolDescriptor extends TargetContextDescriptor {*/public TargetProtocolDescriptor(BinaryReader reader) throws IOException {super(reader);- name = reader.readNext(SwiftUtils::relativeString);+ name = reader.readNext(SwiftTypeMetadataUtils::relativeString);numRequirementsInSig = reader.readNextInt();numRequirements = reader.readNextInt();associatedTypeNames = reader.readNextInt();@@ -131,11 +131,11 @@ public final class TargetProtocolDescriptor extends TargetContextDescriptor {public DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);struct.add(super.toDataType(), super.getStructureName(), "");- struct.add(SwiftUtils.PTR_STRING, "Name", "The name of the protocol");+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "Name", "The name of the protocol");struct.add(DWORD, "NumRequirementsInSignature","The number of generic requirements in the requirement signature of the protocol");struct.add(DWORD, "NumRequirements", "The number of requirements in the protocol");- struct.add(SwiftUtils.PTR_RELATIVE, "AssociatedTypeNames",+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "AssociatedTypeNames","Associated type names, as a space-separated list in the same order as the requirements");return struct;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolRequirement.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolRequirement.javasimilarity index 90%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolRequirement.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolRequirement.javaindex 007152df17..4b76fb9a30 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolRequirement.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetProtocolRequirement.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.*;import ghidra.util.exception.DuplicateNameException;@@ -68,8 +68,8 @@ public class TargetProtocolRequirement extends SwiftTypeMetadataStructure {public DataType toDataType() throws DuplicateNameException, IOException {UnionDataType union = new UnionDataType(CATEGORY_PATH,"Union_DefaultFuncImplementation_DefaultImplementation");- union.add(SwiftUtils.PTR_RELATIVE, "DefaultFuncImplementation", null);- union.add(SwiftUtils.PTR_RELATIVE, "DefaultImplementation", null);+ union.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "DefaultFuncImplementation", null);+ union.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "DefaultImplementation", null);StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);struct.add(flags.toDataType(), "Flags", null);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetRelativeContextPointer.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetRelativeContextPointer.javasimilarity index 94%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetRelativeContextPointer.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetRelativeContextPointer.javaindex fb467bcf12..2648f50996 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetRelativeContextPointer.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetRelativeContextPointer.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.util.exception.DuplicateNameException;@@ -62,6 +62,6 @@ public class TargetRelativeContextPointer extends SwiftTypeMetadataStructure {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {- return SwiftUtils.PTR_RELATIVE_MASKED;+ return SwiftTypeMetadataUtils.PTR_RELATIVE_MASKED;}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetRelativeProtocolRequirementPointer.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetRelativeProtocolRequirementPointer.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetRelativeProtocolRequirementPointer.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetRelativeProtocolRequirementPointer.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientSuperclass.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientSuperclass.javasimilarity index 93%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientSuperclass.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientSuperclass.javaindex 9a6bbfcae6..f57a1d0b04 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientSuperclass.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientSuperclass.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -71,7 +71,7 @@ public class TargetResilientSuperclass extends SwiftTypeMetadataStructure {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getMyStructureName(), 0);- struct.add(SwiftUtils.PTR_RELATIVE, "Superclass", "The superclass of this class.");+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "Superclass", "The superclass of this class.");return struct;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientWitness.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientWitness.javasimilarity index 92%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientWitness.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientWitness.javaindex 03e4544305..a3dfc0808e 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientWitness.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientWitness.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.*;import ghidra.util.exception.DuplicateNameException;@@ -68,8 +68,8 @@ public class TargetResilientWitness extends SwiftTypeMetadataStructure {public DataType toDataType() throws DuplicateNameException, IOException {UnionDataType union = new UnionDataType(CATEGORY_PATH,"Union_Impl_FuncImpl");- union.add(SwiftUtils.PTR_RELATIVE, "Impl", null);- union.add(SwiftUtils.PTR_RELATIVE, "FuncImpl", null);+ union.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "Impl", null);+ union.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "FuncImpl", null);StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);struct.add(TargetRelativeProtocolRequirementPointer.dataType, "Requirement", null);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientWitnessHeader.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientWitnessHeader.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientWitnessHeader.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetResilientWitnessHeader.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetSingletonMetadataInitialization.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetSingletonMetadataInitialization.javasimilarity index 90%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetSingletonMetadataInitialization.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetSingletonMetadataInitialization.javaindex f670a09e29..9ab1bc41b4 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetSingletonMetadataInitialization.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetSingletonMetadataInitialization.java@@ -19,7 +19,7 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.*;import ghidra.util.exception.DuplicateNameException;@@ -99,15 +99,15 @@ public class TargetSingletonMetadataInitialization extends SwiftTypeMetadataStrupublic DataType toDataType() throws DuplicateNameException, IOException {UnionDataType union =new UnionDataType(CATEGORY_PATH, "Union_IncompleteMetadata_ResilientPattern");- union.add(SwiftUtils.PTR_RELATIVE, "IncompleteMetadata",+ union.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "IncompleteMetadata","The incomplete metadata, for structs, enums and classes without resilient ancestry.");- union.add(SwiftUtils.PTR_RELATIVE, "ResilientPattern",+ union.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "ResilientPattern","If the classes descriptor has a resilient superclass, this points at a pattern used to allcoate and initialize metadata for this class, since its size and contents is not known at compile time.");StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);- struct.add(SwiftUtils.PTR_RELATIVE, "InitializationCache", "The initialization cache.");+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "InitializationCache", "The initialization cache.");struct.add(union, union.getName(), null);- struct.add(SwiftUtils.PTR_RELATIVE, "CompletionFunction",+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "CompletionFunction","The completion function. The pattern will always be null, even for a resilient class.");return struct;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetStructDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetStructDescriptor.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetStructDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetStructDescriptor.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeContextDescriptor.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeContextDescriptor.javasimilarity index 90%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeContextDescriptor.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeContextDescriptor.javaindex 67ad43d0f3..2de633593f 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeContextDescriptor.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeContextDescriptor.java@@ -19,7 +19,7 @@ import java.io.IOException;import java.util.Map;import ghidra.app.util.bin.BinaryReader;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -43,7 +43,7 @@ public class TargetTypeContextDescriptor extends TargetContextDescriptor {*/public TargetTypeContextDescriptor(BinaryReader reader) throws IOException {super(reader);- name = reader.readNext(SwiftUtils::relativeString);+ name = reader.readNext(SwiftTypeMetadataUtils::relativeString);accessFunctionPtr = reader.readNextInt();fields = reader.readNextInt();}@@ -108,10 +108,10 @@ public class TargetTypeContextDescriptor extends TargetContextDescriptor {public DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getMyStructureName(), 0);struct.add(super.toDataType(), super.getStructureName(), "");- struct.add(SwiftUtils.PTR_STRING, "Name", "The name of the type");- struct.add(SwiftUtils.PTR_RELATIVE, "AccessFunctionPtr",+ struct.add(SwiftTypeMetadataUtils.PTR_STRING, "Name", "The name of the type");+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "AccessFunctionPtr","A pointer to the metadata access function for this type");- struct.add(SwiftUtils.PTR_RELATIVE, "Fields",+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "Fields","A pointer to the field descriptor for the type, if any");return struct;}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeGenericContextDescriptorHeader.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeGenericContextDescriptorHeader.javasimilarity index 93%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeGenericContextDescriptorHeader.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeGenericContextDescriptorHeader.javaindex 17f1907739..99e1191a97 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeGenericContextDescriptorHeader.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetTypeGenericContextDescriptorHeader.java@@ -20,7 +20,7 @@ import java.util.List;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.swift.SwiftTypeMetadataStructure;-import ghidra.app.util.bin.format.swift.SwiftUtils;+import ghidra.app.util.bin.format.swift.SwiftTypeMetadataUtils;import ghidra.program.model.data.DataType;import ghidra.program.model.data.StructureDataType;import ghidra.util.exception.DuplicateNameException;@@ -88,9 +88,9 @@ public class TargetTypeGenericContextDescriptorHeader extends SwiftTypeMetadataS@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(CATEGORY_PATH, getStructureName(), 0);- struct.add(SwiftUtils.PTR_RELATIVE, "InstantiationCache",+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "InstantiationCache","The metadata instantiation cache.");- struct.add(SwiftUtils.PTR_RELATIVE, "DefaultInstantiationPattern",+ struct.add(SwiftTypeMetadataUtils.PTR_RELATIVE, "DefaultInstantiationPattern","The default instantiation pattern.");struct.add(base.toDataType(), "Base", "The base header.");return struct;diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetVTableDescriptorHeader.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetVTableDescriptorHeader.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TargetVTableDescriptorHeader.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TargetVTableDescriptorHeader.javadiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TypeReferenceKind.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TypeReferenceKind.javasimilarity index 100%rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/swift/types/TypeReferenceKind.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/bin/format/swift/types/TypeReferenceKind.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledBuiltinType.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledBuiltinType.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledBuiltinType.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledBuiltinType.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledNodeKind.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledNodeKind.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledNodeKind.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledNodeKind.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledTree.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledTree.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledTree.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangledTree.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangler.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangler.javasimilarity index 97%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangler.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangler.javaindex d49cf4eb58..983855aab5 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangler.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftDemangler.java@@ -19,11 +19,11 @@ import java.io.IOException;import java.util.*;import ghidra.app.util.bin.format.swift.SwiftTypeMetadata;-import ghidra.app.util.bin.format.swift.SwiftUtils;import ghidra.app.util.demangler.*;import ghidra.app.util.demangler.swift.datatypes.SwiftDataTypeUtils;import ghidra.app.util.demangler.swift.nodes.SwiftNode;import ghidra.app.util.importer.MessageLog;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguage;import ghidra.program.model.listing.Program;import ghidra.util.exception.CancelledException;import ghidra.util.task.TaskMonitor;@@ -66,7 +66,7 @@ public class SwiftDemangler implements Demangler {@Overridepublic boolean canDemangle(Program program) {- return SwiftUtils.isSwift(program);+ return program.getSourceLanguageIDs().contains(SwiftSourceLanguage.SWIFT_ID);}@Overridediff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemanglerOptions.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftDemanglerOptions.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftDemanglerOptions.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftDemanglerOptions.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftNativeDemangler.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftNativeDemangler.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/SwiftNativeDemangler.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/SwiftNativeDemangler.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftArray.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftArray.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftArray.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftArray.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftCharacter.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftCharacter.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftCharacter.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftCharacter.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftDataTypeUtils.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftDataTypeUtils.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftDataTypeUtils.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftDataTypeUtils.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftEnum.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftEnum.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftEnum.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftEnum.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftFunction.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftFunction.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftFunction.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftFunction.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftPrimitive.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftPrimitive.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftPrimitive.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftPrimitive.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftString.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftString.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftString.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftString.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftStructure.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftStructure.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftStructure.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftStructure.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftTuple.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftTuple.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftTuple.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/datatypes/SwiftTuple.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftAllocatorNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftAllocatorNode.javasimilarity index 88%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftAllocatorNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftAllocatorNode.javaindex 331f48e174..3c69a7719e 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftAllocatorNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftAllocatorNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -20,7 +20,7 @@ import ghidra.app.util.demangler.DemangledException;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#Allocator} {@link SwiftNode}@@ -33,19 +33,19 @@ public class SwiftAllocatorNode extends SwiftNode {Demangled namespace = null;Demangled type = null;Demangled labelList = null;- String callingConvention = CompilerSpec.CALLING_CONVENTION_default;+ String callingConvention = SwiftSourceLanguageSpecExtension.SWIFT_STDCALL;for (SwiftNode child : getChildren()) {switch (child.getKind()) {case Class:namespace = child.demangle(demangler);name = "__allocating_init";- callingConvention = CompilerSpec.CALLING_CONVENTION_thiscall;+ callingConvention = SwiftSourceLanguageSpecExtension.SWIFT_THISCALL;break;case Extension:namespace = child.demangle(demangler);if (child.hasChild(SwiftDemangledNodeKind.Class)) {name = "__allocating_init";- callingConvention = CompilerSpec.CALLING_CONVENTION_thiscall;+ callingConvention = SwiftSourceLanguageSpecExtension.SWIFT_THISCALL;}else if (child.hasChild(SwiftDemangledNodeKind.Protocol) ||child.hasChild(SwiftDemangledNodeKind.Structure)) {diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftBoundGenericStructureNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftBoundGenericStructureNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftBoundGenericStructureNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftBoundGenericStructureNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftBuiltinTypeNameNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftBuiltinTypeNameNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftBuiltinTypeNameNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftBuiltinTypeNameNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftClassNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftClassNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftClassNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftClassNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftConstructorNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftConstructorNode.javasimilarity index 93%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftConstructorNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftConstructorNode.javaindex fc02dc718a..9316b14c3a 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftConstructorNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftConstructorNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -19,7 +19,7 @@ import ghidra.app.util.demangler.*;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#Constructor} {@link SwiftNode}@@ -54,7 +54,7 @@ public class SwiftConstructorNode extends SwiftNode {}SwiftFunction function =new SwiftFunction(properties.mangled(), properties.originalDemangled(), name, namespace,- CompilerSpec.CALLING_CONVENTION_thiscall);+ SwiftSourceLanguageSpecExtension.SWIFT_THISCALL);if (type instanceof DemangledFunction functionType) {function.setType(functionType, labelList);}diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDeallocatorNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDeallocatorNode.javasimilarity index 91%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDeallocatorNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDeallocatorNode.javaindex 7874a34eed..b443fa631d 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDeallocatorNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDeallocatorNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -20,7 +20,7 @@ import ghidra.app.util.demangler.DemangledException;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#Deallocator} {@link SwiftNode}@@ -46,6 +46,6 @@ public class SwiftDeallocatorNode extends SwiftNode {return getUnknown();}return new SwiftFunction(properties.mangled(), properties.originalDemangled(), name,- namespace, CompilerSpec.CALLING_CONVENTION_thiscall);+ namespace, SwiftSourceLanguageSpecExtension.SWIFT_THISCALL);}}diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDependentGenericParamTypeNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDependentGenericParamTypeNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDependentGenericParamTypeNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDependentGenericParamTypeNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDependentGenericTypeNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDependentGenericTypeNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDependentGenericTypeNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDependentGenericTypeNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDestructorNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDestructorNode.javasimilarity index 92%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDestructorNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDestructorNode.javaindex 0519a09954..1dd9c217d1 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDestructorNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftDestructorNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -19,7 +19,7 @@ import ghidra.app.util.demangler.*;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#Destructor} {@link SwiftNode}@@ -46,7 +46,7 @@ public class SwiftDestructorNode extends SwiftNode {}SwiftFunction function =new SwiftFunction(properties.mangled(), properties.originalDemangled(), name, namespace,- CompilerSpec.CALLING_CONVENTION_thiscall);+ SwiftSourceLanguageSpecExtension.SWIFT_THISCALL);if (namespace instanceof DemangledDataType type) {function.setReturnType(type);}diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftEnumNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftEnumNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftEnumNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftEnumNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftExtensionNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftExtensionNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftExtensionNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftExtensionNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftFunctionNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftFunctionNode.javasimilarity index 90%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftFunctionNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftFunctionNode.javaindex eea6e07e81..d2fd722458 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftFunctionNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftFunctionNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -19,7 +19,7 @@ import ghidra.app.util.demangler.*;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#Function} {@link SwiftNode}@@ -32,7 +32,7 @@ public class SwiftFunctionNode extends SwiftNode {Demangled namespace = null;Demangled type = null;Demangled labelList = null;- String callingConvention = CompilerSpec.CALLING_CONVENTION_default;+ String callingConvention = SwiftSourceLanguageSpecExtension.SWIFT_STDCALL;for (SwiftNode child : getChildren()) {switch (child.getKind()) {case Identifier:@@ -45,7 +45,7 @@ public class SwiftFunctionNode extends SwiftNode {name = child.demangle(demangler).getName();break;case Class:- callingConvention = CompilerSpec.CALLING_CONVENTION_thiscall;+ callingConvention = SwiftSourceLanguageSpecExtension.SWIFT_THISCALL;// Fall throughcase Enum:case Extension:diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftFunctionTypeNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftFunctionTypeNode.javasimilarity index 96%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftFunctionTypeNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftFunctionTypeNode.javaindex f7ad6b186a..f06e7e48d5 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftFunctionTypeNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftFunctionTypeNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -19,7 +19,7 @@ import ghidra.app.util.demangler.*;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.*;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#FunctionType} {@link SwiftNode}@@ -45,7 +45,7 @@ public class SwiftFunctionTypeNode extends SwiftNode {}SwiftFunction function =new SwiftFunction(properties.mangled(), properties.originalDemangled(), "<unknown>",- null, CompilerSpec.CALLING_CONVENTION_default);+ null, SwiftSourceLanguageSpecExtension.SWIFT_STDCALL);// Parametersfunction.addParameters(SwiftDataTypeUtils.extractParameters(argumentTuple));diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGetterNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGetterNode.javasimilarity index 90%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGetterNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGetterNode.javaindex 1eca9b3cdd..46f04da84e 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGetterNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGetterNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -20,7 +20,7 @@ import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftDataTypeUtils;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#Getter} {@link SwiftNode}@@ -31,7 +31,7 @@ public class SwiftGetterNode extends SwiftNode {public Demangled demangle(SwiftDemangler demangler) throws DemangledException {Demangled demangled = null;String name = "get_";- String callingConvention = CompilerSpec.CALLING_CONVENTION_default;+ String callingConvention = SwiftSourceLanguageSpecExtension.SWIFT_STDCALL;for (SwiftNode child : getChildren()) {switch (child.getKind()) {case Subscript:@@ -40,7 +40,7 @@ public class SwiftGetterNode extends SwiftNode {case Variable:demangled = child.demangle(demangler);if (child.hasChild(SwiftDemangledNodeKind.Class)) {- callingConvention = CompilerSpec.CALLING_CONVENTION_thiscall;+ callingConvention = SwiftSourceLanguageSpecExtension.SWIFT_THISCALL;}break;default:diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalVariableOnceDeclListNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalVariableOnceDeclListNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalVariableOnceDeclListNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalVariableOnceDeclListNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalVariableOnceFunctionNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalVariableOnceFunctionNode.javasimilarity index 92%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalVariableOnceFunctionNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalVariableOnceFunctionNode.javaindex 5f01f65bd4..1b559fb89f 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalVariableOnceFunctionNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftGlobalVariableOnceFunctionNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -19,7 +19,7 @@ import ghidra.app.util.demangler.*;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#GlobalVariableOnceFunction} {@link SwiftNode}@@ -56,6 +56,6 @@ public class SwiftGlobalVariableOnceFunctionNode extends SwiftNode {}}return new SwiftFunction(properties.mangled(), properties.originalDemangled(),- name.toString(), namespace, CompilerSpec.CALLING_CONVENTION_default);+ name.toString(), namespace, SwiftSourceLanguageSpecExtension.SWIFT_STDCALL);}}diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftInOutNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftInOutNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftInOutNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftInOutNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftInitializerNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftInitializerNode.javasimilarity index 91%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftInitializerNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftInitializerNode.javaindex 5e28d1c633..fed9a1a909 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftInitializerNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftInitializerNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -20,7 +20,7 @@ import ghidra.app.util.demangler.DemangledException;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#Initializer} {@link SwiftNode}@@ -46,6 +46,6 @@ public class SwiftInitializerNode extends SwiftNode {return getUnknown();}return new SwiftFunction(properties.mangled(), properties.originalDemangled(), name,- namespace, CompilerSpec.CALLING_CONVENTION_default);+ namespace, SwiftSourceLanguageSpecExtension.SWIFT_STDCALL);}}diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLabelListNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLabelListNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLabelListNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLabelListNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLazyProtocolWitnessTableAccessorNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLazyProtocolWitnessTableAccessorNode.javasimilarity index 91%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLazyProtocolWitnessTableAccessorNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLazyProtocolWitnessTableAccessorNode.javaindex 313d7e9aef..91c397d0f3 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLazyProtocolWitnessTableAccessorNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLazyProtocolWitnessTableAccessorNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -20,7 +20,7 @@ import ghidra.app.util.demangler.DemangledException;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#LazyProtocolWitnessTableAccessor} {@link SwiftNode}@@ -46,6 +46,6 @@ public class SwiftLazyProtocolWitnessTableAccessorNode extends SwiftNode {return getUnknown();}return new SwiftFunction(properties.mangled(), properties.originalDemangled(), name,- namespace, CompilerSpec.CALLING_CONVENTION_default);+ namespace, SwiftSourceLanguageSpecExtension.SWIFT_STDCALL);}}diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLocalDeclNameNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLocalDeclNameNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLocalDeclNameNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftLocalDeclNameNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftModifyAccessorNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftModifyAccessorNode.javasimilarity index 92%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftModifyAccessorNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftModifyAccessorNode.javaindex 9a98f639bf..3d1bcb9e5e 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftModifyAccessorNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftModifyAccessorNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -20,7 +20,7 @@ import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftDataTypeUtils;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#ModifyAccessor} {@link SwiftNode}@@ -31,7 +31,7 @@ public class SwiftModifyAccessorNode extends SwiftNode {public Demangled demangle(SwiftDemangler demangler) throws DemangledException {Demangled demangled = null;String name = "modify_";- String callingConvention = CompilerSpec.CALLING_CONVENTION_thiscall;+ String callingConvention = SwiftSourceLanguageSpecExtension.SWIFT_THISCALL;for (SwiftNode child : getChildren()) {switch (child.getKind()) {case Subscript:diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftOutlinedConsumeNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftOutlinedConsumeNode.javasimilarity index 90%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftOutlinedConsumeNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftOutlinedConsumeNode.javaindex 7f6478baa9..ca434f4d99 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftOutlinedConsumeNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftOutlinedConsumeNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -19,7 +19,7 @@ import ghidra.app.util.demangler.*;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#OutlinedConsume} {@link SwiftNode}@@ -41,7 +41,7 @@ public class SwiftOutlinedConsumeNode extends SwiftNode {}SwiftFunction function =new SwiftFunction(properties.mangled(), properties.originalDemangled(),- "outlined_consume", null, CompilerSpec.CALLING_CONVENTION_default);+ "outlined_consume", null, SwiftSourceLanguageSpecExtension.SWIFT_STDCALL);if (type instanceof DemangledDataType dt) {function.addParameter(new DemangledParameter(dt));}diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftOutlinedCopyNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftOutlinedCopyNode.javasimilarity index 90%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftOutlinedCopyNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftOutlinedCopyNode.javaindex 59f0b37248..94b76715e5 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftOutlinedCopyNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftOutlinedCopyNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -19,7 +19,7 @@ import ghidra.app.util.demangler.*;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#OutlinedCopy} {@link SwiftNode}@@ -41,7 +41,7 @@ public class SwiftOutlinedCopyNode extends SwiftNode {}SwiftFunction function =new SwiftFunction(properties.mangled(), properties.originalDemangled(),- "outlined_copy", null, CompilerSpec.CALLING_CONVENTION_default);+ "outlined_copy", null, SwiftSourceLanguageSpecExtension.SWIFT_STDCALL);if (type instanceof DemangledDataType dt) {function.addParameter(new DemangledParameter(dt));}diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftPrivateDeclNameNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftPrivateDeclNameNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftPrivateDeclNameNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftPrivateDeclNameNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftProtocolConformanceNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftProtocolConformanceNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftProtocolConformanceNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftProtocolConformanceNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftProtocolNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftProtocolNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftProtocolNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftProtocolNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftSetterNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftSetterNode.javasimilarity index 92%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftSetterNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftSetterNode.javaindex 59dbd96ecb..5b8a42a03f 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftSetterNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftSetterNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -20,7 +20,7 @@ import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftDataTypeUtils;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#Setter} {@link SwiftNode}@@ -31,7 +31,7 @@ public class SwiftSetterNode extends SwiftNode {public Demangled demangle(SwiftDemangler demangler) throws DemangledException {Demangled demangled = null;String name = "set_";- String callingConvention = CompilerSpec.CALLING_CONVENTION_thiscall;+ String callingConvention = SwiftSourceLanguageSpecExtension.SWIFT_THISCALL;for (SwiftNode child : getChildren()) {switch (child.getKind()) {case Subscript:diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftStructureNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftStructureNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftStructureNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftStructureNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftSubscriptNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftSubscriptNode.javasimilarity index 89%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftSubscriptNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftSubscriptNode.javaindex 11dc18a4e8..6123328302 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftSubscriptNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftSubscriptNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -19,7 +19,7 @@ import ghidra.app.util.demangler.*;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#Subscript} {@link SwiftNode}@@ -32,11 +32,11 @@ public class SwiftSubscriptNode extends SwiftNode {Demangled namespace = null;Demangled type = null;Demangled labelList = null;- String callingConvention = CompilerSpec.CALLING_CONVENTION_default;+ String callingConvention = SwiftSourceLanguageSpecExtension.SWIFT_STDCALL;for (SwiftNode child : getChildren()) {switch (child.getKind()) {case Class:- callingConvention = CompilerSpec.CALLING_CONVENTION_thiscall;+ callingConvention = SwiftSourceLanguageSpecExtension.SWIFT_THISCALL;// Fall throughcase Structure:namespace = child.demangle(demangler);diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTupleElementNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTupleElementNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTupleElementNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTupleElementNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTupleNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTupleNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTupleNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTupleNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeAliasNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeAliasNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeAliasNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeAliasNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeListNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeListNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeListNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeListNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeMetadataAccessFunctionNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeMetadataAccessFunctionNode.javasimilarity index 92%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeMetadataAccessFunctionNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeMetadataAccessFunctionNode.javaindex 5d0e9efe22..e4f7646da1 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeMetadataAccessFunctionNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftTypeMetadataAccessFunctionNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -19,7 +19,7 @@ import ghidra.app.util.demangler.*;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#TypeMetadataAccessFunction} {@link SwiftNode}@@ -46,7 +46,7 @@ public class SwiftTypeMetadataAccessFunctionNode extends SwiftNode {}SwiftFunction function =new SwiftFunction(properties.mangled(), properties.originalDemangled(), name, namespace,- CompilerSpec.CALLING_CONVENTION_default);+ SwiftSourceLanguageSpecExtension.SWIFT_STDCALL);if (namespace instanceof DemangledDataType type) {function.setReturnType(type);}diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftUnsafeMutableAddressorNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftUnsafeMutableAddressorNode.javasimilarity index 91%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftUnsafeMutableAddressorNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftUnsafeMutableAddressorNode.javaindex 618bb88583..8eb13bc6a4 100644--- a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftUnsafeMutableAddressorNode.java+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftUnsafeMutableAddressorNode.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -20,7 +20,7 @@ import ghidra.app.util.demangler.DemangledException;import ghidra.app.util.demangler.swift.SwiftDemangledNodeKind;import ghidra.app.util.demangler.swift.SwiftDemangler;import ghidra.app.util.demangler.swift.datatypes.SwiftFunction;-import ghidra.program.model.lang.CompilerSpec;+import ghidra.app.util.sourcelanguage.SwiftSourceLanguageSpecExtension;/*** A {@link SwiftDemangledNodeKind#UnsafeMutableAddressor} {@link SwiftNode}@@ -46,6 +46,6 @@ public class SwiftUnsafeMutableAddressorNode extends SwiftNode {return getUnknown();}return new SwiftFunction(properties.mangled(), properties.originalDemangled(), name,- namespace, CompilerSpec.CALLING_CONVENTION_default);+ namespace, SwiftSourceLanguageSpecExtension.SWIFT_STDCALL);}}diff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftUnsupportedNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftUnsupportedNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftUnsupportedNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftUnsupportedNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftVariableNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftVariableNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftVariableNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/SwiftVariableNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericDescriptorNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericDescriptorNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericDescriptorNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericDescriptorNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericIndexNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericIndexNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericIndexNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericIndexNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericPassthroughNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericPassthroughNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericPassthroughNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericPassthroughNode.javadiff --git a/Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericTextNode.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericTextNode.javasimilarity index 100%rename from Ghidra/Features/SwiftDemangler/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericTextNode.javarename to Ghidra/Features/Swift/src/main/java/ghidra/app/util/demangler/swift/nodes/generic/SwiftGenericTextNode.javadiff --git a/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/ElfSwiftSourceLanguage.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/ElfSwiftSourceLanguage.javanew file mode 100644index 0000000000..805c57054c--- /dev/null+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/ElfSwiftSourceLanguage.java@@ -0,0 +1,39 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.util.Arrays;++import ghidra.app.util.opinion.ElfLoader;+import ghidra.program.model.listing.Program;+import ghidra.program.model.mem.MemoryBlock;+import ghidra.util.task.TaskMonitor;++/**+ * The Elf Swift {@link SourceLanguage} class+ */+public class ElfSwiftSourceLanguage extends SwiftSourceLanguage {++ @Override+ public boolean existsIn(Program program, TaskMonitor monitor) {+ if (!program.getExecutableFormat().equals(ElfLoader.ELF_NAME)) {+ return false;+ }+ return Arrays.stream(program.getMemory().getBlocks())+ .map(MemoryBlock::getName)+ .anyMatch(name -> name.startsWith("swift"));+ }+}diff --git a/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/MachoSwiftSourceLanguage.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/MachoSwiftSourceLanguage.javanew file mode 100644index 0000000000..d5384c8704--- /dev/null+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/MachoSwiftSourceLanguage.java@@ -0,0 +1,39 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.util.Arrays;++import ghidra.app.util.opinion.MachoLoader;+import ghidra.program.model.listing.Program;+import ghidra.program.model.mem.MemoryBlock;+import ghidra.util.task.TaskMonitor;++/**+ * The Mach-O Swift {@link SourceLanguage} class+ */+public class MachoSwiftSourceLanguage extends SwiftSourceLanguage {++ @Override+ public boolean existsIn(Program program, TaskMonitor monitor) {+ if (!program.getExecutableFormat().equals(MachoLoader.MACH_O_NAME)) {+ return false;+ }+ return Arrays.stream(program.getMemory().getBlocks())+ .map(MemoryBlock::getName)+ .anyMatch(name -> name.startsWith("__swift"));+ }+}diff --git a/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/PeSwiftSourceLanguage.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/PeSwiftSourceLanguage.javanew file mode 100644index 0000000000..30bb1b6006--- /dev/null+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/PeSwiftSourceLanguage.java@@ -0,0 +1,39 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.util.Arrays;++import ghidra.app.util.opinion.PeLoader;+import ghidra.program.model.listing.Program;+import ghidra.program.model.mem.MemoryBlock;+import ghidra.util.task.TaskMonitor;++/**+ * The PE Swift {@link SourceLanguage} class+ */+public class PeSwiftSourceLanguage extends SwiftSourceLanguage {++ @Override+ public boolean existsIn(Program program, TaskMonitor monitor) {+ if (!program.getExecutableFormat().equals(PeLoader.PE_NAME)) {+ return false;+ }+ return Arrays.stream(program.getMemory().getBlocks())+ .map(MemoryBlock::getName)+ .anyMatch(name -> name.startsWith(".sw5"));+ }+}diff --git a/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/SwiftSourceLanguage.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/SwiftSourceLanguage.javanew file mode 100644index 0000000000..5c19cb7388--- /dev/null+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/SwiftSourceLanguage.java@@ -0,0 +1,29 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++/**+ * The base Swift {@link SourceLanguage} class+ */+public abstract class SwiftSourceLanguage implements SourceLanguage {++ public static final SourceLanguageID SWIFT_ID = new SourceLanguageID("Swift");++ @Override+ public SourceLanguageID getID() {+ return SWIFT_ID;+ }+}diff --git a/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/SwiftSourceLanguageSpecExtension.java b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/SwiftSourceLanguageSpecExtension.javanew file mode 100644index 0000000000..b05e97b4e9--- /dev/null+++ b/Ghidra/Features/Swift/src/main/java/ghidra/app/util/sourcelanguage/SwiftSourceLanguageSpecExtension.java@@ -0,0 +1,59 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.io.FileNotFoundException;+import java.io.IOException;+import java.util.List;++import generic.jar.ResourceFile;+import ghidra.app.util.importer.MessageLog;+import ghidra.framework.Application;+import ghidra.program.database.SpecExtension;+import ghidra.program.model.listing.Program;+import ghidra.util.task.TaskMonitor;++/**+ * Swift {@link SpecExtension spec extensions}+ */+public class SwiftSourceLanguageSpecExtension implements SourceLanguageSpecExtension {++ public static final String SWIFT_STDCALL = "__swift_stdcall";+ public static final String SWIFT_THISCALL = "__swift_thiscall";++ @Override+ public SourceLanguageID getCompatibleSourceLanguage() {+ return SwiftSourceLanguage.SWIFT_ID;+ }++ @Override+ public List<SpecExtensionRule> getSpecExtensionRules(Program program, MessageLog log,+ TaskMonitor monitor) {+ final String filename = "extensions.json";+ try {+ ResourceFile extensionConfigFile = Application.getModuleDataFile(filename);+ return SpecExtensionUtils.readSpecExtensionJsonConfig(extensionConfigFile, program, log,+ monitor);+ }+ catch (FileNotFoundException e) {+ log.appendMsg("Failed to find module data file: " + filename);+ }+ catch (IOException e) {+ log.appendException(e);+ }+ return List.of();+ }+}diff --git a/Ghidra/Features/SwiftDemangler/src/test/java/ghidra/app/util/demangler/swift/SwiftDemanglerTest.java b/Ghidra/Features/Swift/src/test/java/ghidra/app/util/demangler/swift/SwiftDemanglerTest.javasimilarity index 92%rename from Ghidra/Features/SwiftDemangler/src/test/java/ghidra/app/util/demangler/swift/SwiftDemanglerTest.javarename to Ghidra/Features/Swift/src/test/java/ghidra/app/util/demangler/swift/SwiftDemanglerTest.javaindex 7ad9f33d95..fa4d065e24 100644--- a/Ghidra/Features/SwiftDemangler/src/test/java/ghidra/app/util/demangler/swift/SwiftDemanglerTest.java+++ b/Ghidra/Features/Swift/src/test/java/ghidra/app/util/demangler/swift/SwiftDemanglerTest.java@@ -197,7 +197,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {String mangled ="_$s18SwiftDemanglerTest25testJunitFunctionAndTypes_6label2___________7label14____Si_SftSiz_s4Int8Vs5Int16Vs5Int32Vs5Int64VSus5UInt8Vs6UInt16Vs6UInt32Vs6UInt64VS2fS2dSSSaySiGSbSJtF";String demangled =- "struct tuple2 default SwiftDemanglerTest::testJunitFunctionAndTypes(__int64 *,__int8 label2,__int16,__int32,__int64,unsigned __int64,unsigned __int8,unsigned __int16,unsigned __int32,unsigned __int64,float,float,double,double label14,struct Swift::String,Swift::Array<__int64>[],bool,struct Swift::Character)";+ "struct tuple2 __swift_stdcall SwiftDemanglerTest::testJunitFunctionAndTypes(__int64 *,__int8 label2,__int16,__int32,__int64,unsigned __int64,unsigned __int8,unsigned __int16,unsigned __int32,unsigned __int64,float,float,double,double label14,struct Swift::String,Swift::Array<__int64>[],bool,struct Swift::Character)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -241,7 +241,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {**********************************************************************/String mangled = "_$s18SwiftDemanglerTest11MyStructureV6label1ACSi_tcfC";String demangled =- "struct SwiftDemanglerTest::MyStructure default SwiftDemanglerTest::MyStructure::init(__int64 label1)";+ "struct SwiftDemanglerTest::MyStructure __swift_stdcall SwiftDemanglerTest::MyStructure::init(__int64 label1)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -285,7 +285,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {**********************************************************************/String mangled = "_$s18SwiftDemanglerTest11MyStructureV8myMethod6label16label2S2i_SitF";String demangled =- "__int64 default SwiftDemanglerTest::MyStructure::myMethod(__int64 label1,__int64 label2,struct SwiftDemanglerTest::MyStructure)";+ "__int64 __swift_stdcall SwiftDemanglerTest::MyStructure::myMethod(__int64 label1,__int64 label2,struct SwiftDemanglerTest::MyStructure)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -311,7 +311,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {**********************************************************************/String mangled = "_$s18SwiftDemanglerTest11MyStructureV1zSivg";String demangled =- "__int64 default SwiftDemanglerTest::MyStructure::get_z(struct SwiftDemanglerTest::MyStructure)";+ "__int64 __swift_stdcall SwiftDemanglerTest::MyStructure::get_z(struct SwiftDemanglerTest::MyStructure)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -336,7 +336,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {SwiftDemanglerTest.MyStructure.z.setter : Swift.Int**********************************************************************/String mangled = "_$s18SwiftDemanglerTest11MyStructureV1zSivs";- String demangled = "__thiscall SwiftDemanglerTest::MyStructure::set_z(__int64)";+ String demangled = "__swift_thiscall SwiftDemanglerTest::MyStructure::set_z(__int64)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -370,7 +370,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {**********************************************************************/String mangled = "_$s18SwiftDemanglerTest11MyStructureVyS2icig";String demangled =- "__int64 default SwiftDemanglerTest::MyStructure::get_subscript(__int64,struct SwiftDemanglerTest::MyStructure)";+ "__int64 __swift_stdcall SwiftDemanglerTest::MyStructure::get_subscript(__int64,struct SwiftDemanglerTest::MyStructure)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -404,7 +404,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {**********************************************************************/String mangled = "_$s18SwiftDemanglerTest11MyStructureVyS2icis";String demangled =- "__int64 __thiscall SwiftDemanglerTest::MyStructure::set_subscript(__int64)";+ "__int64 __swift_thiscall SwiftDemanglerTest::MyStructure::set_subscript(__int64)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -425,7 +425,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {**********************************************************************/String mangled = "_$s18SwiftDemanglerTest7MyClassCMa";String demangled =- "class SwiftDemanglerTest::MyClass * default SwiftDemanglerTest::MyClass::typeMetadataAccessor(void)";+ "class SwiftDemanglerTest::MyClass * __swift_stdcall SwiftDemanglerTest::MyClass::typeMetadataAccessor(void)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -462,7 +462,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {**********************************************************************/String mangled = "_$s18SwiftDemanglerTest7MyClassC6label1ACSi_tcfC";String demangled =- "class SwiftDemanglerTest::MyClass * __thiscall SwiftDemanglerTest::MyClass::__allocating_init(__int64 label1)";+ "class SwiftDemanglerTest::MyClass * __swift_thiscall SwiftDemanglerTest::MyClass::__allocating_init(__int64 label1)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -499,7 +499,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {**********************************************************************/String mangled = "_$s18SwiftDemanglerTest7MyClassC6label1ACSi_tcfc";String demangled =- "class SwiftDemanglerTest::MyClass * __thiscall SwiftDemanglerTest::MyClass::init(__int64 label1)";+ "class SwiftDemanglerTest::MyClass * __swift_thiscall SwiftDemanglerTest::MyClass::init(__int64 label1)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -543,7 +543,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {**********************************************************************/String mangled = "_$s18SwiftDemanglerTest7MyClassC8myMethod6label16label2S2i_SitF";String demangled =- "__int64 __thiscall SwiftDemanglerTest::MyClass::myMethod(__int64 label1,__int64 label2)";+ "__int64 __swift_thiscall SwiftDemanglerTest::MyClass::myMethod(__int64 label1,__int64 label2)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -569,7 +569,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {**********************************************************************/String mangled = "_$s18SwiftDemanglerTest7MyClassC1zSivg";String demangled =- "__int64 __thiscall SwiftDemanglerTest::MyClass::get_z(class SwiftDemanglerTest::MyClass *)";+ "__int64 __swift_thiscall SwiftDemanglerTest::MyClass::get_z(class SwiftDemanglerTest::MyClass *)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -594,7 +594,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {SwiftDemanglerTest.MyClass.z.setter : Swift.Int**********************************************************************/String mangled = "_$s18SwiftDemanglerTest7MyClassC1zSivs";- String demangled = "__thiscall SwiftDemanglerTest::MyClass::set_z(__int64)";+ String demangled = "__swift_thiscall SwiftDemanglerTest::MyClass::set_z(__int64)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -619,7 +619,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {SwiftDemanglerTest.MyClass.z.modify : Swift.Int**********************************************************************/String mangled = "_$s18SwiftDemanglerTest7MyClassC1zSivM";- String demangled = "__thiscall SwiftDemanglerTest::MyClass::modify_z(__int64)";+ String demangled = "__swift_thiscall SwiftDemanglerTest::MyClass::modify_z(__int64)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -638,7 +638,8 @@ public class SwiftDemanglerTest extends AbstractGenericTest {SwiftDemanglerTest.MyClass.__deallocating_deinit**********************************************************************/String mangled = "_$s18SwiftDemanglerTest7MyClassCfD";- String demangled = "__thiscall SwiftDemanglerTest::MyClass::__deallocating_init(void)";+ String demangled =+ "__swift_thiscall SwiftDemanglerTest::MyClass::__deallocating_init(void)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -658,7 +659,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {**********************************************************************/String mangled = "_$s18SwiftDemanglerTest7MyClassCfd";String demangled =- "class SwiftDemanglerTest::MyClass * __thiscall SwiftDemanglerTest::MyClass::deinit(void)";+ "class SwiftDemanglerTest::MyClass * __swift_thiscall SwiftDemanglerTest::MyClass::deinit(void)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");@@ -696,7 +697,7 @@ public class SwiftDemanglerTest extends AbstractGenericTest {**********************************************************************/String mangled = "_$s18SwiftDemanglerTest16MyAssociatedEnumO8myMethod6label1ACSi_tF";String demangled =- "struct SwiftDemanglerTest::MyAssociatedEnum default SwiftDemanglerTest::MyAssociatedEnum::myMethod(__int64 label1,struct SwiftDemanglerTest::MyAssociatedEnum,undefined)";+ "struct SwiftDemanglerTest::MyAssociatedEnum __swift_stdcall SwiftDemanglerTest::MyAssociatedEnum::myMethod(__int64 label1,struct SwiftDemanglerTest::MyAssociatedEnum,undefined)";if (!(demangler.demangle(mangled) instanceof DemangledFunction function)) {throw new AssertException("Demangled object is not a function");diff --git a/Ghidra/Features/SwiftDemangler/certification.manifest b/Ghidra/Features/SwiftDemangler/certification.manifestdeleted file mode 100644index 6841c5219a..0000000000--- a/Ghidra/Features/SwiftDemangler/certification.manifest+++ /dev/null@@ -1,3 +0,0 @@-##VERSION: 2.0-Module.manifest||GHIDRA||||END|-README.md||GHIDRA||||END|diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/DataArchiveUtils.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/DataArchiveUtils.javanew file mode 100644index 0000000000..7ea870c242--- /dev/null+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/DataArchiveUtils.java@@ -0,0 +1,79 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.io.*;+import java.util.ArrayList;+import java.util.List;++import com.google.gson.Gson;+import com.google.gson.stream.JsonReader;++import generic.jar.ResourceFile;+import ghidra.app.util.importer.MessageLog;+import ghidra.app.util.sourcelanguage.SourceLanguageDataArchive.DataArchiveRule;+import ghidra.app.util.sourcelanguage.SourceLanguageSpecExtension.SpecExtensionRule;+import ghidra.program.database.SpecExtension;+import ghidra.program.model.listing.Program;+import ghidra.util.task.TaskMonitor;++public class DataArchiveUtils {++ /**+ * An entry from a spec extension JSON configuration file+ *+ * @param processor The name of the processor (could be empty/null for wildcard)+ * @param endian The processor endianness ("little" or "big") (could be empty/null for wildcard)+ * @param size The processor size (i.e., "32, "64", etc) (could be empty/null for wildcard)+ * @param variant The processor variant (could be empty/null for wildcard)+ * @param formats The names of the binary file formats (could be empty/null for wildcard)+ * @param file The file path (relative to the JSON configuration file) of the data archive file+ * to add+ */+ private record JsonEntry(String processor, String endian, String size, String variant,+ List<String> formats, String file) {}++ /**+ * {@return a {@link List} of {@link SpecExtensionRule}s based on the given JSON configuration+ * file+ *+ * @param jsonFile The JSON configuration file+ * @param program The {@link Program}+ * @param log The error log+ * @param monitor The monitor+ * @throws IOException if there was a problem reading the JSON configuration file or the+ * {@link SpecExtension} XML files it references+ */+ public static List<DataArchiveRule> readDataArchiveJsonConfig(ResourceFile jsonFile,+ Program program, MessageLog log, TaskMonitor monitor) throws IOException {+ List<DataArchiveRule> ret = new ArrayList<>();+ try (JsonReader reader = new JsonReader(new InputStreamReader(jsonFile.getInputStream()))) {+ JsonEntry[] entries = new Gson().fromJson(reader, JsonEntry[].class);+ if (entries == null) {+ throw new EOFException(jsonFile + " was at end of file");+ }+ for (JsonEntry entry : entries) {+ if (entry == null) {+ continue;+ }+ ResourceFile file = new ResourceFile(jsonFile.getParentFile(), entry.file());+ ret.add(new DataArchiveRule(entry.processor(), entry.endian(), entry.size(),+ entry.variant(), entry.formats(), file));+ }+ }+ return ret;+ }+}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguage.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguage.javanew file mode 100644index 0000000000..c9f1923c58--- /dev/null+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguage.java@@ -0,0 +1,45 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.io.IOException;++import ghidra.program.model.listing.Program;+import ghidra.util.classfinder.ExtensionPoint;+import ghidra.util.exception.CancelledException;+import ghidra.util.task.TaskMonitor;++/**+ * An {@link ExtensionPoint} to dynamically support source language-specific features+ */+public interface SourceLanguage extends ExtensionPoint {++ /**+ * {@return the {@link SourceLanguageID ID} of the source language}+ */+ public SourceLanguageID getID();++ /**+ * {@return true if the source language exists in the given {@link Program}; otherwise false}+ *+ * @param program The {@link Program}+ * @param monitor The {@link TaskMonitor}+ * @throws IOException if an IO-related error occurred+ * @throws CancelledException if the user cancelled the operation+ */+ public boolean existsIn(Program program, TaskMonitor monitor)+ throws IOException, CancelledException;+}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguageDataArchive.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguageDataArchive.javanew file mode 100644index 0000000000..4c67064f16--- /dev/null+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguageDataArchive.java@@ -0,0 +1,61 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.util.List;++import generic.jar.ResourceFile;+import ghidra.app.util.importer.MessageLog;+import ghidra.program.model.listing.Program;+import ghidra.util.classfinder.ExtensionPoint;+import ghidra.util.task.TaskMonitor;++/**+ * An {@link ExtensionPoint} to dynamically support source language-specific data archives+ */+public interface SourceLanguageDataArchive extends ExtensionPoint {++ /**+ * Processor-related attributes that form conditions for applying the given data archive+ * contents to a program+ *+ * @param processor The name of the processor (required)+ * @param endian The processor endianness ("little" or "big") (could be empty/null for wildcard)+ * @param size The processor size (i.e., "32, "64", etc) (could be empty/null for wildcard)+ * @param variant The processor variant (could be empty/null for wildcard)+ * @param formats The names of the supported binary file formats (could be empty/null for+ * wildcard)+ * @param dataArchiveFile The data archive file+ */+ public record DataArchiveRule(String processor, String endian, String size, String variant,+ List<String> formats, ResourceFile dataArchiveFile) {}++ /**+ * {@return the {@link SourceLanguageID} of the source language this+ * {@link SourceLanguageDataArchive} is compatible with}+ */+ public SourceLanguageID getCompatibleSourceLanguage();++ /**+ * {@return the source language's {@link DataArchiveRule}s}+ *+ * @param program The {@link Program}+ * @param log The error log+ * @param monitor The {@link TaskMonitor}+ */+ public List<DataArchiveRule> getDataArchiveRules(Program program, MessageLog log,+ TaskMonitor monitor);+}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguageID.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguageID.javanew file mode 100644index 0000000000..303ef3645e--- /dev/null+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguageID.java@@ -0,0 +1,83 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.util.Objects;+import java.util.regex.Pattern;++import org.apache.commons.lang3.StringUtils;++/**+ * Represents a {@link SourceLanguage source language}'s ID+ */+public class SourceLanguageID implements Comparable<SourceLanguageID> {++ private static final Pattern VALID_ID_PATTERN = Pattern.compile("^[a-zA-Z0-9_.-]+$");++ private final String id;++ /**+ * Creates a new {@link SourceLanguageID}.+ * <p>+ * An ID must not be blank or contain commas.+ *+ * @param id The {@link SourceLanguage}'s ID+ * @throws IllegalArgumentException if the ID blank, null, or contains commas+ */+ public SourceLanguageID(String id) {+ if (StringUtils.isBlank(id)) {+ throw new IllegalArgumentException("Source language 'id' cannot be null or blank");+ }+ if (!VALID_ID_PATTERN.matcher(id).matches()) {+ throw new IllegalArgumentException(+ "Source language 'id' does not match regex: " + VALID_ID_PATTERN);+ }+ this.id = id;+ }++ /**+ * {@return the {@link SourceLanguage} ID as a string}+ */+ public String getIdAsString() {+ return id;+ }++ @Override+ public String toString() {+ return id;+ }++ @Override+ public int compareTo(SourceLanguageID o) {+ return id.compareTo(o.id);+ }++ @Override+ public int hashCode() {+ return Objects.hash(id);+ }++ @Override+ public boolean equals(Object obj) {+ if (this == obj) {+ return true;+ }+ if (!(obj instanceof SourceLanguageID other)) {+ return false;+ }+ return Objects.equals(id, other.id);+ }+}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguageService.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguageService.javanew file mode 100644index 0000000000..94a823777c--- /dev/null+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguageService.java@@ -0,0 +1,225 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.io.IOException;+import java.util.*;++import org.apache.commons.collections4.CollectionUtils;+import org.apache.commons.lang3.StringUtils;++import generic.jar.ResourceFile;+import ghidra.app.util.importer.MessageLog;+import ghidra.app.util.sourcelanguage.SourceLanguageDataArchive.DataArchiveRule;+import ghidra.app.util.sourcelanguage.SourceLanguageSpecExtension.SpecExtensionRule;+import ghidra.program.database.SpecExtension;+import ghidra.program.database.SpecExtension.DocInfo;+import ghidra.program.model.lang.LanguageDescription;+import ghidra.program.model.listing.Program;+import ghidra.util.classfinder.ClassSearcher;+import ghidra.util.classfinder.ExtensionPoint;+import ghidra.util.exception.CancelledException;+import ghidra.util.task.TaskMonitor;++/**+ * A service for applying source language-related {@link ExtensionPoint}s to a {@link Program}+ */+public class SourceLanguageService {++ /**+ * Finds any {@link SourceLanguage}s that+ * {@link SourceLanguage#existsIn(Program, TaskMonitor) exist in} the given program, and+ * returns their {@link SourceLanguageID}s.+ * <p>+ * NOTE: This method does a fresh scan using+ * {@link SourceLanguage#existsIn(Program, TaskMonitor)} and does not check+ * {@link Program#getSourceLanguageIDs()}, so it may be slow.+ *+ * @param program The {@link Program}+ * @param log The error log+ * @param monitor The {@link TaskMonitor}+ * @return The {@link SourceLanguageID}s of the found {@link SourceLanguage}s+ * @throws CancelledException if the user cancelled the operation+ */+ public static Set<SourceLanguageID> find(Program program, MessageLog log, TaskMonitor monitor)+ throws CancelledException {+ Set<SourceLanguageID> foundSet = new HashSet<>();+ for (SourceLanguage sourceLanguage : ClassSearcher.getInstances(SourceLanguage.class)) {+ monitor.checkCancelled();+ SourceLanguageID id = sourceLanguage.getID();+ if (foundSet.contains(id)) {+ continue;+ }+ try {+ if (sourceLanguage.existsIn(program, monitor)) {+ foundSet.add(id);+ }+ }+ catch (IOException e) {+ log.appendMsg("Problem checking for %s in %s: %s".formatted(id, program.getName(),+ e.getMessage()));+ }+ }+ return foundSet;+ }++ /**+ * Adds any {@link SourceLanguageSpecExtension}s that are compatible with the given set of+ * {@link SourceLanguageID}s to the {@link Program}+ *+ * @param program The {@link Program}+ * @param sourceLanguageIDs The {@link SourceLanguageID}s+ * @param log The error log+ * @param monitor The {@link TaskMonitor}+ */+ public static void addSpecExtensions(Program program, Set<SourceLanguageID> sourceLanguageIDs,+ MessageLog log, TaskMonitor monitor) {+ for (SourceLanguageSpecExtension slse : ClassSearcher+ .getInstances(SourceLanguageSpecExtension.class)) {+ if (!sourceLanguageIDs.contains(slse.getCompatibleSourceLanguage())) {+ continue;+ }+ for (SpecExtensionRule rule : slse.getSpecExtensionRules(program, log, monitor)) {+ try {+ processSpecExtensionRule(rule, program, log, monitor);+ }+ catch (Exception e) {+ log.appendMsg("Failed to process spec extension: " + e.getMessage());+ }+ }+ }+ }++ /**+ * Processes a single {@link SpecExtensionRule} and adds the spec extension it defines to the+ * given {@link Program}+ *+ * @param rule The {@link SpecExtensionRule} to process+ * @param program The {@link Program}+ * @param log The error log+ * @param monitor The {@link TaskMonitor}+ * @return True if a spec extension was added to the {@link Program}; otherwise, false+ * @throws Exception if there was a problem processing the {@link SpecExtensionRule}+ */+ private static boolean processSpecExtensionRule(SpecExtensionRule rule, Program program,+ MessageLog log, TaskMonitor monitor) throws Exception {+ LanguageDescription desc = program.getLanguageCompilerSpecPair().getLanguageDescription();+ String programProcessor = desc.getProcessor().toString();+ String programEndian = desc.getEndian().toString();+ String programSize = Integer.toString(desc.getSize());+ String programVariant = desc.getVariant();+ String programFormat = program.getExecutableFormat();++ if (!rule.processor().equals(programProcessor)) {+ return false;+ }+ if (!StringUtils.isEmpty(rule.endian()) && !rule.endian().equals(programEndian)) {+ return false;+ }+ if (!StringUtils.isEmpty(rule.size()) && !rule.size().equals(programSize)) {+ return false;+ }+ if (!StringUtils.isEmpty(rule.variant()) && !rule.variant().equals(programVariant)) {+ return false;+ }+ if (!CollectionUtils.isEmpty(rule.formats()) &&+ rule.formats().stream().noneMatch(programFormat::equals)) {+ return false;+ }++ SpecExtension specExtension = new SpecExtension(program);+ String xml = rule.contents();+ DocInfo docInfo = specExtension.testExtensionDocument(xml);+ if (SpecExtension.getCompilerSpecExtension(program, docInfo) == null) {+ specExtension.addReplaceCompilerSpecExtension(xml, monitor);+ }+ return true;+ }++ /**+ * Adds any {@link SourceLanguageDataArchive}s that are compatible with the given set of+ * {@link SourceLanguageID}s to the {@link Program}+ *+ * @param program The {@link Program}+ * @param sourceLanguageIDs The {@link SourceLanguage}+ * @param log The error log+ * @param monitor The {@link TaskMonitor}+ * @return The number of data archives that were added to the {@link Program}+ */+ public static List<ResourceFile> getDataArchives(Program program,+ Set<SourceLanguageID> sourceLanguageIDs, MessageLog log, TaskMonitor monitor) {+ List<ResourceFile> ret = new ArrayList<>();+ for (SourceLanguageDataArchive slda : ClassSearcher+ .getInstances(SourceLanguageDataArchive.class)) {+ if (!sourceLanguageIDs.contains(slda.getCompatibleSourceLanguage())) {+ continue;+ }+ for (DataArchiveRule rule : slda.getDataArchiveRules(program, log, monitor)) {+ try {+ ResourceFile file = processDataArchiveRule(rule, program, log, monitor);+ if (file != null) {+ ret.add(file);+ }+ }+ catch (Exception e) {+ log.appendMsg("Failed to process data archive: " + e.getMessage());+ }+ }+ }+ return ret;+ }++ /**+ * Processes a single {@link DataArchiveRule} and returns the data archive file if the archive+ * should be applied to the program+ *+ * @param rule The {@link DataArchiveRule} to process+ * @param program The {@link Program}+ * @param log The error log+ * @param monitor The {@link TaskMonitor}+ * @return The data archive file that should be applied to the program, or {@code null} if+ * it should not be applied+ * @throws Exception if there was a problem processing the {@link DataArchiveRule}+ */+ private static ResourceFile processDataArchiveRule(DataArchiveRule rule, Program program,+ MessageLog log, TaskMonitor monitor) throws Exception {+ LanguageDescription desc = program.getLanguageCompilerSpecPair().getLanguageDescription();+ String programProcessor = desc.getProcessor().toString();+ String programEndian = desc.getEndian().toString();+ String programSize = Integer.toString(desc.getSize());+ String programVariant = desc.getVariant();+ String programFormat = program.getExecutableFormat();++ if (!StringUtils.isEmpty(rule.processor()) && !rule.processor().equals(programProcessor)) {+ return null;+ }+ if (!StringUtils.isEmpty(rule.endian()) && !rule.endian().equals(programEndian)) {+ return null;+ }+ if (!StringUtils.isEmpty(rule.size()) && !rule.size().equals(programSize)) {+ return null;+ }+ if (!StringUtils.isEmpty(rule.variant()) && !rule.variant().equals(programVariant)) {+ return null;+ }+ if (!CollectionUtils.isEmpty(rule.formats()) &&+ rule.formats().stream().noneMatch(programFormat::equals)) {+ return null;+ }++ return rule.dataArchiveFile();+ }+}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguageSpecExtension.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguageSpecExtension.javanew file mode 100644index 0000000000..77aad0b26a--- /dev/null+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SourceLanguageSpecExtension.java@@ -0,0 +1,62 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.util.List;++import ghidra.app.util.importer.MessageLog;+import ghidra.program.database.SpecExtension;+import ghidra.program.model.listing.Program;+import ghidra.util.classfinder.ExtensionPoint;+import ghidra.util.task.TaskMonitor;++/**+ * An {@link ExtensionPoint} to dynamically support source language-specific+ * {@link SpecExtension spec extensions}+ */+public interface SourceLanguageSpecExtension extends ExtensionPoint {++ /**+ * Processor-related attributes that form conditions for applying the given spec extension+ * contents to a program+ *+ * @param processor The name of the processor (required)+ * @param endian The processor endianness ("little" or "big") (could be empty/null for wildcard)+ * @param size The processor size (i.e., "32, "64", etc) (could be empty/null for wildcard)+ * @param variant The processor variant (could be empty/null for wildcard)+ * @param formats The names of the supported binary file formats (could be empty/null for+ * wildcard)+ * @param contents The contents of the {@link SpecExtension}, which is currently always XML+ */+ public record SpecExtensionRule(String processor, String endian, String size, String variant,+ List<String> formats, String contents) {}++ /**+ * {@return the {@link SourceLanguageID} of the source language this+ * {@link SourceLanguageSpecExtension} is compatible with}+ */+ public SourceLanguageID getCompatibleSourceLanguage();++ /**+ * {@return the source language's {@link SpecExtensionRule}s}+ *+ * @param program The {@link Program}+ * @param log The error log+ * @param monitor The {@link TaskMonitor}+ */+ public List<SpecExtensionRule> getSpecExtensionRules(Program program, MessageLog log,+ TaskMonitor monitor);+}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SpecExtensionUtils.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SpecExtensionUtils.javanew file mode 100644index 0000000000..237f201752--- /dev/null+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/sourcelanguage/SpecExtensionUtils.java@@ -0,0 +1,107 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.app.util.sourcelanguage;++import java.io.*;+import java.util.*;++import com.google.gson.Gson;+import com.google.gson.stream.JsonReader;++import generic.jar.ResourceFile;+import ghidra.app.util.importer.MessageLog;+import ghidra.app.util.sourcelanguage.SourceLanguageSpecExtension.SpecExtensionRule;+import ghidra.program.database.SpecExtension;+import ghidra.program.model.listing.Program;+import ghidra.util.task.TaskMonitor;++public class SpecExtensionUtils {++ /**+ * An entry from a spec extension JSON configuration file+ *+ * @param processor The name of the processor (required)+ * @param endian The processor endianness ("little" or "big") (could be empty/null for wildcard)+ * @param size The processor size (i.e., "32, "64", etc) (could be empty/null for wildcard)+ * @param variant The processor variant (could be empty/null for wildcard)+ * @param formats The names of the binary file formats (could be empty/null for wildcard)+ * @param directory The directory path (relative to the JSON configuration file) of the spec+ * extension files to add+ */+ private record JsonEntry(String processor, String endian, String size, String variant,+ List<String> formats, String directory) {}+++ /**+ * {@return the given {@link SpecExtension} XML file's contents}+ *+ * @param xmlFile A {@link SpecExtension} XML file+ * @throws IOException if there was a problem reading the XML file+ */+ public static String readSpecExtensionXmlFile(ResourceFile xmlFile) throws IOException {+ return new String(xmlFile.getInputStream().readAllBytes());+ }++ /**+ * {@return a {@link List} of {@link SpecExtension} XML file contents found in the given+ * directory}+ *+ * @param dir A directory containing {@link SpecExtension} XML files+ * @throws IOException if there was a problem reading the XML files+ */+ public static List<String> readSpecExtensionDir(ResourceFile dir) throws IOException {+ List<String> ret = new ArrayList<>();+ ResourceFile[] files = Objects.requireNonNullElse(dir.listFiles(), new ResourceFile[0]);+ for (ResourceFile f : files) {+ ret.add(readSpecExtensionXmlFile(f));+ }+ return ret;+ }++ /**+ * {@return a {@link List} of {@link SpecExtensionRule}s based on the given JSON configuration+ * file+ *+ * @param jsonFile The JSON configuration file+ * @param program The {@link Program}+ * @param log The error log+ * @param monitor The monitor+ * @throws IOException if there was a problem reading the JSON configuration file or the+ * {@link SpecExtension} XML files it references+ */+ public static List<SpecExtensionRule> readSpecExtensionJsonConfig(ResourceFile jsonFile,+ Program program, MessageLog log, TaskMonitor monitor) throws IOException {+ List<SpecExtensionRule> ret = new ArrayList<>();+ try (JsonReader reader = new JsonReader(new InputStreamReader(jsonFile.getInputStream()))) {+ JsonEntry[] entries = new Gson().fromJson(reader, JsonEntry[].class);+ if (entries == null) {+ throw new EOFException(jsonFile + " was at end of file");+ }+ for (JsonEntry entry : entries) {+ if (entry == null) {+ continue;+ }+ ResourceFile dir = new ResourceFile(jsonFile.getParentFile(), entry.directory());+ List<String> specExtensionXmls = readSpecExtensionDir(dir);+ for (String xml : specExtensionXmls) {+ ret.add(new SpecExtensionRule(entry.processor(), entry.endian(),+ entry.size(), entry.variant(), entry.formats(), xml));+ }+ }+ }+ return ret;+ }+}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/ProgramDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/ProgramDB.javaindex e54be07605..e3bee45402 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/ProgramDB.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/ProgramDB.java@@ -18,12 +18,14 @@ package ghidra.program.database;import java.io.IOException;import java.math.BigInteger;import java.util.*;+import java.util.stream.Collectors;import org.apache.commons.lang3.StringUtils;import db.DBHandle;import ghidra.app.plugin.processors.generic.LanguageFixupUtil;import ghidra.app.plugin.processors.sleigh.SleighLanguage;+import ghidra.app.util.sourcelanguage.SourceLanguageID;import ghidra.framework.Application;import ghidra.framework.data.DomainObjectAdapterDB;import ghidra.framework.data.OpenMode;@@ -162,6 +164,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeMprivate static final String EXECUTE_PATH = "Execute Path";private static final String EXECUTE_FORMAT = "Execute Format";private static final String IMAGE_OFFSET = "Image Offset";+ private static final String SOURCE_LANGUAGES = "Source Languages";//// The numbering of managers controls the order in which they are notified.@@ -643,6 +646,28 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeMpl.setString(COMPILER, compiler);}+ @Override+ public Set<SourceLanguageID> getSourceLanguageIDs() {+ Set<SourceLanguageID> ret = new HashSet<>();+ String value = getOptions(PROGRAM_INFO).getString(SOURCE_LANGUAGES, "");+ for (String entry : value.split(",")) {+ entry = entry.trim();+ if (!entry.isEmpty()) {+ ret.add(new SourceLanguageID(entry));+ }+ }+ return ret;+ }++ @Override+ public void setSourceLanguageIDs(Set<SourceLanguageID> sourceLanguageIDs) {+ String combined = sourceLanguageIDs.stream()+ .map(SourceLanguageID::getIdAsString)+ .sorted()+ .collect(Collectors.joining(", "));+ getOptions(PROGRAM_INFO).setString(SOURCE_LANGUAGES, combined);+ }+@Overridepublic CategoryPath getPreferredRootNamespaceCategoryPath() {return preferredRootNamespaceCategory;diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/Program.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/Program.javaindex 792c82ecdf..71b0c75ecb 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/Program.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/Program.java@@ -16,7 +16,9 @@package ghidra.program.model.listing;import java.util.Date;+import java.util.Set;+import ghidra.app.util.sourcelanguage.SourceLanguageID;import ghidra.framework.store.LockException;import ghidra.program.database.IntRangeMap;import ghidra.program.database.ProgramOverlayAddressSpace;@@ -179,6 +181,22 @@ public interface Program extends DataTypeManagerDomainObject, ProgramArchitectur*/public void setCompiler(String compiler);+ /**+ * {@return the {@link SourceLanguageID}s of the source languages found in the program}+ */+ default public Set<SourceLanguageID> getSourceLanguageIDs() {+ return Set.of();+ }++ /**+ * Sets the {@link SourceLanguageID}s of the source languages found in the program+ *+ * @param sourceLanguageIDs The {@link Set} of {@link SourceLanguageID}s+ */+ default public void setSourceLanguageIDs(Set<SourceLanguageID> sourceLanguageIDs) {+ throw new UnsupportedOperationException();+ }+/*** Gets the preferred root data type category path which corresponds* to the global namespace of a namespace-based storage area. Preferencediff --git a/Ghidra/Processors/AARCH64/certification.manifest b/Ghidra/Processors/AARCH64/certification.manifestindex 28010dca3d..824c6bcf3f 100644--- a/Ghidra/Processors/AARCH64/certification.manifest+++ b/Ghidra/Processors/AARCH64/certification.manifest@@ -2,14 +2,6 @@Module.manifest||GHIDRA||||END|README.md||GHIDRA||||END|data/aarch64-pltThunks.xml||GHIDRA||||END|-data/extensions/objc/chkstk_darwin_fixup.xml||GHIDRA||||END|-data/extensions/objc/objc_getProperty_fixup.xml||GHIDRA||||END|-data/extensions/objc/objc_load_fixup.xml||GHIDRA||||END|-data/extensions/objc/objc_msgSend_stub.xml||GHIDRA||||END|-data/extensions/objc/objc_release_fixup.xml||GHIDRA||||END|-data/extensions/objc/objc_retain_fixup.xml||GHIDRA||||END|-data/extensions/objc/objc_setProperty_fixup.xml||GHIDRA||||END|-data/extensions/objc/objc_store_fixup.xml||GHIDRA||||END|data/languages/AARCH64.cspec||GHIDRA||||END|data/languages/AARCH64.dwarf||GHIDRA||||END|data/languages/AARCH64.ldefs||GHIDRA||||END|@@ -24,7 +16,6 @@ data/languages/AARCH64_base_PACoptions.sinc||GHIDRA||||END|data/languages/AARCH64_golang.cspec||GHIDRA||||END|data/languages/AARCH64_golang.register.info||GHIDRA||||END|data/languages/AARCH64_ilp32.cspec||GHIDRA||||END|-data/languages/AARCH64_swift.cspec||GHIDRA||||END|data/languages/AARCH64_win.cspec||GHIDRA||||END|data/languages/AARCH64base.sinc||GHIDRA||||END|data/languages/AARCH64instructions.sinc||GHIDRA||||END|diff --git a/Ghidra/Processors/AARCH64/data/languages/AARCH64.ldefs b/Ghidra/Processors/AARCH64/data/languages/AARCH64.ldefsindex 633ec3d451..58bb44108b 100644--- a/Ghidra/Processors/AARCH64/data/languages/AARCH64.ldefs+++ b/Ghidra/Processors/AARCH64/data/languages/AARCH64.ldefs@@ -13,7 +13,6 @@<compiler name="default" spec="AARCH64.cspec" id="default"/><compiler name="Visual Studio" spec="AARCH64_win.cspec" id="windows"/><compiler name="golang" spec="AARCH64_golang.cspec" id="golang"/>- <compiler name="Swift" spec="AARCH64_swift.cspec" id="swift"/><external_name tool="gnu" name="aarch64"/><external_name tool="DWARF.register.mapping.file" name="AARCH64.dwarf"/><external_name tool="Golang.register.info.file" name="AARCH64_golang.register.info"/>diff --git a/Ghidra/Processors/AARCH64/data/languages/AARCH64.opinion b/Ghidra/Processors/AARCH64/data/languages/AARCH64.opinionindex 2655181d5e..c8beb91ba8 100644--- a/Ghidra/Processors/AARCH64/data/languages/AARCH64.opinion+++ b/Ghidra/Processors/AARCH64/data/languages/AARCH64.opinion@@ -8,16 +8,10 @@<constraint loader="Executable and Linking Format (ELF)" compilerSpecID="golang"><constraint primary="183" secondary="golang" processor="AARCH64" endian="little" size="64" variant="v8A" /></constraint>- <constraint loader="Executable and Linking Format (ELF)" compilerSpecID="swift">- <constraint primary="183" secondary="swift" processor="AARCH64" endian="little" size="64" variant="v8A" />- </constraint><constraint loader="Mac OS X Mach-O" compilerSpecID="default"><constraint primary="16777228" processor="AARCH64" endian="little" size="64" variant="AppleSilicon" /><constraint primary="33554444" processor="AARCH64" endian="little" size="32" variant="ilp32" /></constraint>- <constraint loader="Mac OS X Mach-O" compilerSpecID="swift">- <constraint primary="16777228" secondary="swift" processor="AARCH64" endian="little" size="64" variant="AppleSilicon" />- </constraint><constraint loader="Mac OS X Mach-O" compilerSpecID="golang"><constraint primary="16777228" secondary="golang" processor="AARCH64" endian="little" size="64" variant="AppleSilicon" /></constraint>diff --git a/Ghidra/Processors/AARCH64/data/languages/AARCH64_swift.cspec b/Ghidra/Processors/AARCH64/data/languages/AARCH64_swift.cspecdeleted file mode 100644index a78ec35644..0000000000--- a/Ghidra/Processors/AARCH64/data/languages/AARCH64_swift.cspec+++ /dev/null@@ -1,393 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>--<compiler_spec>- <data_organization>- <absolute_max_alignment value="0" />- <machine_alignment value="4" />- <default_alignment value="2" />- <default_pointer_alignment value="8" />- <pointer_size value="8" />- <wchar_size value="4" />- <short_size value="2" />- <integer_size value="4" />- <long_size value="8" />- <long_long_size value="8" />- <float_size value="4" />- <double_size value="8" />- <long_double_size value="8" />- <size_alignment_map>- <entry size="1" alignment="1" />- <entry size="2" alignment="2" />- <entry size="4" alignment="4" />- <entry size="8" alignment="8" />- </size_alignment_map>- </data_organization>-- <global>- <range space="ram"/>- </global>-- <stackpointer register="sp" space="ram"/>- <funcptr align="4"/> <!-- Function pointers are word aligned and leastsig bit may encode otherstuff -->-- <prefersplit style="inhalf">- <register name="q0"/>- <register name="q1"/>- <register name="q2"/>- <register name="q3"/>- <register name="q4"/>- <register name="q5"/>- <register name="q6"/>- <register name="q7"/>- <register name="q8"/>- <register name="q9"/>- <register name="q10"/>- <register name="q11"/>- <register name="q12"/>- <register name="q13"/>- <register name="q14"/>- <register name="q15"/>- <register name="q16"/>- <register name="q17"/>- <register name="q18"/>- <register name="q19"/>- <register name="q20"/>- <register name="q21"/>- <register name="q22"/>- <register name="q23"/>- <register name="q24"/>- <register name="q25"/>- <register name="q26"/>- <register name="q27"/>- <register name="q28"/>- <register name="q29"/>- <register name="q30"/>- </prefersplit>-- <default_proto>- <prototype name="__swiftcall" extrapop="0" stackshift="0">- <!-- https://github.com/swiftlang/swift/blob/main/docs/ABI/CallingConventionSummary.rst#arm64 -->- <input>- <pentry minsize="8" maxsize="8" storage="hiddenret">- <register name="x8"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d0"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d1"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d2"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d3"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d4"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d5"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d6"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d7"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x0"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x1"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x2"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x3"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x4"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x5"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x6"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x7"/>- </pentry>- <pentry minsize="1" maxsize="500" align="4">- <addr offset="0" space="stack"/>- </pentry>- <rule>- <datatype name="struct" minsize="9"/>- <join/>- </rule>- </input>- <output>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d0"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d1"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d2"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d3"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="x0"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="x1"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="x2"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="x3"/>- </pentry>- <rule>- <datatype name="homogeneous-float-aggregate"/>- <join_per_primitive storage="float"/>- </rule>- <rule>- <datatype name="float"/>- <consume storage="float"/>- </rule>- <rule>- <datatype name="any" minsize="1" maxsize="32"/>- <join/>- </rule>- <rule>- <datatype name="any" minsize="33"/>- <hidden_return voidlock="true"/>- </rule>- </output>- <unaffected>- <register name="x19"/>- <register name="x20"/>- <register name="x21"/>- <register name="x22"/>- <register name="x23"/>- <register name="x24"/>- <register name="x25"/>- <register name="x26"/>- <register name="x27"/>- <register name="x28"/>- <register name="x29"/>- <register name="x30"/>- <register name="sp"/>- <!-- vectors -->- <register name="d8"/>- <register name="d9"/>- <register name="d10"/>- <register name="d11"/>- <register name="d12"/>- <register name="d13"/>- <register name="d14"/>- <register name="d15"/>- </unaffected>- <killedbycall>- <!-- x8: indirect result location register, which is not- reflected in the pentry list -->- <register name="x8"/>- <register name="x9"/>- <register name="x10"/>- <register name="x11"/>- <register name="x12"/>- <register name="x13"/>- <register name="x14"/>- <register name="x15"/>- <register name="x16"/>- <register name="x17"/>- <register name="x18"/>- <!-- vectors -->- <register name="d16"/>- <register name="d17"/>- <register name="d18"/>- <register name="d19"/>- <register name="d20"/>- <register name="d21"/>- <register name="d22"/>- <register name="d23"/>- <register name="d24"/>- <register name="d25"/>- <register name="d26"/>- <register name="d27"/>- <register name="d28"/>- <register name="d29"/>- <register name="d30"/>- <register name="d31"/>- </killedbycall>- </prototype>- </default_proto>- <prototype name="__thiscall" extrapop="0" stackshift="0">- <!-- https://github.com/swiftlang/swift/blob/main/docs/ABI/CallingConventionSummary.rst#arm64 -->- <input>- <pentry minsize="8" maxsize="8" storage="hiddenret">- <register name="x8"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d0"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d1"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d2"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d3"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d4"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d5"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d6"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d7"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x20"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x0"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x1"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x2"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x3"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x4"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x5"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x6"/>- </pentry>- <pentry minsize="1" maxsize="8" extension="zero">- <register name="x7"/>- </pentry>- <pentry minsize="1" maxsize="500" align="4">- <addr offset="0" space="stack"/>- </pentry>- <rule>- <datatype name="struct" minsize="9"/>- <join/>- </rule>- </input>- <output>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d0"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d1"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d2"/>- </pentry>- <pentry minsize="2" maxsize="8" metatype="float">- <register name="d3"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="x0"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="x1"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="x2"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="x3"/>- </pentry>- <rule>- <datatype name="homogeneous-float-aggregate"/>- <join_per_primitive storage="float"/>- </rule>- <rule>- <datatype name="float"/>- <consume storage="float"/>- </rule>- <rule>- <datatype name="any" minsize="1" maxsize="32"/>- <join/>- </rule>- <rule>- <datatype name="any" minsize="33"/>- <hidden_return voidlock="true"/>- </rule>- </output>- <unaffected>- <register name="x19"/>- <register name="x21"/>- <register name="x22"/>- <register name="x23"/>- <register name="x24"/>- <register name="x25"/>- <register name="x26"/>- <register name="x27"/>- <register name="x28"/>- <register name="x29"/>- <register name="x30"/>- <register name="sp"/>- <!-- vectors -->- <register name="d8"/>- <register name="d9"/>- <register name="d10"/>- <register name="d11"/>- <register name="d12"/>- <register name="d13"/>- <register name="d14"/>- <register name="d15"/>- </unaffected>- <killedbycall>- <!-- x8: indirect result location register, which is not- reflected in the pentry list -->- <register name="x8"/>- <register name="x9"/>- <register name="x10"/>- <register name="x11"/>- <register name="x12"/>- <register name="x13"/>- <register name="x14"/>- <register name="x15"/>- <register name="x16"/>- <register name="x17"/>- <register name="x18"/>- <!-- vectors -->- <register name="d16"/>- <register name="d17"/>- <register name="d18"/>- <register name="d19"/>- <register name="d20"/>- <register name="d21"/>- <register name="d22"/>- <register name="d23"/>- <register name="d24"/>- <register name="d25"/>- <register name="d26"/>- <register name="d27"/>- <register name="d28"/>- <register name="d29"/>- <register name="d30"/>- <register name="d31"/>- </killedbycall>- </prototype>-</compiler_spec>diff --git a/Ghidra/Processors/AARCH64/data/languages/AppleSilicon.ldefs b/Ghidra/Processors/AARCH64/data/languages/AppleSilicon.ldefsindex 438a3f92a5..e26a418abe 100644--- a/Ghidra/Processors/AARCH64/data/languages/AppleSilicon.ldefs+++ b/Ghidra/Processors/AARCH64/data/languages/AppleSilicon.ldefs@@ -11,7 +11,6 @@id="AARCH64:LE:64:AppleSilicon"><description>AppleSilicon ARM v8.5-A LE instructions, LE data, AMX extensions</description><compiler name="default" spec="AARCH64_apple.cspec" id="default"/>- <compiler name="Swift" spec="AARCH64_swift.cspec" id="swift"/><compiler name="golang" spec="AARCH64_golang.cspec" id="golang"/><external_name tool="gnu" name="aarch64"/><external_name tool="gnu" name="aarch64:ilp32"/>diff --git a/Ghidra/Processors/x86/certification.manifest b/Ghidra/Processors/x86/certification.manifestindex 71dfe24947..a1625ccaf2 100644--- a/Ghidra/Processors/x86/certification.manifest+++ b/Ghidra/Processors/x86/certification.manifest@@ -1,16 +1,6 @@##VERSION: 2.0Module.manifest||GHIDRA||||END|README.md||GHIDRA||||END|-data/extensions/rust/unix32/cc.xml||GHIDRA||||END|-data/extensions/rust/unix32/probe_fixup.xml||GHIDRA||||END|-data/extensions/rust/unix32/try_fixup.xml||GHIDRA||||END|-data/extensions/rust/unix64/cc.xml||GHIDRA||||END|-data/extensions/rust/unix64/probe_fixup.xml||GHIDRA||||END|-data/extensions/rust/unix64/try_fixup.xml||GHIDRA||||END|-data/extensions/rust/windows32/probe_fixup.xml||GHIDRA||||END|-data/extensions/rust/windows32/try_fixup.xml||GHIDRA||||END|-data/extensions/rust/windows64/probe_fixup.xml||GHIDRA||||END|-data/extensions/rust/windows64/try_fixup.xml||GHIDRA||||END|data/languages/adx.sinc||GHIDRA||||END|data/languages/avx.sinc||GHIDRA||||END|data/languages/avx2.sinc||GHIDRA||||END|@@ -75,7 +65,6 @@ data/languages/x86-64-compat32.pspec||GHIDRA||||END|data/languages/x86-64-gcc.cspec||GHIDRA||||END|data/languages/x86-64-golang.cspec||GHIDRA||||END|data/languages/x86-64-golang.register.info||GHIDRA||||END|-data/languages/x86-64-swift.cspec||GHIDRA||||END|data/languages/x86-64-win.cspec||GHIDRA||||END|data/languages/x86-64.dwarf||GHIDRA||||END|data/languages/x86-64.pspec||GHIDRA||||END|diff --git a/Ghidra/Processors/x86/data/languages/x86-64-swift.cspec b/Ghidra/Processors/x86/data/languages/x86-64-swift.cspecdeleted file mode 100644index 71bfa360ec..0000000000--- a/Ghidra/Processors/x86/data/languages/x86-64-swift.cspec+++ /dev/null@@ -1,263 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>--<compiler_spec>- <data_organization>- <machine_alignment value="2" />- <default_alignment value="2" />- <default_pointer_alignment value="8" />- <pointer_size value="8" />- <wchar_size value="4" />- <short_size value="2" />- <integer_size value="4" />- <long_size value="8" />- <long_long_size value="8" />- <float_size value="4" />- <double_size value="8" />- <long_double_size value="10" /> <!-- aligned-length=16 -->- <size_alignment_map>- <entry size="1" alignment="1" />- <entry size="2" alignment="2" />- <entry size="4" alignment="4" />- <entry size="8" alignment="8" />- <entry size="16" alignment="16" />- </size_alignment_map>- </data_organization>-- <global>- <range space="ram"/>- </global>- <stackpointer register="RSP" space="ram"/>- <returnaddress>- <varnode space="stack" offset="0" size="8"/>- </returnaddress>- <default_proto>- <prototype name="__swiftcall" extrapop="8" stackshift="8">- <!-- https://github.com/swiftlang/swift/blob/main/docs/ABI/CallingConventionSummary.rst#x86-64 -->- <input>- <pentry minsize="8" maxsize="8" storage="hiddenret">- <register name="RAX"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM0_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM1_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM2_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM3_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM4_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM5_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM6_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM7_Qa"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RDI"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RSI"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RDX"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RCX"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="R8"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="R9"/>- </pentry>- <pentry minsize="1" maxsize="500" align="8">- <addr offset="8" space="stack"/>- </pentry>- <rule>- <datatype name="struct" minsize="9"/>- <join/>- </rule>- </input>- <output>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM0_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM1_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM2_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM3_Qa"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RAX"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RDX"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RCX"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="R8"/>- </pentry>- <rule>- <datatype name="homogeneous-float-aggregate"/>- <join_per_primitive storage="float"/>- </rule>- <rule>- <datatype name="float"/>- <consume storage="float"/>- </rule>- <rule>- <datatype name="any" minsize="1" maxsize="32"/>- <join/>- </rule>- <rule>- <datatype name="any" minsize="33"/>- <hidden_return voidlock="true"/>- </rule>- </output>- <killedbycall>- <register name="RAX"/>- <register name="RDX"/>- <register name="XMM0"/>- </killedbycall>- <unaffected>- <register name="RBX"/>- <register name="RSP"/>- <register name="RBP"/>- <register name="R12"/>- <register name="R13"/>- <register name="R14"/>- <register name="R15"/>- </unaffected>- </prototype>- </default_proto>- <prototype name="__thiscall" extrapop="8" stackshift="8">- <!-- https://github.com/swiftlang/swift/blob/main/docs/ABI/CallingConventionSummary.rst#x86-64 -->- <input>- <pentry minsize="8" maxsize="8" storage="hiddenret">- <register name="RAX"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM0_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM1_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM2_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM3_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM4_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM5_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM6_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM7_Qa"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="R13"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RDI"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RSI"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RDX"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RCX"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="R8"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="R9"/>- </pentry>- <pentry minsize="1" maxsize="500" align="8">- <addr offset="8" space="stack"/>- </pentry>- <rule>- <datatype name="struct" minsize="9"/>- <join/>- </rule>- </input>- <output>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM0_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM1_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM2_Qa"/>- </pentry>- <pentry minsize="4" maxsize="8" metatype="float">- <register name="XMM3_Qa"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RAX"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RDX"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="RCX"/>- </pentry>- <pentry minsize="1" maxsize="8">- <register name="R8"/>- </pentry>- <rule>- <datatype name="homogeneous-float-aggregate"/>- <join_per_primitive storage="float"/>- </rule>- <rule>- <datatype name="float"/>- <consume storage="float"/>- </rule>- <rule>- <datatype name="any" minsize="1" maxsize="32"/>- <join/>- </rule>- <rule>- <datatype name="any" minsize="33"/>- <hidden_return voidlock="true"/>- </rule>- </output>- <killedbycall>- <register name="RAX"/>- <register name="RDX"/>- <register name="XMM0"/>- </killedbycall>- <unaffected>- <register name="RBX"/>- <register name="RSP"/>- <register name="RBP"/>- <register name="R12"/>- <register name="R14"/>- <register name="R15"/>- </unaffected>- </prototype>-</compiler_spec>diff --git a/Ghidra/Processors/x86/data/languages/x86.ldefs b/Ghidra/Processors/x86/data/languages/x86.ldefsindex e39b57baeb..fed531548e 100644--- a/Ghidra/Processors/x86/data/languages/x86.ldefs+++ b/Ghidra/Processors/x86/data/languages/x86.ldefs@@ -95,7 +95,6 @@<compiler name="clang" spec="x86-64-win.cspec" id="clangwindows"/><compiler name="gcc" spec="x86-64-gcc.cspec" id="gcc"/><compiler name="golang" spec="x86-64-golang.cspec" id="golang"/>- <compiler name="Swift" spec="x86-64-swift.cspec" id="swift"/><external_name tool="gnu" name="i386:x86-64:intel"/><external_name tool="gnu" name="i386:x86-64"/><external_name tool="IDA-PRO" name="metapc"/>diff --git a/Ghidra/Processors/x86/data/languages/x86.opinion b/Ghidra/Processors/x86/data/languages/x86.opinionindex 4e5fc7a331..e9b887ece0 100644--- a/Ghidra/Processors/x86/data/languages/x86.opinion+++ b/Ghidra/Processors/x86/data/languages/x86.opinion@@ -27,9 +27,6 @@<constraint primary="332" secondary="golang" processor="x86" endian="little" size="32" /><constraint primary="34404" secondary="golang" processor="x86" endian="little" size="64" variant="default" /></constraint>- <constraint compilerSpecID="swift">- <constraint primary="34404" secondary="swift" processor="x86" endian="little" size="64" variant="default" />- </constraint></constraint><constraint loader="Debug Symbols (DBG)" compilerSpecID="windows"><constraint primary="332" processor="x86" endian="little" size="32" />@@ -42,9 +39,6 @@<constraint primary="3" processor="x86" endian="little" size="32" /><constraint primary="62" processor="x86" endian="little" size="64" variant="default" /></constraint>- <constraint compilerSpecID="swift">- <constraint primary="62" secondary="swift" processor="x86" endian="little" size="64" variant="default" />- </constraint><constraint compilerSpecID="golang"><constraint primary="62" secondary="golang" processor="x86" endian="little" size="64" variant="default" /></constraint>@@ -65,9 +59,6 @@<constraint primary="7" processor="x86" endian="little" size="32" /><constraint primary="16777223" processor="x86" endian="little" size="64" variant="default" /></constraint>- <constraint loader="Mac OS X Mach-O" compilerSpecID="swift">- <constraint primary="16777223" secondary="swift" processor="x86" endian="little" size="64" variant="default" />- </constraint><constraint loader="DYLD Cache" compilerSpecID="gcc"><constraint primary="x86_64" processor="x86" endian="little" size="64" variant="default" /></constraint>