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

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 15:35:59 PDT 2016


ruiu added a comment.

Essentially looks good. Please upload the latest patch with all review comments applied. Thanks.


================
Comment at: ELF/LinkerScript.cpp:803-811
@@ -778,5 +802,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:
> ruiu wrote:
> > evgeny777 wrote:
> > > ruiu wrote:
> > > > Can you remove it?
> > > What exactly? The "if (Tok == ";")" ? If so, how will we handle normal symbol assignments then? Like **"mysym = 0;"**
> > I meant the new code you added to this function in this patch.
> The new code is used to stop reading expression in case extra ')' is seen in expression.
> This happens in the case below:
> PROVIDE(a = 100**)**;
> 
> If you want this code to be removed then please suggest how to handle the case above, because ')' will be read as part of expression otherwise.
Ah, I think I finally understood why you added this code. It makes sense. But please add a function comment saying that this function reads a balanced expression until ";".


Repository:
  rL LLVM

https://reviews.llvm.org/D22625





More information about the llvm-commits mailing list