From c2a5661ce61afc0c90af35760f9283a8751750e3 Mon Sep 17 00:00:00 2001 From: Daniel Botnik Date: Sat, 9 Nov 2024 22:16:59 +0200 Subject: [PATCH 1/2] feat(MIPS): added R_MIPS_26 Relocation --- cle/backends/elf/relocation/mips.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cle/backends/elf/relocation/mips.py b/cle/backends/elf/relocation/mips.py index 7f8ddeac..dc1dd2be 100644 --- a/cle/backends/elf/relocation/mips.py +++ b/cle/backends/elf/relocation/mips.py @@ -35,6 +35,18 @@ class R_MIPS_REL32(GenericRelativeReloc): pass +class R_MIPS_26(GenericAbsoluteReloc): + def relocate(self): + if not self.resolved: + return False + + original_value = self.owner.memory.unpack_word(self.dest_addr) + original_value += (self.value // 4) + + self.owner.memory.pack_word(self.dest_addr, original_value) + return True + + class R_MIPS_JUMP_SLOT(GenericAbsoluteReloc): pass @@ -129,7 +141,7 @@ class R_MIPS_TLS_TPREL64(GenericTLSOffsetReloc): # 1: R_MIPS_16, 2: R_MIPS_32, 3: R_MIPS_REL32, - # 4: R_MIPS_26, + 4: R_MIPS_26, 5: R_MIPS_HI16, 6: R_MIPS_LO16, # 7: R_MIPS_GPREL16, From 7ef9f7023a68c181b393ef2a92e4636d43e924fe Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 9 Nov 2024 20:17:37 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- cle/backends/elf/relocation/mips.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cle/backends/elf/relocation/mips.py b/cle/backends/elf/relocation/mips.py index dc1dd2be..54e594bf 100644 --- a/cle/backends/elf/relocation/mips.py +++ b/cle/backends/elf/relocation/mips.py @@ -41,7 +41,7 @@ def relocate(self): return False original_value = self.owner.memory.unpack_word(self.dest_addr) - original_value += (self.value // 4) + original_value += self.value // 4 self.owner.memory.pack_word(self.dest_addr, original_value) return True