private void addDataInfo(Program program, Address loc, StringBuilder sb) {

		Data data = program.getListing().getDataContaining(loc);
		if (data == null) {
			return;
		}

		long dataOffset = loc.subtract(data.getAddress());
		if (dataOffset == 0) {
			// no offset to display
			return;
		}

		String description = "Data Offset";
		if (data.getDataType() instanceof Structure) {
			description = "Structure Offset";
		}

		String name = data.getLabel(); // prefer the label
		if (name == null) {
			name = data.getDataType().getName();
		}

		name = StringUtilities.trimMiddle(name, 60);

		if (name == null) {
			// don't think we can get here
			name = italic("Unnamed");
		}

		appendTableRow(sb, description, name, dataOffset);
	}
A hover service to show tool tip text for hovering over a program address in the listing.
The tool tip text shows relationships to key topological elements of the program relative to
the address -- offset from image base, offset from current memory block; if the address is
within the bounds of a function, the offset from function entry point; if the address is within
the bounds of defined data, the offset from the start of the data.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/hover/ProgramAddressRelationshipListingHover.java