@@ -255,6 +255,9 @@ class IRABIDetailsProvider {
255255 Direct,
256256 // / An indirect call that can be made via a static offset in a vtable.
257257 IndirectVTableStaticOffset,
258+ // / An indirect call that should be made via an offset relative to
259+ // / external base value in a vtable.
260+ IndirectVTableRelativeOffset,
258261 // / The call should be made via the provided thunk function.
259262 Thunk
260263 };
@@ -268,44 +271,73 @@ class IRABIDetailsProvider {
268271 }
269272
270273 static MethodDispatchInfo indirectVTableStaticOffset (
271- size_t bitOffset , Optional<PointerAuthDiscriminator> discriminator) {
272- return MethodDispatchInfo (Kind::IndirectVTableStaticOffset, bitOffset , " " ,
274+ size_t offset , Optional<PointerAuthDiscriminator> discriminator) {
275+ return MethodDispatchInfo (Kind::IndirectVTableStaticOffset, offset , " " ,
273276 discriminator);
274277 }
275278
279+ static MethodDispatchInfo indirectVTableRelativeOffset (
280+ size_t offset, std::string symbolName,
281+ Optional<PointerAuthDiscriminator> discriminator) {
282+ return MethodDispatchInfo (Kind::IndirectVTableRelativeOffset, offset,
283+ symbolName, discriminator);
284+ }
285+
276286 static MethodDispatchInfo thunk (std::string thunkName) {
277287 return MethodDispatchInfo (Kind::Thunk, 0 , thunkName);
278288 }
279289
280290 Kind getKind () const { return kind; }
281- size_t getStaticBitOffset () const {
291+
292+ // / Return the byte offset into the vtable from which the method pointer
293+ // / should be loaded.
294+ size_t getStaticOffset () const {
282295 assert (kind == Kind::IndirectVTableStaticOffset);
283- return bitOffset ;
296+ return offset ;
284297 }
285298 Optional<PointerAuthDiscriminator> getPointerAuthDiscriminator () const {
286- assert (kind == Kind::IndirectVTableStaticOffset);
299+ assert (kind == Kind::IndirectVTableStaticOffset ||
300+ kind == Kind::IndirectVTableRelativeOffset);
287301 return discriminator;
288302 }
289303 StringRef getThunkSymbolName () const {
290304 assert (kind == Kind::Thunk);
291- return thunkName;
305+ return symbolName;
306+ }
307+
308+ // / Return the byte offset relative to base offset value into the vtable
309+ // / from which the method pointer should be loaded.
310+ size_t getRelativeOffset () const {
311+ assert (kind == Kind::IndirectVTableRelativeOffset);
312+ return offset;
313+ }
314+
315+ // / Return the external symbol from which the relative base offset should be
316+ // / loaded.
317+ StringRef getBaseOffsetSymbolName () const {
318+ assert (kind == Kind::IndirectVTableRelativeOffset);
319+ return symbolName;
292320 }
293321
294322 private:
295- MethodDispatchInfo (Kind kind, size_t bitOffset , std::string thunkName = " " ,
323+ MethodDispatchInfo (Kind kind, size_t offset , std::string symbolName = " " ,
296324 Optional<PointerAuthDiscriminator> discriminator = None)
297- : kind(kind), bitOffset(bitOffset ), thunkName(thunkName ),
325+ : kind(kind), offset(offset ), symbolName(symbolName ),
298326 discriminator (discriminator) {}
299327
300328 Kind kind;
301- size_t bitOffset ;
302- std::string thunkName ;
329+ size_t offset ;
330+ std::string symbolName ;
303331 Optional<PointerAuthDiscriminator> discriminator;
304332 };
305333
306334 Optional<MethodDispatchInfo>
307335 getMethodDispatchInfo (const AbstractFunctionDecl *funcDecl);
308336
337+ // / Returns the type of the base offset value located at the specific class
338+ // / base offset symbol.
339+ Type getClassBaseOffsetSymbolType () const ;
340+
309341private:
310342 std::unique_ptr<IRABIDetailsProviderImpl> impl;
311343};
0 commit comments