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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public enum RelocType

// Linux arm32
IMAGE_REL_ARM_PREL31 = 0x10D,
IMAGE_REL_ARM_JUMP24 = 0x10E,

//
// Relocations for R2R image production
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ protected internal override unsafe void EmitRelocation(
Relocation.WriteValue(relocType, (void*)pData, inlineValue + addend);
}
addend = 0;

// Determine if this is call (BL[X]) or jump (B) since they use different
// relocation codes in ELF.
// B.W 1111 0Sii iiii iiii 10J1 Jiii iiii iiii
// BL 1111 0Sii iiii iiii 11J1 Jiii iiii iiii
// BLX 1111 0Sii iiii iiii 11J0 Jiii iiii iii0
if (relocType is IMAGE_REL_BASED_THUMB_BRANCH24 && (pData[3] & 0x40) != 0x40)
{
relocType = IMAGE_REL_ARM_JUMP24;
}
}
}

Expand Down Expand Up @@ -378,6 +388,7 @@ private void EmitRelocationsARM(int sectionIndex, List<SymbolicRelocation> reloc
IMAGE_REL_BASED_THUMB_MOV32 => R_ARM_THM_MOVW_ABS_NC,
IMAGE_REL_BASED_THUMB_MOV32_PCREL => R_ARM_THM_MOVW_PREL_NC,
IMAGE_REL_BASED_THUMB_BRANCH24 => R_ARM_THM_CALL,
IMAGE_REL_ARM_JUMP24 => R_ARM_THM_JUMP24,
IMAGE_REL_ARM_PREL31 => R_ARM_PREL31,
_ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type)
};
Expand Down