[lld] r276574 - Make readExpr return an Expr object instead of a vector of tokens.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 24 16:19:49 PDT 2016


Did it work before? I think we don't support symbols on RHS yet.

On Sun, Jul 24, 2016 at 4:16 PM, Davide Italiano <davide at freebsd.org> wrote:

> On Sun, Jul 24, 2016 at 11:19 AM, Rui Ueyama via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> > Author: ruiu
> > Date: Sun Jul 24 13:19:40 2016
> > New Revision: 276574
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=276574&view=rev
> > Log:
> > Make readExpr return an Expr object instead of a vector of tokens.
> >
> > Previously, we handled an expression as a vector of tokens. In other
> > words, an expression was a vector of uncooked raw StringRefs.
> > When we need a value of an expression, we used ExprParser to run
> > the expression.
> >
> > The separation was needed essentially because parse time is too
> > early to evaluate an expression. In order to evaluate an expression,
> > we need to finalize section sizes. Because linker script parsing
> > is done at very early stage of the linking process, we can't
> > evaluate expressions while parsing.
> >
> > The above mechanism worked fairly well, but there were a few
> > drawbacks.
> >
> > One thing is that we sometimes have to parse the same expression
> > more than once in order to find the end of the expression.
> > In some contexts, linker script expressions have no clear end marker.
> > So, we needed to recognize balanced expressions and ternary operators.
> >
> > The other is poor error reporting. Since expressions are parsed
> > basically twice, and some information that is available at the first
> > stage is lost in the second stage, it was hard to print out
> > apprpriate error messages.
> >
> > This patch fixes the issues with a new approach.
> >
> > Now the expression parsing is integrated into ScriptParser.
> > ExprParser class is removed. Expressions are represented as lambdas
> > instead of vectors of tokens. Lambdas captures information they
> > need to run themselves when they are created.
> >
> > In this way, ends of expressions are naturally detected, and
> > errors are handled in the usual way. This patch also reduces
> > the amount of code.
> >
> > Differential Revision: https://reviews.llvm.org/D22728
> >
>
> This commit breaks (at least) this case. Can you please take a look?
>
> [davide at ganondorf bin]$ ./ld.lld reduction.script
> line 3: malformed number: kernbase
>   . = kernbase + kernphys + SIZEOF_HEADERS;
>       ^
> [davide at ganondorf bin]$ cat reduction.script
> SECTIONS
> {
>   . = kernbase + kernphys + SIZEOF_HEADERS;
> }
>
> --
> Davide
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160724/5f3be58e/attachment.html>


More information about the llvm-commits mailing list