https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126063

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tamar Christina <[email protected]>:

https://gcc.gnu.org/g:11a9bf984b1a9824f6f1d7e522af23836a9f1419

commit r17-4923-g11a9bf984b1a9824f6f1d7e522af23836a9f1419
Author: Tamar Christina <[email protected]>
Date:   Tue Oct 6 10:06:40 2026 +0100

    AArch64: Fix PCH PIE builds by using anchor [PR126063]

    The fix for PR123457 to fix PCH was only partial.  While it added the table
    pointers to GTY so they're tracked as roots, it didn't fix the pointers of
the
    nested classes that are used as hashes for the object.

    This leads to the PCH tests all still crashing when the toolchain is
configured
    with -PIE.

    There are three pointers being used in function_instance::hash ()

    const char *base_name;
    const function_base *base;
    const function_shape *shape;

    These points when PIE and PCH will be loaded into different offsets by each
    invocation of the compiler sharing the same PCH file since these pointer
point
    into the compiler's executable and are no objects allocated by GGC.

    The documentation states that GTY((callback)) can only be used for function
    pointers so can't be used for data pointers.  The base class is marked
    GTY((user)) anyway.  The easiest fix is dropping the pointers from the
    calculation of the hash, however this weakens the hash function.

    Instead this patch registers the pointers with the walkers through
    gt_pch_note_callback and then instead of using the pointers in the hash it
uses
    the stable ptr diff between an anchor and the pointer.

    The idea is that as the executable gets loaded into different addresses,
since
    PCH enforced that it must be the exact same version of the binary that the
    offsets are constant.  So by storing the ptr - offset we get a stable
"hash" ID.

    The anchor here is chosen to be the function_table itself which is being
    relocated by PCH.

    gcc/ChangeLog:

            PR target/126063
            * config/aarch64/aarch64-acle-builtins.cc
(function_instance::hash):
            Use ptr diff for hash instead of ptr.
            (gt_pch_nx): Add the pointers to PCH tracking.

Reply via email to