[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
Fri Nov 12 12:37:54 PST 2021


MaskRay added a comment.

In D96914#3128217 <https://reviews.llvm.org/D96914#3128217>, @hvdijk wrote:

> In D96914#3128155 <https://reviews.llvm.org/D96914#3128155>, @MaskRay wrote:
>
>> (I shall note that declaring reserved identifiers `__start_` is UB in the first place. Well, the compiler has just always been just permissive.)
>
> It's UB from a C and C++ standards POV, it's not UB from an LLVM POV. It's the LLVM POV that's relevant here, C and C++ UB that falls under a supported LLVM extension needs to behave as specified by that extension. Changes to the behaviour of that extension can be made (both in spec and in code), sure, but the fact that they are outside of the scope of the C and C++ standards doesn't automatically make them okay. If I were to commit a patch to clang to issue a hard error whenever an identifier starting with `__` is used outside of a standard library header, I would expect that patch to be reverted promptly, and rightly so.

`-Wreserved-identifier` which is not in -Wall/-Wextra catches exactly this.


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