private Address findLoadAddress(long fileOffset, long headerSize) {

		long headerEndOffset = fileOffset + headerSize - 1;

		// Locate possible load of Elf header within section (i.e., start of file)
		Address headerAddr = null;
		for (ElfSectionHeader section : elf.getSections()) {
			if (section.getType() == ElfSectionHeaderConstants.SHT_NOBITS ||
				section.isInvalidOffset()) {
				continue;
			}
			long startOffset = section.getOffset();
			long endOffset = startOffset + section.getSize() - 1;
			if (fileOffset >= startOffset && headerEndOffset <= endOffset) {
				headerAddr = findLoadAddress(section, fileOffset - section.getOffset());
				if (headerAddr != null) {
					return headerAddr;
				}
			}
		}

		// Locate possible load of Elf header within segment
		for (ElfProgramHeader segment : elf.getProgramHeaders()) {
			if (segment.getType() == ElfProgramHeaderConstants.PT_NULL ||
				segment.isInvalidOffset()) {
				continue;
			}
			long startOffset = segment.getOffset();
			long endOffset = startOffset + segment.getFileSize() - 1;
			if (fileOffset >= startOffset && headerEndOffset <= endOffset) {
				headerAddr = findLoadAddress(segment, fileOffset - segment.getOffset());
				if (headerAddr != null && segment.getType() == ElfProgramHeaderConstants.PT_LOAD) {
					return headerAddr;
				}
			}
		}

		return headerAddr;
	}
Locate an Elf file header/structure within loaded memory based upon its file offset.
Preference is given to an allocated section over segments.
This method assumes filter loads will not be employed for the referenced file
location (e.g., ELF data structures).
TODO: This could be a problem for dynamic
@param fileOffset data offset within file
@param headerSize number of bytes required (minimum value of 1)
@return load address or null if not loaded or load was possibly fragmented.
Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfProgramBuilder.java