private int computeAlignedNewPosition(OptionalHeader optionalHeader,
			DataDirectory[] directories) {
		int lastPos = 0;
		for (SectionHeader sectionHeader : sectionHeaders) {
			if (sectionHeader.getPointerToRawData() + sectionHeader.getSizeOfRawData() > lastPos) {
				lastPos = sectionHeader.getPointerToRawData() + sectionHeader.getSizeOfRawData();
			}
		}
		for (DataDirectory directorie : directories) {
			if (directorie == null || directorie.getSize() == 0) {
				continue;
			}
			if (directorie.rvaToPointer() + directorie.getSize() > lastPos) {
				lastPos = directorie.rvaToPointer() + directorie.getSize();
			}
		}
		return PortableExecutable.computeAlignment(lastPos, optionalHeader.getFileAlignment());
	}
Adds a new section to this file header. Uses the given memory block
as the section template. The section will have the memory block's name, start address,
size, etc. The optional header is needed to determine the free byte position in the
file.
@param block the memory block template
@param optionalHeader the related optional header
@throws RuntimeException if the memory block is uninitialized
Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/FileHeader.java