This is an archive of the discontinued LLVM Phabricator instance.

[MinGW] [ARM] Add stubs for potential automatic dllimported variables
ClosedPublic

Authored by mstorsjo on Aug 29 2018, 12:32 PM.

Details

Summary

The runtime pseudo relocations can't handle the ARM format embedded addresses in movw/movt pairs. By using stubs, the potentially dllimported addresses can be touched up by the runtime pseudo relocation framework.

The MachineOperand TargetFlags range (8 bits) is just about exhausted; this allocates the last bit to MO_COFFSTUB. (In the X86 target, the TargetFlags are just direct values, while most of it is used as a bitfield on ARM and AArch64.) An alternative, to conserve bits, would be to use MO_GOT (which doesn't have much meaning in a COFF context right now).

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Aug 29 2018, 12:32 PM
rnk accepted this revision.Aug 30 2018, 2:32 PM

lgtm, regardless of what we do with the external linkage bit.

lib/Target/ARM/ARMAsmPrinter.cpp
840 ↗(On Diff #163157)

Maybe we should just pass true here instead of !GV->hasInternalLinkage(). We should never use .refptr stubs to access internal symbols, right? They will always be DSO local, and should be accessible with other means.

We don't even use Stub.second.getInt() in the generic AsmPrinter.cpp code that emits the stub globals.

This revision is now accepted and ready to land.Aug 30 2018, 2:32 PM
mstorsjo added inline comments.Aug 31 2018, 12:53 AM
lib/Target/ARM/ARMAsmPrinter.cpp
840 ↗(On Diff #163157)

Sounds good; I'll change it similarly in the existing codepath for X86 as well.

This revision was automatically updated to reflect the committed changes.