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

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 16:33:12 PDT 2016


phosek created this revision.
phosek added reviewers: ruiu, rafael.
phosek added a subscriber: llvm-commits.
phosek added a project: lld.

This add support for HIDDEN command which can be used to define a symbol that will be hidden and won't be exported.

https://reviews.llvm.org/D23534

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

Index: test/ELF/linkerscript/linkerscript-symbols.s
===================================================================
--- test/ELF/linkerscript/linkerscript-symbols.s
+++ 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
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -982,6 +982,12 @@
   if (peek() == "=" || peek() == "+=") {
     Cmd = readAssignment(Tok);
     expect(";");
+  } else if (Tok == "HIDDEN") {
+    expect("(");
+    Cmd = readAssignment(next());
+    Cmd->Hidden = true;
+    expect(")");
+    expect(";");
   } else if (Tok == "PROVIDE") {
     Cmd = readProvide(false);
   } else if (Tok == "PROVIDE_HIDDEN") {


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


More information about the llvm-commits mailing list