GP-6008 Changed SourceType examination to base upon priorty instead of specific value equality when appropriate

This commit is contained in:
ghidra1 2025-09-24 09:16:04 -04:00
parent edea7dfd65
commit a3bd708160
20 changed files with 131 additions and 144 deletions

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -43,13 +43,12 @@ public class LabelDataScript extends GhidraScript {
(!data.getBaseDataType().getName().toLowerCase().contains("string")) &&
(!data.getBaseDataType().getName().toLowerCase().contains("unicode"))) {
Symbol sym = symbolTable.getPrimarySymbol(data.getMinAddress());
if ((sym != null) && ((sym.getSource() == SourceType.DEFAULT) ||
(sym.getSource() == SourceType.ANALYSIS))) {
String newLabel =
data.getDefaultLabelPrefix(null) + "_" +
SymbolUtilities.replaceInvalidChars(
data.getDefaultValueRepresentation(), false) +
"_" + data.getMinAddress().toString();
if (sym != null &&
sym.getSource().isLowerOrEqualPriorityThan(SourceType.ANALYSIS)) {
String newLabel = data.getDefaultLabelPrefix(null) +
"_" + SymbolUtilities
.replaceInvalidChars(data.getDefaultValueRepresentation(), false) +
"_" + data.getMinAddress().toString();
Symbol newSym = symbolTable.createLabel(data.getMinAddress(), newLabel,
SourceType.ANALYSIS);
println(data.getMinAddress().toString() + " " + newLabel);