https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103762

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
Good __tunables_init code:

.L35:
        movq    $-88, %rax 
        leaq    tunable_list(%rip), %rbx 
        movq    %r8, %r12 
        subq    %rbx, %rax 
        movq    %rax, %r15 

Bad __tunables_init code:

.L34:
        movq    $-88, %rax 
        subq    .LC3(%rip), %rax 
        movq    %r8, %rbx 
        movq    %rax, 8(%rsp)
...
        .section        .data.rel.ro.local,"aw"
        .align 8
.LC3:
        .quad   tunable_list

The bad code requires run-time relocation and a memory load.  But this piece
of code is called from

  __tunables_init (__environ);

  ARCH_INIT_CPU_FEATURES (); 

  /* Do static pie self relocation after tunables and cpu features
     are setup for ifunc resolvers. Before this point relocations
     must be avoided.  */
  _dl_relocate_static_pie (); 

For __tunables_init isn't good for performance and fails to run before
static PIE has been relocated.

Reply via email to