public void labelTable(Program program, Instruction start_inst,
			ArrayList<AddLabelCmd> switchLabelList, AddLabelCmd tableNameLabel) {
		// check if the table is already labeled
		Symbol syms[] = program.getSymbolTable().getSymbols(getTopAddress());
		for (Symbol sym : syms) {
			if (sym.getName(false).startsWith(tableNameLabel.getLabelName())) {
				return;
			}
		}

		long tableNumber = 0;
		boolean needTableNumber = false;
		boolean succeed = false;
		String oldName = tableNameLabel.getLabelName();
		Namespace space = null;
		// not putting switch into functions anymore
		//    program.getSymbolTable().getNamespace(start_inst.getMinAddress());
		try {
			space = program.getSymbolTable()
					.createNameSpace(null, "switch_" + start_inst.getMinAddress(),
						SourceType.ANALYSIS);
		}
		catch (DuplicateNameException e) {
			// just go with default space
		}
		catch (InvalidInputException e) {
			// just go with default space
		}
		Symbol oldSym = program.getSymbolTable().getPrimarySymbol(tableNameLabel.getLabelAddr());
		if (oldSym != null && oldSym.getSource() == SourceType.ANALYSIS &&
			oldSym.getName().startsWith("Addr")) {
			oldSym.delete();
		}
		do {
			tableNameLabel.setNamespace(space);
			succeed = tableNameLabel.applyTo(program);
			if (succeed) {
				break;
			}
			tableNumber++;
			needTableNumber = true;
			//tableNameLabel.setLabelName(oldName + "_" + Long.toHexString(tableNumber));
			tableNameLabel.setLabelName(oldName + "_" + tableNumber);
		}
		while (tableNumber < 20);

		if (needTableNumber && tableNumber >= 20) {
			tableNumber = this.topAddress.getOffset();
			tableNameLabel.setLabelName(oldName + "_" + Long.toHexString(tableNumber));
		}

		// make sure the reference is associated with this symbol
		Symbol s = program.getSymbolTable()
				.getGlobalSymbol(tableNameLabel.getLabelName(), tableNameLabel.getLabelAddr());
		for (int op = 0; op < start_inst.getNumOperands(); op++) {
			Reference fromRefs[] = start_inst.getOperandReferences(op);
			for (Reference fromRef : fromRefs) {
				if (fromRef.getToAddress().equals(tableNameLabel.getLabelAddr())) {
					program.getReferenceManager().setAssociation(s, fromRef);
					break;
				}
			}
		}

		// label the index array if this table has one
		if (getIndexLength() > 0) {
			AddLabelCmd lcmd =
				new AddLabelCmd(getTopIndexAddress(), "switchIndex", true, SourceType.ANALYSIS);
			switchLabelList.add(lcmd);
		}

		for (AddLabelCmd lcmd : switchLabelList) {
			lcmd.setNamespace(space);
			if (needTableNumber) {
				lcmd.setLabelName(lcmd.getLabelName() + "_" + Long.toHexString(tableNumber));
			}
			oldSym = program.getSymbolTable().getPrimarySymbol(lcmd.getLabelAddr());
			if (oldSym != null && oldSym.getSource() == SourceType.ANALYSIS &&
				oldSym.getName().startsWith("Addr")) {
				oldSym.delete();
			}
			lcmd.applyTo(program);
		}
	}
Create a switch table. If any new code is found while disassembling the
table destinations, don't finish making the table!

@param program
@param start_inst
@param opindex
@param table
@param flagNewCode
@param monitor

@return true if any new code was discovered!
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/AddressTable.java