[all-commits] [llvm/llvm-project] 92b5b9: [ELF] Postpone evaluation of ORIGIN/LENGTH in a ME...

Fangrui Song via All-commits all-commits at lists.llvm.org
Mon Mar 9 08:31:59 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 92b5b980d2e3ed2abddf116c18d163488b62235f
      https://github.com/llvm/llvm-project/commit/92b5b980d2e3ed2abddf116c18d163488b62235f
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-03-09 (Mon, 09 Mar 2020)

  Changed paths:
    M lld/ELF/LinkerScript.cpp
    M lld/ELF/LinkerScript.h
    M lld/ELF/ScriptParser.cpp
    M lld/test/ELF/linkerscript/memory-err.s
    M lld/test/ELF/linkerscript/memory.s

  Log Message:
  -----------
  [ELF] Postpone evaluation of ORIGIN/LENGTH in a MEMORY command

```
createFiles(args)
 readDefsym
 readerLinkerScript(*mb)
  ...
   readMemory
    readMemoryAssignment("ORIGIN", "org", "o") // eagerly evaluated
target = getTarget();
link(args)
 writeResult<ELFT>()
  ...
   finalizeSections()
    script->processSymbolAssignments()
     addSymbol(cmd) // with this patch, evaluated here
```

readMemoryAssignment eagerly evaluates ORIGIN/LENGTH and returns an uint64_t.
This patch postpones the evaluation to make

* --defsym and symbol assignments
* `CONSTANT(COMMONPAGESIZE)` (requires a non-null `lld::elf::target`)

work. If the expression somehow requires interaction with memory
regions, the circular dependency may cause the expression to evaluate to
a strange value. See the new test added to memory-err.s

Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D75763




More information about the All-commits mailing list