[PATCH] elf: Allocate a new segment for -z separate-code first

Alan Modra amodra@gmail.com
Mon Apr 29 12:08:00 GMT 2019


On Fri, Apr 26, 2019 at 08:49:09PM -0700, H.J. Lu wrote:
> Move
> 
>           else if (info != NULL
>                    && info->separate_code
>                    && executable != ((hdr->flags & SEC_CODE) != 0))
>             {
>               new_segment = TRUE;
>             }
> 
> before
> 
>           else if ((abfd->flags & D_PAGED) != 0
>                    && (((last_hdr->lma + last_size - 1) & -maxpagesize)
>                        == (hdr->lma & -maxpagesize)))
>             {
>               /* If we are demand paged then we can't map two disk
>                  pages onto the same memory page.  */
>               new_segment = FALSE;
>             }
> 
> so that there are no data sections in code segment.

No.  As the comment says, you can't map two disk pages onto the same
memory page.  (Yes, it might work when your actual paging size is less
that maxpagesize, but we want to build executables that work at
maxpagesize.)  See PR22758.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list