[PATCH] D96914: [ELF] Add -z start-stop-gc to let __start_/__stop_ not retain C identifier name sections

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 2 20:01:25 PDT 2021


MaskRay added a comment.

In D96914#3104093 <https://reviews.llvm.org/D96914#3104093>, @jrtc27 wrote:

> In D96914#3098759 <https://reviews.llvm.org/D96914#3098759>, @MaskRay wrote:
>
>> In D96914#3098705 <https://reviews.llvm.org/D96914#3098705>, @hvdijk wrote:
>>
>>> That followup 6d2d3bd0a61f5fc7fd9f61f48bc30e9ca77cc619 <https://reviews.llvm.org/rG6d2d3bd0a61f5fc7fd9f61f48bc30e9ca77cc619> gives off the impression that aside from systemd, nothing else would be broken by the change. That is incorrect, enough time has passed since the traditional GNU ld behaviour was ubiquitous that more software has started relying on the new GNU ld behaviour, and lld 13 breaks at least NetworkManager too. (I have reported this to NetworkManager.) What's the right thing to do here?
>>
>> Thanks for reporting the bug to NetworkManager.
>>
>>> At the very least, I think the release notes simply listing this as an improvement rather than as a breaking change is not enough info for users to beware that their code may need updating, but depending on whether the breakage affects enough other software, maybe it should be reverted on the 13.x branch as well?
>>
>> No, I don't think the additional report from NetworkManager is sufficient to justify restoring the GNU ld buggy behavior.
>
> It wasn't a bug, it was a feature that you broke.
>
>> It's not that many projects depend on the unfortunate behavior and I don't think restoring the behavior now helps any project.
>
> It helps all the projects that are broken by this feature they rely on being removed, with no easy way to work around it in some cases.

`-Wl,-z,nostart-stop-gc` is an easy workaround.

>> Postponing the transition would just cause pain to users of various metadata sections (LLVM PGO).
>
> Or you could fix those to be GC-able via some other means.

It cannot. The very problem of the 2015-10 GNU ld behavior is that it essentially makes all metadata sections using C identifier section names not GCable.
It is a built-in rule which cannot be overridden.

We could add ad-hoc rules like SHF_GROUP sections could still be GCed. That would help some metadata sections but not others which do not use section groups.
Section groups have high costs (`sizeof(Elf64_Shdr) = 64`) and may be too expensive to enable.

LDC is even less of a problem because it already needs many changes when importing LLVM changes.
Well, I have fixed some LLVM upgrade issues for it when I was still using D.

These projects relying on the post-2015-10 GNU ld behavior. While I feel sympathy for them, I think they should take the oneshot pain.
The longer we waited, there could just be more problems, and it would be even more difficult to flip the switch.
>From Chrome OS folks I heard that the transition was still quite smooth.

>> NetworkManager can either fix their code or not use `-Wl,--gc-sections`.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96914



More information about the llvm-commits mailing list