public Symbol setGPSymbol(Program program, Address toAddr) {
		int index = 1;
		// Only try max times. More than max settings of GP is overkill
		while (index < MAX_UNIQUE_GP_SYMBOLS) {
			try {
				String symname = "_gp_" + index++;
				// check if it already exists
				Symbol existingSymbol =
					SymbolUtilities.getLabelOrFunctionSymbol(program, symname, err -> {
						/* ignore multiple symbols, if even one exists we need to skip if it has a different address */ });
				if (existingSymbol != null) {
					if (existingSymbol.getAddress().equals(toAddr)) {
						return existingSymbol;
					}
					continue;  // can't use this one, look for the next free gp_<x> symbol
				}
				Symbol createSymbol =
					program.getSymbolTable().createLabel(toAddr, symname, SourceType.ANALYSIS);
				return createSymbol;
			}
			catch (InvalidInputException e) {
				break;
			}

		}
		return null;
	}
Check for a global GP register symbol or discovered symbol
@param set
Ghidra/Processors/MIPS/src/main/java/ghidra/app/plugin/core/analysis/MipsAddressAnalyzer.java