From fb8402f65fd2af9da8f9df2afb74d929e83f301a Mon Sep 17 00:00:00 2001 From: Officeyutong Date: Fri, 21 Jun 2024 06:56:55 +0800 Subject: [PATCH] fix: do not override symbols in userland eBPF programs with symbols provided by bpftime's bundled libbpf (#305) * update * update --- runtime/agent/CMakeLists.txt | 3 ++- runtime/agent/agent.version | 4 ++++ runtime/syscall-server/CMakeLists.txt | 4 ++-- runtime/syscall-server/syscall-server.version | 4 ++++ 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 runtime/agent/agent.version create mode 100644 runtime/syscall-server/syscall-server.version diff --git a/runtime/agent/CMakeLists.txt b/runtime/agent/CMakeLists.txt index 3aa4013a..f94ad81c 100644 --- a/runtime/agent/CMakeLists.txt +++ b/runtime/agent/CMakeLists.txt @@ -2,7 +2,8 @@ add_library(bpftime-agent SHARED agent.cpp ) add_dependencies(bpftime-agent FridaGum spdlog::spdlog bpftime_frida_uprobe_attach_impl bpftime_syscall_trace_attach_impl) -set_property(TARGET bpftime-agent PROPERTY CXX_STANDARD 20) +set_target_properties(bpftime-agent PROPERTIES CXX_STANDARD 20 LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/agent.version) +target_link_options(bpftime-agent PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/agent.version) target_include_directories(bpftime-agent PRIVATE ${FRIDA_GUM_INSTALL_DIR} diff --git a/runtime/agent/agent.version b/runtime/agent/agent.version new file mode 100644 index 00000000..8b0612cc --- /dev/null +++ b/runtime/agent/agent.version @@ -0,0 +1,4 @@ +{ + global: injected_with_frida; bpftime_hooked_main; __libc_start_main; bpftime_agent_main; syscall_callback; _bpftime__setup_syscall_trace_callback; + local: *; +}; diff --git a/runtime/syscall-server/CMakeLists.txt b/runtime/syscall-server/CMakeLists.txt index cdda1bec..e5f4dc28 100644 --- a/runtime/syscall-server/CMakeLists.txt +++ b/runtime/syscall-server/CMakeLists.txt @@ -23,8 +23,8 @@ target_include_directories(bpftime-syscall-server "../../third_party/libbpf/include/uapi" ${SPDLOG_INCLUDE} ) -set_property(TARGET bpftime-syscall-server PROPERTY CXX_STANDARD 20) - +set_target_properties(bpftime-syscall-server PROPERTIES CXX_STANDARD 20 LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/syscall-server.version) +target_link_options(bpftime-syscall-server PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/syscall-server.version) if(${ENABLE_EBPF_VERIFIER}) add_dependencies(bpftime-syscall-server bpftime-verifier) target_link_libraries(bpftime-syscall-server PRIVATE bpftime-verifier) diff --git a/runtime/syscall-server/syscall-server.version b/runtime/syscall-server/syscall-server.version new file mode 100644 index 00000000..b386f9d0 --- /dev/null +++ b/runtime/syscall-server/syscall-server.version @@ -0,0 +1,4 @@ +{ + global: epoll_wait; epoll_ctl; epoll_create1; ioctl; mmap64; mmap; close; syscall; munmap; + local: *; +};