lkml.org 
[lkml]   [2018]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [POC][RFC][PATCH 1/2] jump_function: Addition of new feature "jump_function"
On Wed, Oct 10, 2018 at 11:17 AM Josh Poimboeuf <jpoimboe@redhat.com> wrote:
>
> On Wed, Oct 10, 2018 at 01:16:05PM -0500, Josh Poimboeuf wrote:
> > On Wed, Oct 10, 2018 at 11:03:43AM -0700, Andy Lutomirski wrote:
> > > > +#define DECLARE_STATIC_CALL(tramp, func) \
> > > > + extern typeof(func) tramp; \
> > > > + static void __used __section(.discard.static_call_tramps) \
> > > > + *__static_call_tramp_##tramp = tramp
> > > > +
> > >
> > > Confused. What's the __static_call_tramp_##tramp variable for? And
> > > why is a DECLARE_ macro defining a variable?
> >
> > This is the magic needed for objtool to find all the call sites.
> >
> > The variable itself isn't needed, but the .discard.static_call_tramps
> > entry is. Objtool reads that section to find out which function call
> > sites are targeted to a static call trampoline.
>
> To clarify: objtool reads that section to find out which functions are
> really static call trampolines. Then it annotates all the instructions
> which call/jmp to those trampolines. Those annotations are then read by
> the kernel.
>

Ah, right, and objtool runs on a per-object basis so it has no other
way to know what symbols are actually static calls.

There's another way to skin this cat, though:

extern typeof(func) __static_call_trampoline_##tramp;
#define tramp __static_call_trampoline_##tramp

And objtool could recognize it by name. But, of course, you can't put
a #define in a macro. But maybe there's a way to hack it up with a
static inline?

Anyway, your way is probably fine with a few caveats:

- It won't really work if the call comes from a .S file.
- There should probably be a comment to help de-confuse future people
like me :)

\
 
 \ /
  Last update: 2018-10-10 23:14    [W:0.114 / U:5.936 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site