Skip to content

Commit

Permalink
Fix mips plt sections being clobbered (#485)
Browse files Browse the repository at this point in the history
* do not clobber plt sections that are previously found

* fix mips test for plt on checkbytes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Ninja3047 and pre-commit-ci[bot] authored Oct 2, 2024
1 parent d6530d3 commit 2bec0d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cle/backends/elf/metaelf.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _load_plt(self):
if ".plt.got" in self.sections_map:
plt_secs = [self.sections_map[".plt.got"]]
if ".MIPS.stubs" in self.sections_map:
plt_secs = [self.sections_map[".MIPS.stubs"]]
plt_secs.append(self.sections_map[".MIPS.stubs"])
if ".plt.sec" in self.sections_map:
plt_secs.append(self.sections_map[".plt.sec"])

Expand Down
9 changes: 8 additions & 1 deletion tests/test_plt.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ def _check_plt_entries(self, filename):
self.assertEqual(diffs, [4] * len(diffs))
return

# all our mips samples have no PLT, just resolver stubs
if filename == os.path.join("mips", "checkbyte"):
self.assertEqual(
ld.main_object.plt,
{"read": 0x4008C0, "puts": 0x4008D0, "__libc_start_main": 0x4008E0},
)
return

# remaining mips samples have no PLT, just resolver stubs
if filename.startswith("mips"):
self.assertEqual(ld.main_object.plt, {})
return
Expand Down

0 comments on commit 2bec0d8

Please sign in to comment.