This is an archive of the discontinued LLVM Phabricator instance.

[ARM] [COFF] Properly produce cross-section relative relocations
ClosedPublic

Authored by mstorsjo on Mar 30 2021, 3:28 AM.

Diff Detail

Event Timeline

mstorsjo created this revision.Mar 30 2021, 3:28 AM
mstorsjo requested review of this revision.Mar 30 2021, 3:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2021, 3:28 AM
compnerd added inline comments.Mar 30 2021, 8:38 AM
llvm/lib/Target/ARM/MCTargetDesc/ARMWinCOFFObjectWriter.cpp
59

I'm not sure I understand entirely how this works. If this is used in a data only table, the data is now PC-relative. Is that really the same thing? Everything on COFF is PC-relative if it is base relocated, but that requires generation in the frontend to account for that, which understands the semantics for the data better than we do at this point.

mstorsjo added inline comments.Mar 30 2021, 8:57 AM
llvm/lib/Target/ARM/MCTargetDesc/ARMWinCOFFObjectWriter.cpp
59

If it's a table of plain addresses, not address differences, I think IsCrossSection isn't set. The coff-relocations.s testcase has a check for it, see around the addr32 label.

As for who makes sure the offset is adjusted to be PC relative (when the subtracted bit in the asm expression isn't the PC but some other address), not entirely sure, but apparently it's done by some other MC layer. This corresponds pretty much 1:1 to the same in the X86 target, see https://github.com/llvm/llvm-project/blob/llvmorg-11.1.0/llvm/lib/Target/X86/MCTargetDesc/X86WinCOFFObjectWriter.cpp#L46-L52.

rnk accepted this revision.Apr 13 2021, 1:53 PM

Approving to unblock.

This revision is now accepted and ready to land.Apr 13 2021, 1:53 PM
This revision was landed with ongoing or failed builds.Apr 14 2021, 2:57 AM
This revision was automatically updated to reflect the committed changes.