[llvm-branch-commits] [llvm] e6c1777 - [MC] Copy visibility for .symver created symbols

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Nov 29 16:56:16 PST 2020


Author: Fangrui Song
Date: 2020-11-29T16:51:48-08:00
New Revision: e6c17776858d9ec5c2ce15447b384da2141bbbad

URL: https://github.com/llvm/llvm-project/commit/e6c17776858d9ec5c2ce15447b384da2141bbbad
DIFF: https://github.com/llvm/llvm-project/commit/e6c17776858d9ec5c2ce15447b384da2141bbbad.diff

LOG: [MC] Copy visibility for .symver created symbols

Added: 
    llvm/test/MC/ELF/symver-visibility.s

Modified: 
    llvm/lib/MC/ELFObjectWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 494f82558d82..10c61fc8b453 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1280,6 +1280,7 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
     // This is the first place we are able to copy this information.
     Alias->setExternal(Symbol.isExternal());
     Alias->setBinding(Symbol.getBinding());
+    Alias->setVisibility(Symbol.getVisibility());
     Alias->setOther(Symbol.getOther());
 
     if (!Symbol.isUndefined() && !Rest.startswith("@@@"))

diff  --git a/llvm/test/MC/ELF/symver-visibility.s b/llvm/test/MC/ELF/symver-visibility.s
new file mode 100644
index 000000000000..92d1da9cdef1
--- /dev/null
+++ b/llvm/test/MC/ELF/symver-visibility.s
@@ -0,0 +1,14 @@
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
+# RUN: llvm-readelf -s %t | FileCheck %s
+
+# CHECK:      NOTYPE GLOBAL HIDDEN    {{[1-9]}} def@@v1
+# CHECK-NEXT: NOTYPE GLOBAL PROTECTED UND       undef at v1
+
+.protected undef
+.symver undef, undef@@@v1
+call undef
+
+.globl def
+.hidden def
+.symver def, def@@@v1
+def:


        


More information about the llvm-branch-commits mailing list