Skip to content

[ELD] Fix ARM OVERLAY VMA/LMA layout - #1731

Closed
Steven Ramirez Rosa (Steven6798) wants to merge 1 commit into
qualcomm:mainfrom
Steven6798:issue-1724
Closed

[ELD] Fix ARM OVERLAY VMA/LMA layout#1731
Steven Ramirez Rosa (Steven6798) wants to merge 1 commit into
qualcomm:mainfrom
Steven6798:issue-1724

Conversation

@Steven6798

Copy link
Copy Markdown
Contributor

Handle OVERLAY members at their shared VMA, assign the first member's AT() LMA, and place subsequent members consecutively. Allow intentional virtual-address overlap between members of the same OVERLAY.

Add an ARM Linux kernel linker-script regression test covering section addresses and program-header VMAs/LMAs.

Fix: #1724

Comment thread lib/Target/CreateProgramHeaders.hpp Outdated
Comment thread lib/Target/CreateProgramHeaders.hpp Outdated
@Steven6798

Copy link
Copy Markdown
Contributor Author

quic-areg I see that the zephyr check fails but I don't know what to make of the results.

Place OVERLAY members at their shared virtual address and allow the
intentional VMA overlap between members of the same OVERLAY. Use the
OVERLAY AT() address as the first member's load address and assign
consecutive LMAs to subsequent members.

Handle overlays without an explicit VMA by deriving the address from the
location counter, and preserve declaration order when chaining LMAs,
including across empty members.

Extend ARM linker-script regression coverage for section and program-header
VMA/LMA layouts, empty first members, and reversed member order.

Fix: qualcomm#1724

Signed-off-by: Steven Ramirez Rosa <ramirezr@qti.qualcomm.com>
@Steven6798

Copy link
Copy Markdown
Contributor Author

Workflows are failing due to reasons unrelated to this PR. I'll track these issues and re-run this PR after they are fixed.

@parth-07 Parth (parth-07) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Steven Ramirez Rosa (@Steven6798) We also need to update CreateScriptProgramHeaders to handle correctly handle overlay when the linker script specifies PHDRS.

@Steven6798

Copy link
Copy Markdown
Contributor Author

Steven Ramirez Rosa (Steven Ramirez Rosa (@Steven6798)) We also need to update CreateScriptProgramHeaders to handle correctly handle overlay when the linker script specifies PHDRS.

Thanks. I'll look into this.

.vectors.bhb.loop8 { KEEP(*(.vectors.bhb.loop8)) }
.vectors { KEEP(*(.vectors)) }
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you place something after the overlay to make sure that the location counter is advanced correctly? Something like after = .;. From the issue desc, it looks like we are advancing the location counter after an overlay by the size of the last section rather than the largest section.

cat > 1.s << \!
.section .a, "ax", %progbits
  .space 0x20
.section .b, "ax", %progbits
  .space 0x40
.section .t, "ax", %progbits
.global _start
_start:
  .space 0x10
!

cat > script.t << \!
SECTIONS {
  . = 0x1000;
  .t : { *(.t) }
  OVERLAY 0x9000 : AT(0x8000) { .b { *(.b) } .a { *(.a) } }
  after = .;
}
!

clang -target arm-linux-gnueabi -c 1.s
ld.eld 1.o -T script.t -o A
ld.lld 1.o -T script.t -o B
llvm-readelf -s A B | grep after

// prologue; those values belong to the enclosing OverlayDesc.
if (isOverlayMember) {
if (overlay->hasStart()) {
overlay->start()->evaluateAndRaiseError();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need to re-evaluate the start expression for each member?

@Steven6798

Steven Ramirez Rosa (Steven6798) commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

The initial scope of this PR was to address a failure in ARM Linux kernel build. The Overlay feature applies to more than just ARM and it looks like ELD is missing much more than I anticipated. We might need to break this feature into multiple follow-ups, address one thing at a time and test all architectures. This looks like a better approach than to focus everything in one PR focused just on ARM. Any feedback?

@Steven6798

Copy link
Copy Markdown
Contributor Author

We might need to break this feature into multiple follow-ups, address one thing at a time and test all architectures. This looks like a better approach than to focus everything in one PR focused just on ARM.

Follow up: #1745

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working 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.

[arm] Linux kernel link fails with "virtual address range overlaps" error

3 participants