[PATCH] D74286: [ELF] Respect output section alignment for AT> (non-null lmaRegion)

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 10 02:11:10 PST 2020


psmith added a comment.

Do you happen to know how this relates to the ALIGN_WITH_INPUT linker script keyword? Apologies I've got stuck in an airport due to flight cancellations and can't check easily. I had thought that in BFD if you wanted InputSection alignment to affect LMA you needed to add ALIGN_WITH_INPUT.

For example, taken from one of the few pages I could find that mentioned it: https://www.openstm32.org/forumthread4866

  don’t forget to use ALIGN_WITH_INPUT section attribute, or you’d have aligned sections slipping if previous section doesn’t completely fill the aligned size.
  ...
    /* The startup code goes first into FLASH */
    .isr_vector : ALIGN_WITH_INPUT
    {
      . = ALIGN(4);
      KEEP(*(.isr_vector)) /* Startup code */
      . = ALIGN(4);
    } >FLASH AT > AXIFLASH

A brief look at BFD implies that LMA is only aligned for an OS that goes into a memory region if ALIGN_WITH_INPUT is true. I suspect that not aligning LMA can give some size savings, for example if at load time the OutputSections are byte-copied from their LMA to their aligned VMA then it doesn't matter if they are not aligned in LMA.

If I'm right it may be worth following BFD here as if we make ALIGN_WITH_INPUT the default, which is safe, then we can't then introduce ALIGN_WITH_INPUT without risking breaking some programs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74286





More information about the llvm-commits mailing list