diff options
Diffstat (limited to 'lib/Target/AArch64/AArch64MCInstLower.cpp')
| -rw-r--r-- | lib/Target/AArch64/AArch64MCInstLower.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/Target/AArch64/AArch64MCInstLower.cpp b/lib/Target/AArch64/AArch64MCInstLower.cpp index f82b9dbc2c9f7..65dae03a24db2 100644 --- a/lib/Target/AArch64/AArch64MCInstLower.cpp +++ b/lib/Target/AArch64/AArch64MCInstLower.cpp @@ -18,7 +18,9 @@ #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/TargetLoweringObjectFile.h" #include "llvm/IR/Mangler.h" +#include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" #include "llvm/Support/CodeGen.h" @@ -33,7 +35,25 @@ AArch64MCInstLower::AArch64MCInstLower(MCContext &ctx, AsmPrinter &printer) MCSymbol * AArch64MCInstLower::GetGlobalAddressSymbol(const MachineOperand &MO) const { - return Printer.getSymbol(MO.getGlobal()); + const GlobalValue *GV = MO.getGlobal(); + unsigned TargetFlags = MO.getTargetFlags(); + const Triple &TheTriple = Printer.TM.getTargetTriple(); + if (!TheTriple.isOSBinFormatCOFF()) + return Printer.getSymbol(GV); + + assert(TheTriple.isOSWindows() && + "Windows is the only supported COFF target"); + + bool IsIndirect = (TargetFlags & AArch64II::MO_DLLIMPORT); + if (!IsIndirect) + return Printer.getSymbol(GV); + + SmallString<128> Name; + Name = "__imp_"; + Printer.TM.getNameWithPrefix(Name, GV, + Printer.getObjFileLowering().getMangler()); + + return Ctx.getOrCreateSymbol(Name); } MCSymbol * |
