Page MenuHomePhabricator

MS ABI: Implement x86_64 RTTI
ClosedPublic

Authored by majnemer on Jun 15 2014, 8:27 AM.

Details

Summary

The RTTI scheme for x86_64 is largely the same as the one for i386.

Differences are largely limited to avoiding load-time relocations by
replacing pointers to RTTI metadata with the difference of that data
relative to the load address of the module.

Interestingly, this precludes the possibility of successfully using RTTI
data from another DLL. The ImageBase reference is always relative to
the current DLL.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 10422.Jun 15 2014, 8:27 AM
majnemer retitled this revision from to MS ABI: Implement x86_64 RTTI.
majnemer updated this object.
majnemer added reviewers: rnk, whunt.
majnemer added a subscriber: Unknown Object (MLST).
majnemer updated this revision to Diff 10424.Jun 15 2014, 9:39 AM
  • Small stylistic tweak.
whunt edited edge metadata.Jun 15 2014, 12:24 PM

lgtm, with a few minor nits. Also, I'm assuming you compared the output with cl?

lib/CodeGen/MicrosoftRTTI.cpp
60 ↗(On Diff #10424)

is it more normal do do this this way or use
return isImageRelative(CGM) ? PtrType : CGM.IntTy;
?

156 ↗(On Diff #10424)

I assume ArrayRef can take a pointer and a size. If so I think it would be more reasonable to adjust the input size rather than slicing the result.

Yes, I checked the output against x64 CL.

Let me know how you feel about my two inline comments and I'll commit after.

lib/CodeGen/MicrosoftRTTI.cpp
60 ↗(On Diff #10424)

I did it this way to mirror getImageRelativeConstant.

156 ↗(On Diff #10424)

I could do something like:

llvm::ArrayRef<llvm::Type *> FieldTypesRef(
    std::begin(FieldTypes),
    isImageRelative(CGM) ? std::end(FieldTypes) : std::end(FieldTypes) - 1);
majnemer closed this revision.Jun 16 2014, 11:55 AM
majnemer updated this revision to Diff 10454.

Closed by commit rL211041 (authored by @majnemer).