S_FILESTATIC records are relatively rare, but cl does generate them. In particular, it seems to only generate them with optimizations turned on and a file static is en-registered into a local variable. The key piece of information in an S_FILESTATIC record that is not present in, for example, an S_LOCAL register, is the file (i.e. module) name that the file static comes from.
The prevailing theory is that this is so that if a function in module a which uses a file static defined in module a is then inlined into some other module b, there is a path back to the original S_LDATA32 record.
In any case, although clang does not generate S_FILESTATIC records, it needs to be able to link them. This was broken before, because S_FILESTATIC records contain a field which refers to the string table. However, unlike other records which refer to the string table (but do so indirectly through the File Checksums table), S_FILESTATIC records point directly into the string table.
To handle this, during linking we need to merge in all strings from S_FILESTATIC records into the master PDB string table, and fixup their offsets in the linked S_FILESTATIC record.
This patch implements this.
This issue was originally discovered by Alexander Ganea as it was causing Visual Studio to crash.