[PATCH] D23534: [ELF] Linkerscript: support hidden symbols assignments

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 18:19:25 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL278770: [ELF] Linkerscript: support hidden symbols assignments (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D23534?vs=68119&id=68125#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23534

Files:
  lld/trunk/ELF/LinkerScript.cpp
  lld/trunk/test/ELF/linkerscript/linkerscript-symbols.s

Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -602,7 +602,7 @@
   InputSectionDescription *readInputSectionRules();
   unsigned readPhdrType();
   SortKind readSortKind();
-  SymbolAssignment *readProvide(bool Hidden);
+  SymbolAssignment *readProvideHidden(bool Provide, bool Hidden);
   SymbolAssignment *readProvideOrAssignment(StringRef Tok);
   Expr readAlign();
   void readSort();
@@ -969,10 +969,10 @@
   return { uint8_t(V >> 24), uint8_t(V >> 16), uint8_t(V >> 8), uint8_t(V) };
 }
 
-SymbolAssignment *ScriptParser::readProvide(bool Hidden) {
+SymbolAssignment *ScriptParser::readProvideHidden(bool Provide, bool Hidden) {
   expect("(");
   SymbolAssignment *Cmd = readAssignment(next());
-  Cmd->Provide = true;
+  Cmd->Provide = Provide;
   Cmd->Hidden = Hidden;
   expect(")");
   expect(";");
@@ -985,9 +985,11 @@
     Cmd = readAssignment(Tok);
     expect(";");
   } else if (Tok == "PROVIDE") {
-    Cmd = readProvide(false);
+    Cmd = readProvideHidden(true, false);
+  } else if (Tok == "HIDDEN") {
+    Cmd = readProvideHidden(false, true);
   } else if (Tok == "PROVIDE_HIDDEN") {
-    Cmd = readProvide(true);
+    Cmd = readProvideHidden(true, true);
   }
   return Cmd;
 }
Index: lld/trunk/test/ELF/linkerscript/linkerscript-symbols.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript-symbols.s
+++ lld/trunk/test/ELF/linkerscript/linkerscript-symbols.s
@@ -35,6 +35,12 @@
 # RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN2 %s
 # HIDDEN2: 0000000000000000         *ABS*    00000000 somesym
 
+# Hidden symbol assignment.
+# RUN: echo "SECTIONS { HIDDEN(newsym = 1);}" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN3 %s
+# HIDDEN3: 0000000000000001         *ABS*    00000000 .hidden newsym
+
 .global _start
 _start:
  nop


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23534.68125.patch
Type: text/x-patch
Size: 2032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160816/a0e3f530/attachment.bin>


More information about the llvm-commits mailing list