[PATCH] D114830: [ELF] Hint -z nostart-stop-gc for __start_ undefined references

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 3 20:34:37 PST 2021


MaskRay added a comment.

In D114830#3168833 <https://reviews.llvm.org/D114830#3168833>, @smeenai wrote:

> This won't diagnose the case where the actual contents of the C-named section get dropped, which can only be caught at runtime.
> For example, our application of encapsulation symbols for library merging <https://engineering.fb.com/2018/01/23/android/android-native-library-merging/> was relying on C-named sections being retained; the behavior change in LLD 13 didn't result in any link-time errors, but it caused run-time crashes because all the `JNI_OnLoad`s were dropped. (It was straightforward for us to add `__attribute__((retain))` because of how our builds are set up, so it wasn't a problem for us.) This is still a good change; just pointing out that it doesn't capture all possible cases which might change program behavior.

This won't diagnose the case when the `__start_` reference is weak.
Among the few Debian Code Search examples, I cannot find undefined weak examples.
I know that Clang InstrProfiling uses undefined weak. Such examples are just rare.
For such cases, we have to rely on the developer to understand the problem. (The section just doesn't exist, so presumably not too difficult to troubleshoot.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114830



More information about the llvm-commits mailing list