Skip to content

Commit

Permalink
dynamic: Init arch-specific structures
Browse files Browse the repository at this point in the history
Trigger architecture specific dynamic initialization when initializing
the dynamic instrumentation mechanics.

Co-authored-by: Gabriel-Andrew Pollo-Guilbert <gabrielpolloguilbert@gmail.com>
Signed-off-by: Clément Guidi <cguidi@ciena.com>
  • Loading branch information
2 people authored and azharivs committed Aug 10, 2023
1 parent 6f727f8 commit 7ee751d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libmcount/dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ static unsigned min_size;
/* disassembly engine for dynamic code patch (for capstone) */
static struct mcount_disasm_engine disasm;

static bool mcount_dynamic_is_initialized;

static struct mcount_orig_insn *create_code(struct Hashmap *map, unsigned long addr)
{
struct mcount_orig_insn *entry;
Expand Down Expand Up @@ -249,6 +251,11 @@ __weak void mcount_disasm_finish(struct mcount_disasm_engine *disasm)
{
}

__weak int mcount_arch_dynamic_init(void)
{
return -1;
}

__weak int mcount_arch_branch_table_size(struct mcount_disasm_info *info)
{
return 0;
Expand Down Expand Up @@ -664,6 +671,13 @@ static int do_dynamic_update(struct uftrace_sym_info *sinfo, char *patch_funcs,

/* TODO: filter out unsupported libs */
for (mdi = mdinfo; mdi != NULL; mdi = mdi->next) {
if (mdi->type == DYNAMIC_NONE && !mcount_dynamic_is_initialized) {
if (mcount_arch_dynamic_init() >= 0)
mcount_dynamic_is_initialized = true;
else
continue;
}

map = mdi->map;
if (mdi->trampoline)
patch_func_matched(mdi, map);
Expand Down

0 comments on commit 7ee751d

Please sign in to comment.