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: (facebookincubator/fizz#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 0916970 commit 0ea2445
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 15 deletions.
1 change: 1 addition & 0 deletions third-party/fizz/src/fizz/CMakeLists.txt
Original file line number Diff line number Diff line change
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 third-party/fizz/src/fizz/client/AsyncFizzClient-inl.h
Original file line number Diff line number Diff line change
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 third-party/fizz/src/fizz/client/AsyncFizzClient.h
Original file line number Diff line number Diff line change
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 third-party/fizz/src/fizz/server/AsyncFizzServer-inl.h
Original file line number Diff line number Diff line change
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 third-party/fizz/src/fizz/server/AsyncFizzServer.h
Original file line number Diff line number Diff line change
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 third-party/fizz/src/fizz/util/Tracing.cpp
Original file line number Diff line number Diff line change
@@ -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 third-party/fizz/src/fizz/util/Tracing.h
Original file line number Diff line number Diff line change
@@ -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 0ea2445

Please sign in to comment.