Re: [RFC][PATCH 00/13] Cleanup recordmcount and begin objtool conversion

From: Matt Helsley
Date: Thu May 30 2019 - 19:56:08 EST


On Wed, May 29, 2019 at 09:11:45AM -0500, Josh Poimboeuf wrote:
> On Wed, May 29, 2019 at 03:41:52PM +0200, Peter Zijlstra wrote:
> > On Tue, May 28, 2019 at 09:43:28AM -0500, Josh Poimboeuf wrote:
> > > Would it be feasible to eventually combine subcommands so that objtool
> > > could do both ORC and mcount generation in a single invocation? I
> > > wonder what what the interface would look like.

I think it'll be feasible. I've done a bit of investigation but don't
have patches for it yet.

> >
> > objtool orc+mcount ?
> >
> > That is, have '+' be a separator for cmd thingies. That would of course
> > require all other arguments to be shared between all commands, which is
> > currently already so, but I've not checked the mcount patches.
>
> The problem is that you have to combine "orc generate" with "mcount
> record". Because even the subcommands have subcommands ;-)
>
> And also sharing arguments between all subcommands isn't ideal.
>
> Maybe could do:
>
> objtool orc generate [orc options] + mcount record [mcount options]

I think that makes more sense; it'll be easier to construct
Make recipes this way. I was thinking '+' would be something like the
getopt handling of the '--' argument where it stops argument parsing so
someting else can consume the remainder.

The really interesting part is deciding which file to operate on is
specified by the arguments to the first subcommand and subsequent subcmds
would then operate on the same object file. For example:

objtool orc generate [orc opts] foo.o + mcount record [mcount opts]

Would it be clearer what's going on if the object file(s) were specified
first and then the passes to run and their arguments came afterwards?
I'm thinking it'd go somewhat like this:

objtool foo.o [bar.o] -- check [check opts] + \
orc generate [orc opts] + \
mcount record [mcount opts]

Then objtool would iterate over the object file(s) to open,
hand off the ELF data structures into each successive pass, and
finally write any accumulated changes back.

Cheers,
-Matt