Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-5365 Fixed MIPS 64-bit packed relocations

emteere5bcfb5f02c0b
diff --git a/Ghidra/Processors/MIPS/src/main/java/ghidra/app/util/bin/format/elf/relocation/MIPS_ElfRelocationContext.java b/Ghidra/Processors/MIPS/src/main/java/ghidra/app/util/bin/format/elf/relocation/MIPS_ElfRelocationContext.java
index a7f4416720..ded286080f 100644
--- a/Ghidra/Processors/MIPS/src/main/java/ghidra/app/util/bin/format/elf/relocation/MIPS_ElfRelocationContext.java
+++ b/Ghidra/Processors/MIPS/src/main/java/ghidra/app/util/bin/format/elf/relocation/MIPS_ElfRelocationContext.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -81,13 +81,19 @@ class MIPS_ElfRelocationContext extends ElfRelocationContext<MIPS_ElfRelocationH
MIPS_Elf64Relocation mips64Relocation = (MIPS_Elf64Relocation) relocation;
- // Each relocation can pack upto 3 relocations for 64-bit
+ // Each relocation can pack up to 3 relocations for 64-bit
for (int n = 0; n < 3; n++) {
if (n == 1) {
+ // The symbol used by the second pack slot is encoded in the info
+ // field of the relocation. This could be any symbol and
+ // does not need to match the first packed entry.
symbolIndex = mips64Relocation.getSpecialSymbolIndex();
}
- else {
+ else if (n == 2) {
+ // The third pack slot should not be referring to any symbol.
+ // Clear out symbol index to catch any errors in relocations
+ // using symbolIndex.
symbolIndex = 0;
}