[prev in list] [next in list] [prev in thread] [next in thread] 

List:       binutils
Subject:    Re: [PATCH v2] elf: Set p_align to the minimum page size if possible
From:       Alan Modra via Binutils <binutils () sourceware ! org>
Date:       2021-12-25 3:58:01
Message-ID: YcaW8Uo2d92J6mw4 () squeak ! grove ! modra ! org
[Download RAW message or body]

On Fri, Dec 24, 2021 at 07:08:57PM -0800, H.J. Lu wrote:
> On Fri, Dec 24, 2021 at 7:04 PM Alan Modra <amodra@gmail.com> wrote:
> >
> > 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.
> >
> 
> I tried setting p_align to 0 and got
> 
> ELF load command address/offset not properly aligned

Yeah, silly me.  The binary I happened to test had p_offset equal to
p_vaddr.  So zero doesn't work.

-- 
Alan Modra
Australia Development Lab, IBM
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic