Handle parsing AT(ADDR(.foo-bar)).
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 18 Jan 2018 01:14:57 +0000 (01:14 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 18 Jan 2018 01:14:57 +0000 (01:14 +0000)
The problem we had with it is that anything inside an AT is an
expression, so we failed to parse the section name because of the - in
it.

llvm-svn: 322801

lld/ELF/ScriptParser.cpp
lld/test/ELF/linkerscript/parse-section-in-addr.s [new file with mode: 0644]

index 65d3332..d66f909 100644 (file)
@@ -923,7 +923,10 @@ ByteCommand *ScriptParser::readByteCommand(StringRef Tok) {
 
 StringRef ScriptParser::readParenLiteral() {
   expect("(");
+  bool Orig = InExpr;
+  InExpr = false;
   StringRef Tok = next();
+  InExpr = Orig;
   expect(")");
   return Tok;
 }
diff --git a/lld/test/ELF/linkerscript/parse-section-in-addr.s b/lld/test/ELF/linkerscript/parse-section-in-addr.s
new file mode 100644 (file)
index 0000000..7a79f64
--- /dev/null
@@ -0,0 +1,10 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+
+# RUN: echo "SECTIONS {                                   \
+# RUN:         .foo-bar : AT(ADDR(.foo-bar)) { *(.text) } \
+# RUN:       }" > %t.script
+# RUN: ld.lld -o %t.so --script %t.script %t.o -shared
+# RUN: llvm-readelf -S %t.so | FileCheck %s
+
+# CHECK: .foo-bar