mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
Merge branch 'GP-4758_ghidra1_ElfX86_64_GotAllocation_Relocs' into patch
This commit is contained in:
@@ -141,6 +141,13 @@ class X86_64_ElfRelocationContext extends ElfRelocationContext<X86_64_ElfRelocat
|
|||||||
|
|
||||||
private Address allocateGot() {
|
private Address allocateGot() {
|
||||||
|
|
||||||
|
if (allocatedGotAddress != null) {
|
||||||
|
if (allocatedGotAddress == Address.NO_ADDRESS) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return allocatedGotAddress;
|
||||||
|
}
|
||||||
|
|
||||||
allocatedGotAddress = Address.NO_ADDRESS;
|
allocatedGotAddress = Address.NO_ADDRESS;
|
||||||
nextAllocatedGotEntryAddress = Address.NO_ADDRESS;
|
nextAllocatedGotEntryAddress = Address.NO_ADDRESS;
|
||||||
|
|
||||||
@@ -193,7 +200,9 @@ class X86_64_ElfRelocationContext extends ElfRelocationContext<X86_64_ElfRelocat
|
|||||||
*/
|
*/
|
||||||
private Address getNextAllocatedGotEntryAddress() {
|
private Address getNextAllocatedGotEntryAddress() {
|
||||||
if (nextAllocatedGotEntryAddress == null) {
|
if (nextAllocatedGotEntryAddress == null) {
|
||||||
allocateGot();
|
if (allocateGot() == null) {
|
||||||
|
return Address.NO_ADDRESS; // failed to allocate got
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Address addr = nextAllocatedGotEntryAddress;
|
Address addr = nextAllocatedGotEntryAddress;
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class X86_64_ElfRelocationHandler extends
|
|||||||
}
|
}
|
||||||
catch (NotFoundException e) {
|
catch (NotFoundException e) {
|
||||||
markAsError(program, relocationAddress, type, symbolName, symbolIndex,
|
markAsError(program, relocationAddress, type, symbolName, symbolIndex,
|
||||||
e.getMessage(), elfRelocationContext.getLog());
|
"GOT allocation failure", elfRelocationContext.getLog());
|
||||||
return RelocationResult.FAILURE;
|
return RelocationResult.FAILURE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -257,6 +257,32 @@ public class X86_64_ElfRelocationHandler extends
|
|||||||
}
|
}
|
||||||
value = symbolGotAddress.getOffset() + addend - offset;
|
value = symbolGotAddress.getOffset() + addend - offset;
|
||||||
memory.setLong(relocationAddress, value);
|
memory.setLong(relocationAddress, value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_X86_64_GOT64: // 64 bit GOT entry offset (UNVERIFIED)
|
||||||
|
symbolGotAddress = elfRelocationContext.getGotEntryAddress(sym);
|
||||||
|
if (symbolGotAddress == null) {
|
||||||
|
markAsError(program, relocationAddress, type, symbolName, symbolIndex,
|
||||||
|
"GOT allocation failure", elfRelocationContext.getLog());
|
||||||
|
return RelocationResult.FAILURE;
|
||||||
|
}
|
||||||
|
value = symbolGotAddress.getOffset() + addend;
|
||||||
|
memory.setLong(relocationAddress, value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_X86_64_PLTOFF64: // 64 bit GOT relative offset to PLT entry (UNVERIFIED)
|
||||||
|
long dotgot;
|
||||||
|
try {
|
||||||
|
dotgot = elfRelocationContext.getGOTValue();
|
||||||
|
}
|
||||||
|
catch (NotFoundException e) {
|
||||||
|
markAsError(program, relocationAddress, type, symbolName, symbolIndex,
|
||||||
|
"GOT allocation failure", elfRelocationContext.getLog());
|
||||||
|
return RelocationResult.FAILURE;
|
||||||
|
}
|
||||||
|
value = symbolValue - dotgot + addend;
|
||||||
|
memory.setLong(relocationAddress, value);
|
||||||
|
break;
|
||||||
|
|
||||||
case R_X86_64_RELATIVE:
|
case R_X86_64_RELATIVE:
|
||||||
// word64 for LP64 and specifies word32 for ILP32,
|
// word64 for LP64 and specifies word32 for ILP32,
|
||||||
|
|||||||
Reference in New Issue
Block a user