This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Linkerscript: symbol assignments with indentifiers on the right side of expression.
ClosedPublic

Authored by grimar on Jul 25 2016, 9:09 AM.

Details

Summary

In symbol assignments symbol may appear on the right-hand side of the expression:
(https://svnweb.freebsd.org/base/head/sys/conf/ldscript.amd64?revision=284870&view=markup#l8)

 /* Read-only sections, merged into text segment: */
kernphys = CONSTANT (MAXPAGESIZE);
 . = kernbase + kernphys + SIZEOF_HEADERS;

Patch implements that.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 65352.Jul 25 2016, 9:09 AM
grimar retitled this revision from to [ELF] Linkerscript: symbol assignments with indentifiers on the right side of expression..
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.
ruiu added inline comments.Jul 25 2016, 10:30 AM
ELF/LinkerScript.cpp
776–778 ↗(On Diff #65352)

Please do this.

uint64_t static getSymbolValue(StringRef S) {
  switch (Config->EKind) {
  case ELF32LEKind:
    if (SymbolBody *B = Symtab<ELF32LE>::X->find(S))
      return B->getVA<ELF32LE>();
    break;
  case ELF32BEKind:
    ...
  case ELF64LEKind:
    ...
  case ELF64BEKind:
    ...
  }
  error("symbol not found: " + S);
  return 0;
}
grimar added a subscriber: davide.Jul 25 2016, 11:20 PM
grimar updated this revision to Diff 65492.Jul 26 2016, 4:13 AM
  • Addressed review comments.
  • Improved testcase.
grimar updated this object.Jul 26 2016, 4:13 AM
ruiu accepted this revision.Jul 26 2016, 10:51 AM
ruiu edited edge metadata.

LGTM

ELF/LinkerScript.cpp
746 ↗(On Diff #65492)

uint64_t static -> static uint64_t.

764–765 ↗(On Diff #65492)

We don't need this guard.

851 ↗(On Diff #65492)

Parse a symbol name or a number literal.

This revision is now accepted and ready to land.Jul 26 2016, 10:51 AM
This revision was automatically updated to reflect the committed changes.
grimar added inline comments.Jul 26 2016, 11:27 AM
ELF/LinkerScript.cpp
746 ↗(On Diff #65492)

Done.

764–765 ↗(On Diff #65492)

Removed.

851 ↗(On Diff #65492)

Fixed.

776–778 ↗(On Diff #65352)

Done.