[PATCH v2] elf: Set p_align to the minimum page size if possible
Alan Modra
amodra@gmail.com
Sat Dec 25 03:04:02 GMT 2021
On Fri, Dec 24, 2021 at 06:50:30PM -0800, H.J. Lu wrote:
> On Fri, Dec 24, 2021 at 5:03 PM Alan Modra <amodra@gmail.com> wrote:
> > 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;
> }
Zero in p_align triggers neither of these conditions. Binaries with
zero p_align run. I checked.
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list