[PATCH] D22625: [ELF] Support PROVIDE and PROVIDE_HIDDEN within SECTIONS {} block

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 06:26:18 PDT 2016


grimar added inline comments.

================
Comment at: ELF/LinkerScript.cpp:799-807
@@ -778,5 +798,11 @@
 std::vector<StringRef> ScriptParser::readSectionsCommandExpr() {
+  int Braces = 0;
   std::vector<StringRef> Expr;
   while (!Error) {
-    StringRef Tok = next();
+    StringRef Tok = peek();
+    Braces += (Tok == "(");
+    Braces -= (Tok == ")");
+    if (Braces < 0)
+      break;
+    next();
     if (Tok == ";")
----------------
evgeny777 wrote:
> grimar wrote:
> > evgeny777 wrote:
> > > ruiu wrote:
> > > > Is this change related to the feature you are adding in this patch?
> > > Yes. As I said in summary, this is intended to early terminate the expression reader in case we see extra ')' bracket. Otherwise parser will eat tokens till it finds semicolon
> > This should be fixed in separate patch.
> May be, but actually this parser improvement is only needed for PROVIDE(). I don't mind making separate review, but not sure if it's really needed. Rui, what's your opinion?
Point here that this feature is useful itself and also should have a testcase which is unrelative to what this patch do. That not only make this patch a bit smaller, but also leaves this improvement in if patch be reverted, for example.


Repository:
  rL LLVM

https://reviews.llvm.org/D22625





More information about the llvm-commits mailing list