From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8B9F33858434; Fri, 1 Oct 2021 08:59:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B9F33858434 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/64697] C++11 thread_local: relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TLS init function for N::ptd' Date: Fri, 01 Oct 2021 08:59:13 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 7.3.0 X-Bugzilla-Keywords: link-failure X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW 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: 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: Fri, 01 Oct 2021 08:59:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D64697 --- Comment #26 from CVS Commits --- The releases/gcc-11 branch has been updated by Eric Botcazou : https://gcc.gnu.org/g:618b7cb3b3fb4d2d92434d31ea8b6746ffef2572 commit r11-9049-g618b7cb3b3fb4d2d92434d31ea8b6746ffef2572 Author: Eric Botcazou Date: Fri Oct 1 10:49:34 2021 +0200 Fix PR c++/64697 at -O1 or above The BFD fix eliminates the link failure and working code is generated at -O0, but _not_ when optimization is enabled because the optimizer chang= es: movq .refptr._ZTH1s(%rip), %rax testq %rax, %rax je .L2 call _ZTH1s into: leaq _ZTH1s(%rip), %rax testq %rax, %rax je .L2 call _ZTH1s 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: cmpq $0, .refptr._ZTH1s(%rip) je .L2 call _ZTH1s and the cmpq keeps a relocation that does not overflow. gcc/ PR c++/64697 * config/i386/i386.c (legitimate_pic_address_disp_p): For PE-CO= FF do not return true for external weak function symbols in medium mo= del.=