Re: [PATCH] objtool: Move objtool_file struct off the stack
From: Josh Poimboeuf
Date: Thu Mar 14 2019 - 12:15:10 EST
On Thu, Mar 14, 2019 at 06:31:37PM +0300, moosotc@xxxxxxxxx wrote:
> Josh Poimboeuf <jpoimboe@xxxxxxxxxx> writes:
>
> > Objtool uses over 512k of stack, thanks to the hash table embedded in
> > the objtool_file struct. This causes an unnecessarily large stack
> > allocation and breaks users with low stack limits.
> >
> > Move the struct off the stack.
> >
> > Fixes: 042ba73fe7eb ("objtool: Add several performance improvements")
> > Reported-by: Vassili Karpov <moosotc@xxxxxxxxx>
> > Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> > ---
> > tools/objtool/check.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> > index 0414a0d52262..91c4799192e1 100644
> > --- a/tools/objtool/check.c
> > +++ b/tools/objtool/check.c
> > @@ -2184,9 +2184,10 @@ static void cleanup(struct objtool_file *file)
> > elf_close(file->elf);
> > }
> >
> > +struct objtool_file file;
> > +
>
> Maybe it also deserves a "static" storage duration (if nothing else this
> would prevent possible name clashes)?
Yeah, good point.
>
> > int check(const char *_objname, bool orc)
> > {
> > - struct objtool_file file;
> > int ret, warnings = 0;
> >
> > objname = _objname;
>
> --
> mailto:moosotc@xxxxxxxxx
--
Josh