From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4907A3856DC5; Mon, 5 Sep 2022 16:35:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4907A3856DC5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662395756; bh=iBhqdKjM7eTfW4pv/gSORQuMpDzNte0opbxEGXL/mc8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=C6WA5E3beHqh9q5acXo9Wa0y9JEotgs+ahF9ev4huh55QFInbswUaOL3wpa4/+EyG kAMQAP/6vNVa+BYW4gNOmhpHAx9dkjFT1hbWDTPfdiAXY7jyCTCb+gpVHxcTIzLBF2 toteWX28/9eJPGXEHHtGUiOqo5dlBNdW1AxP3Vj0= From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/106834] GCC creates R_X86_64_GOTOFF64 for 4-bytes immediate Date: Mon, 05 Sep 2022 16:35:56 +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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106834 --- Comment #9 from H.J. Lu --- _GLOBAL_OFFSET_TABLE_ is a special symbol and can't be accessed like regular symbols. To workaround it: [hjl@gnu-tgl-3 tmp]$ cat x.c #include extern char GLOBAL_OFFSET_TABLE[]; int main() { printf("%lx\n", (unsigned long)GLOBAL_OFFSET_TABLE); } [hjl@gnu-tgl-3 tmp]$ gcc -fPIC x.c /usr/local/bin/ld: /tmp/cc4Lekj4.o: in function `main': x.c:(.text+0x7): undefined reference to `GLOBAL_OFFSET_TABLE' collect2: error: ld returned 1 exit status [hjl@gnu-tgl-3 tmp]$ gcc -fPIC x.c -Wl,--defsym,GLOBAL_OFFSET_TABLE=3D_GLOBAL_OFFSET_TABLE_ [hjl@gnu-tgl-3 tmp]$ ./a.out=20 403fe8 [hjl@gnu-tgl-3 tmp]$=