[PATCH] D44274: Object: Fix handling of @@@ in .symver directive
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 8 15:39:29 PST 2018
vitalybuka updated this revision to Diff 137664.
vitalybuka added a comment.
auto -> explicit types
https://reviews.llvm.org/D44274
Files:
llvm/lib/Object/RecordStreamer.cpp
llvm/test/LTO/X86/symver-asm3.ll
Index: llvm/test/LTO/X86/symver-asm3.ll
===================================================================
--- /dev/null
+++ llvm/test/LTO/X86/symver-asm3.ll
@@ -0,0 +1,17 @@
+; Test special handling of @@@.
+
+; RUN: llvm-as < %s >%t1
+; RUN: llvm-nm %t1 | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+module asm "_start1:"
+module asm ".symver _start1, foo@@@SOME_VERSION1"
+module asm ".symver _start2, foo@@@SOME_VERSION2"
+module asm ".local _start1"
+
+; CHECK-DAG: t _start1
+; CHECK-DAG: U _start2
+; CHECK-DAG: t foo@@SOME_VERSION1
+; CHECK-DAG: t foo at SOME_VERSION2
Index: llvm/lib/Object/RecordStreamer.cpp
===================================================================
--- llvm/lib/Object/RecordStreamer.cpp
+++ llvm/lib/Object/RecordStreamer.cpp
@@ -150,8 +150,43 @@
MCSymbol *RecordStreamer::createELFSymverAlias(StringRef AliasName,
const MCSymbol *Aliasee) {
- // TODO: Handle "@@@". Depending on SymbolAttribute value it needs to be
- // converted into @ or @@.
+ std::pair<StringRef, StringRef> Split = AliasName.split("@@@");
+ SmallString<64> NewName;
+ if (!Split.second.empty()) {
+ if (Split.second.startswith("@"))
+ return nullptr; // Unexpected 4th @.
+
+ // Special processing for "@@@" according
+ // https://sourceware.org/binutils/docs/as/Symver.html
+ bool IsDefined = false;
+ // First check if the aliasee was recorded in the asm.
+ switch (getSymbolState(Aliasee)) {
+ case RecordStreamer::Defined:
+ case RecordStreamer::DefinedGlobal:
+ case RecordStreamer::DefinedWeak:
+ IsDefined = true;
+ break;
+ case RecordStreamer::NeverSeen:
+ case RecordStreamer::Global:
+ case RecordStreamer::Used:
+ case RecordStreamer::UndefinedWeak:
+ break;
+ }
+ if (!IsDefined) {
+ // If we don't have it in assembly, then check if the aliasee was
+ // defined in the IR.
+ const GlobalValue *GV = M.getNamedValue(Aliasee->getName());
+ if (!GV) {
+ auto MI = MangledNameMap.find(Aliasee->getName());
+ if (MI != MangledNameMap.end())
+ GV = MI->second;
+ }
+ IsDefined = GV && GV->isDefinitionExact();
+ }
+ const char *Separator = IsDefined ? "@@" : "@";
+ AliasName =
+ (Split.first + Separator + Split.second).toStringRef(NewName);
+ }
MCSymbol *Alias = MCStreamer::createELFSymverAlias(AliasName, Aliasee);
SymverAliasMap[Aliasee].push_back(Alias);
return Alias;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44274.137664.patch
Type: text/x-patch
Size: 2572 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180308/80b21d60/attachment.bin>
More information about the llvm-commits
mailing list