From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1FE35384B0CC; Thu, 12 May 2022 14:12:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FE35384B0CC From: "alvinhochun at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/104862] extern thread_local (emutls) code crashes with ASLR on Windows Date: Thu, 12 May 2022 14:12:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: alvinhochun at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2022 14:12:47 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104862 Alvin Wong changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ebotcazou at gcc dot gnu.o= rg --- Comment #1 from Alvin Wong --- I found from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D64697#c25 that = there was a change that seems related to the issue observed in this report. Can anyone check? > The master branch has been updated by Eric Botcazou : >=20 > https://gcc.gnu.org/g:021ad8e5cf9ab66e1a0a41dce3a54586facb86e0 >=20 > commit r12-4036-g021ad8e5cf9ab66e1a0a41dce3a54586facb86e0 > Author: Eric Botcazou > Date: Fri Oct 1 10:49:34 2021 +0200 >=20 > Fix PR c++/64697 at -O1 or above >=20=20=20=20=20 > The BFD fix eliminates the link failure and working code is generated= at > -O0, but _not_ when optimization is enabled because the optimizer > changes: >=20=20=20=20=20 > movq .refptr._ZTH1s(%rip), %rax > testq %rax, %rax > je .L2 > call _ZTH1s >=20=20=20=20=20 > into: >=20=20=20=20=20 > leaq _ZTH1s(%rip), %rax > testq %rax, %rax > je .L2 > call _ZTH1s >=20=20=20=20=20 > and the leaq now also gets the relocation overflow. So the fix is to > teach legitimate_pic_address_disp_p to reject the transformation when > the symbol is an external weak function, which yields: >=20=20=20=20=20 > cmpq $0, .refptr._ZTH1s(%rip) > je .L2 > call _ZTH1s >=20=20=20=20=20 > and the cmpq keeps a relocation that does not overflow. >=20=20=20=20=20 > gcc/ > PR c++/64697 > * config/i386/i386.c (legitimate_pic_address_disp_p): For > PE-COFF do > not return true for external weak function symbols in medium > model.=