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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 9 09:52:07 PDT 2021


MaskRay added a comment.

This is critical for programs which use `llvm.used`.

  int foo();
  template <class T>
  inline T x = foo();
  
  int var = x<int>;

The dynamic initializer of x<int> is in a COMDAT section group.
If Solaris ld can GC SHT_INIT_ARRAY in a section group, a `SHF_GNU_RETAIN` counterpart is needed to make the program work.

---

Instrumentation based PGO has names variables referenced by `llvm.used`. Without a `SHF_GNU_RETAIN` counterpart indirect call profiling cannot work.


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