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

--- Comment #17 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 51926
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51926&action=edit
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 possible
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 remember
the address.
The relocations are then stored with what I've talked about, ushort diff from
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).

Reply via email to