mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
d7bbb44f52
2 changed files with 19 additions and 12 deletions
|
@ -31,8 +31,7 @@ import ghidra.app.util.bin.format.MemoryLoadable;
|
||||||
import ghidra.app.util.bin.format.elf.*;
|
import ghidra.app.util.bin.format.elf.*;
|
||||||
import ghidra.app.util.bin.format.elf.ElfDynamicType.ElfDynamicValueType;
|
import ghidra.app.util.bin.format.elf.ElfDynamicType.ElfDynamicValueType;
|
||||||
import ghidra.app.util.bin.format.elf.extend.ElfLoadAdapter;
|
import ghidra.app.util.bin.format.elf.extend.ElfLoadAdapter;
|
||||||
import ghidra.app.util.bin.format.elf.relocation.ElfRelocationContext;
|
import ghidra.app.util.bin.format.elf.relocation.*;
|
||||||
import ghidra.app.util.bin.format.elf.relocation.ElfRelocationHandler;
|
|
||||||
import ghidra.app.util.importer.MessageLog;
|
import ghidra.app.util.importer.MessageLog;
|
||||||
import ghidra.framework.options.Options;
|
import ghidra.framework.options.Options;
|
||||||
import ghidra.framework.store.LockException;
|
import ghidra.framework.store.LockException;
|
||||||
|
@ -732,19 +731,27 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
||||||
private void processRelocations(TaskMonitor monitor) throws CancelledException {
|
private void processRelocations(TaskMonitor monitor) throws CancelledException {
|
||||||
monitor.setMessage("Processing relocation tables...");
|
monitor.setMessage("Processing relocation tables...");
|
||||||
|
|
||||||
|
ElfRelocationTable[] relocationTables = elf.getRelocationTables();
|
||||||
|
if (relocationTables.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean processRelocations = ElfLoaderOptionsFactory.performRelocations(options);
|
boolean processRelocations = ElfLoaderOptionsFactory.performRelocations(options);
|
||||||
|
if (processRelocations && ElfRelocationHandlerFactory.getHandler(elf) == null) {
|
||||||
|
log("ELF relocation handler extension not found! Unable to process relocations.");
|
||||||
|
}
|
||||||
|
|
||||||
Address defaultBase = getDefaultAddress(elf.adjustAddressForPrelink(0));
|
Address defaultBase = getDefaultAddress(elf.adjustAddressForPrelink(0));
|
||||||
AddressSpace defaultSpace = defaultBase.getAddressSpace();
|
AddressSpace defaultSpace = defaultBase.getAddressSpace();
|
||||||
long defaultBaseOffset = defaultBase.getAddressableWordOffset();
|
long defaultBaseOffset = defaultBase.getAddressableWordOffset();
|
||||||
|
|
||||||
int totalCount = 0;
|
int totalCount = 0;
|
||||||
for (ElfRelocationTable relocationTable : elf.getRelocationTables()) {
|
for (ElfRelocationTable relocationTable : relocationTables) {
|
||||||
totalCount += relocationTable.getRelocationCount();
|
totalCount += relocationTable.getRelocationCount();
|
||||||
}
|
}
|
||||||
monitor.initialize(totalCount);
|
monitor.initialize(totalCount);
|
||||||
|
|
||||||
for (ElfRelocationTable relocationTable : elf.getRelocationTables()) {
|
for (ElfRelocationTable relocationTable : relocationTables) {
|
||||||
|
|
||||||
monitor.checkCanceled();
|
monitor.checkCanceled();
|
||||||
|
|
||||||
|
@ -877,7 +884,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
||||||
|
|
||||||
memory.getBytes(relocAddr, bytes);
|
memory.getBytes(relocAddr, bytes);
|
||||||
|
|
||||||
if (context != null && context.hasRelocationHandler()) {
|
if (context != null) {
|
||||||
if (relrTypeUnknown) {
|
if (relrTypeUnknown) {
|
||||||
ElfRelocationHandler.markAsUnsupportedRelr(program, relocAddr);
|
ElfRelocationHandler.markAsUnsupportedRelr(program, relocAddr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class ExternalFunctionMergeManagerTest extends AbstractExternalMergerTest
|
||||||
assertEquals("apples", function.getName());
|
assertEquals("apples", function.getName());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
||||||
checkDataType(DataType.DEFAULT, function.getReturnType());
|
checkDataType(DataType.DEFAULT, function.getReturnType());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getReturn().getSource());
|
assertEquals(SourceType.DEFAULT, function.getReturn().getSource());
|
||||||
assertEquals("unknown", function.getCallingConventionName());
|
assertEquals("unknown", function.getCallingConventionName());
|
||||||
assertEquals(new AddressSet(), function.getBody());
|
assertEquals(new AddressSet(), function.getBody());
|
||||||
assertEquals(null, function.getComment());
|
assertEquals(null, function.getComment());
|
||||||
|
@ -297,7 +297,7 @@ public class ExternalFunctionMergeManagerTest extends AbstractExternalMergerTest
|
||||||
assertEquals("apples", function.getName());
|
assertEquals("apples", function.getName());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
||||||
checkDataType(DataType.DEFAULT, function.getReturnType());
|
checkDataType(DataType.DEFAULT, function.getReturnType());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getReturn().getSource());
|
assertEquals(SourceType.DEFAULT, function.getReturn().getSource());
|
||||||
assertEquals("unknown", function.getCallingConventionName());
|
assertEquals("unknown", function.getCallingConventionName());
|
||||||
assertEquals(new AddressSet(), function.getBody());
|
assertEquals(new AddressSet(), function.getBody());
|
||||||
assertEquals(null, function.getComment());
|
assertEquals(null, function.getComment());
|
||||||
|
@ -518,7 +518,7 @@ public class ExternalFunctionMergeManagerTest extends AbstractExternalMergerTest
|
||||||
assertEquals("apples", function.getName());
|
assertEquals("apples", function.getName());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
||||||
checkDataType(DataType.DEFAULT, function.getReturnType());
|
checkDataType(DataType.DEFAULT, function.getReturnType());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getReturn().getSource());
|
assertEquals(SourceType.DEFAULT, function.getReturn().getSource());
|
||||||
assertEquals("unknown", function.getCallingConventionName());
|
assertEquals("unknown", function.getCallingConventionName());
|
||||||
assertEquals(new AddressSet(), function.getBody());
|
assertEquals(new AddressSet(), function.getBody());
|
||||||
assertEquals(null, function.getComment());
|
assertEquals(null, function.getComment());
|
||||||
|
@ -753,7 +753,7 @@ public class ExternalFunctionMergeManagerTest extends AbstractExternalMergerTest
|
||||||
assertEquals("apples", function.getName());
|
assertEquals("apples", function.getName());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
||||||
checkDataType(DataType.DEFAULT, function.getReturnType());
|
checkDataType(DataType.DEFAULT, function.getReturnType());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getReturn().getSource());
|
assertEquals(SourceType.DEFAULT, function.getReturn().getSource());
|
||||||
assertEquals("unknown", function.getCallingConventionName());
|
assertEquals("unknown", function.getCallingConventionName());
|
||||||
assertEquals(new AddressSet(), function.getBody());
|
assertEquals(new AddressSet(), function.getBody());
|
||||||
assertEquals(null, function.getComment());
|
assertEquals(null, function.getComment());
|
||||||
|
@ -945,7 +945,7 @@ public class ExternalFunctionMergeManagerTest extends AbstractExternalMergerTest
|
||||||
assertEquals("apples", function.getName());
|
assertEquals("apples", function.getName());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
||||||
checkDataType(DataType.DEFAULT, function.getReturnType());
|
checkDataType(DataType.DEFAULT, function.getReturnType());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getReturn().getSource());
|
assertEquals(SourceType.DEFAULT, function.getReturn().getSource());
|
||||||
assertEquals("unknown", function.getCallingConventionName());
|
assertEquals("unknown", function.getCallingConventionName());
|
||||||
assertEquals(new AddressSet(), function.getBody());
|
assertEquals(new AddressSet(), function.getBody());
|
||||||
assertEquals(null, function.getComment());
|
assertEquals(null, function.getComment());
|
||||||
|
@ -1137,7 +1137,7 @@ public class ExternalFunctionMergeManagerTest extends AbstractExternalMergerTest
|
||||||
assertEquals("apples", function.getName());
|
assertEquals("apples", function.getName());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
||||||
checkDataType(DataType.DEFAULT, function.getReturnType());
|
checkDataType(DataType.DEFAULT, function.getReturnType());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getReturn().getSource());
|
assertEquals(SourceType.DEFAULT, function.getReturn().getSource());
|
||||||
assertEquals("unknown", function.getCallingConventionName());
|
assertEquals("unknown", function.getCallingConventionName());
|
||||||
assertEquals(new AddressSet(), function.getBody());
|
assertEquals(new AddressSet(), function.getBody());
|
||||||
assertEquals(null, function.getComment());
|
assertEquals(null, function.getComment());
|
||||||
|
@ -1372,7 +1372,7 @@ public class ExternalFunctionMergeManagerTest extends AbstractExternalMergerTest
|
||||||
assertEquals("apples", function.getName());
|
assertEquals("apples", function.getName());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
assertEquals(SourceType.USER_DEFINED, function.getSymbol().getSource());
|
||||||
checkDataType(DataType.DEFAULT, function.getReturnType());
|
checkDataType(DataType.DEFAULT, function.getReturnType());
|
||||||
assertEquals(SourceType.USER_DEFINED, function.getReturn().getSource());
|
assertEquals(SourceType.DEFAULT, function.getReturn().getSource());
|
||||||
assertEquals("unknown", function.getCallingConventionName());
|
assertEquals("unknown", function.getCallingConventionName());
|
||||||
assertEquals(new AddressSet(), function.getBody());
|
assertEquals(new AddressSet(), function.getBody());
|
||||||
assertEquals(null, function.getComment());
|
assertEquals(null, function.getComment());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue