[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)
This commit is contained in:
Vladislav Khmelevsky 2021-07-31 00:29:23 +03:00 committed by Maksim Panchenko
parent 519cbbaa9a
commit 553f28e921
1 changed files with 6 additions and 8 deletions

View File

@ -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"));