From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 01EEB3858D39; Sat, 4 Dec 2021 15:53:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01EEB3858D39 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug pch/71934] pch cannot be disabled so gcc cannot be position independent Date: Sat, 04 Dec 2021 15:53:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: pch X-Bugzilla-Version: 7.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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: attachments.created 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, 04 Dec 2021 15:53:05 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D71934 --- Comment #17 from Jakub Jelinek --- Created attachment 51926 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D51926&action=3Dedit gcc12-pr71934-reloc-wip.patch Completely untested patch to perform PCH relocation. Due to nested_ptr unfortunately the relocate_ptrs hook isn't always called = with the address of the pointer in the object so that we can remember at PCH save time where the pointer is, so I had to add another argument to the hook. In the common case the new middle argument is NULL, which stands for the first argument is pointer into the object and that address should be remembered for possib= le later relocation. For the nested_ptr case the first argument is address of some temporary pointer and the new middle argument is the pointer to the pointer. And the last case is for some weirdo case in tree-cfg where we call it even= on an unrelated address of LOCATION_BLOCK, it passes the same pointer to first= and second argument and the hook treats it as adjust, but don't actually rememb= er the address. The relocations are then stored with what I've talked about, ushort diff fr= om last address if it fits, or 0 followed by size_t difference from the base. = In a small PCH I've created for stdio.h there were ~ 56000 pointers that need relocations in the image and I needed a single 0 entry at the start with the size_t and all others fit into ushort. The host pch_use_address hooks need to be adjusted so that they do support mapping at a different address, only the Linux hook has been adjusted (and = for testing I've actually hardcoded there that it forces the relocation always)= .=