From 865d01a3cf28f826d482d9e3604d90d9f49b2fc9 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Thu, 31 Aug 2017 08:28:48 +0000 Subject: [AArch64] Support COFF linker directives This is similar to what was done for ARM in SVN r269574; the code and the test are straight copypaste to the corresponding AArch64 code and test directory. Differential revision: https://reviews.llvm.org/D37204 llvm-svn: 312223 --- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp') diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp index 277c88c87c9..b7129bf56b7 100644 --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -17,6 +17,7 @@ #include "AArch64MachineFunctionInfo.h" #include "AArch64RegisterInfo.h" #include "AArch64Subtarget.h" +#include "AArch64TargetObjectFile.h" #include "InstPrinter/AArch64InstPrinter.h" #include "MCTargetDesc/AArch64AddressingModes.h" #include "MCTargetDesc/AArch64MCTargetDesc.h" @@ -209,6 +210,29 @@ void AArch64AsmPrinter::EmitEndOfAsmFile(Module &M) { OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); SM.serializeToStackMapSection(); } + + if (TT.isOSBinFormatCOFF()) { + const auto &TLOF = + static_cast(getObjFileLowering()); + + std::string Flags; + raw_string_ostream OS(Flags); + + for (const auto &Function : M) + TLOF.emitLinkerFlagsForGlobal(OS, &Function); + for (const auto &Global : M.globals()) + TLOF.emitLinkerFlagsForGlobal(OS, &Global); + for (const auto &Alias : M.aliases()) + TLOF.emitLinkerFlagsForGlobal(OS, &Alias); + + OS.flush(); + + // Output collected flags + if (!Flags.empty()) { + OutStreamer->SwitchSection(TLOF.getDrectveSection()); + OutStreamer->EmitBytes(Flags); + } + } } void AArch64AsmPrinter::EmitLOHs() { -- cgit v1.2.3