Skip to content

[ARM] Implement R_ARM_LDC_PC_G1 relocation - #2069

Draft
Deepak Shirke (deepakshirkem) wants to merge 2 commits into
qualcomm:mainfrom
deepakshirkem:fix/arm-ldc-pc-g1
Draft

Deepak Shirke (deepakshirkem) wants to merge 2 commits into
qualcomm:mainfrom
deepakshirkem:fix/arm-ldc-pc-g1

Conversation

@deepakshirkem

@deepakshirkem Deepak Shirke (deepakshirkem) commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

R_ARM_LDC_PC_G1 was previously mapped to the unsupported relocation handler. This change implements the relocation by reusing the shared LDC PC-group handler with group 1 selection.

The relocation uses:

  • S + A - P
  • implicit addend from U:imm8
  • U bit for the sign
  • group 1 residual selection
  • imm8 for the scaled 8-bit immediate
  • 4-byte alignment checking
  • overflow checking when the selected residual is outside [0, 1023]

Fixes #2070

Part of #2001

CC: Steven Ramirez Rosa (@Steven6798)

R_ARM_LDC_PC_G0 was previously unsupported. Add a shared LDC PC-group relocation handler with group 0 selection.

The relocation computes S + A - P, selects the G0 residual, encodes the sign in U, and encodes the scaled 8-bit immediate, reporting overflow when the selected residual does not fit the supported range.

Add standalone tests covering positive and negative PC-relative offsets and overflow handling, along with a runtime test using a VLDR PC-relative load.

Update the ARM relocation documentation for R_ARM_LDC_PC_G0 support.

Signed-off-by: deepakshirkem <deepakshirke509@gmail.com>
R_ARM_LDC_PC_G1 was previously unsupported.

Reuse the shared LDC PC-group relocation handler with group 1 selection.

The relocation computes S + A - P, derives the implicit addend from the
U bit and scaled imm8 field, selects the G1 residual, and encodes the
result back into the instruction. The residual must be 4-byte aligned
and fit in the [0, 1023] range.

Add standalone positive, negative, and overflow coverage, along with a
runtime test using R_ARM_ALU_PC_G0_NC and R_ARM_LDC_PC_G1. Update the ARM
relocation documentation to mark R_ARM_LDC_PC_G1 as supported.

Signed-off-by: deepakshirkem <deepakshirke509@gmail.com>
@deepakshirkem

Copy link
Copy Markdown
Contributor Author

Once G0 lands, I’ll drop the G0 commit and rebase onto main for review. Thank you :))

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.

Looks good. I'll review and approve as soon as the R_ARM_LDC_PC_G0 patch lands.

This branch has not been deployed

No deployments
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.

[ARM] R_ARM_LDC_PC_G1 relocation is unsupported

2 participants