This is an archive of the discontinued LLVM Phabricator instance.

[COFF] [ARM64] Create symbols with regular intervals for relocations against temporary symbols
ClosedPublic

Authored by mstorsjo on Nov 21 2021, 2:27 PM.

Details

Summary

For relocations against temporary symbols (that don't persist in
the object file), we normally adjust them to reference the start of
the section.

For adrp relocations, the immediate offset from the referenced
symbol is stored in the opcode as the 21 bit signed immediate; this
means that the symbol referenced must be within +/- 1 MB from the
referenced symbol.

Create label symbols with regular intervals (1 MB intervals). For
relocations against temporary symbols, pick the preceding added
offset symbol and make the relocation against that instead of
against the start of the section.

This should fix the root issue behind
https://bugs.llvm.org/show_bug.cgi?id=52378.

Diff Detail

Event Timeline

mstorsjo created this revision.Nov 21 2021, 2:27 PM
mstorsjo requested review of this revision.Nov 21 2021, 2:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 21 2021, 2:27 PM
rnk accepted this revision.Nov 22 2021, 11:11 AM

lgtm

Just nits

llvm/lib/MC/WinCOFFObjectWriter.cpp
155–156

These should both really have default member initializers (= false). Looking at the constructor, it's not at all clear how UseBigObj is initialized.

I thought this was part of CodingStandards, but I don't see it there. *shrug*

167

This looks like it should re-initialize UseBigObj, and maybe some other fields... I'm not sure what codepath exercises this reset method (maybe LTO, since it emits multiple objects in process?), but it seems buggy and beyond the scope of this patch.

This revision is now accepted and ready to land.Nov 22 2021, 11:11 AM
mstorsjo added inline comments.Nov 23 2021, 12:11 AM
llvm/lib/MC/WinCOFFObjectWriter.cpp
155–156

I'll add a default initialization of the newly added variable here just for clarity, but I'm leaving the existing code as is for now.