[PATCH] D107747: [ELF] Don't emit SHF_GNU_RETAIN on Solaris

Tomas Matheson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 9 09:56:22 PDT 2021


tmatheson added a comment.

According to D95749 <https://reviews.llvm.org/D95749>, the rationale for allowing `ELFOSABI_NONE` with `SHF_GNU_RETAIN` is to keep consistent behaviour with `STT_GNU_IFUNC` and `STB_GNU_UNIQUE`, which are permitted under `ELFOSABI_NONE`. @MaskRay Should we perhaps revisit that decision?

More details at https://sourceware.org/bugzilla/show_bug.cgi?id=27282

This doesn't seem like the right fix. I would suggest either:

1. Add `SHF_SUNW_NODISCARD` to flags instead of `SHF_GNU_RETAIN` if `Retain` is set and the target is Solaris (if they do in fact have the same semantics)
2. `Retain` is set based on `llvm.compiler.used` (D97448 <https://reviews.llvm.org/D97448>). If this behaviour is not wanted then set `Retain = Used.count(...) && !Solaris`.
3. Add a support check function as you describe here:

> For full generality, any code emitting extensions beyond the ELF gABI should check that all of the assembler, linker, and runtime linker used support it.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107747



More information about the llvm-commits mailing list