Repository: NationalSecurityAgency/ghidra
File: Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/omf/OmfFileHeader.java (Java)

Code before:
			case SEGDEF:
				header.segments.add((OmfSegmentHeader)record);
				break;
			case GRPDEF:
				header.groups.add((OmfGroupRecord)record);
				break;
			case FIXUPP:
				OmfFixupRecord fixuprec = (OmfFixupRecord)record;
				fixuprec.setDataBlock(lastDataBlock);
				header.fixup.add(fixuprec);
				break;
			case LEDATA:
				OmfEnumeratedData enumheader = (OmfEnumeratedData)record;
				header.addEnumeratedBlock(enumheader);
				lastDataBlock = enumheader;
				break;
			case LIDATA:
				OmfIteratedData iterheader = (OmfIteratedData)record;
				if (iterheader.getSegmentIndex() <= 0 || iterheader.getSegmentIndex() > header.segments.size()) {
					throw new OmfException("Bad segment index on LIDATA");
				}
				OmfSegmentHeader segheader2 = header.segments.get(iterheader.getSegmentIndex()-1);
				segheader2.addIteratedData(iterheader);
				lastDataBlock = iterheader;
				break;
			case CEXTDEF:
			case COMDAT:
			case LINKSYM:
			case ALIAS:
			case NBKPAT:
			case LLNAMES:
			case VERNUM:
			case VENDEXT:
				OmfUnsupportedRecord unsupported = (OmfUnsupportedRecord)record;
				log.appendMsg(unsupported.getMessage());
				break;
			default:
				// Should never reach here
			}
		}
		return header;
	}
	
	/**
	 * Assign a load image address to each segment. Follow OMF rules for grouping and ordering
	 * the segments in memory.
	 * @param startAddress is the base memory address for the load image
	 * @param segments is the list of segments
	 * @param groups is the list of specific segments that are grouped together in memory
	 * @throws OmfException for malformed index/alignment/combining fields
	 */

Review comment (suggestion):
Obviously you didn't design this part, but if you willing, I think a better approach would be to just key off the class type of `record` so we don't have to maintain 2 independent mappings of `record type -> record object`.  Ideally we could use [JEP 406: Pattern Matching for switch](https://openjdk.org/jeps/406) but it's only a Preview feature in JDK 17.  You could use if/else's though with [JEP 394: Pattern Matching for instanceof](https://openjdk.org/jeps/394).  Switch isn't as useful here anyway since there shouldn't be any cases that can take advantage of the fall-through.

Code after:
		return header;
	}

	/**
	 * Assign a load image address to each segment. Follow OMF rules for grouping and ordering
	 * the segments in memory.
	 * @param startAddress is the base memory address for the load image
	 * @param segments is the list of segments
	 * @param groups is the list of specific segments that are grouped together in memory
	 * @throws OmfException for malformed index/alignment/combining fields
	 */
	public static void doLinking(long startAddress,ArrayList<OmfSegmentHeader> segments,ArrayList<OmfGroupRecord> groups) throws OmfException {
		// Link anything in groups first
		for (int i = 0; i < groups.size(); ++i) {
			OmfGroupRecord group = groups.get(i);
			group.setStartAddress(startAddress);
			for (int j = 0; j < group.numSegments(); ++j) {
				int index = group.getSegmentIndex(j);
				try {
					OmfSegmentHeader segment = segments.get(index - 1);
					startAddress = segment.relocateSegment(startAddress, -1);
				} catch (IndexOutOfBoundsException ex) {
					throw new OmfException(ex.getMessage());
				}
			}
		}

		// Fill in any remaining segments
		for(int i=0;i<segments.size();++i) {
			OmfSegmentHeader segment = segments.get(i);
			if (segment.getStartAddress() != -1) {
				continue;		// Address already assigned
			}

			startAddress = segment.relocateSegment(startAddress, -1);
			// Look for any segments with same name,class which should be officially "combined" with this segment
			for(int j=i+1;j<segments.size();++j) {
				OmfSegmentHeader combineSeg = segments.get(j);
				if (combineSeg.getStartAddress() != -1) {
					continue;
				}
				if (!combineSeg.getName().equals(segment.getName())) {
					continue;
				}
				if (!combineSeg.getClassName().equals(segment.getClassName())) {
					continue;
				}
				int C = combineSeg.getCombine();
				if (C == 0) {
					continue;			// Private segment
				}