microsoft / microsoft/litebox

ELFs with specific alignment can fail rewriting

Open
#477 0 comments 0 reactions 1 assignee View on GitHub

@wdcui is already working on this.

Since Nov 7, 2025.

bug
Dominant language
Rust
Stars
2.7k
Forks
144
Avg merge
12h 21m
Merged PRs (30d)
146

Description

Discussed separately, but just placing this as a tracking issue for reference:

cargo run -p litebox_syscall_rewriter ./python3 -o /dev/null
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/litebox_syscall_rewriter ./python3 -o /dev/null`
Error: failed to generate object file: Unaligned sh_offset value 0x201000 for section '.text', expected 0x400000

python312.zip

@wdcui said

You’re hitting a layout quirk from BOLT/huge-page alignment:
In your ELF, .text has sh_addralign = 0x200000 (2 MiB).
But its sh_offset = 0x201000, which is not a multiple of 0x200000 (it’s 0x1000 past it).
Some writers (likely via the object crate under the hood) validate that sh_offset % sh_addralign == 0 when (re)emitting an object, and they error out. > Their “expected 0x400000” is the next 2 MiB multiple after 0x201000.

@CvvT said

Looks like a bug from object crate. Should we submit an issue to upstream?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.