mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-4461: Fixing some Mach-O string/symbol table load errors
This commit is contained in:
parent
568ebd45ef
commit
eca1a025c8
4 changed files with 27 additions and 16 deletions
|
@ -386,7 +386,7 @@ public class DynamicSymbolTableCommand extends LoadCommand {
|
|||
symbolTableAddr.add(nlistIndex * nlist.getSize()), RefType.DATA,
|
||||
SourceType.IMPORTED, 0);
|
||||
referenceManager.setPrimary(ref, true);
|
||||
if (stringTableAddr != null) {
|
||||
if (stringTableAddr != null && nlist.getStringTableIndex() != 0) {
|
||||
Address strAddr = stringTableAddr.add(nlist.getStringTableIndex());
|
||||
referenceManager.addMemoryReference(dataAddr, strAddr, RefType.DATA,
|
||||
SourceType.IMPORTED, 0);
|
||||
|
|
|
@ -69,11 +69,14 @@ public class NList implements StructConverter {
|
|||
* @param stringTableOffset offset of the string table
|
||||
*/
|
||||
public void initString(BinaryReader reader, long stringTableOffset) {
|
||||
try {
|
||||
string = reader.readAsciiString(stringTableOffset + n_strx);
|
||||
}
|
||||
catch (Exception e) {
|
||||
string = "";
|
||||
string = "";
|
||||
if (n_strx != 0) {
|
||||
try {
|
||||
string = reader.readAsciiString(stringTableOffset + n_strx);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// use empty string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ public class SymbolTableCommand extends LoadCommand {
|
|||
Data d = DataUtilities.createData(program, nlistAddr, dt, -1,
|
||||
DataUtilities.ClearDataMode.CHECK_FOR_SPACE);
|
||||
|
||||
if (stringTableAddr != null) {
|
||||
if (stringTableAddr != null && nlist.getStringTableIndex() != 0) {
|
||||
Address strAddr = stringTableAddr.add(nlist.getStringTableIndex());
|
||||
DataUtilities.createData(program, strAddr, STRING, -1,
|
||||
DataUtilities.ClearDataMode.CHECK_FOR_SPACE);
|
||||
|
|
|
@ -1450,23 +1450,31 @@ public class MachoProgramBuilder {
|
|||
if (address.compareTo(block.getEnd()) > 0) {
|
||||
break;
|
||||
}
|
||||
int length;
|
||||
try {
|
||||
listing.createData(address, datatype);
|
||||
length = listing.getDataAt(address).getLength();
|
||||
if (datatype instanceof Pointer) {
|
||||
fixupThumbPointers(address);
|
||||
}
|
||||
address = address.add(listing.getDataAt(address).getLength());
|
||||
}
|
||||
catch (Exception e) {
|
||||
// don't worry about exceptions
|
||||
// may have already been created, by relocation, or chain pointers
|
||||
if (!(datatype instanceof Pointer)) {
|
||||
catch (CodeUnitInsertionException e) {
|
||||
if (datatype instanceof TerminatedStringDataType) {
|
||||
// Sometimes there are huge strings, like JSON blobs
|
||||
log.appendMsg("Skipping markup for large string at: " + address);
|
||||
}
|
||||
else if (!(datatype instanceof Pointer)) {
|
||||
// May have already been created, by relocation, or chain pointers
|
||||
log.appendMsg("Skipping markup for existing pointer at: " + address);
|
||||
}
|
||||
else {
|
||||
log.appendException(e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (datatype instanceof Pointer) {
|
||||
fixupThumbPointers(address);
|
||||
catch (Exception e) {
|
||||
log.appendException(e);
|
||||
return;
|
||||
}
|
||||
address = address.add(length);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue