[all-commits] [llvm/llvm-project] db51c4: [ELF] Decrease alignment of ThunkSection on 64-bit...

Peter Smith via All-commits all-commits at lists.llvm.org
Tue Feb 4 02:10:25 PST 2020


  Branch: refs/heads/release/10.x
  Home:   https://github.com/llvm/llvm-project
  Commit: db51c41a646c79e60cc763f0ecd58494112a32d1
      https://github.com/llvm/llvm-project/commit/db51c41a646c79e60cc763f0ecd58494112a32d1
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-02-04 (Tue, 04 Feb 2020)

  Changed paths:
    M lld/ELF/SyntheticSections.cpp
    M lld/test/ELF/aarch64-call26-thunk.s
    M lld/test/ELF/aarch64-cortex-a53-843419-thunk.s
    M lld/test/ELF/aarch64-jump26-thunk.s
    M lld/test/ELF/aarch64-thunk-pi.s
    M lld/test/ELF/aarch64-thunk-script.s
    M lld/test/ELF/ppc64-dtprel.s
    M lld/test/ELF/ppc64-ifunc.s
    M lld/test/ELF/ppc64-long-branch.s
    M lld/test/ELF/ppc64-tls-gd.s
    M lld/test/ELF/ppc64-toc-restore.s

  Log Message:
  -----------
  [ELF] Decrease alignment of ThunkSection on 64-bit targets from 8 to 4

ThunkSection contains 4-byte instructions on all targets that use
thunks. Thunks should not be used in any performance sensitive places,
and locality/cache line/instruction fetching arguments should not apply.

We use 16 bytes as preferred function alignments for modern PowerPC cores.
In any case, 8 is not optimal.

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

(cherry picked from commit 870094decfc9fe80c8e0a6405421b7d09b97b02b)


  Commit: 852b37f83b2dd31ff4d708c2a789857418171f93
      https://github.com/llvm/llvm-project/commit/852b37f83b2dd31ff4d708c2a789857418171f93
  Author: Peter Smith <peter.smith at linaro.org>
  Date:   2020-02-04 (Tue, 04 Feb 2020)

  Changed paths:
    M lld/ELF/Relocations.cpp
    M lld/ELF/SyntheticSections.cpp
    M lld/ELF/SyntheticSections.h
    A lld/test/ELF/aarch64-cortex-a53-843419-thunk-align.s
    M lld/test/ELF/aarch64-cortex-a53-843419-thunk.s
    A lld/test/ELF/arm-fix-cortex-a8-thunk-align.s
    M lld/test/ELF/arm-fix-cortex-a8-thunk.s

  Log Message:
  -----------
  [LLD][ELF][ARM][AArch64] Only round up ThunkSection Size when large OS.

In D71281 a fix was put in to round up the size of a ThunkSection to the
nearest 4KiB when performing errata patching. This fixed a problem with a
very large instrumented program that had thunks and patches mutually
trigger each other. Unfortunately it triggers an assertion failure in an
AArch64 allyesconfig build of the kernel. There is a specific assertion
preventing an InputSectionDescription being larger than 4KiB. This will
always trigger if there is at least one Thunk needed in that
InputSectionDescription, which is possible for an allyesconfig build.

Abstractly the problem case is:
.text : {
          *(.text) ;
          ...
          . = ALIGN(SZ_4K);
          __idmap_text_start = .;
          *(.idmap.text)
          __idmap_text_end = .;
          ...
        }
The assertion checks that __idmap_text_end - __idmap_start is < 4 KiB.
Note that there is more than one InputSectionDescription in the
OutputSection so we can't just restrict the fix to OutputSections smaller
than 4 KiB.

The fix presented here limits the D71281 to InputSectionDescriptions that
meet the following conditions:
1.) The OutputSection is bigger than the thunkSectionSpacing so adding
thunks will affect the addresses of following code.
2.) The InputSectionDescription is larger than 4 KiB. This will prevent
any assertion failures that an InputSectionDescription is < 4 KiB
in size.

We do this at ThunkSection creation time as at this point we know that
the addresses are stable and up to date prior to adding the thunks as
assignAddresses() will have been called immediately prior to thunk
generation.

The fix reverts the two tests affected by D71281 to their original state
as they no longer need the 4KiB size roundup. I've added simpler tests to
check for D71281 when the OutputSection size is larger than the ThunkSection
spacing.

Fixes https://github.com/ClangBuiltLinux/linux/issues/812

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

(cherry picked from commit 01ad4c838466bd5db180608050ed8ccb3b62d136)


Compare: https://github.com/llvm/llvm-project/compare/165a6367631d...852b37f83b2d


More information about the All-commits mailing list