Skip to content

[ARM] Implement R_ARM_LDR_PC_G2 relocation - #1734

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

[ARM] Implement R_ARM_LDR_PC_G2 relocation#1734
Steven Ramirez Rosa (Steven6798) wants to merge 1 commit into
qualcomm:mainfrom
Steven6798:issue-1733

Conversation

@Steven6798

Copy link
Copy Markdown
Contributor

Add support for R_ARM_LDR_PC_G2 by sharing the ARM LDR PC-group residual encoding logic and wiring the relocation to the ARM apply table. The implementation extracts the signed LDR literal addend, computes S + A - P, selects the output U bit from the displacement sign, and writes the group residual into the imm12 field with overflow checking.

Add standalone ARM relocation coverage for both a valid R_ARM_LDR_PC_G2 encoding and an overflow case where the group residual does not fit in imm12.

Fix: #1733

Comment thread test/ARM/standalone/Relocs/R_ARM_LDR_PC_G2/R_ARM_LDR_PC_G2.test Outdated
Comment thread lib/Target/ARM/ARMRelocator.cpp Outdated
Comment thread test/ARM/standalone/Relocs/R_ARM_LDR_PC_G2/Inputs/valid.s Outdated
Comment thread test/ARM/standalone/Relocs/R_ARM_LDR_PC_G2/Inputs/valid.s
.arm

.section .text.1, "ax", %progbits
.space 0x28

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 use .space directive in this test?

@Steven6798 Steven Ramirez Rosa (Steven6798) Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is used to in the test to produce the value 0xfd8. Makes the testing easier. Let me know if there is a better and cleaner way to do this.

Comment thread lib/Target/ARM/ARMRelocator.cpp Outdated
Add support for R_ARM_LDR_PC_G2 by sharing the ARM LDR PC-group
residual encoding logic and wiring the relocation to the ARM apply
table. The implementation extracts the signed LDR literal addend,
computes S + A - P, selects the output U bit from the displacement sign,
and writes the group residual into the imm12 field with overflow
checking.

Add standalone ARM relocation coverage for both a valid R_ARM_LDR_PC_G2
encoding and an overflow case where the group residual does not fit in
imm12.

Fix: qualcomm#1733

Signed-off-by: Steven Ramirez Rosa <ramirezr@qti.qualcomm.com>
@@ -0,0 +1,13 @@
.arm

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.

This file looks identical to valid.s. Can we just use one copy?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I missed that. Thanks!

@Steven6798
Steven Ramirez Rosa (Steven6798) marked this pull request as draft August 21, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arm bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ARM] R_ARM_LDR_PC_G2: unsupported

3 participants