This is an archive of the discontinued LLVM Phabricator instance.

[lld] [COFF] Support 128 bit SIMD/FP ldr/str in IMAGE_REL_ARM64_PAGEOFFSET_12L
ClosedPublic

Authored by mstorsjo on Jul 19 2017, 2:49 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Jul 19 2017, 2:49 PM
ruiu edited edge metadata.Jul 19 2017, 2:55 PM

Where is this behavior documented?

COFF/Chunks.cpp
190 ↗(On Diff #107391)

This is probably more straightforward:

if (Orig & 0x280000)
  Size += 4;
In D35647#815266, @ruiu wrote:

Where is this behavior documented?

On page 533 and 1108 in "ARM Architecture Reference Manual ARMv8, for ARMv8-A architecture profile", at https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile. I found a direct link to a copy if the pdf at http://mazsola.iit.uni-miskolc.hu/~drdani/docs_arm/DDI0487A_e_armv8_arm.pdf as well.

Or if you mean what instruction forms IMAGE_REL_ARM64_PAGEOFFSET_12L can refer to; the official pecoff document doesn't say, but this is based on the instructions that I've seen LLVM produce, with this relocation. That originates from AArch64::fixup_aarch64_ldst_imm12_scale1, ..._scale2, 4, 8 and 16 (in lib/Target/AArch64/MCTargetDesc/AArch64WinCOFFObjectWriter.cpp) - I haven't tried to backtrack to see if those can be applied to other instruction forms as well.

COFF/Chunks.cpp
190 ↗(On Diff #107391)

Sure - I'll update the patch later today.

ruiu added a comment.Jul 19 2017, 10:07 PM

I wanted to ask about IMAGE_REL_ARM64_PAGEOFFSET_12L. Sorry for the confusion. The reason why I wanted more information is because, with this patch, a relocation with this relocation type behaves differently depending on an instruction to which the relocation is applied. I think that is not common. Usually, relocations are agnostic on instructions they are modifying but just blindly mutate bits where they are applied. If you need some different behavior, I thought you'd define a different relocation type.

That being said, is this behavior the same as the Microsoft linker? If so, it's correct whether it is odd or not.

In D35647#815648, @ruiu wrote:

I wanted to ask about IMAGE_REL_ARM64_PAGEOFFSET_12L. Sorry for the confusion. The reason why I wanted more information is because, with this patch, a relocation with this relocation type behaves differently depending on an instruction to which the relocation is applied. I think that is not common. Usually, relocations are agnostic on instructions they are modifying but just blindly mutate bits where they are applied. If you need some different behavior, I thought you'd define a different relocation type.

That being said, is this behavior the same as the Microsoft linker? If so, it's correct whether it is odd or not.

Yes, I've checked it with their linker. (Even though the MSVC compiler for ARM64 isn't available publicly yet, link.exe from MSVC 2013 and onwards already seems to support ARM64.)

I think the sizes are separate relocation types in other object file types, but perhaps Microsoft wanted to save on the number of different relocation. (What's the available range for them in COFF?)

COFF/Chunks.cpp
190 ↗(On Diff #107391)

Actually, it'd be like this:

// 0x04000000 indicates SIMD/FP registers
// 0x00800000 indicates 128 bit
if ((Orig & 0x4800000) == 0x4800000)
  Size += 4;
mstorsjo updated this revision to Diff 107468.Jul 20 2017, 2:45 AM

Rewrote the condition as suggested by Rui (with modifications to keep the exact behaviour as before).

ruiu accepted this revision.Jul 20 2017, 5:12 AM

LGTM

This revision is now accepted and ready to land.Jul 20 2017, 5:12 AM
This revision was automatically updated to reflect the committed changes.