GCC 12 miscompiles elf/dl-tunables.o: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103762 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 (); __tunables_init fails to run before static PIE has been relocated.
dl-tunables.os is also miscompiled: Relocation section '.rela.data.rel.ro.local' at offset 0x4178 contains 1 entry: Offset Info Type Symbol's Value Symbo l's Name + Addend 0000000000000000 0000000700000001 R_X86_64_64 0000000000000000 .data .rel.ro + 0 This also requires run-time relocation.
This GCC bug essentially makes x86-64 a !PI_STATIC_AND_HIDDEN target. This implies changes far beyond that.
Moved to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103762