diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2018-03-09 03:13:37 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2018-03-09 03:13:37 +0000 |
commit | 81e911cd868252e2e788ae1b82fb1ac5b56fd1f6 (patch) | |
tree | f471360406e00741228d00692ec79f5e32777525 | |
parent | 5a91fc6f743659ad30f8f5c42aef8d1056e5e3d5 (diff) | |
download | bcm5719-llvm-81e911cd868252e2e788ae1b82fb1ac5b56fd1f6.tar.gz bcm5719-llvm-81e911cd868252e2e788ae1b82fb1ac5b56fd1f6.zip |
Don't treat .symver as a regular alias definition.
This patch starts simplifying the handling of .symver.
For now it just moves the responsibility for creating an alias down to
the streamer. With that the asm streamer can pass a .symver unchanged,
which is nice since gas cannot parse "foo@bar = zed".
In a followup I hope to move the handling down to the writer so that
we don't need special hacks for avoiding breaking names with @@@ on
windows.
llvm-svn: 327101
-rw-r--r-- | llvm/include/llvm/MC/MCELFStreamer.h | 2 | ||||
-rw-r--r-- | llvm/lib/MC/MCAsmStreamer.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/MC/MCELFStreamer.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/MC/MCParser/ELFAsmParser.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/Object/RecordStreamer.cpp | 2 | ||||
-rw-r--r-- | llvm/test/MC/ARM/comment.s | 6 |
6 files changed, 25 insertions, 6 deletions
diff --git a/llvm/include/llvm/MC/MCELFStreamer.h b/llvm/include/llvm/MC/MCELFStreamer.h index c5b66a163c8..4b3e6aa215b 100644 --- a/llvm/include/llvm/MC/MCELFStreamer.h +++ b/llvm/include/llvm/MC/MCELFStreamer.h @@ -51,6 +51,8 @@ public: unsigned ByteAlignment) override; void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override; + void emitELFSymverDirective(MCSymbol *Alias, + const MCSymbol *Aliasee) override; void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override; diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index f254cb50b60..1d7aa5a9067 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -130,6 +130,9 @@ public: void ChangeSection(MCSection *Section, const MCExpr *Subsection) override; + void emitELFSymverDirective(MCSymbol *Alias, + const MCSymbol *Aliasee) override; + void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) override; void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override; @@ -414,6 +417,15 @@ void MCAsmStreamer::ChangeSection(MCSection *Section, } } +void MCAsmStreamer::emitELFSymverDirective(MCSymbol *Alias, + const MCSymbol *Aliasee) { + OS << ".symver "; + Aliasee->print(OS, MAI); + OS << ", "; + Alias->print(OS, MAI); + EmitEOL(); +} + void MCAsmStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc) { MCStreamer::EmitLabel(Symbol, Loc); diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp index 366125962a5..646d0dbded4 100644 --- a/llvm/lib/MC/MCELFStreamer.cpp +++ b/llvm/lib/MC/MCELFStreamer.cpp @@ -337,6 +337,12 @@ void MCELFStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) { cast<MCSymbolELF>(Symbol)->setSize(Value); } +void MCELFStreamer::emitELFSymverDirective(MCSymbol *Alias, + const MCSymbol *Aliasee) { + const MCExpr *Value = MCSymbolRefExpr::create(Aliasee, getContext()); + EmitAssignment(Alias, Value); +} + void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *S, uint64_t Size, unsigned ByteAlignment) { auto *Symbol = cast<MCSymbolELF>(S); diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index 59ffd756b2b..510c456c775 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -771,9 +771,6 @@ bool ELFAsmParser::ParseDirectiveSymver(StringRef, SMLoc) { MCSymbol *Alias = getContext().getOrCreateSymbol(AliasName); MCSymbol *Sym = getContext().getOrCreateSymbol(Name); - const MCExpr *Value = MCSymbolRefExpr::create(Sym, getContext()); - - getStreamer().EmitAssignment(Alias, Value); getStreamer().emitELFSymverDirective(Alias, Sym); return false; } diff --git a/llvm/lib/Object/RecordStreamer.cpp b/llvm/lib/Object/RecordStreamer.cpp index e94e9cfed39..a9e3a46b519 100644 --- a/llvm/lib/Object/RecordStreamer.cpp +++ b/llvm/lib/Object/RecordStreamer.cpp @@ -114,5 +114,7 @@ void RecordStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, void RecordStreamer::emitELFSymverDirective(MCSymbol *Alias, const MCSymbol *Aliasee) { + const MCExpr *Value = MCSymbolRefExpr::create(Aliasee, getContext()); + EmitAssignment(Alias, Value); SymverAliasMap[Aliasee].push_back(Alias); } diff --git a/llvm/test/MC/ARM/comment.s b/llvm/test/MC/ARM/comment.s index c24bc1aaa40..7187683a85b 100644 --- a/llvm/test/MC/ARM/comment.s +++ b/llvm/test/MC/ARM/comment.s @@ -34,9 +34,9 @@ far: @CHECK-NOT: @ @CHECK-LABEL: bar: -@CHECK: bar1@zed = defined1 -@CHECK: bar3@@zed = defined2 -@CHECK: bar5@@@zed = defined3 +@CHECK: .symver defined1, bar1@zed +@CHECK: .symver defined2, bar3@@zed +@CHECK: .symver defined3, bar5@@@zed @ Make sure we did not mess up the parser state and it still lexes @ comments correctly by excluding the @ in normal symbols |