Search code examples
visual-studiovisual-studio-2015executableportable-executabledebug-symbols

PE file: Debug directory of type IMAGE_DEBUG_TYPE_VC_FEATURE


I compiled a vanilla exe using Visual Studio 2015. Besides the expected debug directory of type IMAGE_DEBUG_TYPE_CODEVIEW, I also found a second one of type IMAGE_DEBUG_TYPE_VC_FEATURE.

I could not find information regarding what data it contains and what it is used for. Could anybody explain or point me to a source explaining it?


Solution

  • when you compile with /GL or link time code generation compilers later than vc 2010 emits an extra debug directory that contains vcfeature these store some counts of pre-vc 110 /GS counts /sdl counts and guardN counts

    dumpbin /headers will show the details of this feature 0xc

    :\>dir /b
    printf.cpp
    
    :\>cat printf.cpp
    #include <stdio.h>
    void main (void) {
        printf("%x\n%d\n%u\n%f\n%g\n%s\n%c\n",256,100,-1,2.2,45.87,"hi",97);
    }
    
    :\>cl /Zi /W4 /GL /Ox /analyze /nologo printf.cpp
    printf.cpp
    
    Generating code
    Finished generating code
    
    :\>dumpbin /headers printf.exe | grep -A 10 "Debug Directories"
      Debug Directories
    
            Time Type        Size      RVA  Pointer
        -------- ------- -------- -------- --------
        5A7F2A78 cv            3C 0004529C    43E9C    Format: RSDS, xxx59}, 1, printf.pdb
        5A7F2A78 feat          14 000452D8    43ED8    Counts: Pre-VC++ 11.00=0, C/C++=194, /GS=194, /sd
    l=0, guardN=193  <<<<<<<<<<<<<
        5A7F2A78 coffgrp      28C 000452EC    43EEC    4C544347 (LTCG)
    

    for starters these are all defined in windows headers

    13 id == coffgrp as already shown created by lint time code generation

    14 is created if you do incremental linking /LINK /LTCG:INCREMENTAL

    here is a dummy debug directory

    Debug Directories(4)
    Type       Size     Address  Pointer
    cv           53       463cc    457cc    
    (    12)      14       46420    45820
    (    13)     29c       46434    45834
    (    14)       0           0        0
    

    dumpbin /headers pogo_vcfeature.exe | grep -A 8 "Debug Directories"

     Debug Directories
    
            Time Type        Size      RVA  Pointer
        -------- ------- -------- -------- --------
        5AD58258 cv            53 000463CC    457CC    
        5AD58258 feat          14 00046420    45820    
        Counts: Pre-VC++ 11.00=0, C/C++=202, /GS=202, /sdl=0, guardN=201
        5AD58258 coffgrp      29C 00046434    45834    
        4C544347 (LTCG)
        5AD58258 iltcg          0 00000000        0
    

    windows headers

    :\>echo %cd%
    C:\Program Files\Windows Kits\10\Include\10.0.16299.0
    
    :\>grep -ir -B 12 -A 4 IMAGE_DEBUG_TYPE_VC_FEATURE *
    xxxxxxxxxxxxxx
    km/ntimage.h:#define IMAGE_DEBUG_TYPE_VC_FEATURE       12
    km/ntimage.h-#define IMAGE_DEBUG_TYPE_POGO             13
    km/ntimage.h-#define IMAGE_DEBUG_TYPE_ILTCG            14
    km/ntimage.h-#define IMAGE_DEBUG_TYPE_MPX              15
    km/ntimage.h-#define IMAGE_DEBUG_TYPE_REPRO            16
    --
    xxxxxxxxxxxxxxxxx
    um/winnt.h:#define IMAGE_DEBUG_TYPE_VC_FEATURE       12
    um/winnt.h-#define IMAGE_DEBUG_TYPE_POGO             13
    um/winnt.h-#define IMAGE_DEBUG_TYPE_ILTCG            14
    um/winnt.h-#define IMAGE_DEBUG_TYPE_MPX              15
    um/winnt.h-#define IMAGE_DEBUG_TYPE_REPRO            16
    
    :\>