public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Simplify ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA and revert aarch64/arm's extern protected data handling
@ 2022-05-01  6:06 Fangrui Song
  2022-05-01  6:06 ` [PATCH 1/3] elf: Remove ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA check for non-DL_EXTERN_PROTECTED_DATA ports Fangrui Song
                   ` (3 more replies)
  0 siblings, 4 replies; 32+ messages in thread
From: Fangrui Song @ 2022-05-01  6:06 UTC (permalink / raw)
  To: libc-alpha, Adhemerval Zanella, Szabolcs Nagy

Say both a.so and b.so define protected var and the executable copy
relocates var. ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA has strange
semantics: a.so accesses the copy in the executable while b.so accesses
its own. This behavior requires that (a) the compiler emits
GOT-generating relocations (b) the linker produces GLOB_DAT instead of
RELATIVE.

Without the ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA code, b.so's GLOB_DAT
will bind to the executable (normal behavior).

For aarch64/arm it makes sense to restore the original behavior and don't
pay the ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA cost. The behavior is very
unlikely used by anyone.

* Clang code generation treats STV_PROTECTED the same way as STV_HIDDEN:
  no GOT-generating relocation in the first place.
* gold and lld reject copy relocation on a STV_PROTECTED symbol.
* Nowadays -fpie/-fpic modes are popular. GCC/Clang's codegen uses
  GOT-generating relocation when accessing an default visibility
  external symbol which avoids copy relocation.

Fangrui Song (3):
  elf: Remove ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA check for
    non-DL_EXTERN_PROTECTED_DATA ports
  Revert "[AArch64][BZ #17711] Fix extern protected data handling"
  Revert "[ARM][BZ #17711] Fix extern protected data handling"

 elf/dl-lookup.c              | 46 ++++++++++++------------------------
 sysdeps/aarch64/dl-machine.h | 13 +++++-----
 sysdeps/aarch64/dl-sysdep.h  |  2 --
 sysdeps/arm/dl-machine.h     | 10 +++-----
 sysdeps/arm/dl-sysdep.h      |  2 --
 5 files changed, 24 insertions(+), 49 deletions(-)

-- 
2.36.0.464.gb9c8b46e94-goog


^ permalink raw reply	[flat|nested] 32+ messages in thread
* [PATCH 2/3] Revert "[AArch64][BZ #17711] Fix extern protected data handling"
@ 2022-05-24 13:46 Wilco Dijkstra
  2022-05-24 17:28 ` maskray
  2022-05-24 21:58 ` H.J. Lu
  0 siblings, 2 replies; 32+ messages in thread
From: Wilco Dijkstra @ 2022-05-24 13:46 UTC (permalink / raw)
  To: Szabolcs Nagy, maskray; +Cc: 'GNU C Library'

Hi, 

>> * Clang code generation treats STV_PROTECTED the same way as STV_HIDDEN:
>>   no GOT-generating relocation in the first place.

We should change GCC's behaviour to match this - is this something that
applies to all targets?

>> * gold and lld reject copy relocation on a STV_PROTECTED symbol.
>> * Nowadays -fpie/-fpic modes are popular. GCC/Clang's codegen uses
>>   GOT-generating relocation when accessing an default visibility
>>   external symbol which avoids copy relocation.

Would it be reasonable to add a way to override settings for binaries?
For example if all imported symbols are marked with the correct visibility,
PIE binaries could avoid using GOT for default visibility external symbols to
get better performance. And non-PIE binaries could force GOT accesses for
non-default visibility to avoid copy relocations and support protected visibility.

Cheers,
Wilco

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2022-05-31 13:48 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-01  6:06 [PATCH 0/3] Simplify ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA and revert aarch64/arm's extern protected data handling Fangrui Song
2022-05-01  6:06 ` [PATCH 1/3] elf: Remove ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA check for non-DL_EXTERN_PROTECTED_DATA ports Fangrui Song
2022-05-01  6:06 ` [PATCH 2/3] Revert "[AArch64][BZ #17711] Fix extern protected data handling" Fangrui Song
2022-05-23 20:10   ` Szabolcs Nagy
2022-05-23 20:17     ` Fangrui Song
2022-05-24  5:13       ` Fangrui Song
2022-05-01  6:06 ` [PATCH 3/3] Revert "[ARM][BZ " Fangrui Song
2022-05-23 20:11   ` Szabolcs Nagy
2022-05-23 20:45     ` Fangrui Song
2022-05-09 21:26 ` [PATCH 0/3] Simplify ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA and revert aarch64/arm's extern protected data handling H.J. Lu
2022-05-10  7:42   ` Fangrui Song
2022-05-10 15:02     ` H.J. Lu
2022-05-12  4:56       ` Fangrui Song
2022-05-13 22:18         ` H.J. Lu
2022-05-13 23:09           ` Fangrui Song
2022-05-24 13:46 [PATCH 2/3] Revert "[AArch64][BZ #17711] Fix extern protected data handling" Wilco Dijkstra
2022-05-24 17:28 ` maskray
2022-05-24 21:58 ` H.J. Lu
2022-05-25 17:13   ` Wilco Dijkstra
2022-05-25 18:21     ` Florian Weimer
2022-05-25 20:44       ` H.J. Lu
2022-05-26 19:17         ` Wilco Dijkstra
2022-05-26 19:25           ` Florian Weimer
2022-05-26 20:03             ` Wilco Dijkstra
2022-05-26 21:27               ` H.J. Lu
2022-05-27 12:43               ` Florian Weimer
2022-05-31  2:03                 ` H.J. Lu
2022-05-31  7:49                   ` Fangrui Song
2022-05-31  9:42                     ` Wilco Dijkstra
2022-05-31 13:47                     ` H.J. Lu
2022-05-31  7:42               ` Fangrui Song
2022-05-25 20:10     ` maskray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).