cmd/link: truncate file after code signature
cmd/link: truncate file after code signature

When external linking, in case that the external linker generates
a code signature with a different size (e.g. as it uses a
different identifier), truncate the file after rewriting the code
signature, to make sure that no bytes after the signature (which
will invalidate the signature).

Fixes #43105.

Change-Id: I732f949fedd6de42d9f3cf6d017f7ba3f4e59e7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/276693
Trust: Cherry Zhang <d62e63aa42ce272d7b6a5055d97e942b33a34679@google.com>
Run-TryBot: Cherry Zhang <d62e63aa42ce272d7b6a5055d97e942b33a34679@google.com>
TryBot-Result: Go Bot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Than McIntosh <4b2922593166fc595a9b1a408f34f5d3817fe9d2@google.com>

cloudflare/go,nawawi/go,nawawi/go,nawawi/go,cloudflare/go,cloudflare/go,golang/go,golang/go,nawawi/go,CAFxX/go,golang/go,golang/go,cloudflare/go,CAFxX/go,nawawi/go,cloudflare/go,CAFxX/go,CAFxX/go,CAFxX/go,CAFxX/go,nawawi/go,cloudflare/go,nawawi/go,golang/go,CAFxX/go,golang/go,cloudflare/go,golang/go,cloudflare/go,golang/go,CAFxX/go,nawawi/go