[lld] r285567 - Correctly merge visibility of linkerscript created symbols.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 06:14:54 PDT 2016


Author: rafael
Date: Mon Oct 31 08:14:53 2016
New Revision: 285567

URL: http://llvm.org/viewvc/llvm-project?rev=285567&view=rev
Log:
Correctly merge visibility of linkerscript created symbols.

Added:
    lld/trunk/test/ELF/linkerscript/visibility.s
Modified:
    lld/trunk/ELF/LinkerScript.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=285567&r1=285566&r2=285567&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Oct 31 08:14:53 2016
@@ -46,9 +46,9 @@ LinkerScriptBase *elf::ScriptBase;
 ScriptConfiguration *elf::ScriptConfig;
 
 template <class ELFT> static void addRegular(SymbolAssignment *Cmd) {
-  Symbol *Sym = Symtab<ELFT>::X->addRegular(Cmd->Name, STV_DEFAULT, nullptr,
+  uint8_t Visibility = Cmd->Hidden ? STV_HIDDEN : STV_DEFAULT;
+  Symbol *Sym = Symtab<ELFT>::X->addRegular(Cmd->Name, Visibility, nullptr,
                                             STB_GLOBAL, STT_NOTYPE, 0);
-  Sym->Visibility = Cmd->Hidden ? STV_HIDDEN : STV_DEFAULT;
   Cmd->Sym = Sym->body();
 
   // If we have no SECTIONS then we don't have '.' and don't call

Added: lld/trunk/test/ELF/linkerscript/visibility.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/visibility.s?rev=285567&view=auto
==============================================================================
--- lld/trunk/test/ELF/linkerscript/visibility.s (added)
+++ lld/trunk/test/ELF/linkerscript/visibility.s Mon Oct 31 08:14:53 2016
@@ -0,0 +1,22 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+
+# RUN: echo "SECTIONS { foo = .; }" > %t1.script
+# RUN: ld.lld -o %t1 --script %t1.script %t.o -shared
+# RUN: llvm-readobj -t %t1 | FileCheck %s
+
+# CHECK:      Symbol {
+# CHECK:        Name: foo
+# CHECK-NEXT:   Value:
+# CHECK-NEXT:   Size:
+# CHECK-NEXT:   Binding: Local
+# CHECK-NEXT:   Type:
+# CHECK-NEXT:   Other [
+# CHECK-NEXT:     STV_HIDDEN
+# CHECK-NEXT:   ]
+# CHECK-NEXT:   Section:
+# CHECK-NEXT: }
+
+        .data
+        .hidden foo
+        .long foo




More information about the llvm-commits mailing list