llvm.org GIT mirror llvm / 07d3177
Revert r107205 and r107207. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107215 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 9 years ago
26 changed file(s) with 39 addition(s) and 98 deletion(s). Raw diff Collapse all Expand all
315315 LLVMExternalWeakLinkage,
316316 LLVMGhostLinkage,
317317 LLVMCommonLinkage,
318 LLVMLinkerPrivateLinkage,
319 LLVMLinkerWeakLinkage);
318 LLVMLinkerPrivateLinkage);
320319
321320 for LLVMLinkage use
322321 (LLVMExternalLinkage => 0,
333332 LLVMExternalWeakLinkage => 11,
334333 LLVMGhostLinkage => 12,
335334 LLVMCommonLinkage => 13,
336 LLVMLinkerPrivateLinkage => 14,
337 LLVMLinkerWeakLinkage => 15);
335 LLVMLinkerPrivateLinkage => 14);
338336
339337 pragma Convention (C, LLVMLinkage);
340338
2323
2424
  • 'private' Linkage
  • 2525
  • 'linker_private' Linkage
  • 26
  • 'linker_weak' Linkage
  • 2726
  • 'internal' Linkage
  • 2827
  • 'available_externally' Linkage
  • 2928
  • 'linkonce' Linkage
  • 546545
    547546
    548547
    private
    549
    Global values with "private" linkage are only directly accessible
    550 by objects in the current module. In particular, linking code into a
    551 module with an private global value may cause the private to be renamed as
    552 necessary to avoid collisions. Because the symbol is private to the
    553 module, all references can be updated. This doesn't show up in any symbol
    554 table in the object file.
    548
    Global values with private linkage are only directly accessible by objects
    549 in the current module. In particular, linking code into a module with an
    550 private global value may cause the private to be renamed as necessary to
    551 avoid collisions. Because the symbol is private to the module, all
    552 references can be updated. This doesn't show up in any symbol table in the
    553 object file.
    555554
    556555
    linker_private
    557
    Similar to private, but the symbol is passed through the
    558 assembler and removed by the linker after evaluation. Note that (unlike
    559 private symbols) linker_private symbols are subject to
    560 coalescing by the linker: weak symbols get merged and redefinitions are
    561 rejected. However, unlike normal strong symbols, they are removed by the
    562 linker from the final linked image (executable or dynamic library).
    563 This is currently only used for Objective-C metadata.
    564
    565
    linker_weak
    566
    Global values with "linker_weak" linkage are given weak linkage,
    567 but are removed by the linker after evaluation. Unlike normal weak
    568 symbols, linker weak symbols are removed by the linker from the linal
    569 linked image (executable or dynamic library). This is currently only used
    570 for Objective-C metadata.
    556
    Similar to private, but the symbol is passed through the assembler and
    557 removed by the linker after evaluation. Note that (unlike private
    558 symbols) linker_private symbols are subject to coalescing by the linker:
    559 weak symbols get merged and redefinitions are rejected. However, unlike
    560 normal strong symbols, they are removed by the linker from the final
    561 linked image (executable or dynamic library).
    571562
    572563
    internal
    573
    Similar to private, but the value shows as a local symbol
    564
    Similar to private, but the value shows as a local symbol
    574565 (STB_LOCAL in the case of ELF) in the object file. This
    575566 corresponds to the notion of the 'static' keyword in C.
    576567
    284284 MCSymbol *GetCPISymbol(unsigned CPID) const;
    285285
    286286 /// GetJTISymbol - Return the symbol for the specified jump table entry.
    287 MCSymbol *GetJTISymbol(unsigned JTID, bool PassToLinker = false) const;
    287 MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
    288288
    289289 /// GetJTSetSymbol - Return the symbol for the specified jump table .set
    290290 /// FIXME: privatize to AsmPrinter.
    401401 //
    402402
    403403 /// getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
    404 /// If PassToLinker is specified, an 'l' label is returned, otherwise a normal
    405 /// 'L' label is returned.
    406 MCSymbol *getJTISymbol(unsigned JTI, MCContext &Ctx,
    407 bool PassToLinker = false) const;
    404 /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
    405 /// normal 'L' label is returned.
    406 MCSymbol *getJTISymbol(unsigned JTI, MCContext &Ctx,
    407 bool isLinkerPrivate = false) const;
    408408 };
    409409
    410410 //===--------------------------------------------------------------------===//
    3838 AppendingLinkage, ///< Special purpose, only applies to global arrays
    3939 InternalLinkage, ///< Rename collisions when linking (static functions).
    4040 PrivateLinkage, ///< Like Internal, but omit from symbol table.
    41 LinkerPrivateLinkage, ///< Like private, but linker removes.
    42 LinkerWeakLinkage, ///< Like linker private, but weak.
    41 LinkerPrivateLinkage, ///< Like Private, but linker removes.
    4342 DLLImportLinkage, ///< Function to be imported from DLL
    4443 DLLExportLinkage, ///< Function to be accessible from DLL.
    4544 ExternalWeakLinkage,///< ExternalWeak linkage description.
    132131 return Linkage == PrivateLinkage;
    133132 }
    134133 static bool isLinkerPrivateLinkage(LinkageTypes Linkage) {
    135 return Linkage == LinkerPrivateLinkage;
    136 }
    137 static bool isLinkerWeakLinkage(LinkageTypes Linkage) {
    138 return Linkage == LinkerWeakLinkage;
    134 return Linkage==LinkerPrivateLinkage;
    139135 }
    140136 static bool isLocalLinkage(LinkageTypes Linkage) {
    141137 return isInternalLinkage(Linkage) || isPrivateLinkage(Linkage) ||
    190186 bool hasInternalLinkage() const { return isInternalLinkage(Linkage); }
    191187 bool hasPrivateLinkage() const { return isPrivateLinkage(Linkage); }
    192188 bool hasLinkerPrivateLinkage() const { return isLinkerPrivateLinkage(Linkage); }
    193 bool hasLinkerWeakLinkage() const { return isLinkerWeakLinkage(Linkage); }
    194189 bool hasLocalLinkage() const { return isLocalLinkage(Linkage); }
    195190 bool hasDLLImportLinkage() const { return isDLLImportLinkage(Linkage); }
    196191 bool hasDLLExportLinkage() const { return isDLLExportLinkage(Linkage); }
    8484 /// be passed through the assembler but be removed by the linker. This
    8585 /// is "l" on Darwin, currently used for some ObjC metadata.
    8686 const char *LinkerPrivateGlobalPrefix; // Defaults to ""
    87
    88 /// LinkerWeakGlobalPrefix - This prefix is used for symbols that are marked
    89 /// "weak" and should be passed through the assembler, but be removed by the
    90 /// linker. This is "l" on Darwin, currently used for some ObjC metadata.
    91 const char *LinkerWeakGlobalPrefix; // Defaults to ""
    9287
    9388 /// InlineAsmStart/End - If these are nonempty, they contain a directive to
    9489 /// emit before and after an inline assembly statement.
    339334 const char *getLinkerPrivateGlobalPrefix() const {
    340335 return LinkerPrivateGlobalPrefix;
    341336 }
    342 const char *getLinkerWeakGlobalPrefix() const {
    343 return LinkerWeakGlobalPrefix;
    344 }
    345337 const char *getInlineAsmStart() const {
    346338 return InlineAsmStart;
    347339 }
    3131 enum ManglerPrefixTy {
    3232 Default, ///< Emit default string before each symbol.
    3333 Private, ///< Emit "private" prefix before each symbol.
    34 LinkerPrivate, ///< Emit "linker private" prefix before each symbol.
    35 LinkerWeak ///< Emit "linker weak" prefix before each symbol.
    34 LinkerPrivate ///< Emit "linker private" prefix before each symbol.
    3635 };
    3736
    3837 private:
    225225 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
    226226 LLVMGhostLinkage, /**< Obsolete */
    227227 LLVMCommonLinkage, /**< Tentative definitions */
    228 LLVMLinkerPrivateLinkage, /**< Like private, but linker removes. */
    229 LLVMLinkerWeakLinkage /**< Like linker private, but weak. */
    228 LLVMLinkerPrivateLinkage /**< Like Private, but linker removes. */
    230229 } LLVMLinkage;
    231230
    232231 typedef enum {
    491491
    492492 KEYWORD(private);
    493493 KEYWORD(linker_private);
    494 KEYWORD(linker_weak);
    495494 KEYWORD(internal);
    496495 KEYWORD(available_externally);
    497496 KEYWORD(linkonce);
    197197 // OptionalAddrSpace ('constant'|'global') ...
    198198 case lltok::kw_private : // OptionalLinkage
    199199 case lltok::kw_linker_private: // OptionalLinkage
    200 case lltok::kw_linker_weak: // OptionalLinkage
    201200 case lltok::kw_internal: // OptionalLinkage
    202201 case lltok::kw_weak: // OptionalLinkage
    203202 case lltok::kw_weak_odr: // OptionalLinkage
    629628 Linkage != GlobalValue::WeakODRLinkage &&
    630629 Linkage != GlobalValue::InternalLinkage &&
    631630 Linkage != GlobalValue::PrivateLinkage &&
    632 Linkage != GlobalValue::LinkerPrivateLinkage &&
    633 Linkage != GlobalValue::LinkerWeakLinkage)
    631 Linkage != GlobalValue::LinkerPrivateLinkage)
    634632 return Error(LinkageLoc, "invalid linkage type for alias");
    635633
    636634 Constant *Aliasee;
    10141012 /// ::= /*empty*/
    10151013 /// ::= 'private'
    10161014 /// ::= 'linker_private'
    1017 /// ::= 'linker_weak'
    10181015 /// ::= 'internal'
    10191016 /// ::= 'weak'
    10201017 /// ::= 'weak_odr'
    10321029 default: Res=GlobalValue::ExternalLinkage; return false;
    10331030 case lltok::kw_private: Res = GlobalValue::PrivateLinkage; break;
    10341031 case lltok::kw_linker_private: Res = GlobalValue::LinkerPrivateLinkage; break;
    1035 case lltok::kw_linker_weak: Res = GlobalValue::LinkerWeakLinkage; break;
    10361032 case lltok::kw_internal: Res = GlobalValue::InternalLinkage; break;
    10371033 case lltok::kw_weak: Res = GlobalValue::WeakAnyLinkage; break;
    10381034 case lltok::kw_weak_odr: Res = GlobalValue::WeakODRLinkage; break;
    27072703 break;
    27082704 case GlobalValue::PrivateLinkage:
    27092705 case GlobalValue::LinkerPrivateLinkage:
    2710 case GlobalValue::LinkerWeakLinkage:
    27112706 case GlobalValue::InternalLinkage:
    27122707 case GlobalValue::AvailableExternallyLinkage:
    27132708 case GlobalValue::LinkOnceAnyLinkage:
    3636 kw_declare, kw_define,
    3737 kw_global, kw_constant,
    3838
    39 kw_private, kw_linker_private, kw_linker_weak, kw_internal, kw_linkonce,
    40 kw_linkonce_odr, kw_weak, kw_weak_odr, kw_appending, kw_dllimport,
    41 kw_dllexport, kw_common,
    39 kw_private, kw_linker_private, kw_internal, kw_linkonce, kw_linkonce_odr,
    40 kw_weak, kw_weak_odr, kw_appending, kw_dllimport, kw_dllexport, kw_common,
    4241 kw_available_externally,
    4342 kw_default, kw_hidden, kw_protected,
    4443 kw_extern_weak,
    7474 case 11: return GlobalValue::LinkOnceODRLinkage;
    7575 case 12: return GlobalValue::AvailableExternallyLinkage;
    7676 case 13: return GlobalValue::LinkerPrivateLinkage;
    77 case 14: return GlobalValue::LinkerWeakLinkage;
    7877 }
    7978 }
    8079
    312312 case GlobalValue::LinkOnceODRLinkage: return 11;
    313313 case GlobalValue::AvailableExternallyLinkage: return 12;
    314314 case GlobalValue::LinkerPrivateLinkage: return 13;
    315 case GlobalValue::LinkerWeakLinkage: return 14;
    316315 }
    317316 }
    318317
    198198 case GlobalValue::LinkOnceODRLinkage:
    199199 case GlobalValue::WeakAnyLinkage:
    200200 case GlobalValue::WeakODRLinkage:
    201 case GlobalValue::LinkerWeakLinkage:
    202201 case GlobalValue::LinkerPrivateLinkage:
    203202 if (MAI->getWeakDefDirective() != 0) {
    204203 // .globl _foo
    16241623 }
    16251624
    16261625 /// GetJTISymbol - Return the symbol for the specified jump table entry.
    1627 MCSymbol *AsmPrinter::GetJTISymbol(unsigned JTID, bool PassToLinker) const {
    1628 return MF->getJTISymbol(JTID, OutContext, PassToLinker);
    1626 MCSymbol *AsmPrinter::GetJTISymbol(unsigned JTID, bool isLinkerPrivate) const {
    1627 return MF->getJTISymbol(JTID, OutContext, isLinkerPrivate);
    16291628 }
    16301629
    16311630 /// GetJTSetSymbol - Return the symbol for the specified jump table .set
    409409 }
    410410
    411411 /// getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
    412 /// If isLinkerPrivate or isLinkerWeak is specified, an 'l' label is returned,
    413 /// otherwise a normal 'L' label is returned.
    414 MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
    415 bool PassToLinker) const {
    412 /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
    413 /// normal 'L' label is returned.
    414 MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
    415 bool isLinkerPrivate) const {
    416416 assert(JumpTableInfo && "No jump tables");
    417417
    418418 assert(JTI < JumpTableInfo->getJumpTables().size() && "Invalid JTI!");
    419419 const MCAsmInfo &MAI = *getTarget().getMCAsmInfo();
    420420
    421 const char *Prefix = PassToLinker ?
    422 MAI.getLinkerPrivateGlobalPrefix() :
    423 MAI.getPrivateGlobalPrefix();
    421 const char *Prefix = isLinkerPrivate ? MAI.getLinkerPrivateGlobalPrefix() :
    422 MAI.getPrivateGlobalPrefix();
    424423 SmallString<60> Name;
    425424 raw_svector_ostream(Name)
    426425 << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
    754754 /// the directive emitted (this occurs in ObjC metadata).
    755755 if (!GV) return false;
    756756
    757 // Check whether the mangled name has the "Private", "LinkerPrivate", or
    758 // "LinkerWeak" prefix.
    757 // Check whether the mangled name has the "Private" or "LinkerPrivate" prefix.
    759758 if (GV->hasLocalLinkage() && !isa(GV)) {
    760759 // FIXME: ObjC metadata is currently emitted as internal symbols that have
    761 // \1L and \1l prefixes on them. Fix them to be Private / LinkerPrivate /
    762 // LinkerWeak and this horrible hack can go away.
    760 // \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and
    761 // this horrible hack can go away.
    763762 MCSymbol *Sym = Mang->getSymbol(GV);
    764763 if (Sym->getName()[0] == 'L' || Sym->getName()[0] == 'l')
    765764 return false;
    734734 else if (SL == GlobalValue::LinkerPrivateLinkage &&
    735735 DL == GlobalValue::LinkerPrivateLinkage)
    736736 return GlobalValue::LinkerPrivateLinkage;
    737 else if (SL == GlobalValue::LinkerWeakLinkage &&
    738 DL == GlobalValue::LinkerWeakLinkage)
    739 return GlobalValue::LinkerWeakLinkage;
    740737 else {
    741738 assert (SL == GlobalValue::PrivateLinkage &&
    742739 DL == GlobalValue::PrivateLinkage && "Unexpected linkage type");
    3030 GlobalPrefix = "";
    3131 PrivateGlobalPrefix = ".";
    3232 LinkerPrivateGlobalPrefix = "";
    33 LinkerWeakGlobalPrefix = "";
    3433 InlineAsmStart = "APP";
    3534 InlineAsmEnd = "NO_APP";
    3635 AssemblerDialect = 0;
    2020 GlobalPrefix = "_";
    2121 PrivateGlobalPrefix = "L";
    2222 LinkerPrivateGlobalPrefix = "l";
    23 LinkerWeakGlobalPrefix = "l";
    2423 AllowQuotesInName = true;
    2524 HasSingleParameterDotFile = false;
    2625 HasSubsectionsViaSymbols = true;
    285285 Out << "GlobalValue::PrivateLinkage"; break;
    286286 case GlobalValue::LinkerPrivateLinkage:
    287287 Out << "GlobalValue::LinkerPrivateLinkage"; break;
    288 case GlobalValue::LinkerWeakLinkage:
    289 Out << "GlobalValue::LinkerWeakLinkage"; break;
    290288 case GlobalValue::AvailableExternallyLinkage:
    291289 Out << "GlobalValue::AvailableExternallyLinkage "; break;
    292290 case GlobalValue::LinkOnceAnyLinkage:
    116116 OutName.append(Prefix, Prefix+strlen(Prefix));
    117117 } else if (PrefixTy == Mangler::LinkerPrivate) {
    118118 const char *Prefix = MAI.getLinkerPrivateGlobalPrefix();
    119 OutName.append(Prefix, Prefix+strlen(Prefix));
    120 } else if (PrefixTy == Mangler::LinkerWeak) {
    121 const char *Prefix = MAI.getLinkerWeakGlobalPrefix();
    122119 OutName.append(Prefix, Prefix+strlen(Prefix));
    123120 }
    124121
    184181 PrefixTy = Mangler::Private;
    185182 else if (GV->hasLinkerPrivateLinkage())
    186183 PrefixTy = Mangler::LinkerPrivate;
    187 else if (GV->hasLinkerWeakLinkage())
    188 PrefixTy = Mangler::LinkerWeak;
    189184
    190185 // If this global has a name, handle it simply.
    191186 if (GV->hasName()) {
    128128 case GlobalValue::WeakAnyLinkage:
    129129 case GlobalValue::WeakODRLinkage:
    130130 case GlobalValue::ExternalLinkage:
    131 case GlobalValue::LinkerWeakLinkage:
    132131 emitArrayBound(GVSym, GV);
    133132 OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global);
    134133
    534534 case GlobalValue::WeakAnyLinkage:
    535535 case GlobalValue::WeakODRLinkage:
    536536 case GlobalValue::ExternalWeakLinkage:
    537 case GlobalValue::LinkerWeakLinkage:
    538537 return ExternalWeak;
    539538
    540539 case GlobalValue::ExternalLinkage:
    14181418 case GlobalValue::ExternalLinkage: break;
    14191419 case GlobalValue::PrivateLinkage: Out << "private "; break;
    14201420 case GlobalValue::LinkerPrivateLinkage: Out << "linker_private "; break;
    1421 case GlobalValue::LinkerWeakLinkage: Out << "linker_weak "; break;
    14221421 case GlobalValue::InternalLinkage: Out << "internal "; break;
    14231422 case GlobalValue::LinkOnceAnyLinkage: Out << "linkonce "; break;
    14241423 case GlobalValue::LinkOnceODRLinkage: Out << "linkonce_odr "; break;
    10571057 return LLVMPrivateLinkage;
    10581058 case GlobalValue::LinkerPrivateLinkage:
    10591059 return LLVMLinkerPrivateLinkage;
    1060 case GlobalValue::LinkerWeakLinkage:
    1061 return LLVMLinkerWeakLinkage;
    10621060 case GlobalValue::DLLImportLinkage:
    10631061 return LLVMDLLImportLinkage;
    10641062 case GlobalValue::DLLExportLinkage:
    11091107 case LLVMLinkerPrivateLinkage:
    11101108 GV->setLinkage(GlobalValue::LinkerPrivateLinkage);
    11111109 break;
    1112 case LLVMLinkerWeakLinkage:
    1113 GV->setLinkage(GlobalValue::LinkerWeakLinkage);
    1114 break;
    11151110 case LLVMDLLImportLinkage:
    11161111 GV->setLinkage(GlobalValue::DLLImportLinkage);
    11171112 break;
    8888 static void DumpSymbolNameForGlobalValue(GlobalValue &GV) {
    8989 // Private linkage and available_externally linkage don't exist in symtab.
    9090 if (GV.hasPrivateLinkage() || GV.hasLinkerPrivateLinkage() ||
    91 GV.hasLinkerWeakLinkage() || GV.hasAvailableExternallyLinkage())
    92 return;
    91 GV.hasAvailableExternallyLinkage()) return;
    9392
    9493 const std::string SymbolAddrStr = " "; // Not used yet...
    9594 char TypeChar = TypeCharForSymbol(GV);