summaryrefslogtreecommitdiff
path: root/output/codeview.c
diff options
context:
space:
mode:
authorFabian Giesen <fabiang@radgametools.com>2016-07-13 17:22:01 -0700
committerCyrill Gorcunov <gorcunov@gmail.com>2016-07-18 14:55:55 +0300
commitbb0fa088fb1c05dfb68e93d2cfc5d28d5792da1d (patch)
treedf77afe5c0275ee064625e2516558fc5935376fe /output/codeview.c
parent6823d01c82e76fbe5635dd833843af5598f8c9e0 (diff)
downloadnasm-bb0fa088fb1c05dfb68e93d2cfc5d28d5792da1d.tar.gz
codeview: Fix ill-formed "S_COMPILE2" record.
write_symbolinfo_properties didn't match the S_COMPILE2 record it's supposed to be writing (the "compiler version" string was emitted starting in the final "version" field); fix that. Write version 8.0.50727; the Windows App Certification Kit (WACK) checks compiler versions as given in app debug info and complains when the toolchain is too old. 8.0.50727 is the lowest permitted "MASM" version for WACK to be happy, so that's what we write. Signed-off-by: Fabian Giesen <fabiang@radgametools.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'output/codeview.c')
-rw-r--r--output/codeview.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/output/codeview.c b/output/codeview.c
index 6e83bd2c..86f63a70 100644
--- a/output/codeview.c
+++ b/output/codeview.c
@@ -624,22 +624,30 @@ static uint16_t write_symbolinfo_obj(struct coff_Section *sect)
static uint16_t write_symbolinfo_properties(struct coff_Section *sect,
const char *const creator_str)
{
+ /* https://github.com/Microsoft/microsoft-pdb/blob/1d60e041/include/cvinfo.h#L3313 */
uint16_t creator_len;
- creator_len = 2 + 4 + 4 + 4 + 4 + strlen(creator_str)+1 + 2;
+ creator_len = 2 + 4 + 2 + 3*2 + 3*2 + strlen(creator_str)+1 + 2;
section_write16(sect, creator_len);
section_write16(sect, 0x1116);
- section_write32(sect, 3); /* language */
+ section_write32(sect, 3); /* language/flags */
if (win64)
- section_write32(sect, 0x000000D0);
+ section_write16(sect, 0x00D0); /* machine */
else if (win32)
- section_write32(sect, 0x00000006);
+ section_write16(sect, 0x0006); /* machine */
else
nasm_assert(!"neither win32 nor win64 are set!");
- section_write32(sect, 0); /* flags*/
- section_write32(sect, 8); /* version */
- section_wbytes(sect, creator_str, strlen(creator_str)+1);
+ section_write16(sect, 0); /* verFEMajor */
+ section_write16(sect, 0); /* verFEMinor */
+ section_write16(sect, 0); /* verFEBuild */
+
+ /* BinScope/WACK insist on version >= 8.0.50727 */
+ section_write16(sect, 8); /* verMajor */
+ section_write16(sect, 0); /* verMinor */
+ section_write16(sect, 50727); /* verBuild */
+
+ section_wbytes(sect, creator_str, strlen(creator_str)+1); /* verSt */
/*
* normally there would be key/value pairs here, but they aren't
* necessary. They are terminated by 2B
@@ -712,7 +720,7 @@ static void write_symbolinfo_table(struct coff_Section *const sect)
/* signature, language, outfile NULL */
obj_length = 2 + 4 + cv8_state.outfile.namebytes;
- creator_length = 2 + 4 + 4 + 4 + 4 + strlen(creator_str)+1 + 2;
+ creator_length = 2 + 4 + 2 + 3*2 + 3*2 + strlen(creator_str)+1 + 2;
sym_length = ( cv8_state.num_syms[SYMTYPE_CODE] * 7) +
( cv8_state.num_syms[SYMTYPE_PROC] * 7) +