Skip to content

Fix evaluation order of (before/in/after)-SECTIONS assignments#1203

Open
parth-07 wants to merge 1 commit into
qualcomm:mainfrom
parth-07:AssignmentEvaluationOrder
Open

Fix evaluation order of (before/in/after)-SECTIONS assignments#1203
parth-07 wants to merge 1 commit into
qualcomm:mainfrom
parth-07:AssignmentEvaluationOrder

Conversation

@parth-07
Copy link
Copy Markdown
Contributor

@parth-07 parth-07 commented May 21, 2026

Until now, eld used to incorrectly evaluate before SECTIONS and after SECTIONS assignments both before and after the in-SECTIONS assignments. This results in incorrect linker script symbol values and incorrect layout.

This patch fixes this linker script assignment evaluation order. Now, we evaluate the assignments after the SECTIONS command as part of the layout re-iteration loop in create(Script)ProgramHeaders.

One of the key design change in this patch is to store AfterSections assignments with the last output section. It is required to properly evaluate the assignments when the link contains multiple SECTIONS commands.

Resolves #430

Copy link
Copy Markdown
Contributor

@Steven6798 Steven6798 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@parth-07 parth-07 force-pushed the AssignmentEvaluationOrder branch from 258b4d0 to adea124 Compare June 1, 2026 16:33
Until now, eld used to incorrectly evaluate before SECTIONS and after
SECTIONS assignments both before and after the in-SECTIONS assignments.
This results in incorrect linker script symbol values and incorrect
layout.

This patch fixes the linker script assignment evaluation order. Now, we
evaluate the assignments after the SECTIONS command as part of the
layout re-iteration loop in create(Script)ProgramHeaders.

One of the key design change in this patch is to store AfterSections
assignments with the last output section. It is required to properly
evaluate the assignments when the link contains multiple SECTIONS
commands.

Resolves qualcomm#430

Signed-off-by: Parth Arora <partaror@qti.qualcomm.com>
@parth-07 parth-07 force-pushed the AssignmentEvaluationOrder branch from adea124 to 00d10a3 Compare June 3, 2026 17:56
Copy link
Copy Markdown
Contributor

@quic-seaswara quic-seaswara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the map file print the assignments, can you please add a test ?

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.

Assignments after SECTIONS command should be evaluated after evaluating assignments in SECTIONS command

3 participants