2929#include " gen/runtime.h"
3030#include " gen/tollvm.h"
3131#include " gen/typinf.h"
32+ #include " gen/linkage.h"
3233#include " ir/iraggr.h"
3334#include " ir/irdsymbol.h"
3435#include " ir/irfunction.h"
@@ -89,8 +90,10 @@ LLGlobalVariable *IrClass::getVtblSymbol(bool define) {
8990
9091 if (define) {
9192 auto init = getVtblInit (); // might define vtbl
92- if (!vtbl->hasInitializer ())
93+ if (!vtbl->hasInitializer ()) {
9394 defineGlobal (vtbl, init, aggrdecl);
95+ vtbl->setLinkage (TYPEINFO_LINKAGE_TYPE); // override
96+ }
9497 }
9598
9699 return vtbl;
@@ -140,8 +143,10 @@ LLGlobalVariable *IrClass::getClassInfoSymbol(bool define) {
140143
141144 if (define) {
142145 auto init = getClassInfoInit ();
143- if (!typeInfo->hasInitializer ())
146+ if (!typeInfo->hasInitializer ()) {
144147 defineGlobal (typeInfo, init, aggrdecl);
148+ typeInfo->setLinkage (TYPEINFO_LINKAGE_TYPE); // override
149+ }
145150 }
146151
147152 return typeInfo;
@@ -381,7 +386,7 @@ LLConstant *IrClass::getClassInfoInit() {
381386 if (isInterface) {
382387 b.push_array (0 , getNullPtr ());
383388 } else {
384- b.push_array (cd->vtbl .length , getVtblSymbol ());
389+ b.push_array (cd->vtbl .length , getVtblSymbol (true )); // override
385390 }
386391
387392 // Interface[] interfaces
@@ -391,7 +396,9 @@ LLConstant *IrClass::getClassInfoInit() {
391396 assert (!isInterface || !cd->baseClass );
392397 if (cd->baseClass ) {
393398 DtoResolveClass (cd->baseClass );
394- b.push (getIrAggr (cd->baseClass )->getClassInfoSymbol ());
399+ auto ti = getIrAggr (cd->baseClass )->getClassInfoSymbol (true );
400+ ti->setLinkage (TYPEINFO_LINKAGE_TYPE); // override
401+ b.push (ti);
395402 } else {
396403 b.push_null (cinfoType);
397404 }
@@ -743,7 +750,7 @@ LLConstant *IrClass::getClassInfoInterfaces() {
743750 assert (itc && " null interface IrTypeClass" );
744751
745752 // classinfo
746- LLConstant *ci = irinter->getClassInfoSymbol ();
753+ LLConstant *ci = irinter->getClassInfoSymbol (true );
747754
748755 // vtbl
749756 LLConstant *vtb;
@@ -772,6 +779,7 @@ LLConstant *IrClass::getClassInfoInterfaces() {
772779 LLConstant *arr = LLConstantArray::get (array_type, constants);
773780 auto ciarr = getInterfaceArraySymbol ();
774781 defineGlobal (ciarr, arr, cd);
782+ ciarr->setLinkage (TYPEINFO_LINKAGE_TYPE); // override
775783
776784 // return null, only baseclass provide interfaces
777785 if (cd->vtblInterfaces ->length == 0 ) {
0 commit comments