From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 638A33850414; Thu, 3 Dec 2020 12:51:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 638A33850414 From: "jakub at redhat dot com" To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/27004] ld.so is miscompiled by GCC 11 Date: Thu, 03 Dec 2020 12:51:00 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: dynamic-link X-Bugzilla-Version: 2.33 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: security- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Dec 2020 12:51:00 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D27004 --- Comment #5 from Jakub Jelinek --- (In reply to Florian Weimer from comment #4) > __builtin_thread_pointer is potentially trapping (which is the root of the > problem). Does GCC know about that? It also results in a load followed by= an > add, instead of a single load, I think. Using the __segfs or __seggs > namespaces looks preferable to me. GCC makes it const __attribute__((nothrow)), and that is I think ok except = in the dynamic linker. I don't think + __self =3D (struct pthread *) (__builtin_thread_pointer () = \ + + offsetof (struct pthread, header.self))= ; \ does what the old code did, which was movq %fs:16, __self but your version is movq %fs:0, %reg; leaq 16(%reg), __self That would be *(struct pthread **) (__builtin_thread_pointer () + offsetof (struct pthread, header.self)) if we optimize that back to just movq %fs:16, __self But, as it is for x86 GCC 11+ only, isn't it better to use __seg_{f,g}s that should work already since GCC 6? --=20 You are receiving this mail because: You are on the CC list for the bug.=