[lld] r276579 - [ELF] Support PROVIDE/PROVIDE_HIDDEN inside output sections description.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 24 16:13:49 PDT 2016


Author: davide
Date: Sun Jul 24 18:13:48 2016
New Revision: 276579

URL: http://llvm.org/viewvc/llvm-project?rev=276579&view=rev
Log:
[ELF] Support PROVIDE/PROVIDE_HIDDEN inside output sections description.

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

Added:
    lld/trunk/test/ELF/linkerscript-provide-in-section.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=276579&r1=276578&r2=276579&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Sun Jul 24 18:13:48 2016
@@ -676,6 +676,10 @@ void ScriptParser::readOutputSectionDesc
         InCmd->Patterns.push_back(next());
       }
       expect(")");
+    } else if (Tok == "PROVIDE") {
+      readProvide(false);
+    } else if (Tok == "PROVIDE_HIDDEN") {
+      readProvide(true);
     } else {
       setError("unknown command " + Tok);
     }

Added: lld/trunk/test/ELF/linkerscript-provide-in-section.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript-provide-in-section.s?rev=276579&view=auto
==============================================================================
--- lld/trunk/test/ELF/linkerscript-provide-in-section.s (added)
+++ lld/trunk/test/ELF/linkerscript-provide-in-section.s Sun Jul 24 18:13:48 2016
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo \
+# RUN: "SECTIONS { . = 1000; .blah : { PROVIDE(foo = .); } }" \
+# RUN:   > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t -shared
+# RUN: llvm-objdump -t %t1 | FileCheck %s
+# CHECK: 00000000000003e8         *ABS*           00000000 foo
+
+# RUN: echo \
+# RUN: "SECTIONS { . = 1000; .blah : { PROVIDE_HIDDEN(foo = .); } }" \
+# RUN:   > %t2.script
+# RUN: ld.lld -o %t2 --script %t2.script %t -shared
+# RUN: llvm-objdump -t %t2 | FileCheck %s --check-prefix=HIDDEN
+# HIDDEN: 00000000000003e8         *ABS*           00000000 .hidden foo
+
+.section blah
+.globl patatino
+patatino:
+  movl $foo, %edx




More information about the llvm-commits mailing list