Skip to content

Commit

Permalink
Update visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Officeyutong committed Oct 19, 2023
1 parent 7d23120 commit 2dd0e15
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
9 changes: 5 additions & 4 deletions runtime/src/bpftime_shm_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,6 @@ bool bpftime_shm::is_exist_fake_fd(int fd) const
return manager->is_allocated(fd);
}

// Declare it as weak symbol, which could be overrided by other symbols
const __attribute__((weak)) shm_open_type global_shm_open_type =
shm_open_type::SHM_NO_CREATE;

bpftime_shm::bpftime_shm()
{
spdlog::info("Global shm constructed. global_shm_open_type {} for {}",
Expand Down Expand Up @@ -511,4 +507,9 @@ bpftime_shm::get_software_perf_event_raw_buffer(int fd, size_t buffer_sz) const
const auto &handler = std::get<bpf_perf_event_handler>(get_handler(fd));
return handler.try_get_software_perf_data_raw_buffer(buffer_sz);
}

// Declare it as weak symbol, which could be overrided by other symbols
extern const __attribute__((weak)) bpftime::shm_open_type global_shm_open_type =
bpftime::shm_open_type::SHM_NO_CREATE;

} // namespace bpftime
19 changes: 19 additions & 0 deletions runtime/test/bpf/replace.bpf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "vmlinux.h"
#include "bpf/bpf_tracing.h"
#include "bpf/bpf_helpers.h"
#include "ffi.bpf.h"

static inline int add_func(int a, int b)
{
return FFI_CALL_NAME_2("add_func", a, b);
}

static inline uint64_t print_func(char *str)
{
return FFI_CALL_NAME_1("print_func", str);
}

int BPF_UPROBE(my_function, int parm1, char* str, char c) {
uint64_t n = print_func(str);
return n + add_func(parm1, c);
}

0 comments on commit 2dd0e15

Please sign in to comment.