[llvm] r331078 - ELFObjectWriter: Allow one unique symver per symbol

Vlad Tsyrklevich via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 27 13:32:34 PDT 2018


Author: vlad.tsyrklevich
Date: Fri Apr 27 13:32:34 2018
New Revision: 331078

URL: http://llvm.org/viewvc/llvm-project?rev=331078&view=rev
Log:
ELFObjectWriter: Allow one unique symver per symbol

Summary:
Only allow a single unique .symver alias per symbol. This matches the
behavior of gas. I noticed that we ignored multiple mismatched symver
directives looking at https://reviews.llvm.org/D45798

Reviewers: pcc, tejohnson, espindola

Reviewed By: pcc

Subscribers: emaste, arichardson, llvm-commits, kcc

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

Added:
    llvm/trunk/test/MC/ELF/multiple-different-symver.s
    llvm/trunk/test/MC/ELF/multiple-equiv-symver.s
Modified:
    llvm/trunk/lib/MC/ELFObjectWriter.cpp

Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=331078&r1=331077&r2=331078&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Fri Apr 27 13:32:34 2018
@@ -420,6 +420,10 @@ void ELFObjectWriter::executePostLayoutB
         !Rest.startswith("@@@"))
       report_fatal_error("A @@ version cannot be undefined");
 
+    if (Renames.count(&Symbol) && Renames[&Symbol] != Alias)
+      report_fatal_error(llvm::Twine("Multiple symbol versions defined for ") +
+                         Symbol.getName());
+
     Renames.insert(std::make_pair(&Symbol, Alias));
   }
 }

Added: llvm/trunk/test/MC/ELF/multiple-different-symver.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/multiple-different-symver.s?rev=331078&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/multiple-different-symver.s (added)
+++ llvm/trunk/test/MC/ELF/multiple-different-symver.s Fri Apr 27 13:32:34 2018
@@ -0,0 +1,6 @@
+// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t 2>&1 | FileCheck %s
+
+// CHECK: Multiple symbol versions defined for foo
+
+.symver foo, foo at 1
+.symver foo, foo at 2

Added: llvm/trunk/test/MC/ELF/multiple-equiv-symver.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/multiple-equiv-symver.s?rev=331078&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/multiple-equiv-symver.s (added)
+++ llvm/trunk/test/MC/ELF/multiple-equiv-symver.s Fri Apr 27 13:32:34 2018
@@ -0,0 +1,6 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - 2>&1 | FileCheck %s
+
+// CHECK-NOT: Multiple symbol versions defined for foo
+
+.symver foo, foo at 1
+.symver foo, foo at 1




More information about the llvm-commits mailing list