[PATCH] D75724: [ELF] Simplify sh_addr computation and warn if sh_addr is not a multiple of sh_addralign

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 8 09:03:27 PDT 2020


psmith added a comment.

If the ld.bfd developers consider both [address] and [ALIGN(section_align)] as undefined behaviour then I'm happy that we can simplify and the above change does implement that. Would like to hear what some of the other reviewers think as well.

For the documentation may I suggest we add something like this to ld.lld.1

  Linker Script implementation notes and policy.
  
  LLD implements a large subset of the GNU ld linker script notation. The LLD
  implementation policy is to implement linker script features as they are
  documented in the ld manual https://sourceware.org/binutils/docs/ld/Scripts.html
  We consider it a bug if the lld implementation does not agree with the manual
  and it is not mentioned in the exceptions below.
  
  The ld manual is not a complete specification, and is not sufficient to build
  an implementation. In particular some features are only defined by the
  implementation and have changed over time.
  
  The lld implementation policy for properties of linker scripts that are not
  defined by the documentation is to follow the GNU ld implementation wherever
  possible. We reserve the right to make different implementation choices where
  it is appropriate for LLD. Intentional deviations will be documented here:
  
  Linker Script deviations
  
  Status: This is under construction and is not complete.
  
  Output Section ALIGN
  
  When an OutputSection S has both [address] and [ALIGN(section_align)]
  LLD will set the alignment of S to the maximum of [ALIGN(section_align)] and
  the maximum alignment of the input sections in S. GNU ld will always use
  [ALIGN(section_align)].
  
  When an OutputSection S has [address] LLD will warn if this not 0 modulo
  OutputSection alignment. The ELF file will set sh_addr to [address] and
  sh_addralign to OutputSection alignment even if this would produce a
  non-compliant ELF file. GNU ld from Binutils 2.35 onwards will reduce
  sh_addralign so that sh_addr = 0 (modulo sh_addralign).

We could add to this as we make more decisions, I've kept to just those made in this review here. We could also add a known limitations for the areas where we haven't implemented corner cases.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75724/new/

https://reviews.llvm.org/D75724





More information about the llvm-commits mailing list