Re: [PATCH v2 03/24] objtool: Handle __sanitize_cov*() tail calls

Peter Zijlstra
2021-06-26T08:19:17Z

On Fri, Jun 25, 2021 at 09:38:24AM -0400, Steven Rostedt wrote:
> On Thu, 24 Jun 2021 11:41:02 +0200
> Peter Zijlstra <peterz@infradead.org> wrote:
>
> > +static void add_call_dest(struct objtool_file *file, struct instruction *insn,
> > + struct symbol *dest, bool sibling)
> > +{
> > + struct reloc *reloc = insn_reloc(file, insn);
> > +
> > + insn->call_dest = dest;
> > + if (!dest)
> > + return;
> > +
> > + if (insn->call_dest->static_call_tramp) {
> > + list_add_tail(&insn->call_node,
> > + &file->static_call_list);
> > + }
> > +
> > + if (insn->sec->noinstr &&
> > + !strncmp(insn->call_dest->name, "__sanitizer_cov_", 16)) {
> > + if (reloc) {
> > + reloc->type = R_NONE;
> > + elf_write_reloc(file->elf, reloc);
> > + }
> > +
> > + elf_write_insn(file->elf, insn->sec,
> > + insn->offset, insn->len,
> > + sibling ? arch_ret_insn(insn->len)
> > + : arch_nop_insn(insn->len));
> > +
> > + insn->type = sibling ? INSN_RETURN : INSN_NOP;
> > + }
> > +
> > + if (mcount && !strcmp(insn->call_dest->name, "__fentry__")) {
> > + if (sibling)
> > + WARN_FUNC("Tail call to __fentry__ !?!?", insn->sec, insn->offset);
>
> Have you ever triggered the above?

No, that would be really daft. But since this function is to be called
for both regular and tail calls, I figured I'd at least pretend to
handle the case.