diff --git a/bindings/ada/llvm/llvm.ads b/bindings/ada/llvm/llvm.ads
index d9820f114910..a41451b94b71 100644
--- a/bindings/ada/llvm/llvm.ads
+++ b/bindings/ada/llvm/llvm.ads
@@ -316,7 +316,8 @@ package llvm is
LLVMExternalWeakLinkage,
LLVMGhostLinkage,
LLVMCommonLinkage,
- LLVMLinkerPrivateLinkage);
+ LLVMLinkerPrivateLinkage,
+ LLVMLinkerWeakLinkage);
for LLVMLinkage use
(LLVMExternalLinkage => 0,
@@ -333,7 +334,8 @@ package llvm is
LLVMExternalWeakLinkage => 11,
LLVMGhostLinkage => 12,
LLVMCommonLinkage => 13,
- LLVMLinkerPrivateLinkage => 14);
+ LLVMLinkerPrivateLinkage => 14,
+ LLVMLinkerWeakLinkage => 15);
pragma Convention (C, LLVMLinkage);
diff --git a/docs/LangRef.html b/docs/LangRef.html
index 32f143a93ae2..282281327f5c 100644
--- a/docs/LangRef.html
+++ b/docs/LangRef.html
@@ -24,6 +24,7 @@
- 'private' Linkage
- 'linker_private' Linkage
+ - 'linker_weak' Linkage
- 'internal' Linkage
- 'available_externally' Linkage
- 'linkonce' Linkage
@@ -546,23 +547,27 @@
- private
- - Global values with private linkage are only directly accessible by objects
- in the current module. In particular, linking code into a module with an
- private global value may cause the private to be renamed as necessary to
- avoid collisions. Because the symbol is private to the module, all
- references can be updated. This doesn't show up in any symbol table in the
- object file.
+ - Global values with "private" linkage are only directly accessible
+ by objects in the current module. In particular, linking code into a
+ module with an private global value may cause the private to be renamed as
+ necessary to avoid collisions. Because the symbol is private to the
+ module, all references can be updated. This doesn't show up in any symbol
+ table in the object file.
- linker_private
- - Similar to private, but the symbol is passed through the assembler and
- removed by the linker after evaluation. Note that (unlike private
- symbols) linker_private symbols are subject to coalescing by the linker:
- weak symbols get merged and redefinitions are rejected. However, unlike
- normal strong symbols, they are removed by the linker from the final
- linked image (executable or dynamic library).
+ - Similar to private, but the symbol is passed through the
+ assembler and removed by the linker after evaluation. Note that (unlike
+ private symbols) linker_private symbols are subject to
+ coalescing by the linker: weak symbols get merged and redefinitions are
+ rejected. However, unlike normal strong symbols, they are removed by the
+ linker from the final linked image (executable or dynamic library).
+
+ - linker_weak
+ - Global values with "linker_weak" linkage are given weak linkage,
+ but are removed by the linker after evaluation.
- internal
- - Similar to private, but the value shows as a local symbol
+
- Similar to private, but the value shows as a local symbol
(STB_LOCAL in the case of ELF) in the object file. This
corresponds to the notion of the 'static' keyword in C.
diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h
index d665c89377f4..23b4f83528e2 100644
--- a/include/llvm-c/Core.h
+++ b/include/llvm-c/Core.h
@@ -226,7 +226,8 @@ typedef enum {
LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
LLVMGhostLinkage, /**< Obsolete */
LLVMCommonLinkage, /**< Tentative definitions */
- LLVMLinkerPrivateLinkage /**< Like Private, but linker removes. */
+ LLVMLinkerPrivateLinkage, /**< Like private, but linker removes. */
+ LLVMLinkerWeakLinkage /**< Like linker private, but weak. */
} LLVMLinkage;
typedef enum {
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h
index 243ddbb5da34..32679b5374ae 100644
--- a/include/llvm/CodeGen/AsmPrinter.h
+++ b/include/llvm/CodeGen/AsmPrinter.h
@@ -285,7 +285,7 @@ namespace llvm {
MCSymbol *GetCPISymbol(unsigned CPID) const;
/// GetJTISymbol - Return the symbol for the specified jump table entry.
- MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
+ MCSymbol *GetJTISymbol(unsigned JTID, bool PassToLinker = false) const;
/// GetJTSetSymbol - Return the symbol for the specified jump table .set
/// FIXME: privatize to AsmPrinter.
diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h
index 409d13ee3fc5..ce8785857e97 100644
--- a/include/llvm/CodeGen/MachineFunction.h
+++ b/include/llvm/CodeGen/MachineFunction.h
@@ -402,10 +402,10 @@ class MachineFunction {
//
/// getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
- /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
- /// normal 'L' label is returned.
- MCSymbol *getJTISymbol(unsigned JTI, MCContext &Ctx,
- bool isLinkerPrivate = false) const;
+ /// If PassToLinker is specified, an 'l' label is returned, otherwise a normal
+ /// 'L' label is returned.
+ MCSymbol *getJTISymbol(unsigned JTI, MCContext &Ctx,
+ bool PassToLinker = false) const;
};
//===--------------------------------------------------------------------===//
diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h
index 658967d81a34..5132d395ef10 100644
--- a/include/llvm/GlobalValue.h
+++ b/include/llvm/GlobalValue.h
@@ -39,7 +39,8 @@ class GlobalValue : public Constant {
AppendingLinkage, ///< Special purpose, only applies to global arrays
InternalLinkage, ///< Rename collisions when linking (static functions).
PrivateLinkage, ///< Like Internal, but omit from symbol table.
- LinkerPrivateLinkage, ///< Like Private, but linker removes.
+ LinkerPrivateLinkage, ///< Like private, but linker removes.
+ LinkerWeakLinkage, ///< Like linker private, but weak.
DLLImportLinkage, ///< Function to be imported from DLL
DLLExportLinkage, ///< Function to be accessible from DLL.
ExternalWeakLinkage,///< ExternalWeak linkage description.
@@ -132,7 +133,10 @@ class GlobalValue : public Constant {
return Linkage == PrivateLinkage;
}
static bool isLinkerPrivateLinkage(LinkageTypes Linkage) {
- return Linkage==LinkerPrivateLinkage;
+ return Linkage == LinkerPrivateLinkage;
+ }
+ static bool isLinkerWeakLinkage(LinkageTypes Linkage) {
+ return Linkage == LinkerWeakLinkage;
}
static bool isLocalLinkage(LinkageTypes Linkage) {
return isInternalLinkage(Linkage) || isPrivateLinkage(Linkage) ||
@@ -187,6 +191,7 @@ class GlobalValue : public Constant {
bool hasInternalLinkage() const { return isInternalLinkage(Linkage); }
bool hasPrivateLinkage() const { return isPrivateLinkage(Linkage); }
bool hasLinkerPrivateLinkage() const { return isLinkerPrivateLinkage(Linkage); }
+ bool hasLinkerWeakLinkage() const { return isLinkerWeakLinkage(Linkage); }
bool hasLocalLinkage() const { return isLocalLinkage(Linkage); }
bool hasDLLImportLinkage() const { return isDLLImportLinkage(Linkage); }
bool hasDLLExportLinkage() const { return isDLLExportLinkage(Linkage); }
diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h
index 8516de0188d6..b76be03fc6c3 100644
--- a/include/llvm/MC/MCAsmInfo.h
+++ b/include/llvm/MC/MCAsmInfo.h
@@ -85,6 +85,11 @@ namespace llvm {
/// be passed through the assembler but be removed by the linker. This
/// is "l" on Darwin, currently used for some ObjC metadata.
const char *LinkerPrivateGlobalPrefix; // Defaults to ""
+
+ /// LinkerWeakGlobalPrefix - This prefix is used for symbols that are marked
+ /// "weak" and should be passed through the assembler, but be removed by the
+ /// linker. This is "l" on Darwin, currently used for some ObjC metadata.
+ const char *LinkerWeakGlobalPrefix; // Defaults to ""
/// InlineAsmStart/End - If these are nonempty, they contain a directive to
/// emit before and after an inline assembly statement.
@@ -335,6 +340,9 @@ namespace llvm {
const char *getLinkerPrivateGlobalPrefix() const {
return LinkerPrivateGlobalPrefix;
}
+ const char *getLinkerWeakGlobalPrefix() const {
+ return LinkerWeakGlobalPrefix;
+ }
const char *getInlineAsmStart() const {
return InlineAsmStart;
}
diff --git a/include/llvm/Target/Mangler.h b/include/llvm/Target/Mangler.h
index a9f3576559d4..167253e2714c 100644
--- a/include/llvm/Target/Mangler.h
+++ b/include/llvm/Target/Mangler.h
@@ -32,7 +32,8 @@ class Mangler {
enum ManglerPrefixTy {
Default, ///< Emit default string before each symbol.
Private, ///< Emit "private" prefix before each symbol.
- LinkerPrivate ///< Emit "linker private" prefix before each symbol.
+ LinkerPrivate, ///< Emit "linker private" prefix before each symbol.
+ LinkerWeak ///< Emit "linker weak" prefix before each symbol.
};
private:
diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp
index 9b4370fbb4ed..3e8414af452f 100644
--- a/lib/AsmParser/LLLexer.cpp
+++ b/lib/AsmParser/LLLexer.cpp
@@ -492,6 +492,7 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(private);
KEYWORD(linker_private);
+ KEYWORD(linker_weak);
KEYWORD(internal);
KEYWORD(available_externally);
KEYWORD(linkonce);
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 1cd66e536ea7..9a9bd122692b 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -198,6 +198,7 @@ bool LLParser::ParseTopLevelEntities() {
// OptionalAddrSpace ('constant'|'global') ...
case lltok::kw_private : // OptionalLinkage
case lltok::kw_linker_private: // OptionalLinkage
+ case lltok::kw_linker_weak: // OptionalLinkage
case lltok::kw_internal: // OptionalLinkage
case lltok::kw_weak: // OptionalLinkage
case lltok::kw_weak_odr: // OptionalLinkage
@@ -629,7 +630,8 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
Linkage != GlobalValue::WeakODRLinkage &&
Linkage != GlobalValue::InternalLinkage &&
Linkage != GlobalValue::PrivateLinkage &&
- Linkage != GlobalValue::LinkerPrivateLinkage)
+ Linkage != GlobalValue::LinkerPrivateLinkage &&
+ Linkage != GlobalValue::LinkerWeakLinkage)
return Error(LinkageLoc, "invalid linkage type for alias");
Constant *Aliasee;
@@ -1013,6 +1015,7 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
/// ::= /*empty*/
/// ::= 'private'
/// ::= 'linker_private'
+/// ::= 'linker_weak'
/// ::= 'internal'
/// ::= 'weak'
/// ::= 'weak_odr'
@@ -1030,6 +1033,7 @@ bool LLParser::ParseOptionalLinkage(unsigned &Res, bool &HasLinkage) {
default: Res=GlobalValue::ExternalLinkage; return false;
case lltok::kw_private: Res = GlobalValue::PrivateLinkage; break;
case lltok::kw_linker_private: Res = GlobalValue::LinkerPrivateLinkage; break;
+ case lltok::kw_linker_weak: Res = GlobalValue::LinkerWeakLinkage; break;
case lltok::kw_internal: Res = GlobalValue::InternalLinkage; break;
case lltok::kw_weak: Res = GlobalValue::WeakAnyLinkage; break;
case lltok::kw_weak_odr: Res = GlobalValue::WeakODRLinkage; break;
@@ -2704,6 +2708,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
break;
case GlobalValue::PrivateLinkage:
case GlobalValue::LinkerPrivateLinkage:
+ case GlobalValue::LinkerWeakLinkage:
case GlobalValue::InternalLinkage:
case GlobalValue::AvailableExternallyLinkage:
case GlobalValue::LinkOnceAnyLinkage:
diff --git a/lib/AsmParser/LLToken.h b/lib/AsmParser/LLToken.h
index 5eed17090883..9430f5d43cfa 100644
--- a/lib/AsmParser/LLToken.h
+++ b/lib/AsmParser/LLToken.h
@@ -37,8 +37,9 @@ namespace lltok {
kw_declare, kw_define,
kw_global, kw_constant,
- kw_private, kw_linker_private, kw_internal, kw_linkonce, kw_linkonce_odr,
- kw_weak, kw_weak_odr, kw_appending, kw_dllimport, kw_dllexport, kw_common,
+ kw_private, kw_linker_private, kw_linker_weak, kw_internal, kw_linkonce,
+ kw_linkonce_odr, kw_weak, kw_weak_odr, kw_appending, kw_dllimport,
+ kw_dllexport, kw_common,
kw_available_externally,
kw_default, kw_hidden, kw_protected,
kw_extern_weak,
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index a252da26f1d0..71efeff4d3b6 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -75,6 +75,7 @@ static GlobalValue::LinkageTypes GetDecodedLinkage(unsigned Val) {
case 11: return GlobalValue::LinkOnceODRLinkage;
case 12: return GlobalValue::AvailableExternallyLinkage;
case 13: return GlobalValue::LinkerPrivateLinkage;
+ case 14: return GlobalValue::LinkerWeakLinkage;
}
}
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index cdeb854d7d1f..4655a65e195f 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -313,6 +313,7 @@ static unsigned getEncodedLinkage(const GlobalValue *GV) {
case GlobalValue::LinkOnceODRLinkage: return 11;
case GlobalValue::AvailableExternallyLinkage: return 12;
case GlobalValue::LinkerPrivateLinkage: return 13;
+ case GlobalValue::LinkerWeakLinkage: return 14;
}
}
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index ffccd9e2c0a8..fa9b777cd8ee 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -199,6 +199,7 @@ void AsmPrinter::EmitLinkage(unsigned Linkage, MCSymbol *GVSym) const {
case GlobalValue::LinkOnceODRLinkage:
case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage:
+ case GlobalValue::LinkerWeakLinkage:
case GlobalValue::LinkerPrivateLinkage:
if (MAI->getWeakDefDirective() != 0) {
// .globl _foo
@@ -1610,8 +1611,8 @@ MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const {
}
/// GetJTISymbol - Return the symbol for the specified jump table entry.
-MCSymbol *AsmPrinter::GetJTISymbol(unsigned JTID, bool isLinkerPrivate) const {
- return MF->getJTISymbol(JTID, OutContext, isLinkerPrivate);
+MCSymbol *AsmPrinter::GetJTISymbol(unsigned JTID, bool PassToLinker) const {
+ return MF->getJTISymbol(JTID, OutContext, PassToLinker);
}
/// GetJTSetSymbol - Return the symbol for the specified jump table .set
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index a38c881982e7..c84c31ec10ae 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -410,17 +410,18 @@ unsigned MachineFunction::addLiveIn(unsigned PReg,
}
/// getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
-/// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
-/// normal 'L' label is returned.
-MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
- bool isLinkerPrivate) const {
+/// If isLinkerPrivate or isLinkerWeak is specified, an 'l' label is returned,
+/// otherwise a normal 'L' label is returned.
+MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
+ bool PassToLinker) const {
assert(JumpTableInfo && "No jump tables");
assert(JTI < JumpTableInfo->getJumpTables().size() && "Invalid JTI!");
const MCAsmInfo &MAI = *getTarget().getMCAsmInfo();
- const char *Prefix = isLinkerPrivate ? MAI.getLinkerPrivateGlobalPrefix() :
- MAI.getPrivateGlobalPrefix();
+ const char *Prefix = PassToLinker ?
+ MAI.getLinkerPrivateGlobalPrefix() :
+ MAI.getPrivateGlobalPrefix();
SmallString<60> Name;
raw_svector_ostream(Name)
<< Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 71ad3fb6f99f..56420539b711 100644
--- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -755,11 +755,12 @@ shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const {
/// the directive emitted (this occurs in ObjC metadata).
if (!GV) return false;
- // Check whether the mangled name has the "Private" or "LinkerPrivate" prefix.
+ // Check whether the mangled name has the "Private", "LinkerPrivate", or
+ // "LinkerWeak" prefix.
if (GV->hasLocalLinkage() && !isa(GV)) {
// FIXME: ObjC metadata is currently emitted as internal symbols that have
- // \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and
- // this horrible hack can go away.
+ // \1L and \1l prefixes on them. Fix them to be Private / LinkerPrivate /
+ // LinkerWeak and this horrible hack can go away.
MCSymbol *Sym = Mang->getSymbol(GV);
if (Sym->getName()[0] == 'L' || Sym->getName()[0] == 'l')
return false;
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 8487c83ce36a..d741245d775d 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -735,6 +735,9 @@ CalculateAliasLinkage(const GlobalValue *SGV, const GlobalValue *DGV) {
else if (SL == GlobalValue::LinkerPrivateLinkage &&
DL == GlobalValue::LinkerPrivateLinkage)
return GlobalValue::LinkerPrivateLinkage;
+ else if (SL == GlobalValue::LinkerWeakLinkage &&
+ DL == GlobalValue::LinkerWeakLinkage)
+ return GlobalValue::LinkerWeakLinkage;
else {
assert (SL == GlobalValue::PrivateLinkage &&
DL == GlobalValue::PrivateLinkage && "Unexpected linkage type");
diff --git a/lib/MC/MCAsmInfo.cpp b/lib/MC/MCAsmInfo.cpp
index a275be2c53c5..79c09a94b9fb 100644
--- a/lib/MC/MCAsmInfo.cpp
+++ b/lib/MC/MCAsmInfo.cpp
@@ -31,6 +31,7 @@ MCAsmInfo::MCAsmInfo() {
GlobalPrefix = "";
PrivateGlobalPrefix = ".";
LinkerPrivateGlobalPrefix = "";
+ LinkerWeakGlobalPrefix = "";
InlineAsmStart = "APP";
InlineAsmEnd = "NO_APP";
AssemblerDialect = 0;
diff --git a/lib/MC/MCAsmInfoDarwin.cpp b/lib/MC/MCAsmInfoDarwin.cpp
index 0bd3b2d001e8..aef4b220671e 100644
--- a/lib/MC/MCAsmInfoDarwin.cpp
+++ b/lib/MC/MCAsmInfoDarwin.cpp
@@ -21,6 +21,7 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
GlobalPrefix = "_";
PrivateGlobalPrefix = "L";
LinkerPrivateGlobalPrefix = "l";
+ LinkerWeakGlobalPrefix = "l";
AllowQuotesInName = true;
HasSingleParameterDotFile = false;
HasSubsectionsViaSymbols = true;
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp
index eda08e7a8895..e72763bbf170 100644
--- a/lib/Target/CppBackend/CPPBackend.cpp
+++ b/lib/Target/CppBackend/CPPBackend.cpp
@@ -286,6 +286,8 @@ void CppWriter::printLinkageType(GlobalValue::LinkageTypes LT) {
Out << "GlobalValue::PrivateLinkage"; break;
case GlobalValue::LinkerPrivateLinkage:
Out << "GlobalValue::LinkerPrivateLinkage"; break;
+ case GlobalValue::LinkerWeakLinkage:
+ Out << "GlobalValue::LinkerWeakLinkage"; break;
case GlobalValue::AvailableExternallyLinkage:
Out << "GlobalValue::AvailableExternallyLinkage "; break;
case GlobalValue::LinkOnceAnyLinkage:
diff --git a/lib/Target/Mangler.cpp b/lib/Target/Mangler.cpp
index 4ef017ab9295..fc2f78d5b620 100644
--- a/lib/Target/Mangler.cpp
+++ b/lib/Target/Mangler.cpp
@@ -118,6 +118,9 @@ void Mangler::getNameWithPrefix(SmallVectorImpl &OutName,
} else if (PrefixTy == Mangler::LinkerPrivate) {
const char *Prefix = MAI.getLinkerPrivateGlobalPrefix();
OutName.append(Prefix, Prefix+strlen(Prefix));
+ } else if (PrefixTy == Mangler::LinkerWeak) {
+ const char *Prefix = MAI.getLinkerWeakGlobalPrefix();
+ OutName.append(Prefix, Prefix+strlen(Prefix));
}
const char *Prefix = MAI.getGlobalPrefix();
@@ -182,6 +185,8 @@ void Mangler::getNameWithPrefix(SmallVectorImpl &OutName,
PrefixTy = Mangler::Private;
else if (GV->hasLinkerPrivateLinkage())
PrefixTy = Mangler::LinkerPrivate;
+ else if (GV->hasLinkerWeakLinkage())
+ PrefixTy = Mangler::LinkerWeak;
// If this global has a name, handle it simply.
if (GV->hasName()) {
diff --git a/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp b/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
index c100c590135e..33a11d09f2e8 100644
--- a/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
+++ b/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
@@ -129,6 +129,7 @@ void XCoreAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage:
case GlobalValue::ExternalLinkage:
+ case GlobalValue::LinkerWeakLinkage:
emitArrayBound(GVSym, GV);
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global);
diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp
index 622a9b529cf3..7bb4d9d74f4e 100644
--- a/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/lib/Transforms/IPO/MergeFunctions.cpp
@@ -535,6 +535,7 @@ static LinkageCategory categorize(const Function *F) {
case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage:
case GlobalValue::ExternalWeakLinkage:
+ case GlobalValue::LinkerWeakLinkage:
return ExternalWeak;
case GlobalValue::ExternalLinkage:
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 057ad916c7f5..8b6aabb53af4 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -1419,6 +1419,7 @@ static void PrintLinkage(GlobalValue::LinkageTypes LT,
case GlobalValue::ExternalLinkage: break;
case GlobalValue::PrivateLinkage: Out << "private "; break;
case GlobalValue::LinkerPrivateLinkage: Out << "linker_private "; break;
+ case GlobalValue::LinkerWeakLinkage: Out << "linker_weak "; break;
case GlobalValue::InternalLinkage: Out << "internal "; break;
case GlobalValue::LinkOnceAnyLinkage: Out << "linkonce "; break;
case GlobalValue::LinkOnceODRLinkage: Out << "linkonce_odr "; break;
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index 295d14868f77..faf62ad6cc7a 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -1058,6 +1058,8 @@ LLVMLinkage LLVMGetLinkage(LLVMValueRef Global) {
return LLVMPrivateLinkage;
case GlobalValue::LinkerPrivateLinkage:
return LLVMLinkerPrivateLinkage;
+ case GlobalValue::LinkerWeakLinkage:
+ return LLVMLinkerWeakLinkage;
case GlobalValue::DLLImportLinkage:
return LLVMDLLImportLinkage;
case GlobalValue::DLLExportLinkage:
@@ -1108,6 +1110,9 @@ void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage) {
case LLVMLinkerPrivateLinkage:
GV->setLinkage(GlobalValue::LinkerPrivateLinkage);
break;
+ case LLVMLinkerWeakLinkage:
+ GV->setLinkage(GlobalValue::LinkerWeakLinkage);
+ break;
case LLVMDLLImportLinkage:
GV->setLinkage(GlobalValue::DLLImportLinkage);
break;
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index 2baf5323f4cb..987ada949f2d 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -89,7 +89,8 @@ static char TypeCharForSymbol(GlobalValue &GV) {
static void DumpSymbolNameForGlobalValue(GlobalValue &GV) {
// Private linkage and available_externally linkage don't exist in symtab.
if (GV.hasPrivateLinkage() || GV.hasLinkerPrivateLinkage() ||
- GV.hasAvailableExternallyLinkage()) return;
+ GV.hasLinkerWeakLinkage() || GV.hasAvailableExternallyLinkage())
+ return;
const std::string SymbolAddrStr = " "; // Not used yet...
char TypeChar = TypeCharForSymbol(GV);