Ghidra is a software reverse engineering (SRE) framework
GP-0: Tidying up Mach-O things
Ryan Kurtz7c1f73d6e269
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/BinaryReader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/BinaryReader.javaindex c04780f196..b9045ad6d3 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/BinaryReader.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/BinaryReader.java@@ -597,6 +597,7 @@ public class BinaryReader {** @param length number of bytes to read* @return the US-ASCII string at the current index+ * @throws IOException if an IO-related error occurred*/public String readNextAsciiString(int length) throws IOException {return readNextString(length, StandardCharsets.US_ASCII, 1);@@ -696,6 +697,7 @@ public class BinaryReader {* Reads a byte array of <code>nElements</code>* starting at the current index and then increments the current* index by <code>SIZEOF_BYTE * nElements</code>.+ * @param nElements number of elements to read* @return the byte array starting at the current index* @exception IOException if an I/O error occurs*/@@ -709,6 +711,7 @@ public class BinaryReader {* Reads a short array of <code>nElements</code>* starting at the current index and then increments the current* index by <code>SIZEOF_SHORT * nElements</code>.+ * @param nElements number of elements to read* @return the short array starting at the current index* @exception IOException if an I/O error occurs*/diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/SectionAttributes.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/SectionAttributes.javaindex 32876b2c6d..c90e77377b 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/SectionAttributes.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/SectionAttributes.java@@ -1,13 +1,12 @@/* ###* IP: GHIDRA- * REVIEWED: YES** 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.@@ -61,6 +60,7 @@ public final class SectionAttributes {}}catch (Exception e) {+ // do nothing}}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/SectionTypes.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/SectionTypes.javaindex 19bf2e923f..8e44732dc9 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/SectionTypes.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/SectionTypes.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.@@ -99,6 +99,7 @@ public final class SectionTypes {}}catch (Exception e) {+ // do nothing}}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/DynamicLibraryModule.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/DynamicLibraryModule.javaindex ef1970c2ec..db7cd40270 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/DynamicLibraryModule.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/DynamicLibraryModule.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.@@ -99,17 +99,22 @@ public class DynamicLibraryModule implements StructConverter {public int getExternalRelocationCount() {return nextrel;}+/**- * low 16 bits are the index into the init section,- * high 16 bits are the index into the term section+ * Low 16 bits are the index into the init section, high 16 bits are the index into the term+ * section+ *+ * @return The init term index*/public int getInitTermIndex() {return iinit_iterm;}+/**- * low 16 bits are the number of init section entries,- * high 16 bits are the number of term section entries- * @return+ * Low 16 bits are the number of init section entries, high 16 bits are the number of term+ * section entries+ *+ * @return The init term count*/public int getInitTermCount() {return ninit_nterm;@@ -121,6 +126,7 @@ public class DynamicLibraryModule implements StructConverter {return objc_module_info_addr;}+ @Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType("dylib_module", 0);struct.add(DWORD, "module_name", "the module name (index into string table)");diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/LoadCommand.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/LoadCommand.javaindex b57e3b94b8..fbc846238e 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/LoadCommand.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/LoadCommand.java@@ -140,7 +140,7 @@ public abstract class LoadCommand implements StructConverter {return;}String comment = getContextualName(source, additionalDescription);- program.getListing().setComment(address, CodeUnit.PLATE_COMMENT, comment);+ program.getListing().setComment(address, CommentType.PLATE, comment);}/**diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/ObsoleteCommand.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/ObsoleteCommand.javaindex 1c7c32b517..fd1996dea1 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/ObsoleteCommand.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/ObsoleteCommand.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.@@ -29,6 +29,7 @@ public abstract class ObsoleteCommand extends LoadCommand {throw new ObsoleteException();}+ @Overridepublic DataType toDataType() throws DuplicateNameException, IOException {StructureDataType struct = new StructureDataType(getCommandName(), 0);struct.add(DWORD, "cmd", null);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/Util.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/Util.javadeleted file mode 100644index 74d70af32c..0000000000--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/Util.java+++ /dev/null@@ -1,21 +0,0 @@-/* ###- * IP: GHIDRA- * REVIEWED: YES- *- * 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.bin.format.macho.commands;--public final class Util {--}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/chained/DyldChainedStartsInSegment.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/chained/DyldChainedStartsInSegment.javaindex 8bfd1b91dc..c2353bf24c 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/chained/DyldChainedStartsInSegment.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/chained/DyldChainedStartsInSegment.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.@@ -75,7 +75,7 @@ public class DyldChainedStartsInSegment implements StructConverter {public void markup(Program program, Address address, MachHeader header, TaskMonitor monitor,MessageLog log) throws CancelledException {try {-+ // TODO?}catch (Exception e) {log.appendMsg(DyldChainedStartsInSegment.class.getSimpleName(),diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/codesignature/CodeSignatureCodeDirectory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/codesignature/CodeSignatureCodeDirectory.javaindex ee520794aa..587db67738 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/codesignature/CodeSignatureCodeDirectory.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/codesignature/CodeSignatureCodeDirectory.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.@@ -23,7 +23,7 @@ import ghidra.app.util.bin.format.macho.MachHeader;import ghidra.app.util.importer.MessageLog;import ghidra.program.model.address.Address;import ghidra.program.model.data.*;-import ghidra.program.model.listing.CodeUnit;+import ghidra.program.model.listing.CommentType;import ghidra.program.model.listing.Program;import ghidra.util.exception.CancelledException;import ghidra.util.exception.DuplicateNameException;@@ -123,15 +123,14 @@ public class CodeSignatureCodeDirectory extends CodeSignatureGenericBlob {DataUtilities.createData(program, identAddr, STRING, -1,DataUtilities.ClearDataMode.CHECK_FOR_SPACE);program.getListing()- .setComment(identAddr, CodeUnit.PRE_COMMENT, "CS_CodeDirectory identifer");+ .setComment(identAddr, CommentType.PRE, "CS_CodeDirectory identifer");}if (teamOffset != 0) {Address teamAddr = addr.add(teamOffset);DataUtilities.createData(program, teamAddr, STRING, -1,DataUtilities.ClearDataMode.CHECK_FOR_SPACE);program.getListing()- .setComment(teamAddr, CodeUnit.PRE_COMMENT,- "CS_CodeDirectory team identifier");+ .setComment(teamAddr, CommentType.PRE, "CS_CodeDirectory team identifier");}if (hashOffset != 0 && hashSize != 0) {Address hashAddr = addr.add(hashOffset);@@ -140,7 +139,7 @@ public class CodeSignatureCodeDirectory extends CodeSignatureGenericBlob {DataUtilities.createData(program, hashAddr, hasheArrayArrayDt, -1,DataUtilities.ClearDataMode.CHECK_FOR_SPACE);program.getListing()- .setComment(hashAddr, CodeUnit.PRE_COMMENT, "CS_CodeDirectory hashes");+ .setComment(hashAddr, CommentType.PRE, "CS_CodeDirectory hashes");}}catch (Exception e) {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/codesignature/CodeSignatureGenericBlob.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/codesignature/CodeSignatureGenericBlob.javaindex 15c13019be..ac469414d2 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/codesignature/CodeSignatureGenericBlob.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/codesignature/CodeSignatureGenericBlob.java@@ -24,7 +24,7 @@ import ghidra.app.util.bin.format.macho.MachHeader;import ghidra.app.util.importer.MessageLog;import ghidra.program.model.address.Address;import ghidra.program.model.data.*;-import ghidra.program.model.listing.CodeUnit;+import ghidra.program.model.listing.CommentType;import ghidra.program.model.listing.Program;import ghidra.util.exception.CancelledException;import ghidra.util.exception.DuplicateNameException;@@ -88,7 +88,7 @@ public class CodeSignatureGenericBlob implements StructConverter {Address hashAddr = address.add(toDataType().getLength());DataUtilities.createData(program, hashAddr, dt, -1,DataUtilities.ClearDataMode.CHECK_FOR_SPACE);- program.getListing().setComment(hashAddr, CodeUnit.PRE_COMMENT, "CS_GenericBlob hash");+ program.getListing().setComment(hashAddr, CommentType.PRE, "CS_GenericBlob hash");}catch (Exception e) {log.appendMsg(CodeSignatureGenericBlob.class.getSimpleName(),diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/dyld/AbstractClassicProcessor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/dyld/AbstractClassicProcessor.javaindex 14388515a7..4f80607718 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/dyld/AbstractClassicProcessor.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/dyld/AbstractClassicProcessor.java@@ -5,9 +5,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.@@ -68,7 +68,7 @@ public abstract class AbstractClassicProcessor {return;}- listing.setComment(symbol.getAddress(), CodeUnit.PLATE_COMMENT, fromDylib);+ listing.setComment(symbol.getAddress(), CommentType.PLATE, fromDylib);long offset = symbol.getAddress().getOffset();@@ -156,8 +156,9 @@ public abstract class AbstractClassicProcessor {}/**- * Return the Symbol for the specified NList.- * Looks in the global namespace first.+ * {@return the Symbol for the specified NList. Looks in the global namespace first.}+ *+ * @param nList The NList*/protected Symbol getSymbol(NList nList) {SymbolTable symbolTable = program.getSymbolTable();@@ -204,10 +205,8 @@ public abstract class AbstractClassicProcessor {}/**- * Returns the relocation base.- * If the program is 64-bit (x86 or PowerPC), then- * return the VM address of the first segment with W bit.- * Otherwise, just return first segment VM address.+ * {@return the relocation base. If the program is 64-bit (x86 or PowerPC), then return the VM+ * address of the first segment with W bit. Otherwise, just return first segment VM address.}*/protected long getRelocationBase() {List<SegmentCommand> segments = header.getLoadCommands(SegmentCommand.class);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheAccelerateInfo.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheAccelerateInfo.javaindex ea97880e88..eff7e25ce6 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheAccelerateInfo.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheAccelerateInfo.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.@@ -314,7 +314,7 @@ public class DyldCacheAccelerateInfo implements StructConverter {DataType dt = new ArrayDataType(WORD, reExportCount, WORD.getLength());DataUtilities.createData(program, addr, dt, -1,DataUtilities.ClearDataMode.CHECK_FOR_SPACE);- program.getListing().setComment(addr, CodeUnit.EOL_COMMENT, "re-exports");+ program.getListing().setComment(addr, CommentType.EOL, "re-exports");monitor.incrementProgress(1);}catch (CodeUnitInsertionException e) {@@ -332,7 +332,7 @@ public class DyldCacheAccelerateInfo implements StructConverter {DataType dt = new ArrayDataType(WORD, depListCount, WORD.getLength());DataUtilities.createData(program, addr, dt, -1,DataUtilities.ClearDataMode.CHECK_FOR_SPACE);- program.getListing().setComment(addr, CodeUnit.EOL_COMMENT, "dependencies");+ program.getListing().setComment(addr, CommentType.EOL, "dependencies");monitor.incrementProgress(1);}catch (CodeUnitInsertionException e) {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheHeader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheHeader.javaindex f388ee3867..a3575aaf05 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheHeader.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheHeader.java@@ -1430,7 +1430,7 @@ public class DyldCacheHeader implements StructConverter {for (DyldCacheImageInfo imageInfo : imageInfoList) {Data d = DataUtilities.createData(program, addr, imageInfo.toDataType(), -1,DataUtilities.ClearDataMode.CHECK_FOR_SPACE);- program.getListing().setComment(addr, CodeUnit.EOL_COMMENT, imageInfo.getPath());+ program.getListing().setComment(addr, CommentType.EOL, imageInfo.getPath());addr = addr.add(d.getLength());monitor.checkCancelled();monitor.incrementProgress(1);@@ -1450,7 +1450,7 @@ public class DyldCacheHeader implements StructConverter {String size = "0x" + Long.toHexString(codeSignatureSize);program.getListing().setComment(fileOffsetToAddr(codeSignatureOffset, program, space),- CodeUnit.PLATE_COMMENT, "Code Signature (" + size + " bytes)");+ CommentType.PLATE, "Code Signature (" + size + " bytes)");monitor.incrementProgress(1);}catch (IllegalArgumentException e) {@@ -1550,8 +1550,7 @@ public class DyldCacheHeader implements StructConverter {for (DyldCacheImageTextInfo imageTextInfo : imageTextInfoList) {Data d = DataUtilities.createData(program, addr, imageTextInfo.toDataType(), -1,DataUtilities.ClearDataMode.CHECK_FOR_SPACE);- program.getListing()- .setComment(addr, CodeUnit.EOL_COMMENT, imageTextInfo.getPath());+ program.getListing().setComment(addr, CommentType.EOL, imageTextInfo.getPath());addr = addr.add(d.getLength());monitor.checkCancelled();monitor.incrementProgress(1);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/threadcommand/FloatStateX86_32.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/threadcommand/FloatStateX86_32.javaindex 20ea4b1068..b8e161a3d2 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/threadcommand/FloatStateX86_32.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/threadcommand/FloatStateX86_32.java@@ -1,13 +1,12 @@/* ###* IP: GHIDRA- * REVIEWED: YES** 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.@@ -17,5 +16,5 @@package ghidra.app.util.bin.format.macho.threadcommand;public class FloatStateX86_32 {-+ // Empty}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/threadcommand/ThreadStateARM.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/threadcommand/ThreadStateARM.javaindex 4f2a84c150..c9a1478039 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/threadcommand/ThreadStateARM.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/threadcommand/ThreadStateARM.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,6 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.macho.MachConstants;import ghidra.program.model.data.*;-import ghidra.util.Conv;import ghidra.util.exception.DuplicateNameException;/**@@ -75,7 +74,7 @@ public class ThreadStateARM extends ThreadState {@Overridepublic long getInstructionPointer() {- return Conv.intToLong(pc);+ return Integer.toUnsignedLong(pc);}@Overridediff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/threadcommand/ThreadStateX86_32.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/threadcommand/ThreadStateX86_32.javaindex dcf18498b2..c334e082f0 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/threadcommand/ThreadStateX86_32.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/threadcommand/ThreadStateX86_32.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,6 @@ import java.io.IOException;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.format.macho.MachConstants;import ghidra.program.model.data.*;-import ghidra.util.Conv;import ghidra.util.exception.DuplicateNameException;/**@@ -67,7 +66,7 @@ public class ThreadStateX86_32 extends ThreadStateX86 {@Overridepublic long getInstructionPointer() {- return Conv.intToLong(eip);+ return Integer.toUnsignedLong(eip);}@Overridediff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/DyldCacheProgramBuilder.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/DyldCacheProgramBuilder.javaindex fa3e894d96..784c560e7b 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/DyldCacheProgramBuilder.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/DyldCacheProgramBuilder.java@@ -482,7 +482,7 @@ public class DyldCacheProgramBuilder extends MachoProgramBuilder {DyldCacheProgramBuilder.this.markupHeaders(header, headerAddr);if (!name.isEmpty()) {- listing.setComment(headerAddr, CodeUnit.PLATE_COMMENT, path);+ listing.setComment(headerAddr, CommentType.PLATE, path);}}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 4266c21ea6..de98e133bc 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@@ -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.@@ -234,7 +234,7 @@ public class MachoPrelinkProgramBuilder extends MachoProgramBuilder {MachoPrelinkProgramBuilder.this.markupHeaders(header, headerAddr);if (!name.isEmpty()) {- listing.setComment(headerAddr, CodeUnit.PLATE_COMMENT, name);+ listing.setComment(headerAddr, CommentType.PLATE, name);}}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 2353cce84e..2c4da7f172 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@@ -1463,7 +1463,7 @@ public class MachoProgramBuilder {}private void addLibrary(String library) {- library = library.replaceAll(" ", "_");+ library = SymbolUtilities.replaceInvalidChars(library, true);try {program.getExternalManager().addExternalLibraryName(library, SourceType.IMPORTED);}@@ -1867,7 +1867,8 @@ public class MachoProgramBuilder {throw new Exception("Library ordinal '%d' outside of expected range".formatted(libraryOrdinal));}- String libraryName = libraryPaths.get(libraryIndex).replaceAll(" ", "_");+ String libraryName =+ SymbolUtilities.replaceInvalidChars(libraryPaths.get(libraryIndex), true);Library library = extManager.getExternalLibrary(libraryName);if (library == null) {throw new Exception(@@ -1880,7 +1881,7 @@ public class MachoProgramBuilder {loc.setName(library, symbol, SourceType.IMPORTED);}catch (InvalidInputException e) {- throw new Exception("Symbol name contains illegal characters");+ throw new Exception(e.getMessage());}}}