Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Commit

Permalink
Instrumentation: Fix start and fini trampoline pointers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yota9 authored and Vasily Leonenko committed Jul 5, 2021
1 parent f177978 commit de0e296
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions bolt/runtime/instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

0 comments on commit de0e296

Please sign in to comment.