[all-commits] [llvm/llvm-project] 7b6a89: [ELF] Detect convergence of output section addresses

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri May 31 09:31:36 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7b6a89f346f281e5b7caa593a8c484eaf4264055
      https://github.com/llvm/llvm-project/commit/7b6a89f346f281e5b7caa593a8c484eaf4264055
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-05-31 (Fri, 31 May 2024)

  Changed paths:
    M lld/ELF/LinkerScript.cpp
    M lld/ELF/LinkerScript.h
    M lld/ELF/Writer.cpp
    M lld/test/ELF/linkerscript/memory-err.s
    A lld/test/ELF/linkerscript/section-not-converge.test

  Log Message:
  -----------
  [ELF] Detect convergence of output section addresses

Some linker scripts don't converge. https://reviews.llvm.org/D66279
("[ELF] Make LinkerScript::assignAddresses iterative") detected
convergence of symbol assignments.

This patch detects convergence of output section addresses. While input
sections might also have convergence issues, they are less common as
expressions that could cause convergence issues typically involve output
sections and symbol assignments.

GNU ld has an error `non constant or forward reference address expression for section` that
correctly rejects
```
SECTIONS {
  .text ADDR(.data)+0x1000 : { *(.text) }
  .data : { *(.data) }
}
```

but not the following variant:
```
SECTIONS {
  .text foo : { *(.text) }
  .data : { *(.data) }
  foo = ADDR(.data)+0x1000;
}
```

Our approach consistently rejects both cases.

Link: https://discourse.llvm.org/t/lld-and-layout-convergence/79232

Pull Request: https://github.com/llvm/llvm-project/pull/93888



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list