ELF LOAD segments creating holes in the process image on GNU/Linux

Florian Weimer fweimer@redhat.com
Mon Jan 3 12:31:13 GMT 2022


At least on x86-64 on GNU/Linux, for PIE and non-PIE binaries, LOAD
segments are not always contiguous.  The triggering conditions are not
quite clear to me.

For ET_EXEC (non-PIE) executables, I think this is a supported feature,
and the kernel and glibc dynamic loader handle this the same way,
creating holes.  However, these holes make dealing with the main
executable slightly more complicated in some cases (e.g., we can handle
contiguous mapping slightly more efficiently when looking objects based
on addresses).  Holes also make page tables less compact (although that
effect is probably minuscule).  Abstractly, I don't see a reason why the
link editor has to create such holes on the most common targets.  (I
have heard that ia64 really needed those holes.)

For ET_DYN (PIE) executables, we have a Linux vs glibc difference: The
Linux loader creates holes as well, while the glibc loader refuses to
create them and fills them with a PROT_NONE mapping from the executable.

Is this something we could fix in ld?

Thanks,
Florian



More information about the Binutils mailing list