[PATCH] D76668: [lld][ELF] Ignore __start/__stop symbols in section groups during GC
Roland McGrath via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 24 15:39:52 PDT 2020
mcgrathr added a comment.
The discussion and the tests should distinguish the COMDAT semantics from the `--gc-sections` semantics. They are related but distinct.
COMDAT is a standard ELF feature. It's clear how it's supposed to behave on its own: only one definition survives. Anything that prevents two input COMDAT groups with the same signature symbol from being reduced to exactly one of them in the output is clearly a bug.
The `__start_*`/`__stop_*` behavior is not formally specified. I was involved with its original creation, so I can speak with some authority on the spirit of its intent. It was never intended to influence what section contents go into the link, merely to provide symbols for the section bounds after all other logic has done so. IIRC this feature predated `--gc-sections`. It also predated the common use of COMDAT for C++. So its interactions with them were never really considered at the time. But I think the natural expectation of what section group semantics mean with these features is clear enough: a group always travels together. So when `--gc-sections` decides that `.text.f` is unreferenced then there is nothing keeping any of the `f` group in the link, so it all goes. The `__start_` and `__stop_` references don't affect this--they only resolve to whatever output section is left with that name after all the other logic such as COMDAT rules and `--gc-sections` has been applied.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76668/new/
https://reviews.llvm.org/D76668
More information about the llvm-commits
mailing list