Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NativeAOT] ELF ARM: Produce different relocation type for B and BL #97823

Merged
merged 1 commit into from
Feb 2, 2024

Conversation

filipnavara
Copy link
Member

@filipnavara filipnavara commented Feb 1, 2024

Release builds produce tail calls. When the target of a tail call is external function it was generated with B.W instruction and R_ARM_THM_CALL relocation. The linker then incorrectly overwrote some bits of the instruction.

Object file:

000564b0 <System.Math__Ceiling>:
   564b0:       b508            push    {r3, lr}
   564b2:       b001            add     sp, #4
   564b4:       f85d eb04       ldr.w   lr, [sp], #4
   564b8:       f7ff bffe       b.w     0 <ceil>
   564bc:       0000            movs    r0, r0

Incorrectly linked executable:

002a6f60 <System.Math__Ceiling>:
  2a6f60:       b508            push    {r3, lr}
  2a6f62:       b001            add     sp, #4
  2a6f64:       f85d eb04       ldr.w   lr, [sp], #4
  2a6f68:       f14a afba       bpl.w   371ee0
  2a6f6c:       0000            movs    r0, r0

Correctly linked executable:

002a6f60 <System.Math__Ceiling>:
  2a6f60:       b508            push    {r3, lr}
  2a6f62:       b001            add     sp, #4
  2a6f64:       f85d eb04       ldr.w   lr, [sp], #4
  2a6f68:       f149 beb8       b.w     3f0cdc <__ThumbV7PILongThunk_ceil>
  2a6f6c:       0000            movs    r0, r0

Contributes to #97729

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Feb 1, 2024
@ghost
Copy link

ghost commented Feb 1, 2024

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Release builds produce tail calls. When the target of a tail call is external function it was generated with B.W instruction and R_ARM_THM_CALL relocation. The linker then incorrectly overwrote some bits of the instruction.

Object file:

000564b0 <System.Math__Ceiling>:
   564b0:       b508            push    {r3, lr}
   564b2:       b001            add     sp, #4
   564b4:       f85d eb04       ldr.w   lr, [sp], #4
   564b8:       f7ff bffe       b.w     0 <ceil>
   564bc:       0000            movs    r0, r0

Incorrectly linked executable:

002a6f60 <System.Math__Ceiling>:
  2a6f60:       b508            push    {r3, lr}
  2a6f62:       b001            add     sp, #4
  2a6f64:       f85d eb04       ldr.w   lr, [sp], #4
  2a6f68:       f14a afba       bpl.w   371ee0
  2a6f6c:       0000            movs    r0, r0
Author: filipnavara
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks

@jkotas jkotas merged commit e9539aa into dotnet:main Feb 2, 2024
110 checks passed
@filipnavara filipnavara deleted the naot-arm-tailcall-reloc branch February 2, 2024 04:08
@github-actions github-actions bot locked and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-arm32 area-NativeAOT-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants