lkml.org 
[lkml]   [2020]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH v4 18/32] objtool: mcount: Move nop_mcount()
On Fri, Jun 12, 2020 at 03:26:56PM +0200, Peter Zijlstra wrote:
> On Tue, Jun 02, 2020 at 12:50:11PM -0700, Matt Helsley wrote:
> > +static int nop_mcount(struct section * const rels,
> > + const char *const txtname)
> > +{
> > + struct reloc *reloc;
> > + struct section *txts = find_section_by_index(lf, rels->sh.sh_info);
> > + unsigned mcountsym = 0;
> > + int once = 0;
> > +
> > + list_for_each_entry(reloc, &rels->reloc_list, list) {
> > + int ret = -1;
> > +
> > + if (!mcountsym)
> > + mcountsym = get_mcountsym(reloc);
> > +
> > + if (mcountsym == GELF_R_INFO(reloc->sym->idx, reloc->type) && !is_fake_mcount(reloc)) {
>
> This makes no sense to me; why not have mcountsym be a 'struct symbol
> *' and have get_mcountsym() return one of those.
>
> if (reloc->sym == mcountsym && ... )
>
> is much nicer, no?

Indeed! I'll change it from returning an unsigned long to struct symbol * before I
move it out of the wrapper code.

>
> > + if (make_nop) {
> > + ret = make_nop(txts, reloc->offset);
> > + if (ret < 0)
> > + return -1;
> > + }
> > + if (warn_on_notrace_sect && !once) {
> > + printf("Section %s has mcount callers being ignored\n",
> > + txtname);
> > + once = 1;
> > + /* just warn? */
> > + if (!make_nop)
> > + return 0;
> > + }
> > + }
> > +
> > + /*
> > + * If we successfully removed the mcount, mark the relocation
> > + * as a nop (don't do anything with it).
> > + */
> > + if (!ret) {
> > + reloc->type = rel_type_nop;
> > + rels->changed = true;
>
> I have an elf_write_rela(), I'll make sure to Cc you.

Thanks! I might also make use of your patch to rewrite instructions. We
need a way to turn certain prologue instructions into nops. Would it be
more widely useful to move that functionality out of mcount and into
the objtool ELF/per-arch code or do you think it's better inside the
mcount subcommand code?

Cheers,
-Matt

\
 
 \ /
  Last update: 2020-06-13 21:50    [W:0.084 / U:2.508 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site