From 3a86e64314eac75e68e090068e9da10e4ac31196 Mon Sep 17 00:00:00 2001 From: ghidra1 Date: Thu, 24 Sep 2026 17:27:15 -0400 Subject: [PATCH] GP-7316 Put switchD... namespaces under the corresponding function --- .../app/cmd/function/DecompilerSwitchAnalysisCmd.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/cmd/function/DecompilerSwitchAnalysisCmd.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/cmd/function/DecompilerSwitchAnalysisCmd.java index 5fd5b4d6b0..e660083a47 100644 --- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/cmd/function/DecompilerSwitchAnalysisCmd.java +++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/cmd/function/DecompilerSwitchAnalysisCmd.java @@ -306,22 +306,27 @@ public class DecompilerSwitchAnalysisCmd extends BackgroundCommand { * Label switch table, cases, default with labels in namespace of the switch */ private void labelSwitch(JumpTable table, TaskMonitor monitor) throws CancelledException { + + String labelName = "switchD"; + AddLabelCmd tableNameLabel = - new AddLabelCmd(table.getSwitchAddress(), "switchD", SourceType.ANALYSIS); + new AddLabelCmd(table.getSwitchAddress(), labelName, SourceType.ANALYSIS); // check if the table is already labeled Symbol syms[] = program.getSymbolTable().getSymbols(table.getSwitchAddress()); for (Symbol sym : syms) { - if (sym.getName(false).startsWith(tableNameLabel.getLabelName())) { + if (sym.getName(false).startsWith(labelName)) { return; } } + Function func = decompilerResults.getFunction(); + // put switch table cases into a new switch namespace Namespace space = null; String switchName = "switchD_" + table.getSwitchAddress(); try { - space = program.getSymbolTable().createNameSpace(null, switchName, SourceType.ANALYSIS); + space = program.getSymbolTable().createNameSpace(func, switchName, SourceType.ANALYSIS); } catch (DuplicateNameException e) { space = program.getSymbolTable().getNamespace(switchName, null);