Skip to content

Commit

Permalink
Fix "symbol in discarded section" linker error for bpf probes
Browse files Browse the repository at this point in the history
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: (#84)

Reviewed By: mingtaoy

Differential Revision: D42998995

fbshipit-source-id: a2d1eb0c98823fc90b9886b98e7e5e671362af63
  • Loading branch information
Nick Richardson authored and facebook-github-bot committed Feb 10, 2023
1 parent 6185432 commit 1da2dcf
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 15 deletions.
1 change: 1 addition & 0 deletions fizz/CMakeLists.txt
Expand Up @@ -218,6 +218,7 @@ set(FIZZ_SOURCES
client/EarlyDataRejectionPolicy.cpp
tool/FizzCommandCommon.cpp
util/FizzUtil.cpp
util/Tracing.cpp
)

add_library(fizz
Expand Down
12 changes: 5 additions & 7 deletions fizz/client/AsyncFizzClient-inl.h
Expand Up @@ -608,16 +608,14 @@ void AsyncFizzClientT<SM>::ActionMoveVisitor::operator()(
template <typename SM>
void AsyncFizzClientT<SM>::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<KeyLogWriter::Label>::max()),
client_.getClientRandom()->data());
#endif

client_.secretAvailable(secret.secret);
}

template <typename SM>
Expand Down
2 changes: 1 addition & 1 deletion fizz/client/AsyncFizzClient.h
Expand Up @@ -15,8 +15,8 @@
#include <fizz/client/FizzClientContext.h>
#include <fizz/protocol/AsyncFizzBase.h>
#include <fizz/protocol/Exporter.h>
#include <fizz/util/Tracing.h>
#include <folly/io/SocketOptionMap.h>
#include <folly/tracing/StaticTracepoint.h>

namespace fizz {
namespace client {
Expand Down
7 changes: 2 additions & 5 deletions fizz/server/AsyncFizzServer-inl.h
Expand Up @@ -343,16 +343,13 @@ void AsyncFizzServerT<SM>::ActionMoveVisitor::operator()(
template <typename SM>
void AsyncFizzServerT<SM>::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<KeyLogWriter::Label>::max()),
server_.getClientRandom()->data());
#endif

server_.secretAvailable(secret.secret);
}

Expand Down
3 changes: 1 addition & 2 deletions fizz/server/AsyncFizzServer.h
Expand Up @@ -13,8 +13,7 @@
#include <fizz/server/FizzServer.h>
#include <fizz/server/FizzServerContext.h>
#include <fizz/server/ServerProtocol.h>
#include <fizz/util/KeyLogWriter.h>
#include <folly/tracing/StaticTracepoint.h>
#include <fizz/util/Tracing.h>

namespace fizz {
namespace server {
Expand Down
21 changes: 21 additions & 0 deletions fizz/util/Tracing.cpp
@@ -0,0 +1,21 @@
#include <fizz/util/Tracing.h>
#include <folly/tracing/StaticTracepoint.h>

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
22 changes: 22 additions & 0 deletions 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 <fizz/util/KeyLogWriter.h>

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

0 comments on commit 1da2dcf

Please sign in to comment.