]> granicus.if.org Git - llvm/commitdiff
[lto] added getCOFFWeakExternalFallback
authorBob Haarman <llvm@inglorion.net>
Thu, 2 Feb 2017 23:10:22 +0000 (23:10 +0000)
committerBob Haarman <llvm@inglorion.net>
Thu, 2 Feb 2017 23:10:22 +0000 (23:10 +0000)
Summary: This allows clients of the LTO API to determine the name of the fallback symbol for COFF weak externals.

Reviewers: pcc

Reviewed By: pcc

Subscribers: mehdi_amini

Differential Revision: https://reviews.llvm.org/D29365

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293960 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/LTO/LTO.h

index 5886ed9917191ddcdafc35ea1abe14b3e64b59a1..c346ec522df436261a4305272c224f13d6ddf800 100644 (file)
@@ -152,6 +152,22 @@ public:
       skip();
     }
 
+    /// For COFF weak externals, returns the name of the symbol that is used
+    /// as a fallback if the weak external remains undefined.
+    std::string getCOFFWeakExternalFallback() const {
+      assert((Flags & object::BasicSymbolRef::SF_Weak) &&
+             (Flags & object::BasicSymbolRef::SF_Indirect) &&
+             "symbol is not a weak external");
+      std::string Name;
+      raw_string_ostream OS(Name);
+      SymTab.printSymbolName(
+          OS,
+          cast<GlobalValue>(
+              cast<GlobalAlias>(getGV())->getAliasee()->stripPointerCasts()));
+      OS.flush();
+      return Name;
+    }
+
     /// Returns the mangled name of the global.
     StringRef getName() const { return Name; }