Re: [PATCH v2 02/24] objtool: Introduce CFI hash
From: Miroslav Benes
Date: Thu Jul 01 2021 - 04:53:56 EST
> > > +++ b/tools/objtool/orc_gen.c
> > > @@ -13,13 +13,19 @@
> > > #include <objtool/warn.h>
> > > #include <objtool/endianness.h>
> > >
> > > -static int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi)
> > > +static int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi,
> > > + struct instruction *insn)
> > > {
> > > - struct instruction *insn = container_of(cfi, struct instruction, cfi);
> > > struct cfi_reg *bp = &cfi->regs[CFI_BP];
> > >
> > > memset(orc, 0, sizeof(*orc));
> > >
> > > + if (!cfi) {
> > > + orc->end = 0;
> > > + orc->sp_reg = ORC_REG_UNDEFINED;
> > > + return 0;
> > > + }
> > > +
> >
> > This looks strange. You access cfi a couple of lines earlier (bp cfi_reg
> > initialization).
>
> That's a relative address compute, it doesn't actually dereference the
> pointer.
Right, I misread the line.
> > Is it even possible to have cfi == NULL here? The second call site below
> > has a check and the first one should not happen (insn->cfip should be
> > always set if I am not missing something).
>
> I can happen for instructions that are not visited, like NOP fillers
> between functions. Remove the check and try to build a file :-)
Doh, I should have done that. Of course there must be unvisited
instructions. Sorry for the noise.
Miroslav