[PATCH v2] elf: Set p_align to the minimum page size if possible
H.J. Lu
hjl.tools@gmail.com
Sat Dec 25 02:50:30 GMT 2021
On Fri, Dec 24, 2021 at 5:03 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Wed, Dec 22, 2021 at 06:38:54AM -0800, H.J. Lu wrote:
> > I choose commonpagesize due to this glibc bug:
> >
> > https://sourceware.org/bugzilla/show_bug.cgi?id=28688
>
> This means we are stuck. Choosing commonpagesize or minpagesize will
> generate binaries that won't run with older glibc if the actual page
> size is maxpagesize (assuming maxpagesize != commonpagesize).
We can make this new behavior as opt-in since this is an optimization
for ld.so.
> I don't see a way to change DT_LOAD p_align that is backwards
> compatible, except perhaps using a p_align of zero if the required
> segment alignment (as calculated from section alignment) is less than
> maxpagesize. That horrible hack just happens to work for older glibc,
> but may break other loaders.
Neither 0 nor 1 work for older glibc:
if (__glibc_unlikely ((ph->p_align & (GLRO(dl_pagesize) - 1)) != 0))
{
errstring = N_("ELF load command alignment not page-aligned");
goto lose;
}
if (__glibc_unlikely (((ph->p_vaddr - ph->p_offset)
& (ph->p_align - 1)) != 0))
{
errstring
= N_("ELF load command address/offset not properly aligned");
goto lose;
}
--
H.J.
More information about the Binutils
mailing list