ld: Read the output in chunks when computing the PE build-id

pecoff_checksum_contents read the output file back one byte at a time,
seeking before every byte and passing each byte to the hash function
separately.  For a 235 MB executable this took about 15% of the link
time.

Read the file using a 64 KB heap buffer.  If its allocation fails,
fall back to a 64-byte buffer on the stack.

ld/
	* emultempl/pe.em (pecoff_checksum_contents): Read the file in
	chunks, with a stack buffer fallback.
	* emultempl/pep.em (pecoff_checksum_contents): Likewise.
2 files changed