Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/relinker/relinker/tests/test_guest_none_relocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ def change_tag(image, tag, value=None, replacement=None):
raise AssertionError(f"Missing dynamic tag {tag:#x}")


def insert_dynamic_tag(image, tag, value):
for position in range(0x2000, 0x2200, 16):
current, _ = struct.unpack_from("<qQ", image, position)
if current == 0:
struct.pack_into("<qQ", image, position, tag, value)
struct.pack_into("<qQ", image, position + 16, 0, 0)
size, = struct.unpack_from("<Q", image, 176 + 32)
struct.pack_into("<QQ", image, 176 + 32, size + 16, size + 16)
return image
raise AssertionError("Missing dynamic terminator")


def unsized_lifecycle(rela, sce, initial):
image = module(rela, sce=sce, lifecycle=True, initial=initial)
return change_tag(change_tag(image, 27, replacement=0x61000001), 28, replacement=0x61000001)
Expand Down Expand Up @@ -138,6 +150,8 @@ def invalid_cases(sce):
ambiguous = module(plt=[NOOP], sce=sce)
yield "ambiguous-plt-format", change_tag(ambiguous, 0x61000027 if sce else 3, value=7,
replacement=20 if sce else 0x6100002b), "Missing or ambiguous dynamic tag"
strtab = 0x61000035 if sce else 5
yield "duplicate-dynamic-tag-strtab", insert_dynamic_tag(module([NOOP], sce=sce), strtab, 0), f"Duplicate dynamic tag {strtab}"


def main():
Expand Down
Loading