From de0e296f9b5cc0c05512d38703ead20e93ac9199 Mon Sep 17 00:00:00 2001 From: Vladislav Khmelevsky Date: Mon, 5 Jul 2021 15:31:23 +0300 Subject: [PATCH] Instrumentation: Fix start and fini trampoline pointers 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 --- bolt/runtime/instr.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/bolt/runtime/instr.cpp b/bolt/runtime/instr.cpp index 8a8180f67429..2617c4a25828 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,11 +106,13 @@ extern void (*__bolt_ind_call_instr_pointer)(); extern void (*__bolt_ind_tailcall_instr_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 { /// A simple allocator that mmaps a fixed size region and manages this space @@ -1620,10 +1622,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"));