Re: [RFC][PATCH 4/5] objtool: Enable compilation of objtool for all architectures

From: Matt Helsley
Date: Tue May 19 2020 - 13:48:19 EST


On Mon, May 18, 2020 at 05:27:54PM -0500, Josh Poimboeuf wrote:
> On Mon, May 18, 2020 at 12:50:45PM -0700, Matt Helsley wrote:
> > > Why were these moved to arch.h? They're not necessarily arch-specific,
> > > but rather "check"-specific, so I think they still belong in check.h, if
> > > possible.
> >
> > Ah, found it. They are arch specific due to struct orc_entry, which is
> > presently not defined for any archs besides x86.
> >
> > Prior to the patch (-> means "includes"):
> > check.h -> asm/orc_types.h (defines struct orc_entry)
> > orc_gen.c -> check,h
> >
> > After patch:
> > check.c -> asm/orc_types.h
> > orc_gen.c -> asm/orc_types.h
> > orc_gen.c -> check.h
> > orc_gen.c -> arch.h
> > { now weak.c } -> check.h
> >
> > So this prevents the headers, which help us keep the weak definitions
> > consistent with the strong definitions, from breaking compiles on archs
> > that lack struct orc_entry.
> >
> > I'm not sure what the best way to remove this dependency is without
> > a nasty void * for the orc entry, or some #ifdef games related to
> > checking for cpp defines from asm/orc_types.h. This approach neatly
> > avoids conditional preprocessor games and type casting though I do
> > agree it's surprising.
> >
> > Do you have any advice here?
>
> Would it work if we just move the check() and orc_dump() prototypes to
> objtool.h? Then weak.c can just include objtool.h. And check.h and
> orc.h would only need to be included for arches which implement them.

OK, I tested that and it works well. In fact it simplifies the includes
a bit so I think it might be the right move.

Cheers,
-Matt Helsley