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

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Making PCH relocatable (as last resort) is doable too, after all, we already
relocate it once during PCH storing, all the info is there.
We even don't need something like the saving_htab for it, all we need it the OS
is unable to give us the expected memory mapping map it elsewhere, compute the
bias (difference from where it is actually mapped and where it was expected to
be mapped) and add that bias to all pointers in the mapped blob and to all the
ggc roots's pointers that point into the original expected memory mapping range
as well.
If there is no overlap between the expected and actual mapping, making sure the
bias isn't added twice is even easier (just always compare if it is in the old
range and only then add bias), but I bet that can't be ensured, so we need to
use something to track whether we've done that already (e.g. what we use for GC
marking normally?).

I think on Linux this shouldn't trigger too often even on 32-bit architectures,
because ASLR isn't all over the address space, just +- a couple of megabytes at
most.

Reply via email to