llvm.org GIT mirror llvm / ecacffa
ARM: correctly mangle dllimport symbols Add support for tracking DLLImport storage class information on a per symbol basis in the ARM instruction selection. Use that information to correctly mangle the symbol (dllimport symbols are referenced via *__imp_<name>). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212430 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 5 years ago
2 changed file(s) with 40 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
794794
795795 MCSymbol *ARMAsmPrinter::GetARMGVSymbol(const GlobalValue *GV,
796796 unsigned char TargetFlags) {
797 bool isIndirect = Subtarget->isTargetMachO() &&
798 (TargetFlags & ARMII::MO_NONLAZY) &&
799 Subtarget->GVIsIndirectSymbol(GV, TM.getRelocationModel());
800 if (!isIndirect)
797 if (Subtarget->isTargetMachO()) {
798 bool IsIndirect = (TargetFlags & ARMII::MO_NONLAZY) &&
799 Subtarget->GVIsIndirectSymbol(GV, TM.getRelocationModel());
800
801 if (!IsIndirect)
802 return getSymbol(GV);
803
804 // FIXME: Remove this when Darwin transition to @GOT like syntax.
805 MCSymbol *MCSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
806 MachineModuleInfoMachO &MMIMachO =
807 MMI->getObjFileInfo();
808 MachineModuleInfoImpl::StubValueTy &StubSym =
809 GV->hasHiddenVisibility() ? MMIMachO.getHiddenGVStubEntry(MCSym)
810 : MMIMachO.getGVStubEntry(MCSym);
811 if (!StubSym.getPointer())
812 StubSym = MachineModuleInfoImpl::StubValueTy(getSymbol(GV),
813 !GV->hasInternalLinkage());
814 return MCSym;
815 } else if (Subtarget->isTargetCOFF()) {
816 assert(Subtarget->isTargetWindows() &&
817 "Windows is the only supported COFF target");
818
819 bool IsIndirect = (TargetFlags & ARMII::MO_DLLIMPORT);
820 if (!IsIndirect)
821 return getSymbol(GV);
822
823 SmallString<128> Name;
824 Name = "__imp_";
825 getNameWithPrefix(Name, GV);
826
827 return OutContext.GetOrCreateSymbol(Name);
828 } else if (Subtarget->isTargetELF()) {
801829 return getSymbol(GV);
802
803 // FIXME: Remove this when Darwin transition to @GOT like syntax.
804 MCSymbol *MCSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
805 MachineModuleInfoMachO &MMIMachO =
806 MMI->getObjFileInfo();
807 MachineModuleInfoImpl::StubValueTy &StubSym =
808 GV->hasHiddenVisibility() ? MMIMachO.getHiddenGVStubEntry(MCSym) :
809 MMIMachO.getGVStubEntry(MCSym);
810 if (!StubSym.getPointer())
811 StubSym = MachineModuleInfoImpl::
812 StubValueTy(getSymbol(GV), !GV->hasInternalLinkage());
813 return MCSym;
830 }
831 llvm_unreachable("unexpected target");
814832 }
815833
816834 void ARMAsmPrinter::
294294
295295 /// MO_OPTION_MASK - Most flags are mutually exclusive; this mask selects
296296 /// just that part of the flag set.
297 MO_OPTION_MASK = 0x7f,
297 MO_OPTION_MASK = 0x3f,
298
299 /// MO_DLLIMPORT - On a symbol operand, this represents that the reference
300 /// to the symbol is for an import stub. This is used for DLL import
301 /// storage class indication on Windows.
302 MO_DLLIMPORT = 0x40,
298303
299304 /// MO_NONLAZY - This is an independent flag, on a symbol operand "FOO" it
300305 /// represents a symbol which, if indirect, will get special Darwin mangling