[all-commits] [llvm/llvm-project] aac4fe: [ELF] Don't emit SHF_GNU_RETAIN on Solaris

Tom Stellard via All-commits all-commits at lists.llvm.org
Thu Aug 12 22:52:27 PDT 2021


  Branch: refs/heads/release/13.x
  Home:   https://github.com/llvm/llvm-project
  Commit: aac4fe380d16a957627af2d6e5110ee35ad7e7e7
      https://github.com/llvm/llvm-project/commit/aac4fe380d16a957627af2d6e5110ee35ad7e7e7
  Author: Rainer Orth <ro at gcc.gnu.org>
  Date:   2021-08-12 (Thu, 12 Aug 2021)

  Changed paths:
    M llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp

  Log Message:
  -----------
  [ELF] Don't emit SHF_GNU_RETAIN on Solaris

The introduction of `SHF_GNU_RETAIN` has caused massive problems on Solaris.

Initially, as reported in Bug 49437, it caused dozens of testsuite failures
on both sparc and x86.  The objects were marked as `ELFOSABI_NONE`, but
`SHF_GNU_RETAIN` is a GNU extension. In the native Solaris ABI, that flag
(in the range for OS-specific values) is `SHF_SUNW_ABSENT` with a
completely different semantics, which confuses Solaris `ld` very much.

Later, the objects became (correctly) marked `ELFOSABI_GNU`, which Solaris
`ld` doesn't support, causing it to SEGV and break the build.  The linker
is currently being hardened to not accept non-native OS ABIs to avoid this.

The need for linker support is already documented in
`clang/include/clang/Basic/AttrDocs.td`, but not currently checked.

This patch avoids all this by not emitting `SHF_GNU_RETAIN` on Solaris at all.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

(cherry picked from commit 7bbbf2956181f375ab193321b37ea71c5fc44054)




More information about the All-commits mailing list