From 553f28e9217d168476148eb13e7e53bdc84883d1 Mon Sep 17 00:00:00 2001 From: Vladislav Khmelevsky Date: Sat, 31 Jul 2021 00:29:23 +0300 Subject: [PATCH] [PR] Instrumentation: Fix start and fini trampoline pointers Summary: The trampolines are no loger pointers to the functions. For propper name resolving by bolt use extern "C" for all external symbols in instr.cpp Vladislav Khmelevsky, Advanced Software Technology Lab, Huawei (cherry picked from FBD30092698) --- bolt/runtime/instr.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/bolt/runtime/instr.cpp b/bolt/runtime/instr.cpp index 446cd3562313..accaa5676f3f 100644 --- a/bolt/runtime/instr.cpp +++ b/bolt/runtime/instr.cpp @@ -54,14 +54,14 @@ #endif -#if defined(__APPLE__) extern "C" { + +#if defined(__APPLE__) extern uint64_t* _bolt_instr_locations_getter(); extern uint32_t _bolt_num_counters_getter(); extern uint8_t* _bolt_instr_tables_getter(); extern uint32_t _bolt_instr_num_funcs_getter(); -} #else @@ -106,10 +106,11 @@ extern void (*__bolt_ind_call_counter_func_pointer)(); extern void (*__bolt_ind_tailcall_counter_func_pointer)(); // Function pointers to init/fini trampoline routines in the binary, so we can // resume regular execution of these functions that we hooked -extern void (*__bolt_start_trampoline)(); -extern void (*__bolt_fini_trampoline)(); +extern void __bolt_start_trampoline(); +extern void __bolt_fini_trampoline(); #endif +} namespace { @@ -1604,10 +1605,7 @@ extern "C" __attribute((naked)) void __bolt_instr_start() /// This is hooking into ELF's DT_FINI extern "C" void __bolt_instr_fini() { - // Currently using assembly inline for trampoline function call - // due to issues with function pointer dereferencing in case of - // C function call. - __asm__ __volatile__("call __bolt_fini_trampoline\n" :::); + __bolt_fini_trampoline(); if (__bolt_instr_sleep_time == 0) __bolt_instr_data_dump(); DEBUG(report("Finished.\n"));