Have you tried this patch? It looks to me like you're trying to compute the checksum of the file before the file is even written out (only the initial header is written at that point). EXEC_P means that there's an aoutheader. Use COFF_IMAGE_WITH_PE to conditionalize code for PE executables.