diff options
| author | Teresa Johnson <tejohnson@google.com> | 2017-03-09 00:19:49 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2017-03-09 00:19:49 +0000 |
| commit | d820447212e616093941f45775b52bd4afc86cf0 (patch) | |
| tree | f3fefe9f71703715ac8123473b2c9b7f2a94f85d /llvm/include | |
| parent | 3dea91fec6354451d36c3afc31fd4ac8674d8b5a (diff) | |
| download | bcm5719-llvm-d820447212e616093941f45775b52bd4afc86cf0.tar.gz bcm5719-llvm-d820447212e616093941f45775b52bd4afc86cf0.zip | |
Perform symbol binding for .symver versioned symbols
Summary:
In a .symver assembler directive like:
.symver name, name2@@nodename
"name2@@nodename" should get the same symbol binding as "name".
While the ELF object writer is updating the symbol binding for .symver
aliases before emitting the object file, not doing so when the module
inline assembly is handled by the RecordStreamer is causing the wrong
behavior in *LTO mode.
E.g. when "name" is global, "name2@@nodename" must also be marked as
global. Otherwise, the symbol is skipped when iterating over the LTO
InputFile symbols (InputFile::Symbol::shouldSkip). So, for example,
when performing any *LTO via the gold-plugin, the versioned symbol
definition is not recorded by the plugin and passed back to the
linker. If the object was in an archive, and there were no other symbols
needed from that object, the object would not be included in the final
link and references to the versioned symbol are undefined.
The llvm-lto2 tests added will give an error about an unused symbol
resolution without the fix.
Reviewers: rafael, pcc
Reviewed By: pcc
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D30485
llvm-svn: 297332
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/MC/MCStreamer.h | 8 | ||||
| -rw-r--r-- | llvm/include/llvm/Object/ModuleSymbolTable.h | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h index b477a608c26..c0d322e3ed3 100644 --- a/llvm/include/llvm/MC/MCStreamer.h +++ b/llvm/include/llvm/MC/MCStreamer.h @@ -489,6 +489,14 @@ public: /// .size symbol, expression virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value); + /// \brief Emit an ELF .symver directive. + /// + /// This corresponds to an assembler statement such as: + /// .symver _start, foo@@SOME_VERSION + /// \param Alias - The versioned alias (i.e. "foo@@SOME_VERSION") + /// \param Aliasee - The aliased symbol (i.e. "_start") + virtual void emitELFSymverDirective(MCSymbol *Alias, const MCSymbol *Aliasee); + /// \brief Emit a Linker Optimization Hint (LOH) directive. /// \param Args - Arguments of the LOH. virtual void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {} diff --git a/llvm/include/llvm/Object/ModuleSymbolTable.h b/llvm/include/llvm/Object/ModuleSymbolTable.h index 70775352d97..333301d5b45 100644 --- a/llvm/include/llvm/Object/ModuleSymbolTable.h +++ b/llvm/include/llvm/Object/ModuleSymbolTable.h @@ -26,6 +26,7 @@ namespace llvm { class GlobalValue; +class RecordStreamer; class ModuleSymbolTable { public: @@ -52,7 +53,7 @@ public: /// For each found symbol, call \p AsmSymbol with the name of the symbol found /// and the associated flags. static void CollectAsmSymbols( - const Triple &TheTriple, StringRef InlineAsm, + const Module &M, function_ref<void(StringRef, object::BasicSymbolRef::Flags)> AsmSymbol); }; |

