Merge remote-tracking branch

'origin/GP-3446_ryanmkurtz_OriginalFileExporter' into patch
(Closes #5346)
This commit is contained in:
Ryan Kurtz 2023-05-18 10:55:33 -04:00
commit 79c9e5cee6

View file

@ -178,6 +178,10 @@ public class OriginalFileExporter extends Exporter {
Iterable<Relocation> relocs = () -> program.getRelocationTable().getRelocations();
Memory memory = program.getMemory();
for (Relocation reloc : relocs) {
if (reloc.getStatus() != Relocation.Status.APPLIED &&
reloc.getStatus() != Relocation.Status.APPLIED_OTHER) {
continue;
}
Address addr = reloc.getAddress();
AddressSourceInfo addrSourceInfo = memory.getAddressSourceInfo(addr);
if (addrSourceInfo == null) {
@ -187,6 +191,7 @@ public class OriginalFileExporter extends Exporter {
if (offset >= 0) {
MemoryBlockSourceInfo memSourceInfo = addrSourceInfo.getMemoryBlockSourceInfo();
byte[] bytes = reloc.getBytes();
if (bytes != null) {
int len = Math.min(bytes.length,
(int) memSourceInfo.getMaxAddress().subtract(addr) + 1);
fout.seek(offset);
@ -194,10 +199,12 @@ public class OriginalFileExporter extends Exporter {
}
}
}
}
catch (Exception e) {
if (!tempFile.delete()) {
log.appendMsg("Failed to delete malformed file: " + tempFile);
}
log.appendException(e);
return false;
}