[all-commits] [llvm/llvm-project] fbf41b: [ELF] Simplify sh_addr computation and warn if sh_...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Mar 11 09:36:19 PDT 2020


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

  Changed paths:
    M lld/ELF/LinkerScript.cpp
    M lld/ELF/LinkerScript.h
    M lld/ELF/Writer.cpp
    M lld/docs/ELF/linker_script.rst
    M lld/test/ELF/linkerscript/lma-align.test
    A lld/test/ELF/linkerscript/section-address-align.test
    M lld/test/ELF/linkerscript/section-align2.test

  Log Message:
  -----------
  [ELF] Simplify sh_addr computation and warn if sh_addr is not a multiple of sh_addralign

See `docs/ELF/linker_script.rst` for the new computation for sh_addr and sh_addralign.
`ALIGN(section_align)` now means: "increase alignment to section_align"
(like yet another input section requirement).

The "start of section .foo changes from 0x11 to 0x20" warning no longer
makes sense. Change it to warn if sh_addr%sh_addralign!=0.

To decrease the alignment from the default max_input_align,
use `.output ALIGN(8) : {}` instead of `.output : ALIGN(8) {}`
See linkerscript/section-address-align.test as an example.

When both an output section address and ALIGN are set (can be seen as an
"undefined behavior" https://sourceware.org/ml/binutils/2020-03/msg00115.html),
lld may align more than GNU ld, but it makes a linker script working
with GNU ld hard to break with lld.

This patch can be considered as restoring part of the behavior before D74736.

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




More information about the All-commits mailing list