mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-15 08:32:07 +00:00
Merge branch 'GP-4461_ryanmkurtz_macho-strings'
This commit is contained in:
commit
1a7a1611ed
@ -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…
Reference in New Issue
Block a user