[PATCH] D83549: [ELF] Do not force bringing out symbols passed by -init and -fini.

Aaron Puchert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 10 13:22:29 PDT 2020


aaronpuchert added a comment.

In D83549#2144625 <https://reviews.llvm.org/D83549#2144625>, @MaskRay wrote:

> @aaronpuchert Your comment https://bugzilla.opensuse.org/show_bug.cgi?id=1155108#c10 "However, it's actually a bug in all three linkers. It has been fixed in lld just today [1]" made me wonder whether https://bugs.llvm.org/show_bug.cgi?id=43927 was really a linker bug.


The linkers were behaving differently though: lld and bfd dropped the FINI entirely whereas gold had FINI=0, which lead to a crash. Which of these behaviors would be expected?

> I need an LLD reproduce file (obtained via `LLD_REPRODUCE=/tmp/rep.tar ...` or `-Wl,--reproduce=/tmp/rep.tar` to under the matter better.

It should suffice to have a source file with a hidden visibility function that's used in a `-init` or `-fini` linker flag with LTO. If that doesn't help, I can also try putting some files together.

> openSUSE's OpenMP problem probably should be fixed by adding `-u __kmp_internal_end_fini` along with `-Wl,-fini=__kmp_internal_end_fini` instead of relying on the linker retaining the bitcode defined symbols.

I think the problem here is that `-Wl,-fini` without `-u` works when you don't use LTO, but when you enable it the function is removed and with it the FINI entry in `.dynamic`. As a layperson I might expect (as the OpenMP writers did) that an explicit `-fini` flag on the command line is sufficient, and that the linker makes sure LTO doesn't drop the function since it is arguably used.

I can't really comment on this patch though, because I don't know under which circumstances one might use inits or finis that are undefined, and then expect them to be dropped.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83549





More information about the llvm-commits mailing list