Re: [PATCH v2 5/9] objtool: Add verbose option for disassembling affected functions

From: Josh Poimboeuf
Date: Thu Apr 13 2023 - 11:10:06 EST


On Thu, Apr 13, 2023 at 04:03:07PM +0200, Miroslav Benes wrote:
> On Thu, 13 Apr 2023, Peter Zijlstra wrote:
>
> > On Wed, Apr 12, 2023 at 12:03:20PM -0700, Josh Poimboeuf wrote:
> > > + objdump_str = "%sobjdump -wdr %s | gawk -M -v _funcs='%s' '"
> > > + "BEGIN { split(_funcs, funcs); }"
> > > + "/^$/ { func_match = 0; }"
> > > + "/<.*>:/ { "
> > > + "f = gensub(/.*<(.*)>:/, \"\\\\1\", 1);"
> > > + "for (i in funcs) {"
> > > + "if (funcs[i] == f) {"
> > > + "func_match = 1;"
> > > + "base = strtonum(\"0x\" $1);"
> > > + "break;"
> > > + "}"
> > > + "}"
> > > + "}"
> > > + "{"
> > > + "if (func_match) {"
> > > + "addr = strtonum(\"0x\" $1);"
> > > + "printf(\"%%04x \", addr - base);"
> > > + "print;"
> > > + "}"
> > > + "}' 1>&2";
> >
> > Do we want to have scripts/objdump-func.awk and use that to avoid the
> > duplication and eventual divergence of these awk thingies?
>
> I vote for that as well. To keep everything in sync can be a nightmare.

Reasons I did it this way for v2:

1) The awk implementation is slightly different (this one doesn't match
*.cold, etc)

2) Objtool is self-sufficient (doesn't need any other files)

3) Any changes to the objdump-func interface might break objtool

4) It's clearly bug-free and self-contained and I don't expect the code
to change much in the future

--
Josh