COFF build-id writes uninitialised data to file
authorAlan Modra <amodra@gmail.com>
Thu, 22 Dec 2022 22:57:14 +0000 (09:27 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 23 Dec 2022 00:05:38 +0000 (10:35 +1030)
commit160a943ff8aa0dd9105164f10d4bfca9db872999
treef8f86d35b0a0d504dae87b91f67d9b4e0472cae9
parent2ac6aa431ecf8bf6afdc18020f3d6e55458df223
COFF build-id writes uninitialised data to file

1) The first write in write_build_id wrote rubbish past the struct
external_IMAGE_DEBUG_DIRECTORY, which was later overwritten with
correct data.  No user visible problem there, except that tools like
valgrind complain.
2) The size for the pdb name was incorrectly calculated.

* emultempl/pe.em (write_build_id): Write the debug directory,
not the entire section contents.
(setup_build_id): Add size for the base name of pdb_name, not
the full path.
* emultempl/pep.em: Likewise.
* testsuite/ld-pe/pdb2-section-contrib.d: Update.
ld/emultempl/pe.em
ld/emultempl/pep.em
ld/testsuite/ld-pe/pdb2-section-contrib.d