[PATCH] D30485: Mark .symver versioned symbol as global

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 28 19:14:27 PST 2017


tejohnson created this revision.
Herald added a subscriber: mehdi_amini.

In a .symver assembler directive like:

  .symver name, name2@@nodename

name2@@nodename should be marked global. This is consistent with how the
symbols are treated in an assembly file compiled with either gas or
llvm-mc.

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 test added will give an error about an unused symbol
resolution without the fix.


https://reviews.llvm.org/D30485

Files:
  lib/MC/MCParser/ELFAsmParser.cpp
  test/LTO/X86/symver-asm.ll


Index: test/LTO/X86/symver-asm.ll
===================================================================
--- test/LTO/X86/symver-asm.ll
+++ test/LTO/X86/symver-asm.ll
@@ -1,7 +1,10 @@
 ; RUN: llvm-as < %s >%t1
 ; RUN: llvm-lto -o %t2 %t1
 ; RUN: llvm-nm %t2 | FileCheck %s
+; RUN: llvm-lto2 -r %t1,io_cancel_0_4,plx -r %t1,io_cancel_0_4,plx -r %t1,io_cancel@@LIBAIO_0.4,plx -o %t3 %t1
+; RUN: llvm-nm %t3.0 | 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 ".symver io_cancel_0_4,io_cancel@@LIBAIO_0.4"
Index: lib/MC/MCParser/ELFAsmParser.cpp
===================================================================
--- lib/MC/MCParser/ELFAsmParser.cpp
+++ lib/MC/MCParser/ELFAsmParser.cpp
@@ -743,6 +743,9 @@
   const MCExpr *Value = MCSymbolRefExpr::create(Sym, getContext());
 
   getStreamer().EmitAssignment(Alias, Value);
+  // The alias name is global since it needs to be externally available
+  // for the linker.
+  getStreamer().EmitSymbolAttribute(Alias, MCSA_Global);
   return false;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30485.90115.patch
Type: text/x-patch
Size: 1081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170301/5cdf9a65/attachment.bin>


More information about the llvm-commits mailing list