This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - implemented ternary operator for linkerscript expressions
ClosedPublic

Authored by grimar on Apr 20 2016, 10:06 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 54387.Apr 20 2016, 10:06 AM
grimar retitled this revision from to [ELF] - implemented ternary operator for linkerscript expressions.
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: grimar, llvm-commits.
davide added a subscriber: davide.Apr 20 2016, 10:37 AM

I have a question (mostly, curiosity). Are you trying to support enough to correctly parse a given linker script (e.g. Linux/FreeBSD kernel) or you're picking features according to some other criterion?

Cheers,

emaste added a subscriber: emaste.Apr 20 2016, 11:28 AM
ruiu added inline comments.Apr 20 2016, 2:00 PM
ELF/LinkerScript.cpp
94–104 ↗(On Diff #54387)

Please sync after r266912. I defined expect and redefined readExpr. Now you can write this as

next(Tokens);
uint64_t V = parseExpr(Tokens, Dot);
if (expect(Tokens, ":")
  return 0;
uint64_t W = parseExpr(Tokens, Dot);
return Cond ? V : W;

I have a question (mostly, curiosity). Are you trying to support enough to correctly parse a given linker script (e.g. Linux/FreeBSD kernel) or you're picking features according to some other criterion?

Cheers,

I am using bsd script as reference (https://svnweb.freebsd.org/base/head/sys/conf/ldscript.amd64?view=markup), so I am trying to support features it uses, assuming that it is reasonable subset.

grimar updated this revision to Diff 54472.Apr 21 2016, 2:24 AM
  • Rebased
ruiu accepted this revision.Apr 21 2016, 12:01 PM
ruiu edited edge metadata.

LGTM with a nit.

ELF/LinkerScript.cpp
138 ↗(On Diff #54472)

Swap Tokens and Lhs so that the order matches with parseExpr1.

This revision is now accepted and ready to land.Apr 21 2016, 12:01 PM
This revision was automatically updated to reflect the committed changes.
grimar updated this object.Apr 22 2016, 3:41 AM
grimar edited edge metadata.
grimar added inline comments.
ELF/LinkerScript.cpp
138 ↗(On Diff #54472)

r267086 changed signature to:

uint64_t LinkerScript<ELFT>::parseExpr1(ArrayRef<StringRef> &Tokens,
                                        uint64_t Lhs, int MinPrec) {

So leaved without changes the order.
But I made it a member of class and changed signature to:

uint64_t LinkerScript<ELFT>::parseTernary(ArrayRef<StringRef> &Tokens, uint64_t Cond)

(to match latest changes about Dot)