From 0ea2445ec8cf4bea1c00329376744ff7ab008bdb Mon Sep 17 00:00:00 2001 From: Nick Richardson Date: Fri, 10 Feb 2023 09:22:13 -0800 Subject: [PATCH] Fix "symbol in discarded section" linker error for bpf probes Summary: Fixes gnu ld linker error where the nop code point injected by a bpf probe was being discarded at linking time. The bpf probe would add reference from the .notes section to this discared func location and a "(...) defined in discarded section (...) referenced in section .note.stapsdt" error would occur. Previously tracked by github issue: (https://github.com/facebookincubator/fizz/issues/84) Reviewed By: mingtaoy Differential Revision: D42998995 fbshipit-source-id: a2d1eb0c98823fc90b9886b98e7e5e671362af63 --- third-party/fizz/src/fizz/CMakeLists.txt | 1 + .../src/fizz/client/AsyncFizzClient-inl.h | 12 +++++----- .../fizz/src/fizz/client/AsyncFizzClient.h | 2 +- .../src/fizz/server/AsyncFizzServer-inl.h | 7 ++---- .../fizz/src/fizz/server/AsyncFizzServer.h | 3 +-- third-party/fizz/src/fizz/util/Tracing.cpp | 21 ++++++++++++++++++ third-party/fizz/src/fizz/util/Tracing.h | 22 +++++++++++++++++++ 7 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 third-party/fizz/src/fizz/util/Tracing.cpp create mode 100644 third-party/fizz/src/fizz/util/Tracing.h diff --git a/third-party/fizz/src/fizz/CMakeLists.txt b/third-party/fizz/src/fizz/CMakeLists.txt index 5c8a575bf05cb..21179a3589852 100644 --- a/third-party/fizz/src/fizz/CMakeLists.txt +++ b/third-party/fizz/src/fizz/CMakeLists.txt @@ -218,6 +218,7 @@ set(FIZZ_SOURCES client/EarlyDataRejectionPolicy.cpp tool/FizzCommandCommon.cpp util/FizzUtil.cpp + util/Tracing.cpp ) add_library(fizz diff --git a/third-party/fizz/src/fizz/client/AsyncFizzClient-inl.h b/third-party/fizz/src/fizz/client/AsyncFizzClient-inl.h index d1dc6d803fc83..75301a224320b 100644 --- a/third-party/fizz/src/fizz/client/AsyncFizzClient-inl.h +++ b/third-party/fizz/src/fizz/client/AsyncFizzClient-inl.h @@ -608,16 +608,14 @@ void AsyncFizzClientT::ActionMoveVisitor::operator()( template void AsyncFizzClientT::ActionMoveVisitor::operator()( SecretAvailable& secret) { - client_.secretAvailable(secret.secret); -#if 0 - FOLLY_SDT( - fizz, - fizz_secret_available, + fizz_probe_secret_available( secret.secret.secret.size(), secret.secret.secret.data(), - secret.secret.type, + KeyLogWriter::secretToNSSLabel(secret.secret.type) + .value_or(std::numeric_limits::max()), client_.getClientRandom()->data()); -#endif + + client_.secretAvailable(secret.secret); } template diff --git a/third-party/fizz/src/fizz/client/AsyncFizzClient.h b/third-party/fizz/src/fizz/client/AsyncFizzClient.h index fae048c9c6131..f113a40576a48 100644 --- a/third-party/fizz/src/fizz/client/AsyncFizzClient.h +++ b/third-party/fizz/src/fizz/client/AsyncFizzClient.h @@ -15,8 +15,8 @@ #include #include #include +#include #include -#include namespace fizz { namespace client { diff --git a/third-party/fizz/src/fizz/server/AsyncFizzServer-inl.h b/third-party/fizz/src/fizz/server/AsyncFizzServer-inl.h index d3f3d13b1a518..86666e6c4dc59 100644 --- a/third-party/fizz/src/fizz/server/AsyncFizzServer-inl.h +++ b/third-party/fizz/src/fizz/server/AsyncFizzServer-inl.h @@ -343,16 +343,13 @@ void AsyncFizzServerT::ActionMoveVisitor::operator()( template void AsyncFizzServerT::ActionMoveVisitor::operator()( SecretAvailable& secret) { -#if 0 - FOLLY_SDT( - fizz, - fizz_secret_available, + fizz_probe_secret_available( secret.secret.secret.size(), secret.secret.secret.data(), KeyLogWriter::secretToNSSLabel(secret.secret.type) .value_or(std::numeric_limits::max()), server_.getClientRandom()->data()); -#endif + server_.secretAvailable(secret.secret); } diff --git a/third-party/fizz/src/fizz/server/AsyncFizzServer.h b/third-party/fizz/src/fizz/server/AsyncFizzServer.h index a63426ba6a998..0ea9b57f0b56b 100644 --- a/third-party/fizz/src/fizz/server/AsyncFizzServer.h +++ b/third-party/fizz/src/fizz/server/AsyncFizzServer.h @@ -13,8 +13,7 @@ #include #include #include -#include -#include +#include namespace fizz { namespace server { diff --git a/third-party/fizz/src/fizz/util/Tracing.cpp b/third-party/fizz/src/fizz/util/Tracing.cpp new file mode 100644 index 0000000000000..fd22535d6fa47 --- /dev/null +++ b/third-party/fizz/src/fizz/util/Tracing.cpp @@ -0,0 +1,21 @@ +#include +#include + +namespace fizz { +extern "C" { +void fizz_probe_secret_available( + long unsigned int secretSize, + unsigned char* secretData, + fizz::KeyLogWriter::Label nssLabel, + unsigned char* clientRandom) { + FOLLY_SDT( + fizz, + fizz_secret_available, + secretSize, + secretData, + nssLabel, + clientRandom); +} +} + +} // namespace fizz diff --git a/third-party/fizz/src/fizz/util/Tracing.h b/third-party/fizz/src/fizz/util/Tracing.h new file mode 100644 index 0000000000000..2275a4cde0b21 --- /dev/null +++ b/third-party/fizz/src/fizz/util/Tracing.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once +#include + +namespace fizz { + +extern "C" { +void fizz_probe_secret_available( + long unsigned int secretSize, + unsigned char* secretData, + fizz::KeyLogWriter::Label nssLabel, + unsigned char* clientRandom); +} + +} // namespace fizz