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
12 changes: 12 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,17 @@ def change_tag(image, tag, value=None, replacement=None):
raise AssertionError(f"Missing dynamic tag {tag:#x}")


def invalid_tls_outside_file(image):
image = bytearray(image)
phnum, = struct.unpack_from("<H", image, 56)
insert_at = 64 + phnum * 56
if insert_at + 56 > len(image):
image.extend(bytes(insert_at + 56 - len(image)))
struct.pack_into("<IIQQQQQQ", image, insert_at, 7, 4, 0x27f9, 0x1100, 0, 8, 8, 8)
struct.pack_into("<H", image, 56, phnum + 1)
return image


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 +149,7 @@ 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"
yield "invalid-tls-segment-outside-file", invalid_tls_outside_file(module([NOOP], sce=sce)), "PT_TLS initialization image is outside the file"


def main():
Expand Down
Loading