From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 638B93858034; Sat, 30 Jan 2021 11:25:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 638B93858034 From: "stsp at users dot sourceforge.net" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/98896] local label displaced with -O2 Date: Sat, 30 Jan 2021 11:25:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: stsp at users dot sourceforge.net X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: Sat, 30 Jan 2021 11:25:06 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98896 --- Comment #6 from Stas Sergeev --- (In reply to Jakub Jelinek from comment #5) > I think Andrew meant asm goto, which you haven't tried. You are right. Thanks for mentioning that. But it doesn't work as well: --- int main(void) { __label__ cont; asm volatile goto ( "push %l[cont]\n" "ret\n" ::::cont); cont: return 0; } --- $ LC_ALL=3DC cc -Wall -ggdb3 -O2 -o jmpret2 jmpret2.c -pie -fPIE /usr/bin/ld: /tmp/cc1UoxnD.o: relocation R_X86_64_32S against `.text.startu= p' can not be used when making a PIE object; recompile with -fPIE And in an asm file we see: --- #APP # 4 "jmpret2.c" 1 push .L2 # ret --- Please compare this to the following: --- int main(void) { __label__ cont; asm volatile ( "push %0\n" "ret\n" ::"r"(&&cont)); cont: return 0; } --- And its asm: --- .L2: .loc 1 4 5 view .LVU1 leaq .L2(%rip), %rax #, tmp83 #APP # 4 "jmpret3.c" 1 push %rax # tmp83 ret --- So... it seems, only the second case can work, and indeed does with clang?=