Skip to content

Relaxation improvements - #1802

Open
Shankar Easwaran (quic-seaswara) wants to merge 2 commits into
mainfrom
relaxation_improvements
Open

Relaxation improvements#1802
Shankar Easwaran (quic-seaswara) wants to merge 2 commits into
mainfrom
relaxation_improvements

Conversation

@quic-seaswara

Copy link
Copy Markdown
Contributor

No description provided.

@quic-seaswara

Shankar Easwaran (quic-seaswara) commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Kernel, Zephyr and all the tests added for rollbacks continue to pass with this change.

@quic-seaswara
Shankar Easwaran (quic-seaswara) marked this pull request as ready for review September 2, 2026 03:41
Comment thread docs/DeveloperDocs/RelaxationDeferredEdits.md
Comment thread include/eld/Fragment/RelaxPlan.h Outdated
Comment thread lib/Fragment/FragmentRef.cpp
Comment thread lib/Target/GNULDBackend.cpp
Comment thread lib/Target/RISCV/RISCVLDBackend.cpp Outdated
Comment thread lib/Target/RISCV/RISCVLDBackend.cpp Outdated
Comment thread lib/Target/RISCV/RISCVLDBackend.cpp Outdated
Comment thread lib/Target/RISCV/RISCVLDBackend.cpp Outdated
Comment thread lib/Target/RISCV/RISCVLDBackend.cpp Outdated
Reverts 68db71e, 5fd859e, 9ed7e64, f010172 (post-ALIGN
AUIPC+JALR rollback and ALIGN re-run logic). Test files added by
these commits are kept in the tree for future reference.

Signed-off-by: Shankar Easwaran <seaswara@qti.qualcomm.com>
@quic-seaswara
Shankar Easwaran (quic-seaswara) force-pushed the relaxation_improvements branch 2 times, most recently from 4593fbc to 712433b Compare September 8, 2026 22:04
Relaxation decisions made in an earlier pass (AUIPC+JALR -> JAL/C.J,
HI20+LO12 -> GP-relative) can be invalidated by a later pass shrinking
a section further (notably R_RISCV_ALIGN), producing an encoding that
can no longer reach its target with no diagnostic.

Instead of applying each relaxation to the fragment buffer and the
relocation as soon as it's decided, record it per-fragment and apply
the whole set once relaxation has settled. Nothing is written until
then, so a decision that turns out not to fit can simply be dropped --
there is nothing to restore, since nothing was ever applied.

Committing a fragment's pending edits in one pass rewrites or deletes
instruction bytes and keeps the relocation's cached encoding in sync,
fixes up relocation and symbol offsets/sizes using the cumulative
effect of every edit, compacts the buffer, and applies any deferred
relocation type/addend changes.

A settle step runs once the main relaxation loop exits, and repeats
until stable, recomputing program headers between rounds. It
re-verifies every deferred call and GP-relative relaxation against
final addresses, rolls back any that no longer fit, and re-decides
alignment padding before committing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Shankar Easwaran <seaswara@qti.qualcomm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel-check zephyr-check Run Zephyr build/check workflow on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants