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