[PATCH] D101873: [clang] Support clang -fpic -fno-semantic-interposition for AArch64

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 5 09:47:19 PDT 2021


MaskRay added a comment.

In D101873#2738643 <https://reviews.llvm.org/D101873#2738643>, @peter.smith wrote:

> I've no comments on the code in D101872 <https://reviews.llvm.org/D101872> , and D10873 <https://reviews.llvm.org/D10873> they look reasonable to me. I guess it is down to whether this is the right thing to do or not.
>
> Just to check my understanding:
>
> - Clang defaults to -fno-semantic-interposition (GCC I believe has the opposite default fsemantic-interposition)

Clang defaults to a state between -fno-semantic-interposition and -fsemantic-interposition (cc1 -fhalf-no-semantic-interposition): interprocedural optimizations are not disabled for default visibility definitions, but dso_local is not added.
This has been the traditional behavior for years.

Adding dso_local (-fno-semantic-interposition) will use `.Lfoo$local`, which can break a small amount of applications, so I don't want to change the default.

> - With this change code in the same translation unit that defines the global will use a local alias for the global rather than accessing via the GOT, but the global will still be defined with default visibility.

Only when -fno-semantic-interpoistion is explicitly specified, i.e. -fpic -fno-semantic-interpoistion

> - Symbol interposing is still permitted at link time so the global can be interposed, but as the code is using a local alias it will still use the original value.
> - Without this chang clang would use fhalf-no-semantic-interposition which I believe permits some assumptions about symbol interpositioning such as resolving some short range assembly pc-relative references to a local alias. These would be out of range if the symbol were interposed anyway.
>
> If I've got this right, particularly the default  then this makes me nervous about the default behaviour as it could silently break some existing code. If a user had to opt in explicitly with -fno-semantic-interposition then fair enough.
>
> Can you let me know, if I'm being overly cautious here? For example are programs that would be affected by this already broken by the half-no-semantic-interpositioning anyway? Is symbol interpositioning so rare that the X86 version of this didn't break anything? Have I got the default of -fno-semantic-interpositioning wrong?

Yes, the first step:) -fno-semantic-interposition is not the default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101873



More information about the cfe-commits mailing list