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
This commit is contained in:
parent
5a91fc6f74
commit
81e911cd86
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue