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

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 15:09:36 PDT 2016


evgeny777 added inline comments.

================
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 == ";")
----------------
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.


Repository:
  rL LLVM

https://reviews.llvm.org/D22625





More information about the llvm-commits mailing list