Re: [PATCH] ELF: don't copy ELF header around
From: Alexey Dobriyan
Date: Wed Dec 11 2019 - 02:19:50 EST
On Tue, Dec 10, 2019 at 05:56:11PM -0800, Andrew Morton wrote:
> On Sun, 8 Dec 2019 20:12:42 +0300 Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:
>
> > ELF header is read into bprm->buf[] by generic execve code.
> >
> > Save a memcpy and allocate just one header for the interpreter instead
> > of two headers (64 bytes instead of 128 on 64-bit).
>
> Hard to review. Why were there two copies in the first place?
That's a good question. Both can live on stack in fact
but [rsp+disp32] addressing generates a lot of bloat (few KB).
> Because of the need to modify the caller's version when we do
> `loc->elf_ex.e_entry += load_bias', yes? Any other place?
No, but I'll double check. It was written this way presumably to not
allocate one more stack variable.
> Local variable `loc' can go away now, yes?
It can.
I have big plans to get rid of all allocations in the common case
and "fetch" headers from pagecache. This is why all headers better to be
"const" which this patch partially progresses to.