Skip to content

feat(args): implement --image-base (reld#14) - #165

Merged
zackees merged 1 commit into
mainfrom
feat/14-image-base
Sep 17, 2026
Merged

zackees merged 1 commit into
mainfrom
feat/14-image-base

Conversation

@zackees

@zackees zackees commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Advances #14 (Wave 2 of #153) — one more entry off the mold skip list, from the evidence gathered in #158.

What was missing

The output image's base address was an architecture constant (Arch::start_memory_address) with no override, so --image-base was rejected outright. It now threads through the platform Args trait as Option<u64> defaulting to None, which leaves every link that does not pass the flag on exactly the address it had — the default is not re-expressed anywhere, so it cannot drift.

Verified against the real thing

--image-base=0x8000000          -> .interp at 0x8000a78, binary runs
--image-base=0xffffffff80000000 -> .text   at 0xffffffff80001460

The second matters: a kernel-style high base has to survive as an unsigned 64-bit value rather than wrapping.

image-base.sh comes off the skip list.

synthetic-symbols.sh stays, for the right reason

It was listed under --image-base too. That flag is no longer why it fails: it now gets through the first half and fails in the second, where a program defines __ehdr_start, _end, _etext and friends itself and mold requires the synthetic definitions to win. The comment now says that, so the next person does not go looking at the wrong flag — which is the same mistake #158 fixed across the rest of the list.

Verification

  • cargo test -p reld-core --lib args::elf::tests::image_base_overrides_the_architecture_default — passes; covers the default, both spellings, the high base, and a rejected value.
  • Full mold suite: 399 passed, 4 failed — the same four NixOS host failures (rpath.sh, sframe.sh, trace.sh, weak-export-dso2.sh) that fail identically on main.
  • cargo test --test acceptance: 212 passed, 11 failed — the same pre-existing environmental failures this host has on main.
  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings — clean.

🤖 Generated with Claude Code

The base address was an architecture constant with no way to override it, so
`--image-base` was rejected outright. It now threads through the platform Args
trait as an `Option<u64>` that defaults to `None`, which leaves every link that
does not pass the flag on exactly the address it had.

`image-base.sh` comes off the mold skip list. `synthetic-symbols.sh` stays, but
for the right reason now: `--image-base` works, and it fails in its second half,
where a program defines `__ehdr_start` and friends itself and the synthetic
definitions are required to win.

Verified against the real thing: `--image-base=0x8000000` puts `.interp` at
0x8000a78 and the binary runs, and `--image-base=0xffffffff80000000` puts
`.text` at 0xffffffff80001460, so a kernel-style high base survives as unsigned.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zackees
zackees merged commit d22e844 into main Sep 17, 2026
18 checks passed
@zackees
zackees deleted the feat/14-image-base branch September 17, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant