1 //===-- LTOModule.cpp - LLVM Link Time Optimizer --------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the Link Time Optimization library. This library is
10 // intended to be used by linker to optimize code at link time.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/LTO/legacy/LTOModule.h"
15 #include "llvm/ADT/Triple.h"
16 #include "llvm/Bitcode/BitcodeReader.h"
17 #include "llvm/CodeGen/TargetSubtargetInfo.h"
18 #include "llvm/IR/Constants.h"
19 #include "llvm/IR/LLVMContext.h"
20 #include "llvm/IR/Mangler.h"
21 #include "llvm/IR/Metadata.h"
22 #include "llvm/IR/Module.h"
23 #include "llvm/MC/MCExpr.h"
24 #include "llvm/MC/MCInst.h"
25 #include "llvm/MC/MCParser/MCAsmParser.h"
26 #include "llvm/MC/MCSection.h"
27 #include "llvm/MC/MCSubtargetInfo.h"
28 #include "llvm/MC/MCSymbol.h"
29 #include "llvm/MC/SubtargetFeature.h"
30 #include "llvm/Object/IRObjectFile.h"
31 #include "llvm/Object/ObjectFile.h"
32 #include "llvm/Support/FileSystem.h"
33 #include "llvm/Support/Host.h"
34 #include "llvm/Support/MemoryBuffer.h"
35 #include "llvm/Support/Path.h"
36 #include "llvm/Support/SourceMgr.h"
37 #include "llvm/Support/TargetRegistry.h"
38 #include "llvm/Support/TargetSelect.h"
39 #include "llvm/Target/TargetLoweringObjectFile.h"
40 #include "llvm/Transforms/Utils/GlobalStatus.h"
41 #include <system_error>
43 using namespace llvm::object
;
45 LTOModule::LTOModule(std::unique_ptr
<Module
> M
, MemoryBufferRef MBRef
,
46 llvm::TargetMachine
*TM
)
47 : Mod(std::move(M
)), MBRef(MBRef
), _target(TM
) {
48 SymTab
.addModule(Mod
.get());
51 LTOModule::~LTOModule() {}
53 /// isBitcodeFile - Returns 'true' if the file (or memory contents) is LLVM
55 bool LTOModule::isBitcodeFile(const void *Mem
, size_t Length
) {
56 Expected
<MemoryBufferRef
> BCData
= IRObjectFile::findBitcodeInMemBuffer(
57 MemoryBufferRef(StringRef((const char *)Mem
, Length
), "<mem>"));
58 return !errorToBool(BCData
.takeError());
61 bool LTOModule::isBitcodeFile(StringRef Path
) {
62 ErrorOr
<std::unique_ptr
<MemoryBuffer
>> BufferOrErr
=
63 MemoryBuffer::getFile(Path
);
67 Expected
<MemoryBufferRef
> BCData
= IRObjectFile::findBitcodeInMemBuffer(
68 BufferOrErr
.get()->getMemBufferRef());
69 return !errorToBool(BCData
.takeError());
72 bool LTOModule::isThinLTO() {
73 Expected
<BitcodeLTOInfo
> Result
= getBitcodeLTOInfo(MBRef
);
75 logAllUnhandledErrors(Result
.takeError(), errs());
78 return Result
->IsThinLTO
;
81 bool LTOModule::isBitcodeForTarget(MemoryBuffer
*Buffer
,
82 StringRef TriplePrefix
) {
83 Expected
<MemoryBufferRef
> BCOrErr
=
84 IRObjectFile::findBitcodeInMemBuffer(Buffer
->getMemBufferRef());
85 if (errorToBool(BCOrErr
.takeError()))
88 ErrorOr
<std::string
> TripleOrErr
=
89 expectedToErrorOrAndEmitErrors(Context
, getBitcodeTargetTriple(*BCOrErr
));
92 return StringRef(*TripleOrErr
).startswith(TriplePrefix
);
95 std::string
LTOModule::getProducerString(MemoryBuffer
*Buffer
) {
96 Expected
<MemoryBufferRef
> BCOrErr
=
97 IRObjectFile::findBitcodeInMemBuffer(Buffer
->getMemBufferRef());
98 if (errorToBool(BCOrErr
.takeError()))
101 ErrorOr
<std::string
> ProducerOrErr
= expectedToErrorOrAndEmitErrors(
102 Context
, getBitcodeProducerString(*BCOrErr
));
105 return *ProducerOrErr
;
108 ErrorOr
<std::unique_ptr
<LTOModule
>>
109 LTOModule::createFromFile(LLVMContext
&Context
, StringRef path
,
110 const TargetOptions
&options
) {
111 ErrorOr
<std::unique_ptr
<MemoryBuffer
>> BufferOrErr
=
112 MemoryBuffer::getFile(path
);
113 if (std::error_code EC
= BufferOrErr
.getError()) {
114 Context
.emitError(EC
.message());
117 std::unique_ptr
<MemoryBuffer
> Buffer
= std::move(BufferOrErr
.get());
118 return makeLTOModule(Buffer
->getMemBufferRef(), options
, Context
,
119 /* ShouldBeLazy*/ false);
122 ErrorOr
<std::unique_ptr
<LTOModule
>>
123 LTOModule::createFromOpenFile(LLVMContext
&Context
, int fd
, StringRef path
,
124 size_t size
, const TargetOptions
&options
) {
125 return createFromOpenFileSlice(Context
, fd
, path
, size
, 0, options
);
128 ErrorOr
<std::unique_ptr
<LTOModule
>>
129 LTOModule::createFromOpenFileSlice(LLVMContext
&Context
, int fd
, StringRef path
,
130 size_t map_size
, off_t offset
,
131 const TargetOptions
&options
) {
132 ErrorOr
<std::unique_ptr
<MemoryBuffer
>> BufferOrErr
=
133 MemoryBuffer::getOpenFileSlice(fd
, path
, map_size
, offset
);
134 if (std::error_code EC
= BufferOrErr
.getError()) {
135 Context
.emitError(EC
.message());
138 std::unique_ptr
<MemoryBuffer
> Buffer
= std::move(BufferOrErr
.get());
139 return makeLTOModule(Buffer
->getMemBufferRef(), options
, Context
,
140 /* ShouldBeLazy */ false);
143 ErrorOr
<std::unique_ptr
<LTOModule
>>
144 LTOModule::createFromBuffer(LLVMContext
&Context
, const void *mem
,
145 size_t length
, const TargetOptions
&options
,
147 StringRef
Data((const char *)mem
, length
);
148 MemoryBufferRef
Buffer(Data
, path
);
149 return makeLTOModule(Buffer
, options
, Context
, /* ShouldBeLazy */ false);
152 ErrorOr
<std::unique_ptr
<LTOModule
>>
153 LTOModule::createInLocalContext(std::unique_ptr
<LLVMContext
> Context
,
154 const void *mem
, size_t length
,
155 const TargetOptions
&options
, StringRef path
) {
156 StringRef
Data((const char *)mem
, length
);
157 MemoryBufferRef
Buffer(Data
, path
);
158 // If we own a context, we know this is being used only for symbol extraction,
159 // not linking. Be lazy in that case.
160 ErrorOr
<std::unique_ptr
<LTOModule
>> Ret
=
161 makeLTOModule(Buffer
, options
, *Context
, /* ShouldBeLazy */ true);
163 (*Ret
)->OwnedContext
= std::move(Context
);
167 static ErrorOr
<std::unique_ptr
<Module
>>
168 parseBitcodeFileImpl(MemoryBufferRef Buffer
, LLVMContext
&Context
,
171 Expected
<MemoryBufferRef
> MBOrErr
=
172 IRObjectFile::findBitcodeInMemBuffer(Buffer
);
173 if (Error E
= MBOrErr
.takeError()) {
174 std::error_code EC
= errorToErrorCode(std::move(E
));
175 Context
.emitError(EC
.message());
180 // Parse the full file.
181 return expectedToErrorOrAndEmitErrors(Context
,
182 parseBitcodeFile(*MBOrErr
, Context
));
186 return expectedToErrorOrAndEmitErrors(
188 getLazyBitcodeModule(*MBOrErr
, Context
, true /*ShouldLazyLoadMetadata*/));
191 ErrorOr
<std::unique_ptr
<LTOModule
>>
192 LTOModule::makeLTOModule(MemoryBufferRef Buffer
, const TargetOptions
&options
,
193 LLVMContext
&Context
, bool ShouldBeLazy
) {
194 ErrorOr
<std::unique_ptr
<Module
>> MOrErr
=
195 parseBitcodeFileImpl(Buffer
, Context
, ShouldBeLazy
);
196 if (std::error_code EC
= MOrErr
.getError())
198 std::unique_ptr
<Module
> &M
= *MOrErr
;
200 std::string TripleStr
= M
->getTargetTriple();
201 if (TripleStr
.empty())
202 TripleStr
= sys::getDefaultTargetTriple();
203 llvm::Triple
Triple(TripleStr
);
205 // find machine architecture for this module
207 const Target
*march
= TargetRegistry::lookupTarget(TripleStr
, errMsg
);
209 return make_error_code(object::object_error::arch_not_found
);
211 // construct LTOModule, hand over ownership of module and target
212 SubtargetFeatures Features
;
213 Features
.getDefaultSubtargetFeatures(Triple
);
214 std::string FeatureStr
= Features
.getString();
215 // Set a default CPU for Darwin triples.
217 if (Triple
.isOSDarwin()) {
218 if (Triple
.getArch() == llvm::Triple::x86_64
)
220 else if (Triple
.getArch() == llvm::Triple::x86
)
222 else if (Triple
.getArch() == llvm::Triple::aarch64
)
226 TargetMachine
*target
=
227 march
->createTargetMachine(TripleStr
, CPU
, FeatureStr
, options
, None
);
229 std::unique_ptr
<LTOModule
> Ret(new LTOModule(std::move(M
), Buffer
, target
));
231 Ret
->parseMetadata();
233 return std::move(Ret
);
236 /// Create a MemoryBuffer from a memory range with an optional name.
237 std::unique_ptr
<MemoryBuffer
>
238 LTOModule::makeBuffer(const void *mem
, size_t length
, StringRef name
) {
239 const char *startPtr
= (const char*)mem
;
240 return MemoryBuffer::getMemBuffer(StringRef(startPtr
, length
), name
, false);
243 /// objcClassNameFromExpression - Get string that the data pointer points to.
245 LTOModule::objcClassNameFromExpression(const Constant
*c
, std::string
&name
) {
246 if (const ConstantExpr
*ce
= dyn_cast
<ConstantExpr
>(c
)) {
247 Constant
*op
= ce
->getOperand(0);
248 if (GlobalVariable
*gvn
= dyn_cast
<GlobalVariable
>(op
)) {
249 Constant
*cn
= gvn
->getInitializer();
250 if (ConstantDataArray
*ca
= dyn_cast
<ConstantDataArray
>(cn
)) {
251 if (ca
->isCString()) {
252 name
= (".objc_class_name_" + ca
->getAsCString()).str();
261 /// addObjCClass - Parse i386/ppc ObjC class data structure.
262 void LTOModule::addObjCClass(const GlobalVariable
*clgv
) {
263 const ConstantStruct
*c
= dyn_cast
<ConstantStruct
>(clgv
->getInitializer());
266 // second slot in __OBJC,__class is pointer to superclass name
267 std::string superclassName
;
268 if (objcClassNameFromExpression(c
->getOperand(1), superclassName
)) {
270 _undefines
.insert(std::make_pair(superclassName
, NameAndAttributes()));
271 if (IterBool
.second
) {
272 NameAndAttributes
&info
= IterBool
.first
->second
;
273 info
.name
= IterBool
.first
->first();
274 info
.attributes
= LTO_SYMBOL_DEFINITION_UNDEFINED
;
275 info
.isFunction
= false;
280 // third slot in __OBJC,__class is pointer to class name
281 std::string className
;
282 if (objcClassNameFromExpression(c
->getOperand(2), className
)) {
283 auto Iter
= _defines
.insert(className
).first
;
285 NameAndAttributes info
;
286 info
.name
= Iter
->first();
287 info
.attributes
= LTO_SYMBOL_PERMISSIONS_DATA
|
288 LTO_SYMBOL_DEFINITION_REGULAR
| LTO_SYMBOL_SCOPE_DEFAULT
;
289 info
.isFunction
= false;
291 _symbols
.push_back(info
);
295 /// addObjCCategory - Parse i386/ppc ObjC category data structure.
296 void LTOModule::addObjCCategory(const GlobalVariable
*clgv
) {
297 const ConstantStruct
*c
= dyn_cast
<ConstantStruct
>(clgv
->getInitializer());
300 // second slot in __OBJC,__category is pointer to target class name
301 std::string targetclassName
;
302 if (!objcClassNameFromExpression(c
->getOperand(1), targetclassName
))
306 _undefines
.insert(std::make_pair(targetclassName
, NameAndAttributes()));
308 if (!IterBool
.second
)
311 NameAndAttributes
&info
= IterBool
.first
->second
;
312 info
.name
= IterBool
.first
->first();
313 info
.attributes
= LTO_SYMBOL_DEFINITION_UNDEFINED
;
314 info
.isFunction
= false;
318 /// addObjCClassRef - Parse i386/ppc ObjC class list data structure.
319 void LTOModule::addObjCClassRef(const GlobalVariable
*clgv
) {
320 std::string targetclassName
;
321 if (!objcClassNameFromExpression(clgv
->getInitializer(), targetclassName
))
325 _undefines
.insert(std::make_pair(targetclassName
, NameAndAttributes()));
327 if (!IterBool
.second
)
330 NameAndAttributes
&info
= IterBool
.first
->second
;
331 info
.name
= IterBool
.first
->first();
332 info
.attributes
= LTO_SYMBOL_DEFINITION_UNDEFINED
;
333 info
.isFunction
= false;
337 void LTOModule::addDefinedDataSymbol(ModuleSymbolTable::Symbol Sym
) {
338 SmallString
<64> Buffer
;
340 raw_svector_ostream
OS(Buffer
);
341 SymTab
.printSymbolName(OS
, Sym
);
345 const GlobalValue
*V
= Sym
.get
<GlobalValue
*>();
346 addDefinedDataSymbol(Buffer
, V
);
349 void LTOModule::addDefinedDataSymbol(StringRef Name
, const GlobalValue
*v
) {
350 // Add to list of defined symbols.
351 addDefinedSymbol(Name
, v
, false);
353 if (!v
->hasSection() /* || !isTargetDarwin */)
356 // Special case i386/ppc ObjC data structures in magic sections:
357 // The issue is that the old ObjC object format did some strange
358 // contortions to avoid real linker symbols. For instance, the
359 // ObjC class data structure is allocated statically in the executable
360 // that defines that class. That data structures contains a pointer to
361 // its superclass. But instead of just initializing that part of the
362 // struct to the address of its superclass, and letting the static and
363 // dynamic linkers do the rest, the runtime works by having that field
364 // instead point to a C-string that is the name of the superclass.
365 // At runtime the objc initialization updates that pointer and sets
366 // it to point to the actual super class. As far as the linker
367 // knows it is just a pointer to a string. But then someone wanted the
368 // linker to issue errors at build time if the superclass was not found.
369 // So they figured out a way in mach-o object format to use an absolute
370 // symbols (.objc_class_name_Foo = 0) and a floating reference
371 // (.reference .objc_class_name_Bar) to cause the linker into erroring when
372 // a class was missing.
373 // The following synthesizes the implicit .objc_* symbols for the linker
374 // from the ObjC data structures generated by the front end.
376 // special case if this data blob is an ObjC class definition
377 if (const GlobalVariable
*GV
= dyn_cast
<GlobalVariable
>(v
)) {
378 StringRef Section
= GV
->getSection();
379 if (Section
.startswith("__OBJC,__class,")) {
383 // special case if this data blob is an ObjC category definition
384 else if (Section
.startswith("__OBJC,__category,")) {
388 // special case if this data blob is the list of referenced classes
389 else if (Section
.startswith("__OBJC,__cls_refs,")) {
395 void LTOModule::addDefinedFunctionSymbol(ModuleSymbolTable::Symbol Sym
) {
396 SmallString
<64> Buffer
;
398 raw_svector_ostream
OS(Buffer
);
399 SymTab
.printSymbolName(OS
, Sym
);
403 const Function
*F
= cast
<Function
>(Sym
.get
<GlobalValue
*>());
404 addDefinedFunctionSymbol(Buffer
, F
);
407 void LTOModule::addDefinedFunctionSymbol(StringRef Name
, const Function
*F
) {
408 // add to list of defined symbols
409 addDefinedSymbol(Name
, F
, true);
412 void LTOModule::addDefinedSymbol(StringRef Name
, const GlobalValue
*def
,
414 // set alignment part log2() can have rounding errors
415 uint32_t align
= def
->getAlignment();
416 uint32_t attr
= align
? countTrailingZeros(align
) : 0;
418 // set permissions part
420 attr
|= LTO_SYMBOL_PERMISSIONS_CODE
;
422 const GlobalVariable
*gv
= dyn_cast
<GlobalVariable
>(def
);
423 if (gv
&& gv
->isConstant())
424 attr
|= LTO_SYMBOL_PERMISSIONS_RODATA
;
426 attr
|= LTO_SYMBOL_PERMISSIONS_DATA
;
429 // set definition part
430 if (def
->hasWeakLinkage() || def
->hasLinkOnceLinkage())
431 attr
|= LTO_SYMBOL_DEFINITION_WEAK
;
432 else if (def
->hasCommonLinkage())
433 attr
|= LTO_SYMBOL_DEFINITION_TENTATIVE
;
435 attr
|= LTO_SYMBOL_DEFINITION_REGULAR
;
438 if (def
->hasLocalLinkage())
439 // Ignore visibility if linkage is local.
440 attr
|= LTO_SYMBOL_SCOPE_INTERNAL
;
441 else if (def
->hasHiddenVisibility())
442 attr
|= LTO_SYMBOL_SCOPE_HIDDEN
;
443 else if (def
->hasProtectedVisibility())
444 attr
|= LTO_SYMBOL_SCOPE_PROTECTED
;
445 else if (def
->canBeOmittedFromSymbolTable())
446 attr
|= LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN
;
448 attr
|= LTO_SYMBOL_SCOPE_DEFAULT
;
450 if (def
->hasComdat())
451 attr
|= LTO_SYMBOL_COMDAT
;
453 if (isa
<GlobalAlias
>(def
))
454 attr
|= LTO_SYMBOL_ALIAS
;
456 auto Iter
= _defines
.insert(Name
).first
;
458 // fill information structure
459 NameAndAttributes info
;
460 StringRef NameRef
= Iter
->first();
462 assert(NameRef
.data()[NameRef
.size()] == '\0');
463 info
.attributes
= attr
;
464 info
.isFunction
= isFunction
;
467 // add to table of symbols
468 _symbols
.push_back(info
);
471 /// addAsmGlobalSymbol - Add a global symbol from module-level ASM to the
473 void LTOModule::addAsmGlobalSymbol(StringRef name
,
474 lto_symbol_attributes scope
) {
475 auto IterBool
= _defines
.insert(name
);
477 // only add new define if not already defined
478 if (!IterBool
.second
)
481 NameAndAttributes
&info
= _undefines
[IterBool
.first
->first()];
483 if (info
.symbol
== nullptr) {
484 // FIXME: This is trying to take care of module ASM like this:
486 // module asm ".zerofill __FOO, __foo, _bar_baz_qux, 0"
488 // but is gross and its mother dresses it funny. Have the ASM parser give us
489 // more details for this type of situation so that we're not guessing so
492 // fill information structure
493 info
.name
= IterBool
.first
->first();
495 LTO_SYMBOL_PERMISSIONS_DATA
| LTO_SYMBOL_DEFINITION_REGULAR
| scope
;
496 info
.isFunction
= false;
497 info
.symbol
= nullptr;
499 // add to table of symbols
500 _symbols
.push_back(info
);
505 addDefinedFunctionSymbol(info
.name
, cast
<Function
>(info
.symbol
));
507 addDefinedDataSymbol(info
.name
, info
.symbol
);
509 _symbols
.back().attributes
&= ~LTO_SYMBOL_SCOPE_MASK
;
510 _symbols
.back().attributes
|= scope
;
513 /// addAsmGlobalSymbolUndef - Add a global symbol from module-level ASM to the
515 void LTOModule::addAsmGlobalSymbolUndef(StringRef name
) {
516 auto IterBool
= _undefines
.insert(std::make_pair(name
, NameAndAttributes()));
518 _asm_undefines
.push_back(IterBool
.first
->first());
520 // we already have the symbol
521 if (!IterBool
.second
)
524 uint32_t attr
= LTO_SYMBOL_DEFINITION_UNDEFINED
;
525 attr
|= LTO_SYMBOL_SCOPE_DEFAULT
;
526 NameAndAttributes
&info
= IterBool
.first
->second
;
527 info
.name
= IterBool
.first
->first();
528 info
.attributes
= attr
;
529 info
.isFunction
= false;
530 info
.symbol
= nullptr;
533 /// Add a symbol which isn't defined just yet to a list to be resolved later.
534 void LTOModule::addPotentialUndefinedSymbol(ModuleSymbolTable::Symbol Sym
,
536 SmallString
<64> name
;
538 raw_svector_ostream
OS(name
);
539 SymTab
.printSymbolName(OS
, Sym
);
543 auto IterBool
= _undefines
.insert(std::make_pair(name
, NameAndAttributes()));
545 // we already have the symbol
546 if (!IterBool
.second
)
549 NameAndAttributes
&info
= IterBool
.first
->second
;
551 info
.name
= IterBool
.first
->first();
553 const GlobalValue
*decl
= Sym
.dyn_cast
<GlobalValue
*>();
555 if (decl
->hasExternalWeakLinkage())
556 info
.attributes
= LTO_SYMBOL_DEFINITION_WEAKUNDEF
;
558 info
.attributes
= LTO_SYMBOL_DEFINITION_UNDEFINED
;
560 info
.isFunction
= isFunc
;
564 void LTOModule::parseSymbols() {
565 for (auto Sym
: SymTab
.symbols()) {
566 auto *GV
= Sym
.dyn_cast
<GlobalValue
*>();
567 uint32_t Flags
= SymTab
.getSymbolFlags(Sym
);
568 if (Flags
& object::BasicSymbolRef::SF_FormatSpecific
)
571 bool IsUndefined
= Flags
& object::BasicSymbolRef::SF_Undefined
;
574 SmallString
<64> Buffer
;
576 raw_svector_ostream
OS(Buffer
);
577 SymTab
.printSymbolName(OS
, Sym
);
580 StringRef
Name(Buffer
);
583 addAsmGlobalSymbolUndef(Name
);
584 else if (Flags
& object::BasicSymbolRef::SF_Global
)
585 addAsmGlobalSymbol(Name
, LTO_SYMBOL_SCOPE_DEFAULT
);
587 addAsmGlobalSymbol(Name
, LTO_SYMBOL_SCOPE_INTERNAL
);
591 auto *F
= dyn_cast
<Function
>(GV
);
593 addPotentialUndefinedSymbol(Sym
, F
!= nullptr);
598 addDefinedFunctionSymbol(Sym
);
602 if (isa
<GlobalVariable
>(GV
)) {
603 addDefinedDataSymbol(Sym
);
607 assert(isa
<GlobalAlias
>(GV
));
608 addDefinedDataSymbol(Sym
);
611 // make symbols for all undefines
612 for (StringMap
<NameAndAttributes
>::iterator u
=_undefines
.begin(),
613 e
= _undefines
.end(); u
!= e
; ++u
) {
614 // If this symbol also has a definition, then don't make an undefine because
615 // it is a tentative definition.
616 if (_defines
.count(u
->getKey())) continue;
617 NameAndAttributes info
= u
->getValue();
618 _symbols
.push_back(info
);
622 /// parseMetadata - Parse metadata from the module
623 void LTOModule::parseMetadata() {
624 raw_string_ostream
OS(LinkerOpts
);
627 if (NamedMDNode
*LinkerOptions
=
628 getModule().getNamedMetadata("llvm.linker.options")) {
629 for (unsigned i
= 0, e
= LinkerOptions
->getNumOperands(); i
!= e
; ++i
) {
630 MDNode
*MDOptions
= LinkerOptions
->getOperand(i
);
631 for (unsigned ii
= 0, ie
= MDOptions
->getNumOperands(); ii
!= ie
; ++ii
) {
632 MDString
*MDOption
= cast
<MDString
>(MDOptions
->getOperand(ii
));
633 OS
<< " " << MDOption
->getString();
638 // Globals - we only need to do this for COFF.
639 const Triple
TT(_target
->getTargetTriple());
640 if (!TT
.isOSBinFormatCOFF())
643 for (const NameAndAttributes
&Sym
: _symbols
) {
646 emitLinkerFlagsForGlobalCOFF(OS
, Sym
.symbol
, TT
, M
);
649 // Add other interesting metadata here.