diff --git a/ld/pdb.c b/ld/pdb.c
index 3885340d567..e0bdc1122fd 100644
--- a/ld/pdb.c
+++ b/ld/pdb.c
@@ -3811,6 +3811,7 @@ create_linker_symbols (bfd *abfd, uint8_t **syms, uint32_t *sym_byte_size,
   env_size += strlen (exeval) + 1;
   env_size += sizeof (pdb);
   env_size += strlen (pdbval) + 1;
+  env_size++; /* Terminating empty string.  */
 
   if (env_size % 4)
     padding2 = 4 - (env_size % 4);
@@ -3883,6 +3884,8 @@ create_linker_symbols (bfd *abfd, uint8_t **syms, uint32_t *sym_byte_size,
   memcpy (ptr, pdbval, strlen (pdbval) + 1);
   ptr += strlen (pdbval) + 1;
 
+  *ptr++ = 0;
+
   /* Microsoft's LINK also includes "cmd", the command-line options passed
      to the linker, but unfortunately we don't have access to argc and argv
      at this stage.  */
