Re: [PATCH 3/5] objtool: Support Clang non-section symbols in ORC generation

From: Josh Poimboeuf
Date: Fri Apr 03 2020 - 10:58:21 EST


On Fri, Apr 03, 2020 at 10:58:20AM +0200, Miroslav Benes wrote:
> > + if (insn_sec->sym) {
> > + rela->sym = insn_sec->sym;
> > + rela->addend = insn_off;
> > + } else {
> > + /*
> > + * The Clang assembler doesn't produce section symbols, so we
> > + * have to reference the function symbol instead:
> > + */
> > + rela->sym = find_symbol_containing(insn_sec, insn_off);
> > + if (!rela->sym) {
> > + /*
> > + * Hack alert. This happens when we need to reference
> > + * the NOP pad insn immediately after the function.
> > + */
> > + rela->sym = find_symbol_containing(insn_sec,
> > + insn_off - 1);
> > + }
>
> I suppose there is always just one NOP pad insn, right? Anyway, it would
> be better to get rid of it as you proposed.

There can actually be multiple NOPs because functions are aligned on a
16-byte boundary. But the undefined ORC entry is always at the first
NOP because objtool merges duplicate entries.

--
Josh