llvm.org GIT mirror llvm / 9010765
[IRObjectFile] Propagate .weak attribute correctly for ASM symbols. PR: 28256 Differential Revision: http://reviews.llvm.org/D21616 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273474 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 3 years ago
4 changed file(s) with 16 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
115115 Res |= BasicSymbolRef::SF_Undefined;
116116 Res |= BasicSymbolRef::SF_Global;
117117 break;
118 case RecordStreamer::GlobalWeak:
119 Res |= BasicSymbolRef::SF_Weak;
120 Res |= BasicSymbolRef::SF_Global;
118121 }
119122 AsmUndefinedRefs(Key, BasicSymbolRef::Flags(Res));
120123 }
2222 case Used:
2323 S = Defined;
2424 break;
25 case GlobalWeak:
26 break;
2527 }
2628 }
2729
28 void RecordStreamer::markGlobal(const MCSymbol &Symbol) {
30 void RecordStreamer::markGlobal(const MCSymbol &Symbol,
31 MCSymbolAttr Attribute) {
2932 State &S = Symbols[Symbol.getName()];
3033 switch (S) {
3134 case DefinedGlobal:
3235 case Defined:
33 S = DefinedGlobal;
36 S = (Attribute == MCSA_Weak) ? GlobalWeak : DefinedGlobal;
3437 break;
3538
3639 case NeverSeen:
3740 case Global:
3841 case Used:
39 S = Global;
42 S = (Attribute == MCSA_Weak) ? GlobalWeak : Global;
43 break;
44 case GlobalWeak:
4045 break;
4146 }
4247 }
4752 case DefinedGlobal:
4853 case Defined:
4954 case Global:
55 case GlobalWeak:
5056 break;
5157
5258 case NeverSeen:
8490 bool RecordStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
8591 MCSymbolAttr Attribute) {
8692 if (Attribute == MCSA_Global || Attribute == MCSA_Weak)
87 markGlobal(*Symbol);
93 markGlobal(*Symbol, Attribute);
8894 return true;
8995 }
9096
1414 namespace llvm {
1515 class RecordStreamer : public MCStreamer {
1616 public:
17 enum State { NeverSeen, Global, Defined, DefinedGlobal, Used };
17 enum State { NeverSeen, Global, GlobalWeak, Defined, DefinedGlobal, Used };
1818
1919 private:
2020 StringMap Symbols;
2121 void markDefined(const MCSymbol &Symbol);
22 void markGlobal(const MCSymbol &Symbol);
22 void markGlobal(const MCSymbol &Symbol, MCSymbolAttr Attribute);
2323 void markUsed(const MCSymbol &Symbol);
2424 void visitUsedSymbol(const MCSymbol &Sym) override;
2525
0 ; RUN: llvm-as %s -o=%t1
11 ; RUN: llvm-nm %t1 | FileCheck %s
22
3 ; CHECK: T __libc_blah
3 ; CHECK: W __libc_blah
44
55 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
66 target triple = "x86_64-unknown-freebsd11.0"