[PATCH] D107955: [ELF] Use SHF_SUNW_NODISCARD instead of SHF_GNU_RETAIN on Solaris

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 12 04:41:36 PDT 2021


ro created this revision.
ro added reviewers: MaskRay, tmatheson.
Herald added subscribers: pengfei, rupprecht, fedor.sergeev, hiraditya, jyknight.
Herald added a reviewer: jhenderson.
ro requested review of this revision.
Herald added a project: LLVM.

Instead of the GNU extension `SHF_GNU_RETAIN`, Solaris provides equivalent
functionality with `SHF_SUNW_NODISCARD`. This patch implements the necessary
support.

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

The patch passes existing tests, although I suspect something might still be missing.
I've inspected `elf-retain.o` with both Solaris' native `elfdump` and `llvm-readelf` to
check that the `SHF_SUNW_NODISCARD` flag is indeed present.

One caveat is that, unlike Solaris, Illumos and derivatives don't support
`SHF_SUNW_NODISCARD`. Unfortunately, there's currently no way to distinguish
the two related OSes and the Illumos community barely reacted to my attempts to
reach out to them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107955

Files:
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/ObjectYAML/ELFYAML.h
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/MC/MCParser/ELFAsmParser.cpp
  llvm/lib/MC/MCSectionELF.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/test/CodeGen/X86/elf-retain.ll
  llvm/tools/llvm-readobj/ELFDumper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107955.365966.patch
Type: text/x-patch
Size: 8403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210812/dc383849/attachment.bin>


More information about the llvm-commits mailing list