-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix R_MIPS_HI16 and R_MIPS_LO16 (#516)
- Loading branch information
1 parent
e45626c
commit d6530d3
Showing
2 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# pylint: disable=missing-class-docstring | ||
from __future__ import annotations | ||
|
||
import binascii | ||
import os | ||
import unittest | ||
|
||
import cle | ||
|
||
TEST_FILE = os.path.join( | ||
os.path.dirname(os.path.realpath(__file__)), | ||
os.path.join("..", "..", "binaries", "tests"), | ||
os.path.join("mips", "mips-hilo.o"), | ||
) | ||
|
||
|
||
class TestMipsRellocations(unittest.TestCase): | ||
|
||
@staticmethod | ||
def test_mips_hilo16(): | ||
# 0x21000: R_MIPS_HI16 3c080002 lui $t0, 2 | ||
# 0x21004: R_MIPS_HI16 3c090002 lui $t1, 2 | ||
# 0x21008: R_MIPS_LO16 21081004 addi $t0, $t0, 4100 | ||
# 0x2100c: R_MIPS_LO16 2108102c addi $t0, $t0, 4140 | ||
# 0x21010: R_MIPS_HI16 3c080003 lui $t0, 3 | ||
# 0x21014: R_MIPS_HI16 3c090004 lui $t1, 4 | ||
# 0x21018: R_MIPS_LO16 2108101c addi $t0, $t0, 4124 | ||
EXPECTED_RESULT = b"3c0800023c090002210810042108102c3c0800033c0900042108101c" | ||
|
||
ld = cle.Loader(TEST_FILE, auto_load_libs=False, main_opts={"base_addr": 0x21000}) | ||
assert EXPECTED_RESULT == binascii.hexlify(ld.memory.load(0x21000, 0x1C)) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |