Skip to content

[ARM] Implement R_ARM_THM_PC8 relocation - #1776

Open
Deepak Shirke (deepakshirkem) wants to merge 1 commit into
qualcomm:mainfrom
deepakshirkem:fix/arm-thm-pc8-1337
Open

[ARM] Implement R_ARM_THM_PC8 relocation#1776
Deepak Shirke (deepakshirkem) wants to merge 1 commit into
qualcomm:mainfrom
deepakshirkem:fix/arm-thm-pc8-1337

Conversation

@deepakshirkem

@deepakshirkem Deepak Shirke (deepakshirkem) commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Implement the apply function for R_ARM_THM_PC8 using the formula S + A - P per ARM IHI0044. The result is encoded as imm8 = val >> 2 in the 16-bit Thumb LDR/ADR literal instruction (bits[7:0]). Only positive 4-byte aligned offsets in range [0, 1023] are permitted.

Fixes #1337

CC: Steven Ramirez Rosa (@Steven6798)

@Steven6798

Copy link
Copy Markdown
Contributor

Deepak Shirke (@deepakshirkem) remember to update the docs when a new relocation is added.

R_ARM_THM_PC8 was previously unsupported. Implement the apply
function using formula S + A - P per ARM IHI0044:
- Extract addend from 16-bit Thumb instruction imm8 field
- Positive offset only (no U bit)
- 10-bit range [0, 1023], must be 4-byte aligned
- Encode result as imm8 = val >> 2 in bits[7:0]

Signed-off-by: deepakshirkem <deepakshirke509@gmail.com>
pReloc.issueUnsignedOverflow(pParent, val, 0, 0x3fc);
return ARMRelocator::Overflow;
}
if (val & 0x3)

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.

Why is BadReloc returned here ? Do we have 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.

[ARM] R_ARM_THM_PC8: unsupported

4 participants