public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug build/28712] New: GCC 12 miscompiles static PIE elf/dl-tunables.o
@ 2021-12-18 15:26 hjl.tools at gmail dot com
  2021-12-18 16:34 ` [Bug build/28712] GCC 12 miscompiles PIE and PIC elf/dl-tunables.c hjl.tools at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: hjl.tools at gmail dot com @ 2021-12-18 15:26 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28712

            Bug ID: 28712
           Summary: GCC 12 miscompiles static PIE elf/dl-tunables.o
           Product: glibc
           Version: 2.35
            Status: NEW
          Severity: normal
          Priority: P2
         Component: build
          Assignee: unassigned at sourceware dot org
          Reporter: hjl.tools at gmail dot com
                CC: carlos at redhat dot com
  Target Milestone: ---
            Target: x86-64

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug build/28712] GCC 12 miscompiles PIE and PIC elf/dl-tunables.c
  2021-12-18 15:26 [Bug build/28712] New: GCC 12 miscompiles static PIE elf/dl-tunables.o hjl.tools at gmail dot com
@ 2021-12-18 16:34 ` hjl.tools at gmail dot com
  2021-12-18 22:45 ` fweimer at redhat dot com
  2021-12-27 13:42 ` hjl.tools at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: hjl.tools at gmail dot com @ 2021-12-18 16:34 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28712

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|GCC 12 miscompiles static   |GCC 12 miscompiles PIE and
                   |PIE elf/dl-tunables.o       |PIC elf/dl-tunables.c

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug build/28712] GCC 12 miscompiles PIE and PIC elf/dl-tunables.c
  2021-12-18 15:26 [Bug build/28712] New: GCC 12 miscompiles static PIE elf/dl-tunables.o hjl.tools at gmail dot com
  2021-12-18 16:34 ` [Bug build/28712] GCC 12 miscompiles PIE and PIC elf/dl-tunables.c hjl.tools at gmail dot com
@ 2021-12-18 22:45 ` fweimer at redhat dot com
  2021-12-27 13:42 ` hjl.tools at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2021-12-18 22:45 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28712

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com

--- Comment #2 from Florian Weimer <fweimer at redhat dot com> ---
This GCC bug essentially makes x86-64 a !PI_STATIC_AND_HIDDEN target. This
implies changes far beyond that.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug build/28712] GCC 12 miscompiles PIE and PIC elf/dl-tunables.c
  2021-12-18 15:26 [Bug build/28712] New: GCC 12 miscompiles static PIE elf/dl-tunables.o hjl.tools at gmail dot com
  2021-12-18 16:34 ` [Bug build/28712] GCC 12 miscompiles PIE and PIC elf/dl-tunables.c hjl.tools at gmail dot com
  2021-12-18 22:45 ` fweimer at redhat dot com
@ 2021-12-27 13:42 ` hjl.tools at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: hjl.tools at gmail dot com @ 2021-12-27 13:42 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28712

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |MOVED
             Status|NEW                         |RESOLVED

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
Moved to

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2021-12-27 13:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-18 15:26 [Bug build/28712] New: GCC 12 miscompiles static PIE elf/dl-tunables.o hjl.tools at gmail dot com
2021-12-18 16:34 ` [Bug build/28712] GCC 12 miscompiles PIE and PIC elf/dl-tunables.c hjl.tools at gmail dot com
2021-12-18 22:45 ` fweimer at redhat dot com
2021-12-27 13:42 ` hjl.tools at gmail dot com

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).