[PATCH] D139205: [lld][Alignment] Use Align in ELF Sections

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 2 10:09:52 PST 2022


arichardson added a comment.

If you look at the `-Xclang -fdump-record-layouts` output you can see that it does improve the requirerd size, but due to the 8 byte alignment requirement it is still rounded up to 48 (for 64-bit architectures). However, for 32-bit arch reordering does help: 36 vs 40 bytes.

  *** Dumping AST Record Layout
           0 | struct OutputSegment
       0:0-2 |   uint8_t sectionKind
       0:3-3 |   uint8_t bss
       0:4-4 |   uint8_t keepUnique
           1 |   uint8_t partition
           2 |   struct llvm::Align addralign
           2 |     uint8_t ShiftValue
           4 |   uint32_t type
           8 |   class llvm::StringRef name
           8 |     const char * Data
          16 |     size_t Length
          24 |   uint64_t flags
          32 |   uint32_t entsize
          36 |   uint32_t link
          40 |   uint32_t info
             | [sizeof=48, dsize=44, align=8,
             |  nvsize=44, nvalign=8]

Whereas the current patch has sizeof==dsize:

  *** Dumping AST Record Layout
           0 | struct OutputSegment
       0:0-2 |   uint8_t sectionKind
       0:3-3 |   uint8_t bss
       0:4-4 |   uint8_t keepUnique
           1 |   uint8_t partition
           4 |   uint32_t type
           8 |   class llvm::StringRef name
           8 |     const char * Data
          16 |     size_t Length
          24 |   uint64_t flags
          32 |   struct llvm::Align addralign
          32 |     uint8_t ShiftValue
          36 |   uint32_t entsize
          40 |   uint32_t link
          44 |   uint32_t info
             | [sizeof=48, dsize=48, align=8,
             |  nvsize=48, nvalign=8]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139205



More information about the llvm-commits mailing list