On Fri, Jul 10, 2020 at 06:31:55PM -0400, Steven Rostedt wrote: > On Fri, 10 Jul 2020 15:38:41 +0200 > Peter Zijlstra <pet...@infradead.org> wrote:
> > + /* find key symbol */ > > + key_name = strdup(insn->call_dest->name); > > Should check for failed allocation of strdup(). Rigt, I'll go add the perror and exit. > > + if (strncmp(key_name, STATIC_CALL_TRAMP_PREFIX_STR, > > + strlen(STATIC_CALL_TRAMP_PREFIX_STR))) { > > + WARN("static_call: trampoline name malformed: %s", > > key_name); > > + return -1; > > + } > > + tmp = key_name + STATIC_CALL_TRAMP_PREFIX_LEN - > > STATIC_CALL_KEY_PREFIX_LEN; > > + memcpy(tmp, STATIC_CALL_KEY_PREFIX_STR, > > STATIC_CALL_KEY_PREFIX_LEN); > > + > > + key_sym = find_symbol_by_name(file->elf, tmp); > > + if (!key_sym) { > > + WARN("static_call: can't find static_call_key symbol: > > %s", tmp); > > + return -1; > > + } > > + free(key_name); > > + > > + /* populate reloc for 'key' */ > > + reloc = malloc(sizeof(*reloc)); > > + if (!reloc) { > > + perror("malloc"); > > + return -1; > > + } > > + memset(reloc, 0, sizeof(*reloc)); > > + reloc->sym = key_sym; > > + reloc->addend = 0; > > + reloc->type = R_X86_64_PC32; > > How easy would this be for other architectures to implement this? That > is how much of this function is x86 specific? I'm not sure; I think it's fairly generic except for the reloc types. So ARM64 for example might need to use SHT_REL and R_AARCH64_PREL32 instead. But I suppose we'll see that if/when someone tries to make it work.