From 6611f0982139496b2edb89ac97873e3637b5e145 Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza Date: Mon, 22 Jul 2024 11:02:18 -0300 Subject: [PATCH] SymbolExternalizer: Check KLP_ macros only if there was externzalized syms Signed-off-by: Marcos Paulo de Souza --- libcextract/Passes.cpp | 2 +- libcextract/SymbolExternalizer.hh | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libcextract/Passes.cpp b/libcextract/Passes.cpp index 86361d6..a399459 100644 --- a/libcextract/Passes.cpp +++ b/libcextract/Passes.cpp @@ -459,7 +459,7 @@ class FunctionExternalizerPass : public Pass ClangCompat_None, ctx->OFS); PrettyPrint::Set_AST(ctx->AST.get()); - if (ctx->Ibt && ctx->AST) { + if (ctx->Ibt && ctx->AST && externalizer.Has_Externalizations()) { /* Do a sanity check on IBT macros. Some kernel branches can't use it, so do a check here for sanity reasons. */ Preprocessor &pp = ctx->AST->getPreprocessor(); diff --git a/libcextract/SymbolExternalizer.hh b/libcextract/SymbolExternalizer.hh index fff6ec2..5840b15 100644 --- a/libcextract/SymbolExternalizer.hh +++ b/libcextract/SymbolExternalizer.hh @@ -340,6 +340,17 @@ class SymbolExternalizer return Log; } + /** Returns true if there was at least one externalized symbol */ + inline bool Has_Externalizations(void) + { + for (auto const& [key, val] : SymbolsMap) { + if (val.ExtType == ExternalizationType::STRONG) + return true; + } + + return false; + } + /** Dump the SymbolsMap structure into stdout for debugging purposes. */ void Dump_SymbolsMap(void);