summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-07-24 23:13:48 +0000
committerDavide Italiano <davide@freebsd.org>2016-07-24 23:13:48 +0000
commit054a6796342d6516779f4941542cc103bc05acd0 (patch)
tree1780e59186c6a511bcac76f110d46ee895867f11
parentee410aca067078efccb212685258969127f6dd71 (diff)
downloadbcm5719-llvm-054a6796342d6516779f4941542cc103bc05acd0.tar.gz
bcm5719-llvm-054a6796342d6516779f4941542cc103bc05acd0.zip
[ELF] Support PROVIDE/PROVIDE_HIDDEN inside output sections description.
Differential Revision: https://reviews.llvm.org/D22738 llvm-svn: 276579
-rw-r--r--lld/ELF/LinkerScript.cpp4
-rw-r--r--lld/test/ELF/linkerscript-provide-in-section.s20
2 files changed, 24 insertions, 0 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index cfc6f293e12..2ddfd9c526a 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -676,6 +676,10 @@ void ScriptParser::readOutputSectionDescription(StringRef OutSec) {
InCmd->Patterns.push_back(next());
}
expect(")");
+ } else if (Tok == "PROVIDE") {
+ readProvide(false);
+ } else if (Tok == "PROVIDE_HIDDEN") {
+ readProvide(true);
} else {
setError("unknown command " + Tok);
}
diff --git a/lld/test/ELF/linkerscript-provide-in-section.s b/lld/test/ELF/linkerscript-provide-in-section.s
new file mode 100644
index 00000000000..ca375e749d3
--- /dev/null
+++ b/lld/test/ELF/linkerscript-provide-in-section.s
@@ -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
OpenPOWER on IntegriCloud